#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.13 2023/08/26 05:22:50 riastradh Exp $");
#include <sys/param.h>
#include <sys/buf.h>
#include <sys/errno.h>
#include <sys/kauth.h>
#include <sys/mount.h>
#include <sys/namei.h>
#include <sys/vnode.h>
#include <sys/vnode_if.h>
#include <sys/dirent.h>
#include <miscfs/genfs/genfs.h>
#include <ufs/ext2fs/ext2fs.h>
#include <ufs/ext2fs/ext2fs_dir.h>
#include <ufs/ext2fs/ext2fs_extern.h>
#include <ufs/ufs/inode.h>
#include <ufs/ufs/ufs_extern.h>
#include <ufs/ufs/ufsmount.h>
static int ext2fs_sane_rename(struct vnode *, struct componentname *,
struct vnode *, struct componentname *,
kauth_cred_t, bool);
static bool ext2fs_rename_ulr_overlap_p(const struct ufs_lookup_results *,
const struct ufs_lookup_results *);
static int ext2fs_rename_recalculate_fulr(struct vnode *,
struct ufs_lookup_results *, const struct ufs_lookup_results *,
const struct componentname *);
static bool ext2fs_rmdired_p(struct vnode *);
static int ext2fs_read_dotdot(struct vnode *, kauth_cred_t, ino_t *);
static int ext2fs_rename_replace_dotdot(struct vnode *,
struct vnode *, struct vnode *, kauth_cred_t);
static int ext2fs_gro_lock_directory(struct mount *, struct vnode *);
static const struct genfs_rename_ops ext2fs_genfs_rename_ops;
static int
ext2fs_sane_rename(
struct vnode *fdvp, struct componentname *fcnp,
struct vnode *tdvp, struct componentname *tcnp,
kauth_cred_t cred, bool posixly_correct)
{
struct ufs_lookup_results fulr, tulr;
return genfs_sane_rename(&ext2fs_genfs_rename_ops,
fdvp, fcnp, &fulr, tdvp, tcnp, &tulr,
cred, posixly_correct);
}
int
ext2fs_rename(void *v)
{
return genfs_insane_rename(v, &ext2fs_sane_rename);
}
static bool
ext2fs_gro_directory_empty_p(struct mount *mp, kauth_cred_t cred,
struct vnode *vp, struct vnode *dvp)
{
(void)mp;
KASSERT(mp != NULL);
KASSERT(vp != NULL);
KASSERT(dvp != NULL);
KASSERT(vp != dvp);
KASSERT(vp->v_mount == mp);
KASSERT(dvp->v_mount == mp);
KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
return ext2fs_dirempty(VTOI(vp), VTOI(dvp)->i_number, cred);
}
static int
ext2fs_gro_rename_check_possible(struct mount *mp,
struct vnode *fdvp, struct vnode *fvp,
struct vnode *tdvp, struct vnode *tvp)
{
(void)mp;
KASSERT(mp != NULL);
KASSERT(fdvp != NULL);
KASSERT(fvp != NULL);
KASSERT(tdvp != NULL);
KASSERT(fdvp != fvp);
KASSERT(fdvp != tvp);
KASSERT(tdvp != fvp);
KASSERT(tdvp != tvp);
KASSERT(fvp != tvp);
KASSERT(fdvp->v_type == VDIR);
KASSERT(tdvp->v_type == VDIR);
KASSERT(fdvp->v_mount == mp);
KASSERT(fvp->v_mount == mp);
KASSERT(tdvp->v_mount == mp);
KASSERT((tvp == NULL) || (tvp->v_mount == mp));
KASSERT(VOP_ISLOCKED(fdvp) == LK_EXCLUSIVE);
KASSERT(VOP_ISLOCKED(fvp) == LK_EXCLUSIVE);
KASSERT(VOP_ISLOCKED(tdvp) == LK_EXCLUSIVE);
KASSERT((tvp == NULL) || (VOP_ISLOCKED(tvp) == LK_EXCLUSIVE));
return genfs_ufslike_rename_check_possible(
VTOI(fdvp)->i_e2fs_flags, VTOI(fvp)->i_e2fs_flags,
VTOI(tdvp)->i_e2fs_flags, (tvp? VTOI(tvp)->i_e2fs_flags : 0),
(tvp != NULL),
EXT2_IMMUTABLE, EXT2_APPEND);
}
static int
ext2fs_gro_rename_check_permitted(struct mount *mp, kauth_cred_t cred,
struct vnode *fdvp, struct vnode *fvp,
struct vnode *tdvp, struct vnode *tvp)
{
(void)mp;
KASSERT(mp != NULL);
KASSERT(fdvp != NULL);
KASSERT(fvp != NULL);
KASSERT(tdvp != NULL);
KASSERT(fdvp != fvp);
KASSERT(fdvp != tvp);
KASSERT(tdvp != fvp);
KASSERT(tdvp != tvp);
KASSERT(fvp != tvp);
KASSERT(fdvp->v_type == VDIR);
KASSERT(tdvp->v_type == VDIR);
KASSERT(fdvp->v_mount == mp);
KASSERT(fvp->v_mount == mp);
KASSERT(tdvp->v_mount == mp);
KASSERT((tvp == NULL) || (tvp->v_mount == mp));
KASSERT(VOP_ISLOCKED(fdvp) == LK_EXCLUSIVE);
KASSERT(VOP_ISLOCKED(fvp) == LK_EXCLUSIVE);
KASSERT(VOP_ISLOCKED(tdvp) == LK_EXCLUSIVE);
KASSERT((tvp == NULL) || (VOP_ISLOCKED(tvp) == LK_EXCLUSIVE));
return genfs_ufslike_rename_check_permitted(cred,
fdvp, VTOI(fdvp)->i_e2fs_mode, VTOI(fdvp)->i_uid,
fvp, VTOI(fvp)->i_uid,
tdvp, VTOI(tdvp)->i_e2fs_mode, VTOI(tdvp)->i_uid,
tvp, (tvp? VTOI(tvp)->i_uid : 0));
}
static int
ext2fs_gro_remove_check_possible(struct mount *mp,
struct vnode *dvp, struct vnode *vp)
{
(void)mp;
KASSERT(mp != NULL);
KASSERT(dvp != NULL);
KASSERT(vp != NULL);
KASSERT(dvp != vp);
KASSERT(dvp->v_type == VDIR);
KASSERT(vp->v_type != VDIR);
KASSERT(dvp->v_mount == mp);
KASSERT(vp->v_mount == mp);
KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
return genfs_ufslike_remove_check_possible(
VTOI(dvp)->i_e2fs_flags, VTOI(vp)->i_e2fs_flags,
EXT2_IMMUTABLE, EXT2_APPEND);
}
static int
ext2fs_gro_remove_check_permitted(struct mount *mp, kauth_cred_t cred,
struct vnode *dvp, struct vnode *vp)
{
(void)mp;
KASSERT(mp != NULL);
KASSERT(dvp != NULL);
KASSERT(vp != NULL);
KASSERT(dvp != vp);
KASSERT(dvp->v_type == VDIR);
KASSERT(vp->v_type != VDIR);
KASSERT(dvp->v_mount == mp);
KASSERT(vp->v_mount == mp);
KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
return genfs_ufslike_remove_check_permitted(cred,
dvp, VTOI(dvp)->i_e2fs_mode, VTOI(dvp)->i_uid,
vp, VTOI(vp)->i_uid);
}
static int
ext2fs_gro_rename(struct mount *mp, kauth_cred_t cred,
struct vnode *fdvp, struct componentname *fcnp,
void *fde, struct vnode *fvp,
struct vnode *tdvp, struct componentname *tcnp,
void *tde, struct vnode *tvp, nlink_t *tvp_nlinkp)
{
struct ufs_lookup_results *fulr = fde;
struct ufs_lookup_results *tulr = tde;
bool directory_p, reparent_p;
int error;
(void)mp;
KASSERT(mp != NULL);
KASSERT(fdvp != NULL);
KASSERT(fcnp != NULL);
KASSERT(fulr != NULL);
KASSERT(fvp != NULL);
KASSERT(tdvp != NULL);
KASSERT(tcnp != NULL);
KASSERT(tulr != NULL);
KASSERT(fulr != tulr);
KASSERT(fdvp != fvp);
KASSERT(fdvp != tvp);
KASSERT(tdvp != fvp);
KASSERT(tdvp != tvp);
KASSERT(fvp != tvp);
KASSERT(fdvp->v_mount == mp);
KASSERT(fvp->v_mount == mp);
KASSERT(tdvp->v_mount == mp);
KASSERT((tvp == NULL) || (tvp->v_mount == mp));
KASSERT(VOP_ISLOCKED(fdvp) == LK_EXCLUSIVE);
KASSERT(VOP_ISLOCKED(fvp) == LK_EXCLUSIVE);
KASSERT(VOP_ISLOCKED(tdvp) == LK_EXCLUSIVE);
KASSERT((tvp == NULL) || (VOP_ISLOCKED(tvp) == LK_EXCLUSIVE));
if ((nlink_t)VTOI(fvp)->i_e2fs_nlink >= EXT2FS_LINK_MAX)
return EMLINK;
directory_p = (fvp->v_type == VDIR);
KASSERT(directory_p == ((VTOI(fvp)->i_e2fs_mode & IFMT) == IFDIR));
KASSERT((tvp == NULL) || (directory_p == (tvp->v_type == VDIR)));
KASSERT((tvp == NULL) || (directory_p ==
((VTOI(tvp)->i_e2fs_mode & IFMT) == IFDIR)));
reparent_p = (fdvp != tdvp);
KASSERT(reparent_p == (VTOI(fdvp)->i_number != VTOI(tdvp)->i_number));
KASSERT((nlink_t)VTOI(fvp)->i_e2fs_nlink < EXT2FS_LINK_MAX);
VTOI(fvp)->i_e2fs_nlink++;
VTOI(fvp)->i_flag |= IN_CHANGE;
error = ext2fs_update(fvp, NULL, NULL, UPDATE_WAIT);
if (error)
goto whymustithurtsomuch;
if (tvp == NULL) {
if (directory_p && reparent_p) {
if ((nlink_t)VTOI(tdvp)->i_e2fs_nlink >= EXT2FS_LINK_MAX) {
error = EMLINK;
goto whymustithurtsomuch;
}
KASSERT((nlink_t)VTOI(tdvp)->i_e2fs_nlink < EXT2FS_LINK_MAX);
VTOI(tdvp)->i_e2fs_nlink++;
VTOI(tdvp)->i_flag |= IN_CHANGE;
error = ext2fs_update(tdvp, NULL, NULL, UPDATE_WAIT);
if (error) {
KASSERT(0 < VTOI(tdvp)->i_e2fs_nlink);
VTOI(tdvp)->i_e2fs_nlink--;
VTOI(tdvp)->i_flag |= IN_CHANGE;
goto whymustithurtsomuch;
}
}
error = ext2fs_direnter(VTOI(fvp), tdvp, tulr, tcnp);
if (error) {
if (directory_p && reparent_p) {
KASSERT(0 < VTOI(tdvp)->i_e2fs_nlink);
VTOI(tdvp)->i_e2fs_nlink--;
VTOI(tdvp)->i_flag |= IN_CHANGE;
(void)ext2fs_update(tdvp, NULL, NULL,
UPDATE_WAIT);
}
goto whymustithurtsomuch;
}
} else {
if (directory_p)
cache_purge(tdvp);
error = ext2fs_dirrewrite(VTOI(tdvp), tulr, VTOI(fvp), tcnp);
if (error)
goto whymustithurtsomuch;
if (directory_p && !reparent_p) {
KASSERT(fdvp == tdvp);
KASSERT(0 < VTOI(tdvp)->i_e2fs_nlink);
VTOI(tdvp)->i_e2fs_nlink--;
VTOI(tdvp)->i_flag |= IN_CHANGE;
}
KASSERT(0 < VTOI(tvp)->i_e2fs_nlink);
VTOI(tvp)->i_e2fs_nlink--;
if (directory_p) {
if (VTOI(tvp)->i_e2fs_nlink != 1)
ufs_dirbad(VTOI(tvp), (doff_t)0,
"hard-linked directory");
VTOI(tvp)->i_e2fs_nlink = 0;
error = ext2fs_truncate(tvp, (off_t)0, IO_SYNC, cred);
#if 0
if (error)
goto whymustithurtsomuch;
#endif
}
*tvp_nlinkp = VTOI(tvp)->i_e2fs_nlink;
VTOI(tvp)->i_flag |= IN_CHANGE;
}
if (directory_p && reparent_p) {
error = ext2fs_rename_replace_dotdot(fvp, fdvp, tdvp, cred);
if (error)
goto whymustithurtsomuch;
cache_purge(fdvp);
}
if (!reparent_p && (tvp == NULL) &&
ext2fs_rename_ulr_overlap_p(fulr, tulr)) {
error = ext2fs_rename_recalculate_fulr(fdvp, fulr, tulr, fcnp);
#if 0
if (error)
goto whymustithurtsomuch;
#endif
}
error = ext2fs_dirremove(fdvp, fulr, fcnp);
if (error)
goto whymustithurtsomuch;
#if 0
genfs_rename_cache_purge(fdvp, fvp, tdvp, tvp);
#endif
whymustithurtsomuch:
KASSERT(0 < VTOI(fvp)->i_e2fs_nlink);
VTOI(fvp)->i_e2fs_nlink--;
VTOI(fvp)->i_flag |= IN_CHANGE;
return error;
}
static bool
ext2fs_rename_ulr_overlap_p(const struct ufs_lookup_results *fulr,
const struct ufs_lookup_results *tulr)
{
doff_t from_prev_start, from_prev_end, to_start, to_end;
KASSERT(fulr != NULL);
KASSERT(tulr != NULL);
KASSERT(fulr != tulr);
from_prev_end = fulr->ulr_offset;
KASSERT(fulr->ulr_count <= from_prev_end);
from_prev_start = (from_prev_end - fulr->ulr_count);
to_start = tulr->ulr_offset;
KASSERT(tulr->ulr_count < (EXT2FS_MAXDIRSIZE - to_start));
to_end = (to_start + tulr->ulr_count);
return
(((to_start <= from_prev_start) && (from_prev_start < to_end)) ||
((to_start <= from_prev_end) && (from_prev_end < to_end)));
}
static int
ext2fs_rename_recalculate_fulr(struct vnode *dvp,
struct ufs_lookup_results *fulr, const struct ufs_lookup_results *tulr,
const struct componentname *fcnp)
{
struct mount *mp;
struct ufsmount *ump;
int dirblksiz;
doff_t search_start, search_end;
doff_t offset;
struct buf *bp;
char *dirbuf;
struct ext2fs_direct *ep;
uint32_t reclen;
uint32_t prev_reclen;
int error;
KASSERT(dvp != NULL);
KASSERT(dvp->v_mount != NULL);
KASSERT(VTOI(dvp) != NULL);
KASSERT(fulr != NULL);
KASSERT(tulr != NULL);
KASSERT(fulr != tulr);
KASSERT(ext2fs_rename_ulr_overlap_p(fulr, tulr));
mp = dvp->v_mount;
ump = VFSTOUFS(mp);
KASSERT(ump != NULL);
KASSERT(ump == VTOI(dvp)->i_ump);
dirblksiz = ump->um_dirblksiz;
KASSERT(0 < dirblksiz);
KASSERT((dirblksiz & (dirblksiz - 1)) == 0);
KASSERT(dirblksiz <= mp->mnt_stat.f_iosize);
search_start = tulr->ulr_offset;
KASSERT(fulr->ulr_reclen < (EXT2FS_MAXDIRSIZE - fulr->ulr_offset));
search_end = (fulr->ulr_offset + fulr->ulr_reclen);
KASSERT(search_start <= search_end);
KASSERT((search_end - (search_start &~ (dirblksiz - 1))) <= dirblksiz);
dirbuf = NULL;
bp = NULL;
error = ext2fs_blkatoff(dvp, (off_t)search_start, &dirbuf, &bp);
if (error)
return error;
KASSERT(dirbuf != NULL);
KASSERT(bp != NULL);
KASSERT((search_end - search_start) <=
(bp->b_bcount - (search_start & (mp->mnt_stat.f_iosize - 1))));
prev_reclen = fulr->ulr_count;
offset = search_start;
for (;;) {
KASSERT(search_start <= offset);
KASSERT(offset < search_end);
ep = (struct ext2fs_direct *)
(dirbuf + (offset - search_start));
reclen = fs2h16(ep->e2d_reclen);
if (ep->e2d_ino == 0)
goto next;
if (fs2h32(ep->e2d_ino) == UFS_WINO)
goto next;
if (fcnp->cn_namelen != ep->e2d_namlen)
goto next;
if (memcmp(ep->e2d_name, fcnp->cn_nameptr, fcnp->cn_namelen))
goto next;
break;
next:
if (! ((reclen < search_end) &&
(offset < (search_end - reclen)))) {
brelse(bp, 0);
return EIO;
}
KASSERT(reclen < search_end);
KASSERT(offset < (search_end - reclen));
KASSERT((offset &~ (dirblksiz - 1)) ==
((offset + reclen) &~ (dirblksiz - 1)));
prev_reclen = reclen;
offset += reclen;
}
fulr->ulr_offset = offset;
fulr->ulr_reclen = reclen;
fulr->ulr_count = ((offset & (dirblksiz - 1))? prev_reclen : 0);
brelse(bp, 0);
return 0;
}
static int
ext2fs_gro_remove(struct mount *mp, kauth_cred_t cred,
struct vnode *dvp, struct componentname *cnp, void *de, struct vnode *vp,
nlink_t *tvp_nlinkp)
{
struct ufs_lookup_results *ulr = de;
int error;
(void)mp;
KASSERT(mp != NULL);
KASSERT(dvp != NULL);
KASSERT(cnp != NULL);
KASSERT(ulr != NULL);
KASSERT(vp != NULL);
KASSERT(dvp != vp);
KASSERT(dvp->v_mount == mp);
KASSERT(vp->v_mount == mp);
KASSERT(dvp->v_type == VDIR);
KASSERT(vp->v_type != VDIR);
KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
error = ext2fs_dirremove(dvp, ulr, cnp);
if (error)
return error;
KASSERT(0 < VTOI(vp)->i_e2fs_nlink);
VTOI(vp)->i_e2fs_nlink--;
VTOI(vp)->i_flag |= IN_CHANGE;
*tvp_nlinkp = VTOI(vp)->i_e2fs_nlink;
return 0;
}
static int
ext2fs_gro_lookup(struct mount *mp, struct vnode *dvp,
struct componentname *cnp, void *de_ret, struct vnode **vp_ret)
{
struct ufs_lookup_results *ulr_ret = de_ret;
struct vnode *vp;
int error;
(void)mp;
KASSERT(mp != NULL);
KASSERT(dvp != NULL);
KASSERT(cnp != NULL);
KASSERT(ulr_ret != NULL);
KASSERT(vp_ret != NULL);
KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
cnp->cn_flags &=~ MODMASK;
cnp->cn_flags |= (LOCKPARENT | LOCKLEAF);
error = relookup(dvp, &vp, cnp, 0 );
if ((error == 0) && (vp == NULL)) {
error = ENOENT;
goto out;
} else if (error) {
return error;
}
KASSERT(vp != NULL);
VOP_UNLOCK(vp);
out: *ulr_ret = VTOI(dvp)->i_crap;
*vp_ret = vp;
return error;
}
static bool
ext2fs_rmdired_p(struct vnode *vp)
{
KASSERT(vp != NULL);
KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
KASSERT(vp->v_type == VDIR);
return ext2fs_size(VTOI(vp)) == 0;
}
static int
ext2fs_gro_genealogy(struct mount *mp, kauth_cred_t cred,
struct vnode *fdvp, struct vnode *tdvp,
struct vnode **intermediate_node_ret)
{
struct vnode *vp, *dvp;
ino_t dotdot_ino = -1;
int error;
KASSERT(mp != NULL);
KASSERT(fdvp != NULL);
KASSERT(tdvp != NULL);
KASSERT(fdvp != tdvp);
KASSERT(intermediate_node_ret != NULL);
KASSERT(fdvp->v_mount == mp);
KASSERT(tdvp->v_mount == mp);
KASSERT(fdvp->v_type == VDIR);
KASSERT(tdvp->v_type == VDIR);
error = ext2fs_gro_lock_directory(mp, tdvp);
if (error)
return error;
vp = tdvp;
vref(vp);
for (;;) {
KASSERT(vp != NULL);
KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
KASSERT(vp->v_mount == mp);
KASSERT(vp->v_type == VDIR);
KASSERT(!ext2fs_rmdired_p(vp));
if (VTOI(vp)->i_number == UFS_ROOTINO) {
vput(vp);
*intermediate_node_ret = NULL;
return 0;
}
error = ext2fs_read_dotdot(vp, cred, &dotdot_ino);
if (error) {
vput(vp);
return error;
}
if (VTOI(fdvp)->i_number == dotdot_ino) {
VOP_UNLOCK(vp);
*intermediate_node_ret = vp;
return 0;
}
error = vcache_get(mp, &dotdot_ino, sizeof(dotdot_ino), &dvp);
vput(vp);
if (error)
return error;
error = vn_lock(dvp, LK_EXCLUSIVE);
if (error) {
vrele(dvp);
return error;
}
KASSERT(dvp != NULL);
KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
vp = dvp;
if (vp->v_type != VDIR) {
vput(vp);
return ENOTDIR;
}
if (ext2fs_rmdired_p(vp)) {
vput(vp);
return ENOENT;
}
}
}
static int
ext2fs_read_dotdot(struct vnode *vp, kauth_cred_t cred, ino_t *ino_ret)
{
struct ext2fs_dirtemplate dirbuf;
int error;
KASSERT(vp != NULL);
KASSERT(ino_ret != NULL);
KASSERT(vp->v_type == VDIR);
error = ufs_bufio(UIO_READ, vp, &dirbuf, sizeof dirbuf, (off_t)0,
IO_NODELOCKED, cred, NULL, NULL);
if (error)
return error;
if (dirbuf.dotdot_namlen != 2 ||
dirbuf.dotdot_name[0] != '.' ||
dirbuf.dotdot_name[1] != '.')
return ENOTDIR;
*ino_ret = fs2h32(dirbuf.dotdot_ino);
return 0;
}
static int
ext2fs_rename_replace_dotdot(struct vnode *vp,
struct vnode *fdvp, struct vnode *tdvp,
kauth_cred_t cred)
{
struct ext2fs_dirtemplate dirbuf;
int error;
KASSERT(0 < VTOI(fdvp)->i_e2fs_nlink);
VTOI(fdvp)->i_e2fs_nlink--;
VTOI(fdvp)->i_flag |= IN_CHANGE;
error = ufs_bufio(UIO_READ, vp, &dirbuf, sizeof dirbuf, (off_t)0,
IO_NODELOCKED, cred, NULL, NULL);
if (error)
return error;
if (dirbuf.dotdot_namlen != 2 ||
dirbuf.dotdot_name[0] != '.' ||
dirbuf.dotdot_name[1] != '.') {
ufs_dirbad(VTOI(vp), (doff_t)12, "bad `..' entry");
return 0;
}
if (fs2h32(dirbuf.dotdot_ino) != VTOI(fdvp)->i_number) {
ufs_dirbad(VTOI(vp), (doff_t)12,
"`..' does not point at parent");
return 0;
}
dirbuf.dotdot_ino = h2fs32(VTOI(tdvp)->i_number);
(void)ufs_bufio(UIO_WRITE, vp, &dirbuf, sizeof dirbuf, (off_t)0,
(IO_NODELOCKED | IO_SYNC), cred, NULL, NULL);
return 0;
}
static int
ext2fs_gro_lock_directory(struct mount *mp, struct vnode *vp)
{
(void)mp;
KASSERT(mp != NULL);
KASSERT(vp != NULL);
KASSERT(vp->v_mount == mp);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (ext2fs_rmdired_p(vp)) {
VOP_UNLOCK(vp);
return ENOENT;
}
return 0;
}
static const struct genfs_rename_ops ext2fs_genfs_rename_ops = {
.gro_directory_empty_p = ext2fs_gro_directory_empty_p,
.gro_rename_check_possible = ext2fs_gro_rename_check_possible,
.gro_rename_check_permitted = ext2fs_gro_rename_check_permitted,
.gro_remove_check_possible = ext2fs_gro_remove_check_possible,
.gro_remove_check_permitted = ext2fs_gro_remove_check_permitted,
.gro_rename = ext2fs_gro_rename,
.gro_remove = ext2fs_gro_remove,
.gro_lookup = ext2fs_gro_lookup,
.gro_genealogy = ext2fs_gro_genealogy,
.gro_lock_directory = ext2fs_gro_lock_directory,
};