Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make: document the guard for directories in unl...



details:   https://anonhg.NetBSD.org/src/rev/e2b540f4a808
branches:  trunk
changeset: 371785:e2b540f4a808
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Oct 10 17:33:35 2022 +0000

description:
make: document the guard for directories in unlink_file

Document only the POSIX requirement for now, as I didn't find
information about _which_ ancient UNIX systems would corrupt the
filesystem on unlinking a directory.

http://man.cat-v.org/unix-1st/2/sys-unlink (1971) says:
> It is also illegal to unlink a directory (except for the super-user).

https://mail-index.netbsd.org/tech-toolchain/2022/10/06/msg004147.html

diffstat:

 usr.bin/make/main.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r 0cf657b8c7de -r e2b540f4a808 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Oct 09 21:43:38 2022 +0000
+++ b/usr.bin/make/main.c       Mon Oct 10 17:33:35 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.583 2022/09/28 16:34:47 sjg Exp $   */
+/*     $NetBSD: main.c,v 1.584 2022/10/10 17:33:35 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.583 2022/09/28 16:34:47 sjg Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.584 2022/10/10 17:33:35 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -1890,6 +1890,10 @@
                return false;
 
        if (S_ISDIR(st.st_mode)) {
+               /*
+                * POSIX says for unlink: "The path argument shall not name
+                * a directory unless [...]".
+                */
                errno = EISDIR;
                return false;
        }



Home | Main Index | Thread Index | Old Index