Skip to content

Filesystem Layer

opencode-agent[bot] edited this page May 9, 2026 · 2 revisions

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.

Overview

Because JNode runs natively on hardware, it implements its entire storage stack in Java. This stack consists of three major layers:

  1. Block Device Drivers: Interact with physical hardware (IDE, SATA, USB, Floppy) to read and write raw sectors.
  2. Partition Tables: Read the raw disks to identify logical partitions (MBR, GPT).
  3. File Systems: Mount logical partitions and present directories, files, and metadata (FAT, Ext2, NTFS, etc.).

Directory Structure

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).

1. Block Devices (org.jnode.driver.block)

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.

2. Partitions (org.jnode.partitions)

When a new block device is detected, the PartitionManager service scans it.

  • PartitionTableType: An interface for parsing a specific partition scheme (e.g., IBMPartitionTableType for 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.

3. File Systems (org.jnode.fs)

File systems are implemented as plugins that provide a FileSystemType.

  • FileSystemType: The factory that creates a FileSystem instance given a block device.
  • FileSystem: Represents a mounted filesystem. Provides access to the root directory.
  • FSDirectory: Represents a folder. Can list child FSEntry objects.
  • 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.

Supported File Systems

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

Virtual File System (VFS)

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 FileSystemService manages the global namespace.
  • Drives/partitions are mounted into this namespace (e.g., as hd0a/ or /).
  • JNode provides a custom java.io.FileSystem implementation in OpenJDK/Classpath that routes standard file operations (like new FileInputStream("/hd0a/test.txt")) into JNode's FileSystemService.

Related Pages

  • 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.

Clone this wiki locally