pfpacket / rust-9p

Tokio-based asynchronous filesystems library using 9P2000.L protocol, an extended variant of 9P from Plan 9.
BSD 3-Clause "New" or "Revised" License
123 stars 17 forks source link

Is there any way to build on MacOS? #7

Open gcavalcante8808 opened 5 years ago

gcavalcante8808 commented 5 years ago

I'm trying to build the unfp on MacOS/Darwin, but following errors was returned:

image

I'm using rustc 1.37.0-nightly (37d001e4d 2019-05-29). Thanks in advance.

pfpacket commented 5 years ago

macos-fix branch will fix it. Would you try it out?

gcavalcante8808 commented 5 years ago

@pfpacket Thanks for the response. Ill try it on monday. Thanks for the tip.

jnoxon commented 4 years ago

fails on macos-fix branch with:

   Compiling unpfs v0.0.1 (/Volumes/Dev/rust-9p/example/unpfs)
     Running `rustc --edition=2018 --crate-name unpfs src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -C metadata=0853013c7702cc9d -C extra-filename=-0853013c7702cc9d --out-dir /Volumes/Dev/rust-9p/example/unpfs/target/release/deps -L dependency=/Volumes/Dev/rust-9p/example/unpfs/target/release/deps --extern env_logger=/Volumes/Dev/rust-9p/example/unpfs/target/release/deps/libenv_logger-98d61231efd42903.rlib --extern filetime=/Volumes/Dev/rust-9p/example/unpfs/target/release/deps/libfiletime-bc98e1c30b76f668.rlib --extern nix=/Volumes/Dev/rust-9p/example/unpfs/target/release/deps/libnix-292b27877362d2b2.rlib --extern rs9p=/Volumes/Dev/rust-9p/example/unpfs/target/release/deps/librs9p-3d4bb29b9aa32668.rlib`
error[E0308]: mismatched types
   --> src/main.rs:211:62
    |
211 |         let omode = nix::sys::stat::Mode::from_bits_truncate(mode);
    |                                                              ^^^^ expected u16, found u32
    |
help: you can convert an `u32` to `u16` and panic if the converted value wouldn't fit
    |
211 |         let omode = nix::sys::stat::Mode::from_bits_truncate(mode.try_into().unwrap());
    |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^
lf94 commented 3 years ago

Considering rust-9p specifically targets 9p2000.L, which is Linux specific, isn't it expected that building for MacOS won't work?

pfpacket commented 3 years ago

Considering rust-9p specifically targets 9p2000.L, which is Linux specific, isn't it expected that building for MacOS won't work?

You can run 9P2000.L file servers on macOS and still 9P2000.L clients such as v9fs can connect to them and mount them, which means something.

lf94 commented 3 years ago

Ah ok, then disregard my comment :)

LionsAd commented 2 years ago
diff --git a/example/unpfs/src/main.rs b/example/unpfs/src/main.rs
index ccd5deb..34f3b2f 100644
--- a/example/unpfs/src/main.rs
+++ b/example/unpfs/src/main.rs
@@ -22,6 +22,8 @@ use {
 mod utils;
 use crate::utils::*;

+use std::convert::TryInto;
+
 // Some clients will incorrectly set bits in 9p flags that don't make sense.
 // For exmaple, the linux 9p kernel client propagates O_DIRECT to TCREATE and TOPEN
 // and from there to the server.
@@ -258,7 +260,7 @@ impl Filesystem for Unpfs {
             realpath.join(name)
         };
         let oflags = nix::fcntl::OFlag::from_bits_truncate((flags & UNIX_FLAGS) as i32);
-        let omode = nix::sys::stat::Mode::from_bits_truncate(mode);
+        let omode = nix::sys::stat::Mode::from_bits_truncate(mode.try_into().unwrap());
         let fd = nix::fcntl::open(&path, oflags, omode)?;

         let qid = get_qid(&path).await?;

fixes the Mac build :)