tech-userlevel archive

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

[PATCH] link.2: NetBSD doesn't allow link(2) to a directory, ever



cf. src/sys/kern/vfs_syscalls.c#do_sys_linkat:
        /* Prevent hard links on directories. */
        if (vp->v_type == VDIR) {
                error = EPERM;
                goto abortop;
        }

This happens before any call to the VFS, so NetBSD simply refuses links
to directories (this is legal, but the manual needs to be updated).
This blames back to 1.423 (2011-04-24).
---
Index: lib/libc/sys/link.2
===================================================================
RCS file: /cvsroot/src/lib/libc/sys/link.2,v
retrieving revision 1.33
diff -u -r1.33 link.2
--- lib/libc/sys/link.2	1 Sep 2019 19:52:32 -0000	1.33
+++ lib/libc/sys/link.2	19 Jul 2024 23:54:35 -0000
@@ -78,8 +78,7 @@
 .Fa name2
 must be in the same file system.
 .Fa name1
-may not be a directory unless the caller is the super-user
-and the file system containing it supports linking to directories.
+may not be a directory.
 .Pp
 .Fn linkat
 works the same way as
@@ -188,11 +187,7 @@
 .It Bq Er EPERM
 The file named by
 .Fa name1
-is a directory and the effective
-user ID is not super-user,
-or the file system containing the file does not permit the use of
-.Fn link
-on a directory.
+is a directory.
 .It Bq Er EROFS
 The requested link requires writing in a directory on a read-only file
 system.

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index