]> git.ipfire.org Git - thirdparty/man-pages.git/commit
link.2: ERRORS: add ENOENT when target is deleted
authorMathias Rav <m@git.strova.dk>
Wed, 25 Nov 2020 13:27:32 +0000 (14:27 +0100)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Thu, 26 Nov 2020 09:58:54 +0000 (10:58 +0100)
commit336be2e745d4e9cecba1c53013d628f4e467bcff
treeab890249f0f67528faaafc554cb3f8dffe46191b
parentaf5a2ff87ec2be8e233ddf19299d4c5d6c74cd7c
link.2: ERRORS: add ENOENT when target is deleted

Linux kernel commit aae8a97d3ec30788790d1720b71d76fd8eb44b73 (part
of kernel release v2.6.39) added a check to disallow creating a
hardlink to an unlinked file.

The manual page already describes the trick of using
AT_SYMLINK_FOLLOW as an alternative to AT_EMPTY_PATH, and for
AT_EMPTY_PATH the manual page already notes that it "will
generally not work if the file has a link count of zero". However,
the precise error (ENOENT) is not mentioned, and the error case
isn't mentioned in the ERRORS section at all.

This makes it easy to overlook the fact that the AT_SYMLINK_FOLLOW
trick on /proc/self/fd/NN won't work on deleted files, as
evidenced by the follow message (which turns up when googling
"linkat deleted ENOENT"):
https://groups.google.com/g/linux.kernel/c/zZO4lqqwp64

Signed-off-by: Mathias Rav <m@git.strova.dk>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man2/link.2