rust-9p icon indicating copy to clipboard operation
rust-9p copied to clipboard

Is there any way to build on MacOS?

Open gcavalcante8808 opened this issue 5 years ago • 7 comments

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.

gcavalcante8808 avatar May 30 '19 23:05 gcavalcante8808

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

pfpacket avatar Jun 01 '19 16:06 pfpacket

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

gcavalcante8808 avatar Jun 01 '19 17:06 gcavalcante8808

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());
    |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^

jnoxon avatar Nov 12 '19 20:11 jnoxon

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

lf94 avatar Jan 03 '21 19:01 lf94

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.

pfpacket avatar Jan 05 '21 11:01 pfpacket

Ah ok, then disregard my comment :)

lf94 avatar Jan 05 '21 13:01 lf94

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 :)

LionsAd avatar Jan 25 '22 21:01 LionsAd