Module Name: src
Committed By: rillig
Date: Mon Oct 10 17:33:35 UTC 2022
Modified Files:
src/usr.bin/make: main.c
Log Message:
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
To generate a diff of this commit:
cvs rdiff -u -r1.583 -r1.584 src/usr.bin/make/main.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.583 src/usr.bin/make/main.c:1.584
--- src/usr.bin/make/main.c:1.583 Wed Sep 28 16:34:47 2022
+++ src/usr.bin/make/main.c Mon Oct 10 17:33:35 2022
@@ -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 @@ unlink_file(const char *file)
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;
}