From 2dd4c920c7beca8ae71ed8d948c67b8c9c7f7fe4 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Sun, 19 Nov 2017 16:22:35 -0700
Subject: [PATCH] 0.3.1 - fix issue with new FUSE

---
 Cargo.lock        |  2 +-
 Cargo.toml        |  2 +-
 src/mount/fuse.rs | 11 ++++++-----
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index de9fe59..fc036af 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -71,7 +71,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "redoxfs"
-version = "0.3.0"
+version = "0.3.1"
 dependencies = [
  "fuse 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index a5bf005..f285af5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
 name = "redoxfs"
 description = "The Redox Filesystem"
 repository = "https://github.com/redox-os/redoxfs"
-version = "0.3.0"
+version = "0.3.1"
 license-file = "LICENSE"
 readme = "README.md"
 authors = ["Jeremy Soller <jackpot51@gmail.com>"]
diff --git a/src/mount/fuse.rs b/src/mount/fuse.rs
index bdfab5b..4b03fed 100644
--- a/src/mount/fuse.rs
+++ b/src/mount/fuse.rs
@@ -1,6 +1,7 @@
 extern crate fuse;
 extern crate time;
 
+use std::cmp;
 use std::ffi::OsStr;
 use std::io;
 use std::os::unix::ffi::OsStrExt;
@@ -175,9 +176,9 @@ impl<D: Disk> Filesystem for Fuse<D> {
         }
     }
 
-    fn read(&mut self, _req: &Request, block: u64, _fh: u64, offset: u64, size: u32, reply: ReplyData) {
+    fn read(&mut self, _req: &Request, block: u64, _fh: u64, offset: i64, size: u32, reply: ReplyData) {
         let mut data = vec![0; size as usize];
-        match self.fs.read_node(block, offset, &mut data) {
+        match self.fs.read_node(block, cmp::max(0, offset) as u64, &mut data) {
             Ok(count) => {
                 reply.data(&data[..count]);
             },
@@ -187,9 +188,9 @@ impl<D: Disk> Filesystem for Fuse<D> {
         }
     }
 
-    fn write(&mut self, _req: &Request, block: u64, _fh: u64, offset: u64, data: &[u8], _flags: u32, reply: ReplyWrite) {
+    fn write(&mut self, _req: &Request, block: u64, _fh: u64, offset: i64, data: &[u8], _flags: u32, reply: ReplyWrite) {
         let mtime = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
-        match self.fs.write_node(block, offset, &data, mtime.as_secs(), mtime.subsec_nanos()) {
+        match self.fs.write_node(block, cmp::max(0, offset) as u64, &data, mtime.as_secs(), mtime.subsec_nanos()) {
             Ok(count) => {
                 reply.written(count as u32);
             },
@@ -207,7 +208,7 @@ impl<D: Disk> Filesystem for Fuse<D> {
         reply.ok();
     }
 
-    fn readdir(&mut self, _req: &Request, parent_block: u64, _fh: u64, offset: u64, mut reply: ReplyDirectory) {
+    fn readdir(&mut self, _req: &Request, parent_block: u64, _fh: u64, offset: i64, mut reply: ReplyDirectory) {
         let mut children = Vec::new();
         match self.fs.child_nodes(&mut children, parent_block) {
             Ok(()) => {
-- 
GitLab