error when compiling on macOS
casouri opened this issue · 9 comments
Is catfs supposted to run on macOS?
Errors below occured when I try to install it with cargo.
error[E0425]: cannot find function `fdopendir` in module `libc`
--> src/catfs/rlibc.rs:56:29
|
56 | let dh = unsafe { libc::fdopendir(fd) };
| ^^^^^^^^^ did you mean `opendir`?
help: possible candidate is found in another module, you can import it into scope
|
6 | use catfs::rlibc::fdopendir;
|
error[E0425]: cannot find function `pipe2` in module `libc`
--> src/catfs/rlibc.rs:178:30
|
178 | let res = unsafe { libc::pipe2(p.as_mut_ptr(), libc::O_CLOEXEC) };
| ^^^^^ did you mean `pipe`?
error[E0425]: cannot find function `splice` in module `libc`
--> src/catfs/rlibc.rs:207:30
|
207 | let res = unsafe { libc::splice(fd, off_from_ptr, other, off_to_ptr, len, 0) };
| ^^^^^^ not found in `libc`
help: possible candidate is found in another module, you can import it into scope
|
6 | use catfs::rlibc::splice;
|
error[E0425]: cannot find value `AT_EMPTY_PATH` in module `libc`
--> src/catfs/rlibc.rs:279:66
|
279 | let res = unsafe { libc::fstatat(dir, s.as_ptr(), stp, libc::AT_EMPTY_PATH) };
| ^^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find function `utimensat` in module `libc`
--> src/catfs/rlibc.rs:342:30
|
342 | let res = unsafe { libc::utimensat(dir, s.as_ptr(), times.as_mut_ptr(), flags as i32) };
| ^^^^^^^^^ did you mean `utimes`?
help: possible candidate is found in another module, you can import it into scope
|
6 | use catfs::rlibc::utimensat;
|
error[E0425]: cannot find function `posix_fallocate` in module `libc`
--> src/catfs/rlibc.rs:435:34
|
435 | let res = unsafe { libc::posix_fallocate(self.fd, offset as i64, len as i64) };
| ^^^^^^^^^^^^^^^ not found in `libc`
error[E0308]: mismatched types
--> src/catfs/mod.rs:195:21
|
195 | st.f_blocks,
| ^^^^^^^^^^^ expected u64, found u32
help: you can cast an `u32` to `u64`, which will zero-extend the source value
|
195 | st.f_blocks.into(),
| ^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> src/catfs/mod.rs:196:21
|
196 | st.f_bfree,
| ^^^^^^^^^^ expected u64, found u32
help: you can cast an `u32` to `u64`, which will zero-extend the source value
|
196 | st.f_bfree.into(),
| ^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> src/catfs/mod.rs:197:21
|
197 | st.f_bavail,
| ^^^^^^^^^^^ expected u64, found u32
help: you can cast an `u32` to `u64`, which will zero-extend the source value
|
197 | st.f_bavail.into(),
| ^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> src/catfs/mod.rs:198:21
|
198 | st.f_files,
| ^^^^^^^^^^ expected u64, found u32
help: you can cast an `u32` to `u64`, which will zero-extend the source value
|
198 | st.f_files.into(),
| ^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> src/catfs/mod.rs:199:21
|
199 | st.f_ffree,
| ^^^^^^^^^^ expected u64, found u32
help: you can cast an `u32` to `u64`, which will zero-extend the source value
|
199 | st.f_ffree.into(),
| ^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> src/catfs/file.rs:598:56
|
598 | self.src_file = File::openat(dir, path, flags, mode)?;
| ^^^^ expected u32, found u16
help: you can cast an `u16` to `u32`, which will zero-extend the source value
|
598 | self.src_file = File::openat(dir, path, flags, mode.into())?;
| ^^^^^^^^^^^
error[E0560]: struct `catfs::libc::dirent` has no field named `d_off`
--> src/catfs/rlibc.rs:89:17
|
89 | d_off: 0,
| ^^^^^^ `catfs::libc::dirent` does not have this field
|
= note: available fields are: `d_ino`, `d_seekoff`, `d_reclen`, `d_namlen`, `d_type`, `d_name`
error[E0308]: mismatched types
--> src/catfs/rlibc.rs:92:25
|
92 | d_name: [0i8; 256], // FIXME: don't hardcode 256
| ^^^^^^^^^^ expected an array with a fixed size of 1024 elements, found one with 256 elements
|
= note: expected type `[i8; 1024]`
found type `[i8; 256]`
error[E0609]: no field `d_off` on type `catfs::libc::dirent`
--> src/catfs/rlibc.rs:120:24
|
120 | return self.en.d_off;
| ^^^^^ unknown field
|
= note: available fields are: `d_ino`, `d_seekoff`, `d_reclen`, `d_namlen`, `d_type`, `d_name`
error[E0308]: mismatched types
--> src/catfs/rlibc.rs:158:48
|
158 | let res = unsafe { libc::mkdir(s.as_ptr(), mode) };
| ^^^^ expected u16, found u32
error[E0308]: mismatched types
--> src/catfs/rlibc.rs:168:55
|
168 | let res = unsafe { libc::mkdirat(dir, s.as_ptr(), mode) };
| ^^^^ expected u16, found u32
error[E0308]: mismatched types
--> src/catfs/rlibc.rs:352:56
|
352 | let res = unsafe { libc::fchmodat(dir, s.as_ptr(), mode, flags as i32) };
| ^^^^ expected u16, found u32
error[E0308]: mismatched types
--> src/catfs/rlibc.rs:459:50
|
459 | let res = unsafe { libc::fchmod(self.fd, mode) };
| ^^^^ expected u16, found u32
error[E0308]: mismatched types
--> src/catfs/inode.rs:39:15
|
39 | match t & libc::S_IFMT {
| ^^^^^^^^^^^^ expected u32, found u16
error[E0308]: mismatched types
--> src/catfs/inode.rs:40:9
|
40 | libc::S_IFLNK => fuse::FileType::Symlink,
| ^^^^^^^^^^^^^ expected u32, found u16
|
= note: expected type `u32`
found type `u16`
error[E0308]: mismatched types
--> src/catfs/inode.rs:41:9
|
41 | libc::S_IFREG => fuse::FileType::RegularFile,
| ^^^^^^^^^^^^^ expected u32, found u16
|
= note: expected type `u32`
found type `u16`
error[E0308]: mismatched types
--> src/catfs/inode.rs:42:9
|
42 | libc::S_IFBLK => fuse::FileType::BlockDevice,
| ^^^^^^^^^^^^^ expected u32, found u16
|
= note: expected type `u32`
found type `u16`
error[E0308]: mismatched types
--> src/catfs/inode.rs:43:9
|
43 | libc::S_IFDIR => fuse::FileType::Directory,
| ^^^^^^^^^^^^^ expected u32, found u16
|
= note: expected type `u32`
found type `u16`
error[E0308]: mismatched types
--> src/catfs/inode.rs:44:9
|
44 | libc::S_IFCHR => fuse::FileType::CharDevice,
| ^^^^^^^^^^^^^ expected u32, found u16
|
= note: expected type `u32`
found type `u16`
error[E0308]: mismatched types
--> src/catfs/inode.rs:45:9
|
45 | libc::S_IFIFO => fuse::FileType::NamedPipe,
| ^^^^^^^^^^^^^ expected u32, found u16
|
= note: expected type `u32`
found type `u16`
error[E0277]: no implementation for `u32 & u16`
--> src/catfs/inode.rs:39:13
|
39 | match t & libc::S_IFMT {
| ^ no implementation for `u32 & u16`
|
= help: the trait `std::ops::BitAnd<u16>` is not implemented for `u32`
error[E0308]: mismatched types
--> src/catfs/inode.rs:131:31
|
131 | kind: to_filetype(st.st_mode),
| ^^^^^^^^^^ expected u32, found u16
help: you can cast an `u16` to `u32`, which will zero-extend the source value
|
131 | kind: to_filetype(st.st_mode.into()),
| ^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> src/evicter/mod.rs:104:50
|
104 | DiskSpace::Percent(p) => ((st.f_blocks * st.f_frsize) as f64 * p / 100.0) as u64,
| ^^^^^^^^^^^ expected u32, found u64
error[E0277]: cannot multiply `u64` to `u32`
--> src/evicter/mod.rs:104:48
|
104 | DiskSpace::Percent(p) => ((st.f_blocks * st.f_frsize) as f64 * p / 100.0) as u64,
| ^ no implementation for `u32 * u64`
|
= help: the trait `std::ops::Mul<u64>` is not implemented for `u32`
error[E0308]: mismatched types
--> src/evicter/mod.rs:108:37
|
108 | let x = desired - (st.f_bfree * st.f_frsize) as i64;
| ^^^^^^^^^^^ expected u32, found u64
error[E0277]: cannot multiply `u64` to `u32`
--> src/evicter/mod.rs:108:35
|
108 | let x = desired - (st.f_bfree * st.f_frsize) as i64;
| ^ no implementation for `u32 * u64`
|
= help: the trait `std::ops::Mul<u64>` is not implemented for `u32`
error: aborting due to 32 previous errors
error: failed to compile `catfs v0.8.0`, intermediate artifacts can be found at `/var/folders/8j/gcq2wfcj41jbn45x071shl4h0000gn/T/cargo-install.75RhyeDLPNLv`
I am not able to support catfs on OS X because I don't have an apple laptop. I skimmed over the compiler errors and most of them seem to be trivially fixable. Happy to guide you through it if you'd like to submit a PR
Please do! However, I'm still learning so I can't promise anything.
the best way is to try and then ask specific questions here
I have a MacOS developer rig and am happy to work on getting catfs working on Mac. I have no experience with rust, but am able to reproduce the above errors exactly.
The first issues seem to be lib related; are these functions platform-specific, or is the Library failing to get loaded on macOS? Maybe there’s a missing dev package (crate?) on macOS.
How would you like to proceed? Thanks in advance for catfs (and goofys) and your time.
Some of these are from the libc crate and I am not sure if it's ported to OS X. Some of them are from internal libc wrapper that I wrote myself. I don't think there's a general solution here.
Thanks for your response. The libc crate is definitely ported to MacOS (see here) -- which is included in Cargo.toml
as a dependency and being imported in libc.rs
.
Some of the functions do appear in the MacOS libc API (eg. fdopendir
) while others do not (eg. pipe2
, splice
, posix_fallocate
). I can take a stab at substituting functions where the signatures match, but in cases where they don't (eg. pipe2
), the wrapper will have to be modified.
Unfortunately there's no comments in the code, so I'm not sure why certain thing are being done (eg. passing O_CLOEXEC
to pipe2
), etc. If you're willing to take a look and clarify once I have a PR that would be much appreciated.
After looking more closely, it appears that a number of crucial libc
functions aren't available on MacOS. It might be possible to "fake" some of the functionality within the rlibc.rs
wrapper by someone who is familiar with how filesystem-level calls work -- unfortunately, that's beyond me.
I guess catfs isn't likely to work with MacOS anytime soon. 😢
what functions specifically are not available?
My apologies for the delay -- I haven't abandoned the issue. Missing functions are:
pipe2
(thoughpipe
is available)splice
AT_EMPTY_PATH
utimensat
(thoughutime
andutimes
are available)posix_fallocate
The rest of the error in this trace look like casting issues, though this mismatch might be a known issue.