mirror of https://github.com/mkerrisk/man-pages
open.2: Fix bug in linkat(2) call example
AT_EMPTY_PATH works with empty strings (""), but not with NULL (or at least it's not obvious). The relevant kernel code is the following: linux$ sed -n 189,198p fs/namei.c result->refcnt = 1; /* The empty path is special. */ if (unlikely(!len)) { if (empty) *empty = 1; if (!(flags & LOOKUP_EMPTY)) { putname(result); return ERR_PTR(-ENOENT); } } Reported-by: Walter Harms <wharms@bfs.de> Cc: Theodore Ts'o <tytso@mit.edu> Cc: Adam Borowski <kilobyte@angband.pl> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
3eb81f5117
commit
1c55195743
|
@ -824,7 +824,7 @@ fd = open("/path/to/dir", O_TMPFILE | O_RDWR,
|
|||
|
||||
/* File I/O on \(aqfd\(aq... */
|
||||
|
||||
linkat(fd, NULL, AT_FDCWD, "/path/for/file", AT_EMPTY_PATH);
|
||||
linkat(fd, "", AT_FDCWD, "/path/for/file", AT_EMPTY_PATH);
|
||||
|
||||
/* If the caller doesn\(aqt have the CAP_DAC_READ_SEARCH
|
||||
capability (needed to use AT_EMPTY_PATH with linkat(2)),
|
||||
|
|
Loading…
Reference in New Issue