RFR: 8229872: (fs) Increase buffer size used with getmntent

Florian Weimer fweimer at redhat.com
Wed Sep 4 16:15:55 UTC 2019


* Vladimir Kempik:

> After thinking about it, I think it’s better to leave getlinelen as is, and just increase maxLineSize by one in getMountEntries.
>
> here is webrev: http://cr.openjdk.java.net/~vkempik/8229872/webrev.07/

Buffer sizes should be size_t, not int (in
Java_sun_nio_fs_LinuxNativeDispatcher_getmntent).

The error handling in Java_sun_nio_fs_UnixNativeDispatcher_getlinelen
does not look portable to me.  Some versions of getline return -1 on
EOF.  Something like

    int saved_errno;
    ssize_t res = getline(&lineBuffer, &lineSize, fp);
    saved_errno = errno;
    free(lineBuffer);
    if (feof(fp))
        return 0;
    if (res == -1)
        throwUnixException(env, saved_errno);
    return res;

should work.
    
Thanks,
Florian


More information about the nio-dev mailing list