Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/common lstat: since namei() returns an error (EIS...



details:   https://anonhg.NetBSD.org/src/rev/82f5ddb9008f
branches:  trunk
changeset: 495327:82f5ddb9008f
user:      pk <pk%NetBSD.org@localhost>
date:      Wed Jul 26 11:43:07 2000 +0000

description:
lstat: since namei() returns an error (EISDIR) if there is no parent to lock,
retry the lookup without LOCKPARENT if that happens. This is safe, since
need to have LOCKPARENT only if the vnode is of type VLNK.

diffstat:

 sys/compat/common/vfs_syscalls_43.c |  29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diffs (52 lines):

diff -r 94e41d79efcb -r 82f5ddb9008f sys/compat/common/vfs_syscalls_43.c
--- a/sys/compat/common/vfs_syscalls_43.c       Wed Jul 26 11:42:41 2000 +0000
+++ b/sys/compat/common/vfs_syscalls_43.c       Wed Jul 26 11:43:07 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls_43.c,v 1.13 2000/03/30 11:27:15 augustss Exp $    */
+/*     $NetBSD: vfs_syscalls_43.c,v 1.14 2000/07/26 11:43:07 pk Exp $  */
 
 /*
  * Copyright (c) 1989, 1993
@@ -146,11 +146,22 @@
        struct stat43 osb;
        int error;
        struct nameidata nd;
+       int ndflags;
 
-       NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
-           SCARG(uap, path), p);
-       if ((error = namei(&nd)))
+       ndflags = NOFOLLOW | LOCKLEAF | LOCKPARENT;
+again:
+       NDINIT(&nd, LOOKUP, ndflags, UIO_USERSPACE, SCARG(uap, path), p);
+       if ((error = namei(&nd))) {
+               if (error == EISDIR && (ndflags & LOCKPARENT) != 0) {
+                       /*
+                        * Should only happen on '/'. Retry without LOCKPARENT;
+                        * this is safe since the vnode won't be a VLNK.
+                        */
+                       ndflags &= ~LOCKPARENT;
+                       goto again;
+               }
                return (error);
+       }
        /*
         * For symbolic links, always return the attributes of its
         * containing directory, except for mode, size, and links.
@@ -158,10 +169,12 @@
        vp = nd.ni_vp;
        dvp = nd.ni_dvp;
        if (vp->v_type != VLNK) {
-               if (dvp == vp)
-                       vrele(dvp);
-               else
-                       vput(dvp);
+               if ((ndflags & LOCKPARENT) != 0) {
+                       if (dvp == vp)
+                               vrele(dvp);
+                       else
+                               vput(dvp);
+               }
                error = vn_stat(vp, &sb, p);
                vput(vp);
                if (error)



Home | Main Index | Thread Index | Old Index