A Java NIO FileSystem implementation over DiscUtils
all formats are mounted by fuse also!
fs | list | upload | download | copy | move | rm | mkdir | cache | watch | create | comment |
---|---|---|---|---|---|---|---|---|---|---|---|
UDF | - | ||||||||||
FAT | β (RAW) | - | |||||||||
NTFS | β (VDI) | β (VDI) | - | ||||||||
HSF+ | β (DMG) | - | π« (ISO) same error on original | ||||||||
EXT | π§ (VDI) | - | |||||||||
XFS | - | ||||||||||
ISO | π§ | - | β | ||||||||
VHD | β (fat16) | β (fat16) | - | ||||||||
VDI | β (ntfs,fat16) | β (ntfs,fat16) | - | ||||||||
XVA | - | ||||||||||
VMDK | - | ||||||||||
DMG | β | ||||||||||
Registry | β | - | - | - | Windows 10's registry | ||||||
β BCD | β | - | - | - | Windows XP's bcd | ||||||
iSCSI | π« | server jscsi | |||||||||
NFS | π« | - | server nfs4j | ||||||||
ODS | π« | - | server vavi-net-ods | ||||||||
EMU | β (nhd) | - | - | vavi-nio-file-emu vavi-nio-file-fat | |||||||
CHD | - | jpcsp |
vavi-nio-file-discutils is a Java library to read and write ISO files and Virtual Machine disk files (VHD, VDI, XVA, VMDK, etc). DiscUtils is developed in Java with no native code.
Implementation of the ISO, UDF, FAT and NTFS file systems is now fairly stable. VHD, XVA, VMDK and VDI disk formats are implemented, as well as read/write Registry support. The library also includes a simple iSCSI initiator, for accessing disks via iSCSI and an NFS client implementation.
Note: this is a fork of https://github.com/DiscUtils/DiscUtils, which itself is a fork of https://github.com/quamotion/DiscUtils, which itself is a fork of https://discutils.codeplex.com/.
See more up to date documentation at the Wiki
This repository has performed a few changes to the core DiscUtils library. For starters, all projects have been converted to Java, and are targeting Java 8.
The vavi-nio-file-discutils library has been split into 25 independent projects, which can function without the others present. This reduces the "cost" of having vavi-nio-file-discutils immensely, as we're down from the 1 MB binary it used to be.
To work with this, four Meta packages have been created:
- complete: Everything, like before
- containers: such as VMDK, VHD, VHDX
- fileSystems: such as NTFS, FAT, EXT
- transports: such as NFS
- partitions: such as apple, bios, pc98
vavi-nio-file-discutils has a number of detection helpers. These provide services like "which filesystem is this stream?". For this to work, you must register your filesystem providers with the discUtils core. To do this, write:
META-INF/services/`class name`
Where class name
is the classes you wish to register.:
META-INF/services/discUtils.core.internal.LogicalVolumeFactory # From containers
META-INF/services/discUtils.core.vfs.VfsFileSystemFactory # From fileSystems
META-INF/services/discUtils.core.internal.VirtualDiskTransport # From transports
META-INF/services/discUtils.core.partitions.PartitionTableFactory # From partitions
as a java nio filesystem spi
URI uri = URI.create("discutils:file:/Users/foo/bar.vdi");
FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap());
// use java nio file system
Files.list(fs.getRootDirectories().iterator().next()).forEach(System.err::println);
// mount as fuse
Fuse.getFuse().mount(fs, "/your/mountPoint", Collections.emptyMap());
Here's a few really simple examples.
CDBuilder builder = new CDBuilder();
builder.useJoliet = true;
builder.volumeIdentifier = "A_SAMPLE_DISK";
builder.addFile("folder/Hello.txt", "Hello World!".getBytes(Charset.forName("ASCII")));
builder.build("/tmp/sample.iso");
You can add files as byte arrays (shown above), as files from the Windows filesystem, or as a Stream. By using a different form of Build, you can get a Stream to the ISO file, rather than writing it to the Windows filesystem.
try (FileStream isoStream = File.open("/tmp/sample.iso")) {
CDReader cd = new CDReader(isoStream, true);
Stream fileStream = cd.openFile("folder/Hello.txt", FileMode.Open);
// Use fileStream...
}
You can also browse through the directory hierarchy, starting at cd.Root.
long diskSize = 30 * 1024 * 1024; // 30MB
try (Stream vhdStream = File.create("/tmp/mydisk.vhd")) {
Disk disk = Disk.initializeDynamic(vhdStream, diskSize);
BiosPartitionTable.initialize(disk, WellKnownPartitionType.WindowsFat);
try (FatFileSystem fs = FatFileSystem.formatPartition(disk, 0, null)) {
fs.createDirectory("TestDir/CHILD");
// do other things with the file system...
}
}
As with ISOs, you can browse the file system, starting at fs.Root.
try (FileStream fs = File.create("myfloppy.vfd");
FatFileSystem floppy = FatFileSystem.formatFloppy(fs, FloppyDiskType.HighDensity, "MY FLOPPY ");
Stream s = floppy.openFile("foo.txt", FileMode.Create)) {
// Use stream...
}
Again, start browsing the file system at floppy.Root.
- https://github.com/twiglet/cs2j
- https://github.com/feyris-tan/dotnetIo4j (vavi patched)
- bcd ... https://thestarman.pcministry.com/asm/mbr/BCD.htm
compile by jdk8https://github.com/AssafTzurEl/discUtils/commit/3853944811a16d6220dcb6e8d408561e05569e43file separator- test on windows
pc98 partition(done)- d88 floppy disk
- qcow2 (wip, see aaru)
- chd (wip, see aaru)
- qlgenerator (wip, see vavi.apps.qlgenerator package)
- https://mamedev.emulab.it/haze/2012/02/16/chd-v5/
- https://github.com/rtissera/libchdr
- pscx2 has already chd code!
- iso9660
CommonVolumeDescriptor
asuser:attributes
- https://github.com/Janix520/java-iso-tools
registryπ vdi check sector length?-> Util#SeekableByteChannel*