RFR: 8349812: (fs) Files.newByteChannel with empty path name and CREATE_NEW throws unexpected exception

Brian Burkhalter bpb at openjdk.org
Tue Feb 11 21:48:11 UTC 2025


On Tue, 11 Feb 2025 20:49:55 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> src/java.base/unix/classes/sun/nio/fs/UnixChannelFactory.java line 198:
>> 
>>> 196:             // create flags
>>> 197:             if (flags.createNew) {
>>> 198:                 byte[] pathForSysCall = path.getByteArrayForSysCalls();
>> 
>> Does this need to be done at line 240 as well?
>> 
>> fd = openat(dfd, path.asByteArray(), oflags, mode);
>
> With *at functions the second parameter is relative to the open directory so need to be careful, need to make sure there are good tests before changing anything. In other words, something else must be broken if *at functions are being called with a getByteArrayForSysCalls as the second parameter.

> When *at functions the second parameter is relative to the open directory [...]

I tested this for `fstatat` by obtaining the attributes of a file via a `SecureDirectoryStream` and it made no difference, but if `UnixFileSystem.needToResolveAgainstDefaultDirectory()` returned `true`, it seems likely it would introduce a problem. Hence I suggest ignoring my comment above and leaving line 240 as is.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23560#discussion_r1951653832


More information about the nio-dev mailing list