RFR: 8229872: (fs) Increase buffer size used with getmntent
Vladimir Kempik
vkempik at azul.com
Mon Aug 19 13:01:42 UTC 2019
Maybe it can be done it this way:
in jni’s Java_sun_nio_fs_LinuxNativeDispatcher_setmntent0
go thru file line by line ( with getline) and find longest line, then rewind to file begin.
Thanks, Vladimir
> 19 авг. 2019 г., в 15:54, Florian Weimer <fweimer at redhat.com> написал(а):
>
> * Alan Bateman:
>
>> On 19/08/2019 12:56, Florian Weimer wrote:
>>> * Vladimir Kempik:
>>>
>>>> :
>>>>
>>>> A possible way is to use getmntent instead, it will allocated 4kb buffer on glibc and «as much as needed» on musl
>>>> (https://www.openwall.com/lists/musl/2016/09/08/1)
>>>> But getmntent is dubbed "MT-Unsafe race:mntentbuf locale»
>>>>
>>>>
>
>> Is errno set to something useful when getmntent_r fails? Just
>> wondering if it can be used to allocate a larger buffer.
>
> getmntent_r currently ignores overlong lines.
>
> One problem is that the interface is fairly broken: Reading a line
> consumes it from the stdio stream, and one can determine the required
> buffer size only after doing that. This means that the input has to be
> seekable, so that the file pointer can be restored to the original value
> in case the supplied buffer is too small. /proc/mounts is seekable, so
> it could work, but there have been quite a few buffer boundary issues in
> the kernel's procfs code, so I'm a bit wary of making this change.
>
> getmntent is easier to fix because glibc can manage the buffer
> allocation internally and make it thread-local. But it will take years
> until a potential fix reaches most distributions, and until that
> happens, using getmntent makes things potentially worse.
>
> Thanks,
> Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190819/42824fc8/signature.asc>
More information about the nio-dev
mailing list