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

наб <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <l6rb4t2vdlpkrqwx5mrqpgep63xa5zwectmrakcafzztoeer62@tarta.nabijaczleweli.xyz>
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.
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmaa/MUACgkQvP0LAY0m
WPG6Rw/+Pj0xqXG9ytR/pGjCaK80Fm2rmGTQb0Q4S3SRd7mQzocvOcIt/QRXCzPg
waHnkbxlbhqXa5HCa8JStYFKlNM+8gPaoVDpDPSO+BQ7O4MC6nt2vMXryV0V1oxi
T3Sdot9xLzA5ndnKNq6fOWHr8Pltcq/DLJZ8d9yfB/57obvdQ/MmTWMRcOdnS4AN
jtsw1wgxU1e8OB036cFmKomq+eIpty438uFfzG9lGRbtgHkIByeFrv8MhuUFFsJO
fFUBM5AkPRgHgQJ0mY8LQc0wX0btzbBNCu2reEGMRH0Bf67w6kTd9XZRCfg2sC14
UXVZkIKIPo9VbVCsdBhbSni/Ma84+6LSig+yFYsnkWYl335xAX/Bd/L54vPFDS1v
K41mT5hjidBg7wyJ/vkVkIe6XURVY+pxqn0v/VnWjVy+QepOczq7cAB7p7XAVbeF
jgGCoKDu6OHC1OtfVamq1ARjq1cCfM2A3CSuHw42VoAHURZt7cYmb2FgZvDdlsfK
3N6VjTRzmJ3K+QYdjrGHvF5mWl5AZ+zJfnfFEDxNI/31al59ezk0KfOZpiA1tL9K
e9Yyahcli5xydQQtjry/Tytj0ABDCoya8bV29CmTCfNs+25u3BwtYQgq4/R8E71w
sBQJjPOIWDKHGbqeWBCzT9tHcUzkFW32pVPAi8AO3D6MO5BcTrk=
=wkyJ
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.