Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs/genfs Don't use genfs_rename_knote() in the "rena...



details:   https://anonhg.NetBSD.org/src/rev/27f9205d2916
branches:  trunk
changeset: 989926:27f9205d2916
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Oct 20 13:29:06 2021 +0000

description:
Don't use genfs_rename_knote() in the "rename foo over hard-link to itself"
case, which simply results in removing the "from" name; there are assertions
in genfs_rename_knote() that are too strong for that case.

PR kern/56460

diffstat:

 sys/miscfs/genfs/genfs_rename.c |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (47 lines):

diff -r eb4f2afb377d -r 27f9205d2916 sys/miscfs/genfs/genfs_rename.c
--- a/sys/miscfs/genfs/genfs_rename.c   Wed Oct 20 13:03:29 2021 +0000
+++ b/sys/miscfs/genfs/genfs_rename.c   Wed Oct 20 13:29:06 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfs_rename.c,v 1.6 2021/10/20 03:08:18 thorpej Exp $ */
+/*     $NetBSD: genfs_rename.c,v 1.7 2021/10/20 13:29:06 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.6 2021/10/20 03:08:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.7 2021/10/20 13:29:06 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/kauth.h>
@@ -312,10 +312,14 @@
                        fcnp->cn_namelen) == 0))
                        /* Renaming an entry over itself does nothing.  */
                        error = 0;
-               else
+               else {
                        /* XXX Can't use VOP_REMOVE because of locking.  */
                        error = genfs_rename_remove(ops, mp, cred,
                            fdvp, fcnp, fde, fvp, &tvp_new_nlink);
+                       VN_KNOTE(fdvp, NOTE_WRITE);
+                       VN_KNOTE(fvp,
+                           tvp_new_nlink == 0 ? NOTE_DELETE : NOTE_LINK);
+               }
                goto out;
        }
        KASSERT(fvp != tvp);
@@ -370,10 +374,9 @@
                goto out;
 
        /* Success!  */
+       genfs_rename_knote(fdvp, fvp, tdvp, tvp, tvp_new_nlink);
 
-out:   if (error == 0) {
-               genfs_rename_knote(fdvp, fvp, tdvp, tvp, tvp_new_nlink);
-       }
+out:
        genfs_rename_exit(ops, mp, fdvp, fvp, tdvp, tvp);
        return error;
 }



Home | Main Index | Thread Index | Old Index