Change fuse dependency to fuser

This commit is contained in:
Travis Burtrum 2022-08-03 22:56:56 -04:00
parent ff1b918e82
commit 3d4f6a5583
3 changed files with 97 additions and 35 deletions

106
Cargo.lock generated
View File

@ -31,13 +31,19 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "byteorder"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]] [[package]]
name = "cache-fs" name = "cache-fs"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bincode", "bincode",
"env_logger", "env_logger",
"fuse", "fuser",
"libc", "libc",
"log", "log",
"serde", "serde",
@ -63,28 +69,19 @@ dependencies = [
] ]
[[package]] [[package]]
name = "fuse" name = "fuser"
version = "0.4.0-dev" version = "0.11.0"
source = "git+https://github.com/zargony/fuse-rs#39fde4a5c47ce370d228ac190f950bd835db7f47" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aef8400a4ea1d18a8302e2952f5137a9a21ab257825ccc7d67db4a8018b89022"
dependencies = [ dependencies = [
"fuse-abi",
"fuse-sys",
"libc", "libc",
"log", "log",
"thread-scoped", "memchr",
] "page_size",
[[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 = [
"pkg-config", "pkg-config",
"smallvec",
"users",
"zerocopy",
] ]
[[package]] [[package]]
@ -126,6 +123,16 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 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]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.25" version = "0.3.25"
@ -193,6 +200,12 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "smallvec"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.99" version = "1.0.99"
@ -204,6 +217,18 @@ dependencies = [
"unicode-ident", "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]] [[package]]
name = "termcolor" name = "termcolor"
version = "1.1.3" version = "1.1.3"
@ -213,18 +238,28 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "thread-scoped"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcbb6aa301e5d3b0b5ef639c9a9c7e2f1c944f177b460c04dc24c69b1fa2bd99"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.3" version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" 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]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@ -255,3 +290,24 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 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",
]

View File

@ -19,7 +19,8 @@ include = [
[dependencies] [dependencies]
#fuse = "0.3" #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" env_logger = "0.6"
libc = "0.2" libc = "0.2"
log = "0.4" log = "0.4"

View File

@ -1,4 +1,4 @@
use fuse::{ use fuser::{
FileAttr, FileType, Filesystem, ReplyAttr, ReplyData, ReplyDirectory, ReplyEmpty, ReplyEntry, FileAttr, FileType, Filesystem, ReplyAttr, ReplyData, ReplyDirectory, ReplyEmpty, ReplyEntry,
ReplyOpen, Request, ReplyOpen, Request,
}; };
@ -59,6 +59,7 @@ struct FileAttrDef {
pub gid: u32, pub gid: u32,
pub rdev: u32, pub rdev: u32,
pub flags: u32, pub flags: u32,
pub blksize: u32,
} }
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
@ -331,6 +332,7 @@ fn meta2attr(m: &std::fs::Metadata, ino: u64) -> Result<FileAttr> {
gid: m.gid(), gid: m.gid(),
rdev: m.rdev() as u32, rdev: m.rdev() as u32,
flags: 0, 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}"); debug!("open: ino: {ino}, flags: {flags}");
if let Some(file_handle) = self.opened_files.get_mut(&ino) { if let Some(file_handle) = self.opened_files.get_mut(&ino) {
@ -441,11 +443,13 @@ impl Filesystem for CacheFs {
fn read( fn read(
&mut self, &mut self,
_req: &Request, _req: &Request<'_>,
ino: u64, ino: u64,
fh: u64, fh: u64,
offset: i64, offset: i64,
size: u32, size: u32,
_flags: i32,
_lock_owner: Option<u64>,
reply: ReplyData, reply: ReplyData,
) { ) {
debug!("read: ino: {ino}, fh: {fh}, offset: {offset}, size: {size}"); debug!("read: ino: {ino}, fh: {fh}, offset: {offset}, size: {size}");
@ -482,11 +486,11 @@ impl Filesystem for CacheFs {
fn release( fn release(
&mut self, &mut self,
_req: &Request, _req: &Request<'_>,
ino: u64, ino: u64,
fh: u64, fh: u64,
_flags: u32, _flags: i32,
_lock_owner: u64, _lock_owner: Option<u64>,
_flush: bool, _flush: bool,
reply: ReplyEmpty, reply: ReplyEmpty,
) { ) {
@ -507,7 +511,7 @@ impl Filesystem for CacheFs {
reply.ok(); 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}"); debug!("opendir: ino: {ino}, flags: {flags}");
match self.tree.getattr(ino) { match self.tree.getattr(ino) {
None => reply.error(ENOENT), None => reply.error(ENOENT),
@ -568,7 +572,7 @@ impl Filesystem for CacheFs {
reply.ok(); 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}"); debug!("releasedir: ino: {ino}, fh: {fh}, flags: {flags}");
// or could just always return ok() ? // or could just always return ok() ?
match self.tree.file(ino) { match self.tree.file(ino) {
@ -645,5 +649,6 @@ fn main() {
let cmd_opts = OsString::from(cmd_opts); let cmd_opts = OsString::from(cmd_opts);
let options = [OsStr::new("-o"), cmd_opts.as_os_str()]; 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");
} }