diff --git a/Cargo.lock b/Cargo.lock index 8cbe220..95fca93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,13 +31,19 @@ dependencies = [ "serde", ] +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + [[package]] name = "cache-fs" version = "0.1.0" dependencies = [ "bincode", "env_logger", - "fuse", + "fuser", "libc", "log", "serde", @@ -63,28 +69,19 @@ dependencies = [ ] [[package]] -name = "fuse" -version = "0.4.0-dev" -source = "git+https://github.com/zargony/fuse-rs#39fde4a5c47ce370d228ac190f950bd835db7f47" +name = "fuser" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aef8400a4ea1d18a8302e2952f5137a9a21ab257825ccc7d67db4a8018b89022" dependencies = [ - "fuse-abi", - "fuse-sys", "libc", "log", - "thread-scoped", -] - -[[package]] -name = "fuse-abi" -version = "0.4.0-dev" -source = "git+https://github.com/zargony/fuse-rs#39fde4a5c47ce370d228ac190f950bd835db7f47" - -[[package]] -name = "fuse-sys" -version = "0.4.0-dev" -source = "git+https://github.com/zargony/fuse-rs#39fde4a5c47ce370d228ac190f950bd835db7f47" -dependencies = [ + "memchr", + "page_size", "pkg-config", + "smallvec", + "users", + "zerocopy", ] [[package]] @@ -126,6 +123,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "page_size" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "pkg-config" version = "0.3.25" @@ -193,6 +200,12 @@ dependencies = [ "syn", ] +[[package]] +name = "smallvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" + [[package]] name = "syn" version = "1.0.99" @@ -204,6 +217,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + [[package]] name = "termcolor" version = "1.1.3" @@ -213,18 +238,28 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "thread-scoped" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcbb6aa301e5d3b0b5ef639c9a9c7e2f1c944f177b460c04dc24c69b1fa2bd99" - [[package]] name = "unicode-ident" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + +[[package]] +name = "users" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032" +dependencies = [ + "libc", + "log", +] + [[package]] name = "winapi" version = "0.3.9" @@ -255,3 +290,24 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "zerocopy" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "332f188cc1bcf1fe1064b8c58d150f497e697f49774aa846f2dc949d9a25f236" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0fbc82b82efe24da867ee52e015e58178684bd9dd64c34e66bdf21da2582a9f" +dependencies = [ + "proc-macro2", + "syn", + "synstructure", +] diff --git a/Cargo.toml b/Cargo.toml index 6268357..7fbca93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,8 @@ include = [ [dependencies] #fuse = "0.3" -fuse = { git = "https://github.com/zargony/fuse-rs" } +#fuse = { git = "https://github.com/zargony/fuse-rs" } +fuser = "0.11" env_logger = "0.6" libc = "0.2" log = "0.4" diff --git a/src/main.rs b/src/main.rs index 0f7ce7f..d71a78d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use fuse::{ +use fuser::{ FileAttr, FileType, Filesystem, ReplyAttr, ReplyData, ReplyDirectory, ReplyEmpty, ReplyEntry, ReplyOpen, Request, }; @@ -59,6 +59,7 @@ struct FileAttrDef { pub gid: u32, pub rdev: u32, pub flags: u32, + pub blksize: u32, } #[derive(Serialize, Deserialize)] @@ -331,6 +332,7 @@ fn meta2attr(m: &std::fs::Metadata, ino: u64) -> Result { gid: m.gid(), rdev: m.rdev() as u32, flags: 0, + blksize: m.blksize() as u32, }) } @@ -362,7 +364,7 @@ impl Filesystem for CacheFs { } } - fn open(&mut self, _req: &Request, ino: u64, flags: u32, reply: ReplyOpen) { + fn open(&mut self, _req: &Request, ino: u64, flags: i32, reply: ReplyOpen) { debug!("open: ino: {ino}, flags: {flags}"); if let Some(file_handle) = self.opened_files.get_mut(&ino) { @@ -441,11 +443,13 @@ impl Filesystem for CacheFs { fn read( &mut self, - _req: &Request, + _req: &Request<'_>, ino: u64, fh: u64, offset: i64, size: u32, + _flags: i32, + _lock_owner: Option, reply: ReplyData, ) { debug!("read: ino: {ino}, fh: {fh}, offset: {offset}, size: {size}"); @@ -482,11 +486,11 @@ impl Filesystem for CacheFs { fn release( &mut self, - _req: &Request, + _req: &Request<'_>, ino: u64, fh: u64, - _flags: u32, - _lock_owner: u64, + _flags: i32, + _lock_owner: Option, _flush: bool, reply: ReplyEmpty, ) { @@ -507,7 +511,7 @@ impl Filesystem for CacheFs { reply.ok(); } - fn opendir(&mut self, _req: &Request, ino: u64, flags: u32, reply: ReplyOpen) { + fn opendir(&mut self, _req: &Request, ino: u64, flags: i32, reply: ReplyOpen) { debug!("opendir: ino: {ino}, flags: {flags}"); match self.tree.getattr(ino) { None => reply.error(ENOENT), @@ -568,7 +572,7 @@ impl Filesystem for CacheFs { reply.ok(); } - fn releasedir(&mut self, _req: &Request, ino: u64, fh: u64, flags: u32, reply: ReplyEmpty) { + fn releasedir(&mut self, _req: &Request, ino: u64, fh: u64, flags: i32, reply: ReplyEmpty) { debug!("releasedir: ino: {ino}, fh: {fh}, flags: {flags}"); // or could just always return ok() ? match self.tree.file(ino) { @@ -645,5 +649,6 @@ fn main() { let cmd_opts = OsString::from(cmd_opts); let options = [OsStr::new("-o"), cmd_opts.as_os_str()]; - fuse::mount(cache, mountpoint, &options).expect("mount failed"); + #[allow(deprecated)] + fuser::mount(cache, mountpoint, &options).expect("mount failed"); }