-
Notifications
You must be signed in to change notification settings - Fork 0
Filesystem Layer
JNode's filesystem architecture is a modular layer that abstracts block devices, partition tables, and file systems, exposing a unified Virtual File System (VFS) to Java applications.
Because JNode runs natively on hardware, it implements its entire storage stack in Java. This stack consists of three major layers:
- Block Device Drivers: Interact with physical hardware (IDE, SATA, USB, Floppy) to read and write raw sectors.
- Partition Tables: Read the raw disks to identify logical partitions (MBR, GPT).
- File Systems: Mount logical partitions and present directories, files, and metadata (FAT, Ext2, NTFS, etc.).
All filesystem code is located in the fs/ subproject.
| Path | Purpose |
|---|---|
fs/src/driver/ |
Block device drivers (ide/, floppy/, scsi/, ramdisk/). |
fs/src/partitions/ |
Partition table parsers (ibm/ (MBR), gpt/, apm/). |
fs/src/fs/ |
The core FS API and filesystem implementations. |
fs/src/commands/ |
Shell commands for disk/FS management (e.g., format, mount). |
A block device is a Device that exposes the BlockDeviceAPI.
-
BlockDeviceAPI: Provides methods to read and write chunks of data at specific sector offsets. -
Geometry: Represents the physical layout of the disk (Cylinders, Heads, Sectors). -
FSBlockDeviceAPI: An extension used by filesystems, providing optimized access.
Block drivers (like the IDE driver) are registered with the DeviceManager just like any other driver.
When a new block device is detected, the PartitionManager service scans it.
-
PartitionTableType: An interface for parsing a specific partition scheme (e.g.,IBMPartitionTableTypefor MBR). -
PartitionTable/PartitionTableEntry: Represent the parsed structure.
If a partition table is found, the manager creates new Device objects for each partition. These partition devices also expose BlockDeviceAPI and FSBlockDeviceAPI, mapping logical block requests to physical offsets on the parent disk.
File systems are implemented as plugins that provide a FileSystemType.
-
FileSystemType: The factory that creates aFileSysteminstance given a block device. -
FileSystem: Represents a mounted filesystem. Provides access to the root directory. -
FSDirectory: Represents a folder. Can list childFSEntryobjects. -
FSEntry: A directory entry (file or folder). Provides access to metadata (size, dates, permissions). -
FSFile: Represents a file. Provides methods to read and write bytes.
JNode has varying levels of support for several filesystems, implemented in fs/src/fs/org/jnode/fs/:
-
Read/Write:
fat(FAT12/16/32),ramfs,exfat -
Read-Only:
ext2,ntfs,iso9660(CD-ROMs),hfs -
Virtual/Network:
nfs,smbfs,ftpfs
See VFS-Layer for a detailed deep dive into JNode's in-memory VFS implementation, including the mount mechanism, FileSystemType interface, and path resolution flow.
- The
FileSystemServicemanages the global namespace. - Drives/partitions are mounted into this namespace (e.g., as
hd0a/or/). - JNode provides a custom
java.io.FileSystemimplementation in OpenJDK/Classpath that routes standard file operations (likenew FileInputStream("/hd0a/test.txt")) into JNode'sFileSystemService.
- Driver-Framework — How block devices are registered and managed.
-
Plugin-System — How filesystem types (
FileSystemType) are registered via extension points. - Architecture — How the FS layer fits into the overall OS architecture.