Module Name: src Committed By: hannken Date: Sun May 25 13:48:40 UTC 2014
Modified Files: src/sys/ufs/ufs: ufs_extern.h ufs_lookup.c Log Message: Remove ufs_checkpath() and ufs_readdotdot(). These are relics from the pre-genfs_rename era. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/ufs/ufs/ufs_extern.h cvs rdiff -u -r1.130 -r1.131 src/sys/ufs/ufs/ufs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/ufs/ufs/ufs_extern.h diff -u src/sys/ufs/ufs/ufs_extern.h:1.74 src/sys/ufs/ufs/ufs_extern.h:1.75 --- src/sys/ufs/ufs/ufs_extern.h:1.74 Thu May 8 08:21:53 2014 +++ src/sys/ufs/ufs/ufs_extern.h Sun May 25 13:48:40 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extern.h,v 1.74 2014/05/08 08:21:53 hannken Exp $ */ +/* $NetBSD: ufs_extern.h,v 1.75 2014/05/25 13:48:40 hannken Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -125,9 +125,6 @@ int ufs_dirremove(struct vnode *, const int ufs_dirrewrite(struct inode *, off_t, struct inode *, ino_t, int, int, int); int ufs_dirempty(struct inode *, ino_t, kauth_cred_t); -int ufs_checkpath(struct inode *, struct inode *, kauth_cred_t); -int ufs_parentcheck(struct vnode *, struct vnode *, kauth_cred_t, - int *, struct vnode **); int ufs_blkatoff(struct vnode *, off_t, char **, struct buf **, bool); /* ufs_rename.c -- for lfs */ Index: src/sys/ufs/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.130 src/sys/ufs/ufs/ufs_lookup.c:1.131 --- src/sys/ufs/ufs/ufs_lookup.c:1.130 Thu May 8 08:21:53 2014 +++ src/sys/ufs/ufs/ufs_lookup.c Sun May 25 13:48:40 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.130 2014/05/08 08:21:53 hannken Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.131 2014/05/25 13:48:40 hannken Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.130 2014/05/08 08:21:53 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.131 2014/05/25 13:48:40 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -1228,204 +1228,6 @@ ufs_dirempty(struct inode *ip, ino_t par return (1); } -/* - * Check if source directory is in the path of the target directory. - * Target is supplied locked, source is unlocked. - * The target is always vput before returning. - */ -int -ufs_checkpath(struct inode *source, struct inode *target, kauth_cred_t cred) -{ - struct vnode *nextvp, *vp; - int error, rootino, namlen; - struct dirtemplate dirbuf; - const int needswap = UFS_MPNEEDSWAP(target->i_ump); - - vp = ITOV(target); - if (target->i_number == source->i_number) { - error = EEXIST; - goto out; - } - rootino = UFS_ROOTINO; - error = 0; - if (target->i_number == rootino) - goto out; - - for (;;) { - if (vp->v_type != VDIR) { - error = ENOTDIR; - break; - } - error = vn_rdwr(UIO_READ, vp, (void *)&dirbuf, - sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE, - IO_NODELOCKED, cred, NULL, NULL); - if (error != 0) - break; -#if (BYTE_ORDER == LITTLE_ENDIAN) - if (FSFMT(vp) && needswap == 0) - namlen = dirbuf.dotdot_type; - else - namlen = dirbuf.dotdot_namlen; -#else - if (FSFMT(vp) && needswap != 0) - namlen = dirbuf.dotdot_type; - else - namlen = dirbuf.dotdot_namlen; -#endif - if (namlen != 2 || - dirbuf.dotdot_name[0] != '.' || - dirbuf.dotdot_name[1] != '.') { - error = ENOTDIR; - break; - } - if (ufs_rw32(dirbuf.dotdot_ino, needswap) == source->i_number) { - error = EINVAL; - break; - } - if (ufs_rw32(dirbuf.dotdot_ino, needswap) == rootino) - break; - VOP_UNLOCK(vp); - error = VFS_VGET(vp->v_mount, - ufs_rw32(dirbuf.dotdot_ino, needswap), &nextvp); - vrele(vp); - if (error) { - vp = NULL; - break; - } - vp = nextvp; - } - -out: - if (error == ENOTDIR) - printf("checkpath: .. not a directory\n"); - if (vp != NULL) - vput(vp); - return (error); -} - -/* - * Extract the inode number of ".." from a directory. - * Helper for ufs_parentcheck. - */ -static int -ufs_readdotdot(struct vnode *vp, int needswap, kauth_cred_t cred, ino_t *result) -{ - struct dirtemplate dirbuf; - int namlen, error; - - error = vn_rdwr(UIO_READ, vp, &dirbuf, - sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE, - IO_NODELOCKED, cred, NULL, NULL); - if (error) { - return error; - } - -#if (BYTE_ORDER == LITTLE_ENDIAN) - if (FSFMT(vp) && needswap == 0) - namlen = dirbuf.dotdot_type; - else - namlen = dirbuf.dotdot_namlen; -#else - if (FSFMT(vp) && needswap != 0) - namlen = dirbuf.dotdot_type; - else - namlen = dirbuf.dotdot_namlen; -#endif - if (namlen != 2 || - dirbuf.dotdot_name[0] != '.' || - dirbuf.dotdot_name[1] != '.') { - printf("ufs_readdotdot: directory %llu contains " - "garbage instead of ..\n", - (unsigned long long) VTOI(vp)->i_number); - return ENOTDIR; - } - *result = ufs_rw32(dirbuf.dotdot_ino, needswap); - return 0; -} - -/* - * Check if LOWER is a descendent of UPPER. If we find UPPER, return - * nonzero in FOUND and return a reference to the immediate descendent - * of UPPER in UPPERCHILD. If we don't find UPPER (that is, if we - * reach the volume root and that isn't UPPER), return zero in FOUND - * and null in UPPERCHILD. - * - * Neither UPPER nor LOWER should be locked. - * - * On error (such as a permissions error checking up the directory - * tree) fail entirely. - * - * Note that UPPER and LOWER must be on the same volume, and because - * we inspect only that volume NEEDSWAP can be constant. - */ -int -ufs_parentcheck(struct vnode *upper, struct vnode *lower, kauth_cred_t cred, - int *found_ret, struct vnode **upperchild_ret) -{ - const int needswap = UFS_MPNEEDSWAP(VTOI(lower)->i_ump); - ino_t upper_ino, found_ino = 0; /* XXX: gcc */ - struct vnode *current, *next; - int error; - - if (upper == lower) { - vref(upper); - *found_ret = 1; - *upperchild_ret = upper; - return 0; - } - if (VTOI(lower)->i_number == UFS_ROOTINO) { - *found_ret = 0; - *upperchild_ret = NULL; - return 0; - } - - upper_ino = VTOI(upper)->i_number; - - current = lower; - vref(current); - vn_lock(current, LK_EXCLUSIVE | LK_RETRY); - - for (;;) { - error = ufs_readdotdot(current, needswap, cred, &found_ino); - if (error) { - vput(current); - return error; - } - if (found_ino == upper_ino) { - VOP_UNLOCK(current); - *found_ret = 1; - *upperchild_ret = current; - return 0; - } - if (found_ino == UFS_ROOTINO) { - vput(current); - *found_ret = 0; - *upperchild_ret = NULL; - return 0; - } - VOP_UNLOCK(current); - error = VFS_VGET(current->v_mount, found_ino, &next); - if (error) { - vrele(current); - return error; - } - KASSERT(VOP_ISLOCKED(next)); - if (next->v_type != VDIR) { - printf("ufs_parentcheck: inode %llu reached via .. of " - "inode %llu is not a directory\n", - (unsigned long long)VTOI(next)->i_number, - (unsigned long long)VTOI(current)->i_number); - vput(next); - vrele(current); - return ENOTDIR; - } - vrele(current); - current = next; - } - - return 0; -} - #define UFS_DIRRABLKS 0 int ufs_dirrablks = UFS_DIRRABLKS;