Re: readlink() example sometimes fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Mats,

On 30 August 2016 at 03:17, Mats Wichmann <mats@xxxxxxxxxxx> wrote:
> On 08/28/2016 02:48 PM, Michael Kerrisk (man-pages) wrote:
>
>> So, it's not going to be possible to explain every corner case here, but
>> text such as you suggest is good to alert the programmer. Starting from
>> your suggestion, I reworked this to:
>>
>>        For many pseudofiles that are autogenerated by the kernel,  stat()
>>        does not return an accurate value in the st_size field.  For exam‐
>>        ple, the value 0 is returned for many files under the /proc direc‐
>>        tory,  while various files under /sys report a size of 4096 bytes,
>>        even though the file content is  smaller.   For  such  files,  one
>>        should  simply  try  to read as many bytes as possible (and append
>>        '\0' to the returned buffer if  it  is  to  be  interpreted  as  a
>>        string).
>>
>> Okay?
>
> Is it possibly better to not suggest that for some /proc files it might
> still be useful? (I don't actually know if there are cases where it is):
>
> "For pseudofiles that are autogenerated by the kernel, stat() does not
> return a meaningful value in the st_size field".

Yes, some scripting confirms you are right. I changed the wording as
you suggest. Thanks for catching that!

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux