From 015d352e3334a8e960559873cb4beedddbb5735e Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jeremy@system76.com>
Date: Tue, 23 Apr 2019 13:55:46 -0600
Subject: [PATCH] Fixes for Redox when part of unix target family

---
 Cargo.toml       |  2 +-
 src/bin/mount.rs | 16 ++++++++--------
 src/mount/mod.rs |  6 +++---
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 80e0a89..8c90867 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,7 +25,7 @@ doc = false
 redox_syscall = "0.1"
 uuid = { version = "0.5", features = ["v4"] }
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(not(target_os = "redox"))'.dependencies]
 fuse = "0.3"
 libc = "0.2"
 time = "0.1"
diff --git a/src/bin/mount.rs b/src/bin/mount.rs
index d7587a8..7a251bf 100644
--- a/src/bin/mount.rs
+++ b/src/bin/mount.rs
@@ -1,7 +1,7 @@
 #![deny(warnings)]
-#![cfg_attr(unix, feature(libc))]
+#![cfg_attr(not(target_os = "redox"), feature(libc))]
 
-#[cfg(unix)]
+#[cfg(not(target_os = "redox"))]
 extern crate libc;
 
 #[cfg(target_os = "redox")]
@@ -13,7 +13,7 @@ extern crate uuid;
 use std::env;
 use std::fs::File;
 use std::io::{Read, Write};
-use std::os::unix::io::FromRawFd;
+use std::os::unix::io::{FromRawFd, RawFd};
 use std::process;
 
 use redoxfs::{DiskCache, DiskFile, mount};
@@ -41,18 +41,18 @@ fn setsig() {
     sigaction(SIGTERM, Some(&sig_action), None).unwrap();
 }
 
-#[cfg(unix)]
+#[cfg(not(target_os = "redox"))]
 // on linux, this is implemented properly, so no need for this unscrupulous nonsense!
 fn setsig() {
     ()
 }
 
-#[cfg(unix)]
+#[cfg(not(target_os = "redox"))]
 fn fork() -> isize {
     unsafe { libc::fork() as isize }
 }
 
-#[cfg(unix)]
+#[cfg(not(target_os = "redox"))]
 fn pipe(pipes: &mut [i32; 2]) -> isize {
     unsafe { libc::pipe(pipes.as_mut_ptr()) as isize }
 }
@@ -254,8 +254,8 @@ fn main() {
 
     let mut pipes = [0; 2];
     if pipe(&mut pipes) == 0 {
-        let mut read = unsafe { File::from_raw_fd(pipes[0]) };
-        let write = unsafe { File::from_raw_fd(pipes[1]) };
+        let mut read = unsafe { File::from_raw_fd(pipes[0] as RawFd) };
+        let write = unsafe { File::from_raw_fd(pipes[1] as RawFd) };
 
         let pid = fork();
         if pid == 0 {
diff --git a/src/mount/mod.rs b/src/mount/mod.rs
index 4bcf5a1..892c264 100644
--- a/src/mount/mod.rs
+++ b/src/mount/mod.rs
@@ -4,13 +4,13 @@ use std::path::Path;
 use disk::Disk;
 use filesystem::FileSystem;
 
-#[cfg(unix)]
+#[cfg(not(target_os = "redox"))]
 mod fuse;
 
 #[cfg(target_os = "redox")]
 mod redox;
 
-#[cfg(all(unix, target_os = "macos"))]
+#[cfg(target_os = "macos")]
 pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mountpoint: &P, callback: F) -> io::Result<()> {
     use std::ffi::OsStr;
 
@@ -24,7 +24,7 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mou
     ])
 }
 
-#[cfg(all(unix, not(target_os = "macos")))]
+#[cfg(all(not(target_os = "macos"), not(target_os = "redox")))]
 pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mountpoint: &P, callback: F) -> io::Result<()> {
     fuse::mount(filesystem, mountpoint, callback, &[])
 }
-- 
GitLab