Skip to content

Conversation

@hsule
Copy link
Contributor

@hsule hsule commented Jan 19, 2026

Fixes issue#78 with enabling mkfs.simplefs to be compiled and executed on macOS. Currently, the utility depends on Linux-specific headers and ioctl operations, which prevents the rv32emu CI from running simplefs test cases on macOS runners.


Summary by cubic

Enable mkfs.simplefs to build and run on macOS by adding platform-specific headers, endian helpers, and block device size detection. This unblocks running simplefs tests on macOS runners while keeping Linux behavior unchanged.

  • New Features
    • Add conditional includes for Linux and macOS; define htole/le macros via OSSwap* on macOS.
    • Implement macOS block device size detection using DKIOCGETBLOCKCOUNT and DKIOCGETBLOCKSIZE.
    • Retain Linux path using BLKGETSIZE64; no CLI or usage changes.
    • Add a macOS CI job that builds mkfs.simplefs and formats a test image.

Written for commit 1889a19. Summary will update on new commits.

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 1 file

@ChinYikMing
Copy link
Contributor

@hsule Rewrite commit message properly, check this ref.

@@ -1,5 +1,14 @@
#include <fcntl.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider to add this build check:

diff --git a/mkfs.c b/mkfs.c
index 59dd967..c2f5626 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1,3 +1,8 @@
+#if !defined(__linux__) && !defined(__APPLE__)
+#error \
+    "Do not manage to build this file unless your platform is Linux or macOS."
+#endif
+
 #include <fcntl.h>
 #include <linux/fs.h>
 #include <stdint.h>

@ChinYikMing
Copy link
Contributor

Once this is fixed, consider to help to enable mounting simplefs on macOS runner at CI [1], [2].

[1] https://github.com/sysprog21/rv32emu/blob/master/.ci/boot-linux-prepare.sh
[2] https://github.com/sysprog21/rv32emu/blob/master/.ci/boot-linux.sh

@ChinYikMing
Copy link
Contributor

Can you add CI for the verification?

mkfs.simplefs depended on Linux-only headers and ioctl calls, so the
rv32emu CI could not run simplefs tests on macOS runners.

Add macOS-specific endian helpers and detect block device size via
DKIOCGETBLOCKCOUNT/DKIOCGETBLOCKSIZE while keeping the Linux path
(BLKGETSIZE64) unchanged.

Fixes: sysprog21#78

Signed-off-by: hsule <leann9001@gmail.com>
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.

1 issue found across 3 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name=".ci/test-mkfs-macos.sh">

<violation number="1" location=".ci/test-mkfs-macos.sh:16">
P2: macOS dd does not support the GNU `status=none` operand, so this dd call will fail and abort the macOS test run under `set -e`.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@hsule
Copy link
Contributor Author

hsule commented Jan 20, 2026

@ChinYikMing Thanks for the review!
I’ve fixed the comments and added CI verification (macOS build + format a test image).
Could you please help check if everything looks good now?

@ChinYikMing
Copy link
Contributor

ChinYikMing commented Jan 22, 2026

rv32emu relies on tag rel2025.0, need to bump to rel2026.0 for this patch? cc @jserv .

Add a CI script to build mkfs.simplefs and format a test image on
macOS runners.

Signed-off-by: hsule <leann9001@gmail.com>
@jserv
Copy link
Collaborator

jserv commented Jan 26, 2026

rv32emu relies on tag rel2025.0, need to bump to rel2026.0 for this patch?

Yes, let's move forward.

@sysprog21 sysprog21 deleted a comment from cubic-dev-ai bot Jan 26, 2026
@sysprog21 sysprog21 deleted a comment from cubic-dev-ai bot Jan 26, 2026
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 3 files

@jserv jserv requested a review from ChinYikMing January 26, 2026 16:18
Copy link
Contributor

@ChinYikMing ChinYikMing left a comment

Choose a reason for hiding this comment

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

LGTM!

@jserv jserv merged commit 860c9cd into sysprog21:master Jan 27, 2026
3 of 4 checks passed
@jserv
Copy link
Collaborator

jserv commented Jan 27, 2026

Thank @hsule for contributing!

@hsule hsule deleted the mkfs_macos branch January 28, 2026 14:54
@hsule
Copy link
Contributor Author

hsule commented Jan 29, 2026

@jserv, since the PR is now merged, could you please help bump the tag to rel2026.0?
This will allow the reference in rv32emu to be updated, as mentioned in the previous comments:

Once this is fixed, consider to help to enable mounting simplefs on macOS runner at CI [1], [2].

[1] https://github.com/sysprog21/rv32emu/blob/master/.ci/boot-linux-prepare.sh [2] https://github.com/sysprog21/rv32emu/blob/master/.ci/boot-linux.sh

rv32emu relies on tag rel2025.0, need to bump to rel2026.0 for this patch? cc @jserv .

@jserv
Copy link
Collaborator

jserv commented Jan 29, 2026

since the PR is now merged, could you please help bump the tag to rel2026.0? This will allow the reference in rv32emu to be updated, as mentioned in the previous comments:

I would like to wait for #79 and prepare new tag next week.

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.

Support mkfs.simplefs on macOS

3 participants