open.2: Fix bug in linkat(2) call example
PATCH 1/1 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 <[email protected]>
Cc Theodore Ts'o <[email protected]>
Cc Adam Borowski <[email protected]>
Signed-off-by Alejandro Colomar <[email protected]>
--- man2/open.2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man2/open.2 +1 -1
@@ -823,7 +823,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)),
Signature · 1 line
2.30.1.721.g45526154a5