aboutsummaryrefslogtreecommitdiffstats
path: root/lib/open.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/open.c')
-rw-r--r--lib/open.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/open.c b/lib/open.c
index 4572ebf6cd2..0c2742bbda6 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -92,9 +92,13 @@ open (const char *filename, int flags, ...)
92#endif 92#endif
93 93
94#if OPEN_TRAILING_SLASH_BUG 94#if OPEN_TRAILING_SLASH_BUG
95 /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR 95 /* Fail if one of O_CREAT, O_WRONLY, O_RDWR is specified and the filename
96 is specified, then fail. 96 ends in a slash, as POSIX says such a filename must name a directory
97 Rationale: POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html> 97 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
98 "A pathname that contains at least one non-<slash> character and that
99 ends with one or more trailing <slash> characters shall not be resolved
100 successfully unless the last pathname component before the trailing
101 <slash> characters names an existing directory"
98 If the named file already exists as a directory, then 102 If the named file already exists as a directory, then
99 - if O_CREAT is specified, open() must fail because of the semantics 103 - if O_CREAT is specified, open() must fail because of the semantics
100 of O_CREAT, 104 of O_CREAT,
@@ -164,6 +168,12 @@ open (const char *filename, int flags, ...)
164#if OPEN_TRAILING_SLASH_BUG 168#if OPEN_TRAILING_SLASH_BUG
165 /* If the filename ends in a slash and fd does not refer to a directory, 169 /* If the filename ends in a slash and fd does not refer to a directory,
166 then fail. 170 then fail.
171 Rationale: POSIX says such a filename must name a directory
172 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
173 "A pathname that contains at least one non-<slash> character and that
174 ends with one or more trailing <slash> characters shall not be resolved
175 successfully unless the last pathname component before the trailing
176 <slash> characters names an existing directory"
167 If the named file without the slash is not a directory, open() must fail 177 If the named file without the slash is not a directory, open() must fail
168 with ENOTDIR. */ 178 with ENOTDIR. */
169 if (fd >= 0) 179 if (fd >= 0)