I'm using brtfs, and I'd like my Java program to copy a set of large files copy-on-write.
In other words, what's the equivalent of cp --reflink=auto in some library that hopefully exists and somebody has heard of, so they can tell me? :-)
I'm using brtfs, and I'd like my Java program to copy a set of large files copy-on-write.
In other words, what's the equivalent of cp --reflink=auto in some library that hopefully exists and somebody has heard of, so they can tell me? :-)
Copyright © 2021 Jogjafile Inc.
There isn't a Java-specific API to my knowledge, because this is a rather specific, OS-dependent, and filesystem-dependent feature. However, with the help of a library that can issue ioctls (e.g. this one which I have no affiliation with and found by googling), you can issue the
ficlonerangeioctl.To invoke it you'll need to put together a struct:
It's a bit roundabout in Java, but as an example, you should be able to do this as follows using the linked library:
Native.getDirectBufferPointerIf that seems too brittle, consider writing a C or C++ library that calls the ioctl and has a more convenient API, and then call into it via JNI.