Skip to content

Port branchfs to macOS#26

Open
nitin966 wants to merge 2 commits intomultikernel:mainfrom
nitin966:main
Open

Port branchfs to macOS#26
nitin966 wants to merge 2 commits intomultikernel:mainfrom
nitin966:main

Conversation

@nitin966
Copy link

Description

Port branchfs to macOS with verified integration tests and stable control interface

Testing

All existing tests pass

@nitin966 nitin966 mentioned this pull request Mar 16, 2026
@congwang-mk
Copy link
Contributor

Could we separate the platform specific code? For example, src/platform/linux.rs and src/platform/macos.rs behind a src/platform/mod.rs that re-exports the right impl via #[cfg]. Move into it:

  • Ioctl constants
  • Mount option construction
  • init() capability setup
  • Passthrough open logic
  • access() impl
  • Rename flag handling

Copy link
Contributor

@congwang-mk congwang-mk left a comment

Choose a reason for hiding this comment

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

Thanks for your update. Some additional reviews

let options = vec![
let mut options = vec![
MountOption::FSName("branchfs".to_string()),
MountOption::DefaultPermissions,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this also removed for Linux?

crtime: UNIX_EPOCH,
kind: FileType::RegularFile,
perm: 0o600,
perm: 0o777,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this perm change expected?

// Report a non-zero size so the kernel issues read() calls.
// The actual content length is determined by the read handler.
let size = if ino == CTL_INO { 256 } else { 0 };
let size = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentional?

let mut buf = [0u8; 128];
let ret = libc::ioctl(fd, FS_IOC_BRANCH_CREATE as libc::c_ulong, buf.as_mut_ptr());
if ret < 0 {
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd"))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Dead code?

if ret < 0 {
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd"))]
return Err(unsafe { *libc::__error() });
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd")))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

#[cfg(target_os = "linux")]
pub use linux::*;

#[cfg(not(target_os = "linux"))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Flip this?


#[cfg(not(target_os = "linux"))]
mod macos;
#[cfg(not(target_os = "linux"))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

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