Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs Fix last commit that broke lookup for dot with op DE...



details:   https://anonhg.NetBSD.org/src/rev/41a3c430bf37
branches:  trunk
changeset: 778103:41a3c430bf37
user:      hannken <hannken%NetBSD.org@localhost>
date:      Fri Mar 16 08:39:54 2012 +0000

description:
Fix last commit that broke lookup for dot with op DELETE.

Reviewed by: David Holland <dholland%netbsd.org@localhost>

diffstat:

 sys/ufs/ext2fs/ext2fs_lookup.c |  38 ++++++++++++++++++++++----------------
 sys/ufs/ufs/ufs_lookup.c       |  39 ++++++++++++++++++++++-----------------
 2 files changed, 44 insertions(+), 33 deletions(-)

diffs (149 lines):

diff -r 338e14d811e2 -r 41a3c430bf37 sys/ufs/ext2fs/ext2fs_lookup.c
--- a/sys/ufs/ext2fs/ext2fs_lookup.c    Fri Mar 16 08:14:11 2012 +0000
+++ b/sys/ufs/ext2fs/ext2fs_lookup.c    Fri Mar 16 08:39:54 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ext2fs_lookup.c,v 1.68 2012/03/13 18:41:03 elad Exp $  */
+/*     $NetBSD: ext2fs_lookup.c,v 1.69 2012/03/16 08:39:54 hannken Exp $       */
 
 /*
  * Modified for NetBSD 1.2E
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.68 2012/03/13 18:41:03 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.69 2012/03/16 08:39:54 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -586,18 +586,26 @@
                        results->ulr_count = 0;
                else
                        results->ulr_count = results->ulr_offset - prevoff;
-               if (flags & ISDOTDOT)
-                       VOP_UNLOCK(vdp); /* race to get the inode */
-               error = VFS_VGET(vdp->v_mount, foundino, &tdp);
-               if (flags & ISDOTDOT)
-                       vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
-               if (error)
-                       return (error);
+               if (dp->i_number == foundino) {
+                       vref(vdp);
+                       tdp = vdp;
+               } else {
+                       if (flags & ISDOTDOT)
+                               VOP_UNLOCK(vdp); /* race to get the inode */
+                       error = VFS_VGET(vdp->v_mount, foundino, &tdp);
+                       if (flags & ISDOTDOT)
+                               vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
+                       if (error)
+                               return (error);
+               }
                /*
                 * Write access to directory required to delete files.
                 */
                if ((error = VOP_ACCESS(vdp, VWRITE, cred)) != 0) {
-                       vput(tdp);
+                       if (dp->i_number == foundino)
+                               vrele(tdp);
+                       else
+                               vput(tdp);
                        return (error);
                }
                /*
@@ -611,15 +619,13 @@
                            tdp, vdp, genfs_can_sticky(cred, dp->i_uid,
                            VTOI(tdp)->i_uid));
                        if (error) {
-                               vput(tdp);
+                               if (dp->i_number == foundino)
+                                       vrele(tdp);
+                               else
+                                       vput(tdp);
                                return (EPERM);
                        }
                }
-               if (dp->i_number == foundino) {
-                       vref(vdp);
-                       *vpp = vdp;
-                       return (0);
-               }
                *vpp = tdp;
                return (0);
        }
diff -r 338e14d811e2 -r 41a3c430bf37 sys/ufs/ufs/ufs_lookup.c
--- a/sys/ufs/ufs/ufs_lookup.c  Fri Mar 16 08:14:11 2012 +0000
+++ b/sys/ufs/ufs/ufs_lookup.c  Fri Mar 16 08:39:54 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_lookup.c,v 1.112 2012/03/13 18:41:14 elad Exp $    */
+/*     $NetBSD: ufs_lookup.c,v 1.113 2012/03/16 08:39:54 hannken Exp $ */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.112 2012/03/13 18:41:14 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.113 2012/03/16 08:39:54 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -532,19 +532,27 @@
                        results->ulr_count = 0;
                else
                        results->ulr_count = results->ulr_offset - prevoff;
-               if (flags & ISDOTDOT)
-                       VOP_UNLOCK(vdp); /* race to get the inode */
-               error = VFS_VGET(vdp->v_mount, foundino, &tdp);
-               if (flags & ISDOTDOT)
-                       vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
-               if (error)
-                       goto out;
+               if (dp->i_number == foundino) {
+                       vref(vdp);
+                       tdp = vdp;
+               } else {
+                       if (flags & ISDOTDOT)
+                               VOP_UNLOCK(vdp); /* race to get the inode */
+                       error = VFS_VGET(vdp->v_mount, foundino, &tdp);
+                       if (flags & ISDOTDOT)
+                               vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
+                       if (error)
+                               goto out;
+               }
                /*
                 * Write access to directory required to delete files.
                 */
                error = VOP_ACCESS(vdp, VWRITE, cred);
                if (error) {
-                       vput(tdp);
+                       if (dp->i_number == foundino)
+                               vrele(tdp);
+                       else
+                               vput(tdp);
                        goto out;
                }
                /*
@@ -558,17 +566,14 @@
                            tdp, vdp, genfs_can_sticky(cred, dp->i_uid,
                            VTOI(tdp)->i_uid));
                        if (error) {
-                               vput(tdp);
+                               if (dp->i_number == foundino)
+                                       vrele(tdp);
+                               else
+                                       vput(tdp);
                                error = EPERM;
                                goto out;
                        }
                }
-               if (dp->i_number == foundino) {
-                       vref(vdp);
-                       *vpp = vdp;
-                       error = 0;
-                       goto out;
-               }
                *vpp = tdp;
                error = 0;
                goto out;



Home | Main Index | Thread Index | Old Index