Skip to content

Conversation

@ChinYikMing
Copy link
Collaborator

@ChinYikMing ChinYikMing commented Oct 25, 2025

Description

To enhance the guest OS functionality, this commit integrates the simplefs kernel module to support an additional filesystem. It appends simplefs as a new Linux image artifact and automatically builds the latest simplefs.ko when make build-linux-image is executed.

Testing

  1. Clone the repo:
$ git clone https://github.com/ChinYikMing/rv32emu.git -b mount-simplefs --depth 1 && cd rv32emu
  1. Build emulator
$ make ENABLE_SYSTEM=1 INITRD_SIZE=32 -j8
  1. Fetch artifacts
$ make artifact ENABLE_SYSTEM=1
  1. Create ext4 disk image and store simple.ko
$ dd if=/dev/zero of=disk.img bs=4M count=32
$ mkfs.ext4 disk.img
$ mkdir mnt
$ sudo mount disk.img mnt
$ sudo cp build/linux-image/simplefs.ko mnt
$ sudo umount mnt
  1. Clone simplefs to create simplefs disk image
$ git clone https://github.com/sysprog21/simplefs.git --depth 1
$ make test.img -C simplefs
  1. Boot guestOS
$ build/rv32emu -k build/linux-image/Image -i build/linux-image/rootfs.cpio -x vblk:disk.img -x vblk:simplefs/test.img
  1. insmod simplefs.ko
# mkdir -p mnt && mount /dev/vdb mnt && insmod mnt/simplefs.ko
  1. Mount simplefs disk image
# mkdir -p simplefs && mount -t simplefs /dev/vda simplefs
  1. Manipulate the disk image typed simplefs
# cd simplefs
# touch apple
# ls
apple
# mkdir banana
# ls 
apple banana

Expectation

  • Filesystem commands like cd, touch, ls, mkdir, etc should be operational.

  • Run mount and the /dev/vda has filesystem typed simplefs will be shown.

Sample output:

# mount
rootfs on / type rootfs (rw,size=241136k,nr_inodes=60284)
devtmpfs on /dev type devtmpfs (rw,relatime,size=241136k,nr_inodes=60284,mode=755)
proc on /proc type proc (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=666)
tmpfs on /dev/shm type tmpfs (rw,relatime)
tmpfs on /tmp type tmpfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
sysfs on /sys type sysfs (rw,relatime)
/dev/vdb on /root/mnt type ext4 (rw,relatime)
/dev/vda on /root/simplefs type simplefs (rw,relatime)

Summary by cubic

Add simplefs support by auto-building and packaging simplefs.ko as a Linux image artifact, so the guest OS can mount and use simplefs volumes. README includes brief usage steps.

  • New Features

    • Build simplefs.ko in tools/build-linux-image.sh and output to build/linux-image/.
    • Include simplefs.ko in artifact checksums (mk/artifact.mk).
    • Add SIMPLEFS as external data and a build prerequisite (mk/external.mk, mk/tools.mk).
    • Document how to attach the module and mount a simplefs disk in the README.
  • Dependencies

    • Clone sysprog21/simplefs (master) during build and verify via SHA1.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 5 files

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="README.md">

<violation number="1" location="README.md:114">
The sentence uses the singular verb &quot;is&quot; with the plural subject &quot;other filesystems&quot;; please change it to &quot;are&quot; for correct subject–verb agreement.</violation>
</file>

<file name="mk/external.mk">

<violation number="1" location="mk/external.mk:141">
Pin SIMPLEFS to an immutable tag or commit. Using `master` with a fixed SHA causes the verification step to fail as soon as upstream updates, breaking the build.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@jserv
Copy link
Contributor

jserv commented Oct 27, 2025

I like the idea of “eating your own dog food,” and simplefs can be a great demonstration of a minimalist software stack.

@ChinYikMing ChinYikMing force-pushed the mount-simplefs branch 3 times, most recently from 80aca2e to 4b1e7a2 Compare October 27, 2025 18:13
@ChinYikMing ChinYikMing marked this pull request as ready for review October 27, 2025 18:36
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Comment on lines +12 to +13
# FIXME: mkfs.simplefs is not compilable on macOS, thus running the
# simplefs cases on Linux runner for now
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should track this issue.

Copy link
Collaborator Author

@ChinYikMing ChinYikMing Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should track this issue.

Describe the issue in the aaa9c44 commit message and create a issue in simplefs.

To enhance the guest OS functionality, this commit integrates the
simplefs kernel module to support an additional filesystem. It appends
simplefs as a new Linux image artifact and automatically builds the
latest simplefs.ko when make build-linux-image is executed.

simplefs: https://github.com/sysprog21/simplefs
To reflect the integration of simplefs.

simplefs: https://github.com/sysprog21/simplefs
Move Linux artifact-related build commands into the artifact Makefile to
improve CI readability and simplify adding new Linux artifacts in the
future.
Note:
- 7z does not recognize the simplefs format, thus verifying the written
  files in guestOS's stdout instead of using 7z l in hostOS.
- simplefs CI test cases does not run on macOS runner because the
  mkfs.simplefs cannot be compiled on macOS runner due to platform-
  specific header(<linux/fs.h>) is included at mkfs.c. [1]
  Before patching the simplefs upstream, skip the macOS runner for now.

[1] https://github.com/sysprog21/simplefs/blob/d7e0c9b6c1e09343ed862c709d3258c22f4a9a83/mkfs.c#L2
@ChinYikMing ChinYikMing requested a review from jserv October 28, 2025 18:22
@jserv jserv merged commit f6627f1 into sysprog21:master Oct 29, 2025
8 of 10 checks passed
@jserv
Copy link
Contributor

jserv commented Oct 29, 2025

Thank @ChinYikMing for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants