# HG changeset patch # User Bruno Haible # Date 1213271257 -7200 # Node ID 180d2f8d135e25c5b0856325a40563d3749f0a6c # Parent 97894444a90284592217f54a65081a527cb803b5 Add a comment. diff -r 97894444a902 -r 180d2f8d135e lib/open.c --- a/lib/open.c Thu Jun 12 02:17:36 2008 +0200 +++ b/lib/open.c Thu Jun 12 13:47:37 2008 +0200 @@ -53,6 +53,27 @@ } # if OPEN_TRAILING_SLASH_BUG + /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR + is specified, then fail. + Rationale: POSIX + says that + "A pathname that contains at least one non-slash character and that + ends withone or more trailing slashes shall be resolved as if a + single dot character ( '.' ) were appended to the pathname." + and + "The special filename dot shall refer to the directory specified by + its predecessor." + If the named file already exists as a directory, then + - if O_CREAT is specified, open() must fail because of the semantics + of O_CREAT, + - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX + says that it + fails with errno = EISDIR in this case. + If the named file does not exist or does not name a directory, then + - if O_CREAT is specified, open() must fail since open() cannot create + directories, + - if O_WRONLY or O_RDWR is specified, open() must fail because the + file does not contain a '.' directory. */ if (flags & (O_CREAT | O_WRONLY | O_RDWR)) { size_t len = strlen (filename);