All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] link.2: ERRORS: add ENOENT when target is deleted
@ 2020-11-25 13:27 Mathias Rav
  2020-11-26 10:00 ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 4+ messages in thread
From: Mathias Rav @ 2020-11-25 13:27 UTC (permalink / raw)
  To: mtk.manpages; +Cc: linux-man, Mathias Rav, Mathias Rav

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

Signed-off-by: Mathias Rav <m@git.strova.dk>
---
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

 man2/link.2 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/man2/link.2 b/man2/link.2
index 1e7b2efd8..202119c6e 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
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] link.2: ERRORS: add ENOENT when target is deleted
  2020-11-25 13:27 [patch] link.2: ERRORS: add ENOENT when target is deleted Mathias Rav
@ 2020-11-26 10:00 ` Michael Kerrisk (man-pages)
  2020-11-26 12:36   ` Alejandro Colomar (man-pages)
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-11-26 10:00 UTC (permalink / raw)
  To: Mathias Rav; +Cc: mtk.manpages, linux-man, Mathias Rav

On 11/25/20 2:27 PM, Mathias Rav wrote:
> Linux kernel commit aae8a97d3ec30788790d1720b71d76fd8eb44b73
> (part of kernel release v2.6.39) added a check to disallow creating a
> hardlink to an unlinked file.
> 
> Signed-off-by: Mathias Rav <m@git.strova.dk>

Thanks, Matthias. Patch applied.

> ---
> 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

I think the above piece is actually worth including in the
commit message, so I added it.

Thanks,

Michael

>  man2/link.2 | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/man2/link.2 b/man2/link.2
> index 1e7b2efd8..202119c6e 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
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] link.2: ERRORS: add ENOENT when target is deleted
  2020-11-26 10:00 ` Michael Kerrisk (man-pages)
@ 2020-11-26 12:36   ` Alejandro Colomar (man-pages)
  2020-11-26 12:53     ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-11-26 12:36 UTC (permalink / raw)
  To: Michael Kerrisk (man-pages), Mathias Rav; +Cc: linux-man, Mathias Rav

Hi Mathias & Michael,

Please, see a fix below.

Cheers,

Alex

On 11/26/20 11:00 AM, Michael Kerrisk (man-pages) wrote:
> On 11/25/20 2:27 PM, Mathias Rav wrote:
>> Linux kernel commit aae8a97d3ec30788790d1720b71d76fd8eb44b73
>> (part of kernel release v2.6.39) added a check to disallow creating a
>> hardlink to an unlinked file.
>>
>> Signed-off-by: Mathias Rav <m@git.strova.dk>
> 
> Thanks, Matthias. Patch applied.
> 
>> ---
>> 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
> 
> I think the above piece is actually worth including in the
> commit message, so I added it.
> 
> Thanks,
> 
> Michael
> 
>>  man2/link.2 | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/man2/link.2 b/man2/link.2
>> index 1e7b2efd8..202119c6e 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).

+.TP

>> +.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
>>
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] link.2: ERRORS: add ENOENT when target is deleted
  2020-11-26 12:36   ` Alejandro Colomar (man-pages)
@ 2020-11-26 12:53     ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-11-26 12:53 UTC (permalink / raw)
  To: Alejandro Colomar (man-pages), Mathias Rav
  Cc: mtk.manpages, linux-man, Mathias Rav

On 11/26/20 1:36 PM, Alejandro Colomar (man-pages) wrote:
> Hi Mathias & Michael,
> 
> Please, see a fix below.


Thanks, Alex. Fixed!

Cheers,

Michael

> Cheers,
> 
> Alex
> 
> On 11/26/20 11:00 AM, Michael Kerrisk (man-pages) wrote:
>> On 11/25/20 2:27 PM, Mathias Rav wrote:
>>> Linux kernel commit aae8a97d3ec30788790d1720b71d76fd8eb44b73
>>> (part of kernel release v2.6.39) added a check to disallow creating a
>>> hardlink to an unlinked file.
>>>
>>> Signed-off-by: Mathias Rav <m@git.strova.dk>
>>
>> Thanks, Matthias. Patch applied.
>>
>>> ---
>>> 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
>>
>> I think the above piece is actually worth including in the
>> commit message, so I added it.
>>
>> Thanks,
>>
>> Michael
>>
>>>  man2/link.2 | 4 ++++
>>>  1 file changed, 4 insertions(+)
>>>
>>> diff --git a/man2/link.2 b/man2/link.2
>>> index 1e7b2efd8..202119c6e 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).
> 
> +.TP
> 
>>> +.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
>>>
>>
>>


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-26 12:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 13:27 [patch] link.2: ERRORS: add ENOENT when target is deleted Mathias Rav
2020-11-26 10:00 ` Michael Kerrisk (man-pages)
2020-11-26 12:36   ` Alejandro Colomar (man-pages)
2020-11-26 12:53     ` Michael Kerrisk (man-pages)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.