Files
hfsutils/test
Pablo Lezaeta 5c3886a5d5 feat: Add mount.hfs/mount.hfs+ utilities and toolset targets
Mount Implementation:
- Standard Unix mount utilities for HFS and HFS+ filesystems
- Follows Unix/BSD/Linux mount conventions
- Works standalone or as mount(8) helper

Features:
- Standard options: -o ro/rw, -r/-w, -v, --help, --version
- Standard exit codes (0=success, 1=usage error, 32=mount failure)
- Filesystem validation (verifies HFS/HFS+ signatures)
- Mountpoint validation (checks directory exists)
- Clear error messages with helpful suggestions

Files Created:
- src/mount/mount_main.c - Entry point and option parsing
- src/mount/mount_hfs.c - HFS mount implementation
- src/mount/mount_hfsplus.c - HFS+ mount implementation
- src/mount/mount_common.h - Shared definitions
- src/mount/Makefile - Build system

Makefile Targets:
- make set-hfs: Builds mkfs.hfs, fsck.hfs, mount.hfs
- make set-hfsplus: Builds mkfs.hfs+, fsck.hfs+, mount.hfs+
  * Also creates .hfsplus symlinks (mkfs.hfsplus, etc.)

Test Updates:
- Added mount tests to test_mkfs.sh
- Tests handle missing kernel drivers gracefully
- Fail only on implementation errors, not missing drivers
- Verify successful mounts with mount table check

Error Handling:
- ENODEV: Suggests loading kernel module (modprobe hfs/hfsplus)
- EACCES/EPERM: Permission denied message
- EBUSY: Device or mountpoint busy
- Invalid filesystem: Clear signature validation error

Usage Examples:
  mount.hfs /dev/sdb1 /mnt/hfs
  mount.hfs+ -r /dev/sdb1 /mnt/hfsplus
  mount.hfs+ -o ro,sync /dev/loop0 /mnt/test
2025-12-17 21:58:23 -03:00
..
2025-12-17 21:39:46 -03:00

HFS Utils Test Suite

Structure

test/
├── test_mkfs.sh      - Test filesystem creation
├── test_fsck.sh      - Test validation and repair
└── test_hfsutils.sh  - Test hfsutil commands

Running Tests

Run all tests:

cd test
bash test_mkfs.sh && bash test_fsck.sh && bash test_hfsutils.sh

Run individual tests:

bash test/test_mkfs.sh     # Test mkfs.hfs and mkfs.hfs+
bash test/test_fsck.sh     # Test fsck.hfs and fsck.hfs+
bash test/test_hfsutils.sh # Test hfsutil commands

Test Coverage

test_mkfs.sh (5 tests)

  • HFS creation with valid signature (0x4244)
  • HFS+ creation with valid signature (0x482b)
  • Minimum sizes (800KB HFS, 10MB HFS+)
  • Custom size (-s option)
  • Journaling (-j option) with Linux warning

test_fsck.sh (2 tests)

  • Clean volume validation
  • Exit code correctness

test_hfsutils.sh (3 tests)

  • hformat command
  • hmount/humount
  • Version info

Requirements

  • Build complete: ./build.sh
  • Executables in build/standalone/
  • Linux/macOS with bash

Exit Codes

  • 0 = All tests passed
  • 1 = Test failed (filesystem is corrupt or command failed)