Skip to content

Commit 43dd25c

Browse files
committed
Fix fusefs on macos
* Fix si-fs project building for mac in buck2 * Added libfuse to fuser features * Switch EBADFD to EBADF for cross platform bad file descriptor * Pass additional link args on mac so the rust binary can link the the macfuse symbols * Fixed old fixup format
1 parent e72c3d4 commit 43dd25c

File tree

9 files changed

+81
-7
lines changed

9 files changed

+81
-7
lines changed

bin/si-fs/BUCK

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ rust_binary(
1616
],
1717
srcs = glob(["src/**/*.rs"]),
1818
env = {"CARGO_BIN_NAME": "si-fs"},
19+
rustc_flags = select({
20+
"config//os:macos": ["-C", "link-arg=-L/usr/local/lib", "-C", "link-arg=-lfuse"],
21+
"DEFAULT": [],
22+
}),
1923
)
2024

2125
rust_binary_pkg(

bin/si-fs/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A FUSE filesystem for editing System Initiative assets in your favorite editor.
1212
2. Mount the filesystem:
1313

1414
```bash
15-
buck2 run //bin/si-fs -- --foreground --workspace-id <WORKSPACE_ID> --endpoint <ENDPOINT> /mountpoint
15+
buck2 run //bin/si-fs -- --foreground --workspace-id <WORKSPACE_ID> [--endpoint <ENDPOINT>] /mountpoint
1616
```
1717

1818
At this point, we recommend running in the foreground, so you can see any errors
@@ -125,3 +125,13 @@ The function must be on the same change set as the schema you are attaching to.
125125

126126
Like when creating a new function, Attribute and Action functions will be put
127127
into a pending state.
128+
129+
## Mac Setup
130+
131+
Ensure you setup macFUSE before attempting above setup
132+
https://github.com/macfuse/macfuse/wiki/Getting-Started
133+
134+
You will need to use a mountpoint in your user profile otherwise you will get `std io error: Read-only file system (os error 30)` when trying to write to the filesystem.
135+
136+
eg. `buck2 run //bin/si-fs -- --foreground --workspace-id <WORKSPACE_ID> ~/si-mount`
137+

lib/si-filesystem/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use inode_table::{
5757
use nix::{
5858
libc::{
5959
EACCES,
60-
EBADFD,
60+
EBADF,
6161
EINVAL,
6262
ENODATA,
6363
ENOENT,
@@ -1686,7 +1686,7 @@ impl SiFileSystem {
16861686
};
16871687

16881688
let Some(mut open_file) = self.open_files.get_mut(&fh) else {
1689-
reply.error(EBADFD);
1689+
reply.error(EBADF);
16901690
return Ok(());
16911691
};
16921692

prelude/rust/cargo_buildscript.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ def buildscript_run(
196196
for path in glob(["{}/**".format(local_manifest_dir)])
197197
}
198198

199+
# platform is not supported by the _cargo_buildscript_rule function, so remove it before adding the target
200+
# The error without this - error: Found `platform` extra named parameter(s) for call to _cargo_buildscript_rule
201+
#
202+
# not sure how to stop it being added by reindeer
203+
kwargs.pop("platform", None)
204+
199205
_cargo_buildscript_rule(
200206
name = name,
201207
buildscript = buildscript_rule,

third-party/rust/BUCK

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6941,6 +6941,22 @@ cargo.rust_library(
69416941
env = {
69426942
"OUT_DIR": "$(location :fuser-0.16.0-build-script-run[out_dir])",
69436943
},
6944+
platform = {
6945+
"macos-arm64": dict(
6946+
features = [
6947+
"default",
6948+
"libfuse",
6949+
"pkg-config",
6950+
],
6951+
),
6952+
"macos-x86_64": dict(
6953+
features = [
6954+
"default",
6955+
"libfuse",
6956+
"pkg-config",
6957+
],
6958+
),
6959+
},
69446960
rustc_flags = ["@$(location :fuser-0.16.0-build-script-run[rustc_flags])"],
69456961
visibility = [],
69466962
deps = [
@@ -6960,13 +6976,47 @@ cargo.rust_binary(
69606976
crate = "build_script_build",
69616977
crate_root = "fuser-0.16.0.crate/build.rs",
69626978
edition = "2024",
6979+
platform = {
6980+
"macos-arm64": dict(
6981+
features = [
6982+
"default",
6983+
"libfuse",
6984+
"pkg-config",
6985+
],
6986+
deps = [":pkg-config-0.3.32"],
6987+
),
6988+
"macos-x86_64": dict(
6989+
features = [
6990+
"default",
6991+
"libfuse",
6992+
"pkg-config",
6993+
],
6994+
deps = [":pkg-config-0.3.32"],
6995+
),
6996+
},
69636997
visibility = [],
69646998
)
69656999

69667000
buildscript_run(
69677001
name = "fuser-0.16.0-build-script-run",
69687002
package_name = "fuser",
69697003
buildscript_rule = ":fuser-0.16.0-build-script-build",
7004+
platform = {
7005+
"macos-arm64": dict(
7006+
features = [
7007+
"default",
7008+
"libfuse",
7009+
"pkg-config",
7010+
],
7011+
),
7012+
"macos-x86_64": dict(
7013+
features = [
7014+
"default",
7015+
"libfuse",
7016+
"pkg-config",
7017+
],
7018+
),
7019+
},
69707020
version = "0.16.0",
69717021
)
69727022

third-party/rust/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

third-party/rust/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,6 @@ spicedb-grpc = { git = "https://github.com/systeminit/spicedb-client.git", branc
208208
tokio-postgres-rustls = { git = "https://github.com/jbg/tokio-postgres-rustls.git", branch = "master" }
209209

210210
# END: DEPENDENCIES
211+
212+
[target.'cfg(target_os = "macos")'.dependencies]
213+
fuser = { version = "0.16.0", features = ["libfuse", "pkg-config"] }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
buildscript.run = false
22

3-
[platform_fixup.'cfg(target_os = "windows")']
3+
['cfg(target_os = "windows")']
44
buildscript.run = true
5-
[platform_fixup.'cfg(target_os = "windows")'.buildscript.prebuilt_cxx_library]
5+
['cfg(target_os = "windows")'.buildscript.prebuilt_cxx_library]
66
name = "libwindows.a"
77
static_libs = ["lib/libwindows.a"]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
buildscript.run = false
22

3-
[platform_fixup.'cfg(target_os = "windows")']
3+
['cfg(target_os = "windows")']
44
buildscript.run = true
5-
[platform_fixup.'cfg(target_os = "windows")'.buildscript.prebuilt_cxx_library]
5+
['cfg(target_os = "windows")'.buildscript.prebuilt_cxx_library]
66
name = "libwindows.a"
77
static_libs = ["lib/libwindows.a"]

0 commit comments

Comments
 (0)