Skip to content

Enhancement: Add mkdir -p support for recursive directory creation #463

@LSantha

Description

@LSantha

Problem

JNode shell mkdir command does not support -p (parents) flag for creating nested directories. Users must create each level manually.

Current Behavior

  • mkdir /devices/hdc0/a/b/c fails if intermediate directories /devices/hdc0/a or /devices/hdc0/a/b do not exist
  • Only single directory creation: mkdir <directory> with no flags

Expected Behavior

  • mkdir -p /devices/hdc0/a/b/c should create /devices/hdc0/a, /devices/hdc0/a/b, and /devices/hdc0/a/b/c as needed
  • mkdir --parents <path> should work as alternative syntax

Validation Instructions (QEMU)

# Start JNode with FAT32 test image
rm -f /tmp/jnode.serial2 /tmp/qemu_serial.log
qemu-system-x86_64 -m 768 -cdrom all/build/cdroms/jnode-x86-lite.iso \
  -drive file=/tmp/fat32-working.img,format=raw \
  -serial file:/tmp/qemu_serial.log \
  -serial unix:/tmp/jnode.serial2,server,nowait \
  -no-reboot -display none &

sleep 45
ln -sf /tmp/jnode.serial2 /tmp/jnode_com2

# Test current behavior (should fail if parent does not exist)
python3 .opencode/skills/jnode-interact/scripts/jnode_agent_cmd.py "mkdir /devices/hdc0/parent/child"

# After fix, this should succeed
python3 .opencode/skills/jnode-interact/scripts/jnode_agent_cmd.py "mkdir -p /devices/hdc0/parent/child"
python3 .opencode/skills/jnode-interact/scripts/jnode_agent_cmd.py "ls /devices/hdc0/parent"

Implementation Notes

  • Edit cli/src/commands/org/jnode/command/file/MkdirCommand.java
  • Add --parents | -p option flag
  • Use File.mkdirs() instead of File.mkdir() when -p is specified
  • Update XML descriptor: cli/descriptors/org.jnode.command.file.xml

Unit Tests

  • Create test in cli/src/commands/org/jnode/command/file/MkdirCommandTest.java
  • Test: single create, nested create with -p, nested create without -p (should fail)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions