RFR: 8293122: (fs) Use file cloning in macOS version of Files::copy method
Alan Bateman
alanb at openjdk.org
Wed Sep 7 15:17:49 UTC 2022
On Wed, 7 Sep 2022 00:48:31 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Use BSD system call `clonefile` if possible when using `Files::copy` on macOS.
src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java line 101:
> 99: BsdFileStore bfs = (BsdFileStore)provider().getFileStore(src);
> 100: if (!bfs.equals(provider().getFileStore(dst.getParent())) ||
> 101: !bfs.supportsCloning())
Is 'dst' a relative path, in which case you can't rely on getParent. In any case, I don't think we should be checking the FileStore here as that means finding the mount entry. If we do clonefile then I think you'll have to rely on the EXDEV error.
src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java line 141:
> 139: // cancellation is not possible, or attributes are not to be copied
> 140: if (!cloneFileNotSupported && addressToPollForCancel == 0 &&
> 141: flags.copyPosixAttributes) {
This will need some thought as this means it will only be used when Files.copy is invoked with the COPY_ATTRIBUTES option.
-------------
PR: https://git.openjdk.org/jdk/pull/10188
More information about the nio-dev
mailing list