Skip to content

Commit

Permalink
feat(ofs): add freebsd OS support (#4403)
Browse files Browse the repository at this point in the history
* feat(ofs): support freebsd

* feat(ofs): fix code

* feat(ofs): fix code

* feat(ofs): fix code
  • Loading branch information
oowl authored Mar 28, 2024
1 parent a9a9301 commit d65ac9c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 0 additions & 2 deletions bin/ofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ url = "2.5.0"
chrono = "0.4.34"
sharded-slab = "0.1.7"
bytes = "1.5.0"

[target.'cfg(target_os = "linux")'.dependencies]
libc = "0.2.151"
fuse3 = { "version" = "0.7.1", "features" = ["tokio-runtime", "unprivileged"] }
nix = { version = "0.27.1", features = ["user"] }
Expand Down
6 changes: 6 additions & 0 deletions bin/ofs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ sudo pacman -S fuse3 --noconfirm # archlinux
sudo apt-get -y install fuse # debian/ubuntu
```

### Load `FUSE` kernel module on FreeBSD

```shell
kldload fuse
```

### Install `ofs`

`ofs` could be installed by `cargo`:
Expand Down
1 change: 0 additions & 1 deletion bin/ofs/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use url::Url;
#[command(version, about)]
pub struct Config {
/// fuse mount path
#[cfg(target_os = "linux")]
#[arg(env = "OFS_MOUNT_PATH", index = 1)]
pub mount_path: String,

Expand Down
8 changes: 2 additions & 6 deletions bin/ofs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use tokio::signal;
pub mod config;
pub use config::Config;

#[cfg(target_os = "linux")]
mod fuse;

pub async fn execute(cfg: Config) -> Result<()> {
Expand All @@ -49,7 +48,6 @@ pub async fn execute(cfg: Config) -> Result<()> {
let backend = Operator::via_map(scheme, op_args)?;

let args = Args {
#[cfg(target_os = "linux")]
mount_path: cfg.mount_path,
backend,
};
Expand All @@ -58,18 +56,16 @@ pub async fn execute(cfg: Config) -> Result<()> {

#[derive(Debug)]
struct Args {
#[cfg(target_os = "linux")]
mount_path: String,
backend: Operator,
}

#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "freebsd")))]
async fn execute_inner(args: Args) -> Result<()> {
_ = args.backend;
Err(anyhow::anyhow!("platform not supported"))
}

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
async fn execute_inner(args: Args) -> Result<()> {
use fuse3::path::Session;
use fuse3::MountOptions;
Expand Down

0 comments on commit d65ac9c

Please sign in to comment.