From: Mathias Rav Date: Wed, 25 Nov 2020 13:27:32 +0000 (+0100) Subject: link.2: ERRORS: add ENOENT when target is deleted X-Git-Tag: man-pages-5.10~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=336be2e745d4e9cecba1c53013d628f4e467bcff;p=thirdparty%2Fman-pages.git 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 Signed-off-by: Michael Kerrisk --- diff --git a/man2/link.2 b/man2/link.2 index 1e7b2efd81..202119c6ef 100644 --- a/man2/link.2 +++ b/man2/link.2 @@ -318,6 +318,10 @@ open(path, O_TMPFILE | O_EXCL, mode); .IP See .BR open (2). +.B ENOENT +An attempt was made to link to a +.I /proc/self/fd/NN +file corresponding to a file that has been deleted. .TP .B ENOENT .I oldpath