diff --git a/Cargo.lock b/Cargo.lock index 7ac4bc5b40..b3da683a63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,9 +16,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.18" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] @@ -46,9 +46,9 @@ dependencies = [ [[package]] name = "base64ct" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdca834647821e0b13d9539a8634eb62d3501b6b6c2cec1722786ee6671b851" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bitflags" @@ -58,22 +58,28 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "blake2" -version = "0.10.4" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ "digest", ] [[package]] name = "block-buffer" -version = "0.10.2" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + [[package]] name = "cfg-if" version = "1.0.0" @@ -91,9 +97,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.2" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" dependencies = [ "libc", ] @@ -110,9 +116,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.3" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer", "crypto-common", @@ -121,13 +127,13 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.9.0" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" dependencies = [ "atty", "humantime", - "log 0.4.17", + "log", "regex", "termcolor", ] @@ -139,23 +145,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] -name = "fuse" -version = "0.3.1" +name = "fuser" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e57070510966bfef93662a81cb8aa2b1c7db0964354fa9921434f04b9e8660" +checksum = "5910691a0ececcc6eba8bb14029025c2d123e96a53db1533f6a4602861a5aaf7" dependencies = [ "libc", - "log 0.3.9", + "log", + "memchr", + "page_size", "pkg-config", - "thread-scoped", - "time", + "smallvec", + "users", + "zerocopy", ] [[package]] name = "generic-array" -version = "0.14.5" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -163,9 +172,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -189,18 +198,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" - -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -dependencies = [ - "log 0.4.17", -] +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "log" @@ -230,10 +230,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] -name = "pkg-config" -version = "0.3.25" +name = "page_size" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "proc-macro2" +version = "1.0.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +dependencies = [ + "proc-macro2", +] [[package]] name = "rand" @@ -308,16 +336,16 @@ dependencies = [ [[package]] name = "redoxfs" -version = "0.5.3" +version = "0.5.4" dependencies = [ "aes", "argon2", "base64ct", "env_logger", - "fuse", + "fuser", "getrandom", "libc", - "log 0.4.17", + "log", "redox_simple_endian", "redox_syscall", "seahash", @@ -328,9 +356,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ "aho-corasick", "memchr", @@ -339,9 +367,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "seahash" @@ -349,6 +377,12 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + [[package]] name = "subtle" version = "2.4.1" @@ -356,10 +390,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] -name = "termcolor" -version = "1.1.3" +name = "syn" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] @@ -376,17 +421,11 @@ dependencies = [ "redox_termios", ] -[[package]] -name = "thread-scoped" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcbb6aa301e5d3b0b5ef639c9a9c7e2f1c944f177b460c04dc24c69b1fa2bd99" - [[package]] name = "time" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", "wasi 0.10.0+wasi-snapshot-preview1", @@ -395,9 +434,25 @@ dependencies = [ [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "users" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032" +dependencies = [ + "libc", + "log", +] [[package]] name = "uuid" @@ -456,3 +511,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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6505e6815af7de1746a08f69c69606bb45695a17149517680f3b2149713b19a3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 459ca3800d..f7afc69773 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ force-soft = [ ] std = [ "env_logger", - "fuse", + "fuser", "getrandom", "libc", "termion", @@ -68,6 +68,6 @@ std = [ ] [target.'cfg(not(target_os = "redox"))'.dependencies] -fuse = { version = "0.3", optional = true } +fuser = { version = "0.12.0", optional = true } libc = { version = "0.2", optional = true } time = { version = "0.1", optional = true } diff --git a/src/archive.rs b/src/archive.rs index b8401c1257..2b258d94a0 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -113,7 +113,7 @@ pub fn archive>(fs: &mut FileSystem, parent_path: P) // Squash alloc log tx.sync(true)?; - let mut end_block = tx.header.size() / BLOCK_SIZE; + let end_block = tx.header.size() / BLOCK_SIZE; /* TODO: Cut off any free blocks at the end of the filesystem let mut end_changed = true; while end_changed { diff --git a/src/mount/fuse.rs b/src/mount/fuse.rs index cde92c9870..ca2d586945 100644 --- a/src/mount/fuse.rs +++ b/src/mount/fuse.rs @@ -1,5 +1,4 @@ -extern crate fuse; -extern crate time; +extern crate fuser; use std::cmp; use std::ffi::OsStr; @@ -8,17 +7,22 @@ use std::os::unix::ffi::OsStrExt; use std::path::Path; use std::time::{SystemTime, UNIX_EPOCH}; +use self::fuser::MountOption; +use self::fuser::TimeOrNow; +use crate::mount::fuse::TimeOrNow::Now; +use crate::mount::fuse::TimeOrNow::SpecificTime; + use crate::{filesystem, Disk, Node, TreeData, TreePtr, BLOCK_SIZE}; -use self::fuse::{ +use self::fuser::{ FileAttr, FileType, Filesystem, ReplyAttr, ReplyCreate, ReplyData, ReplyDirectory, ReplyEmpty, ReplyEntry, ReplyStatfs, ReplyWrite, Request, Session, }; -use self::time::Timespec; +use std::time::Duration; -const TTL: Timespec = Timespec { sec: 1, nsec: 0 }; // 1 second +const TTL: Duration = Duration::new(1, 0); // 1 second -const NULL_TIME: Timespec = Timespec { sec: 0, nsec: 0 }; +const NULL_TIME: Duration = Duration::new(0, 0); pub fn mount( filesystem: filesystem::FileSystem, @@ -36,7 +40,7 @@ where // while building the Redox OS kernel. This means that we need to write on // a filesystem that belongs to `root`, which in turn means that we need to // be `root`, thus that we need to allow `root` to have access. - let defer_permissions = [OsStr::new("-o"), OsStr::new("defer_permissions")]; + let defer_permissions = [MountOption::CUSTOM("defer_permissions".to_owned())]; let mut session = Session::new( Fuse { fs: filesystem }, @@ -65,19 +69,11 @@ fn node_attr(node: &TreeData) -> FileAttr { size: node.data().size(), // Blocks is in 512 byte blocks, not in our block size blocks: (node.data().size() + BLOCK_SIZE - 1) / BLOCK_SIZE * (BLOCK_SIZE / 512), - atime: Timespec { - sec: node.data().atime().0 as i64, - nsec: node.data().atime().1 as i32, - }, - mtime: Timespec { - sec: node.data().mtime().0 as i64, - nsec: node.data().mtime().1 as i32, - }, - ctime: Timespec { - sec: node.data().ctime().0 as i64, - nsec: node.data().ctime().1 as i32, - }, - crtime: NULL_TIME, + blksize: 512, + atime: SystemTime::UNIX_EPOCH + Duration::new(node.data().atime().0, node.data().atime().1), + mtime: SystemTime::UNIX_EPOCH + Duration::new(node.data().mtime().0, node.data().mtime().1), + ctime: SystemTime::UNIX_EPOCH + Duration::new(node.data().ctime().0, node.data().ctime().1), + crtime: UNIX_EPOCH + NULL_TIME, kind: if node.data().is_dir() { FileType::Directory } else if node.data().is_symlink() { @@ -130,12 +126,13 @@ impl Filesystem for Fuse { uid: Option, gid: Option, size: Option, - atime: Option, - mtime: Option, + atime: Option, + mtime: Option, + _ctime: Option, _fh: Option, - _crtime: Option, - _chgtime: Option, - _bkuptime: Option, + _crtime: Option, + _chgtime: Option, + _bkuptime: Option, _flags: Option, reply: ReplyAttr, ) { @@ -174,14 +171,22 @@ impl Filesystem for Fuse { } if let Some(atime) = atime { + let atime_c = match atime { + SpecificTime(st) => st.duration_since(UNIX_EPOCH).unwrap(), + Now => SystemTime::now().duration_since(UNIX_EPOCH).unwrap(), + }; node.data_mut() - .set_atime(atime.sec as u64, atime.nsec as u32); + .set_atime(atime_c.as_secs(), atime_c.subsec_nanos()); node_changed = true; } if let Some(mtime) = mtime { + let mtime_c = match mtime { + SpecificTime(st) => st.duration_since(UNIX_EPOCH).unwrap(), + Now => SystemTime::now().duration_since(UNIX_EPOCH).unwrap(), + }; node.data_mut() - .set_mtime(mtime.sec as u64, mtime.nsec as u32); + .set_mtime(mtime_c.as_secs(), mtime_c.subsec_nanos()); node_changed = true; } @@ -218,6 +223,8 @@ impl Filesystem for Fuse { _fh: u64, offset: i64, size: u32, + _flags: i32, + _lock_owner: Option, reply: ReplyData, ) { let node_ptr = TreePtr::::new(node_id as u32); @@ -249,7 +256,9 @@ impl Filesystem for Fuse { _fh: u64, offset: i64, data: &[u8], - _flags: u32, + _write_flags: u32, + _flags: i32, + _lock_owner: Option, reply: ReplyWrite, ) { let node_ptr = TreePtr::::new(node_id as u32); @@ -298,9 +307,10 @@ impl Filesystem for Fuse { if offset == 0 { skip = 0; i = 0; - reply.add(parent_id, i, FileType::Directory, "."); + let _full = reply.add(parent_id, i, FileType::Directory, "."); + i += 1; - reply.add( + let _full = reply.add( //TODO: get parent? parent_id, i, @@ -354,7 +364,8 @@ impl Filesystem for Fuse { parent_id: u64, name: &OsStr, mode: u32, - flags: u32, + _umask: u32, + flags: i32, reply: ReplyCreate, ) { let parent_ptr = TreePtr::::new(parent_id as u32); @@ -370,7 +381,7 @@ impl Filesystem for Fuse { }) { Ok(node) => { // println!("Create {:?}:{:o}:{:o}", node.1.name(), node.1.mode, mode); - reply.created(&TTL, &node_attr(&node), 0, 0, flags); + reply.created(&TTL, &node_attr(&node), 0, 0, flags as u32); } Err(error) => { reply.error(error.errno as i32); @@ -384,6 +395,7 @@ impl Filesystem for Fuse { parent_id: u64, name: &OsStr, mode: u32, + _umask: u32, reply: ReplyEntry, ) { let parent_ptr = TreePtr::::new(parent_id as u32); @@ -512,6 +524,7 @@ impl Filesystem for Fuse { orig_name: &OsStr, new_parent: u64, new_name: &OsStr, + _flags: u32, reply: ReplyEmpty, ) { let orig_parent_ptr = TreePtr::::new(orig_parent as u32);