0.4.4 - no_std support
This commit is contained in:
Generated
+52
-52
@@ -1,185 +1,185 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
|
||||
[[package]]
|
||||
name = "fuse"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80e57070510966bfef93662a81cb8aa2b1c7db0964354fa9921434f04b9e8660"
|
||||
dependencies = [
|
||||
"libc 0.2.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thread-scoped 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc",
|
||||
"log 0.3.9",
|
||||
"pkg-config",
|
||||
"thread-scoped",
|
||||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.97"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
|
||||
dependencies = [
|
||||
"log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.3.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c"
|
||||
dependencies = [
|
||||
"libc 0.2.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc",
|
||||
"rand 0.4.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
|
||||
dependencies = [
|
||||
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuchsia-cprng",
|
||||
"libc",
|
||||
"rand_core 0.3.1",
|
||||
"rdrand",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
dependencies = [
|
||||
"rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.4.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
||||
|
||||
[[package]]
|
||||
name = "rdrand"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
||||
dependencies = [
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.3.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee"
|
||||
dependencies = [
|
||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redoxfs"
|
||||
version = "0.4.3"
|
||||
version = "0.4.4"
|
||||
dependencies = [
|
||||
"fuse 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuse",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"time",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[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"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
|
||||
dependencies = [
|
||||
"libc 0.2.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasi 0.10.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc",
|
||||
"wasi",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bcc7e3b898aa6f6c08e5295b6c89258d1331e9ac578cc992fb818759951bdc22"
|
||||
dependencies = [
|
||||
"rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.23",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
"checksum cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
"checksum fuse 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80e57070510966bfef93662a81cb8aa2b1c7db0964354fa9921434f04b9e8660"
|
||||
"checksum libc 0.2.97 (registry+https://github.com/rust-lang/crates.io-index)" = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
|
||||
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
|
||||
"checksum log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
"checksum pkg-config 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
|
||||
"checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c"
|
||||
"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
|
||||
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
||||
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
||||
"checksum redox_syscall 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee"
|
||||
"checksum thread-scoped 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bcbb6aa301e5d3b0b5ef639c9a9c7e2f1c944f177b460c04dc24c69b1fa2bd99"
|
||||
"checksum time 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
|
||||
"checksum uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc7e3b898aa6f6c08e5295b6c89258d1331e9ac578cc992fb818759951bdc22"
|
||||
"checksum wasi 0.10.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||
"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
+14
-4
@@ -2,7 +2,7 @@
|
||||
name = "redoxfs"
|
||||
description = "The Redox Filesystem"
|
||||
repository = "https://gitlab.redox-os.org/redox-os/redoxfs"
|
||||
version = "0.4.3"
|
||||
version = "0.4.4"
|
||||
license-file = "LICENSE"
|
||||
readme = "README.md"
|
||||
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
|
||||
@@ -15,22 +15,32 @@ path = "src/lib.rs"
|
||||
name = "redoxfs"
|
||||
path = "src/bin/mount.rs"
|
||||
doc = false
|
||||
required-features = ["std"]
|
||||
|
||||
[[bin]]
|
||||
name = "redoxfs-ar"
|
||||
path = "src/bin/ar.rs"
|
||||
doc = false
|
||||
required-features = ["std"]
|
||||
|
||||
[[bin]]
|
||||
name = "redoxfs-mkfs"
|
||||
path = "src/bin/mkfs.rs"
|
||||
doc = false
|
||||
required-features = ["std"]
|
||||
|
||||
[dependencies]
|
||||
redox_syscall = "0.2.9"
|
||||
uuid = { version = "0.5", features = ["v4"] }
|
||||
|
||||
[dependencies.uuid]
|
||||
version = "0.5"
|
||||
default-features = false
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = ["fuse", "time", "uuid/v4"]
|
||||
|
||||
[target.'cfg(not(target_os = "redox"))'.dependencies]
|
||||
fuse = "0.3"
|
||||
fuse = { version = "0.3", optional = true }
|
||||
libc = "0.2"
|
||||
time = "0.1"
|
||||
time = { version = "0.1", optional = true }
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
use syscall::error::Result;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use self::cache::DiskCache;
|
||||
#[cfg(feature = "std")]
|
||||
pub use self::file::DiskFile;
|
||||
#[cfg(feature = "std")]
|
||||
pub use self::sparse::DiskSparse;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
mod cache;
|
||||
#[cfg(feature = "std")]
|
||||
mod file;
|
||||
#[cfg(feature = "std")]
|
||||
mod sparse;
|
||||
|
||||
/// A disk
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
use std::cmp::min;
|
||||
use core::cmp::min;
|
||||
|
||||
use BLOCK_SIZE;
|
||||
|
||||
|
||||
+12
-6
@@ -1,5 +1,5 @@
|
||||
use std::cmp::min;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use alloc::vec::Vec;
|
||||
use core::cmp::min;
|
||||
|
||||
use syscall::error::{Error, Result, EEXIST, EINVAL, EISDIR, ENOENT, ENOSPC, ENOTDIR, ENOTEMPTY};
|
||||
|
||||
@@ -38,6 +38,7 @@ impl<D: Disk> FileSystem<D> {
|
||||
}
|
||||
|
||||
/// Create a file system on a disk
|
||||
#[cfg(feature = "std")]
|
||||
pub fn create(disk: D, ctime: u64, ctime_nsec: u32) -> Result<Self> {
|
||||
Self::create_reserved(disk, &[], ctime, ctime_nsec)
|
||||
}
|
||||
@@ -45,6 +46,7 @@ impl<D: Disk> FileSystem<D> {
|
||||
/// Create a file system on a disk, with reserved data at the beginning
|
||||
/// Reserved data will be zero padded up to the nearest block
|
||||
/// We need to pass ctime and ctime_nsec in order to initialize the unix timestamps
|
||||
#[cfg(feature = "std")]
|
||||
pub fn create_reserved(
|
||||
mut disk: D,
|
||||
reserved: &[u8],
|
||||
@@ -453,8 +455,14 @@ impl<D: Disk> FileSystem<D> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_node(&mut self, block: u64, offset: u64, buf: &mut [u8]) -> Result<usize> {
|
||||
let atime = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
|
||||
pub fn read_node(
|
||||
&mut self,
|
||||
block: u64,
|
||||
offset: u64,
|
||||
buf: &mut [u8],
|
||||
atime: u64,
|
||||
atime_nsec: u32,
|
||||
) -> Result<usize> {
|
||||
let block_offset = offset / BLOCK_SIZE;
|
||||
let mut byte_offset = (offset % BLOCK_SIZE) as usize;
|
||||
|
||||
@@ -518,8 +526,6 @@ impl<D: Disk> FileSystem<D> {
|
||||
}
|
||||
|
||||
if i > 0 {
|
||||
let atime_nsec = atime.subsec_nanos();
|
||||
let atime = atime.as_secs();
|
||||
let mut node = self.node(block)?;
|
||||
if atime > node.1.atime || (atime == node.1.atime && atime_nsec > node.1.atime_nsec) {
|
||||
let is_old = atime - node.1.atime > 3600; // Last read was more than a day ago
|
||||
|
||||
+4
-5
@@ -1,7 +1,5 @@
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::{fmt, mem, slice};
|
||||
|
||||
use uuid::Uuid;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::{fmt, mem, slice};
|
||||
|
||||
use {BLOCK_SIZE, SIGNATURE, VERSION};
|
||||
|
||||
@@ -38,8 +36,9 @@ impl Header {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub fn new(size: u64, root: u64, free: u64) -> Header {
|
||||
let uuid = Uuid::new_v4();
|
||||
let uuid = uuid::Uuid::new_v4();
|
||||
Header {
|
||||
signature: *SIGNATURE,
|
||||
version: VERSION,
|
||||
|
||||
+14
-3
@@ -1,31 +1,42 @@
|
||||
#![crate_name = "redoxfs"]
|
||||
#![crate_type = "lib"]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate core;
|
||||
|
||||
extern crate syscall;
|
||||
extern crate uuid;
|
||||
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use core::sync::atomic::AtomicUsize;
|
||||
|
||||
pub const BLOCK_SIZE: u64 = 4096;
|
||||
pub const SIGNATURE: &'static [u8; 8] = b"RedoxFS\0";
|
||||
pub const VERSION: u64 = 4;
|
||||
pub static IS_UMT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use self::archive::{archive, archive_at};
|
||||
pub use self::disk::{Disk, DiskCache, DiskFile, DiskSparse};
|
||||
pub use self::disk::Disk;
|
||||
#[cfg(feature = "std")]
|
||||
pub use self::disk::{DiskCache, DiskFile, DiskSparse};
|
||||
pub use self::extent::Extent;
|
||||
pub use self::filesystem::FileSystem;
|
||||
pub use self::header::Header;
|
||||
#[cfg(feature = "std")]
|
||||
pub use self::mount::mount;
|
||||
pub use self::node::Node;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
mod archive;
|
||||
mod disk;
|
||||
mod extent;
|
||||
mod filesystem;
|
||||
mod header;
|
||||
#[cfg(feature = "std")]
|
||||
mod mount;
|
||||
mod node;
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(all(feature = "std", test))]
|
||||
mod tests;
|
||||
|
||||
+22
-6
@@ -242,11 +242,15 @@ impl<D: Disk> Filesystem for Fuse<D> {
|
||||
size: u32,
|
||||
reply: ReplyData,
|
||||
) {
|
||||
let atime = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
|
||||
let mut data = vec![0; size as usize];
|
||||
match self
|
||||
.fs
|
||||
.read_node(block, cmp::max(0, offset) as u64, &mut data)
|
||||
{
|
||||
match self.fs.read_node(
|
||||
block,
|
||||
cmp::max(0, offset) as u64,
|
||||
&mut data,
|
||||
atime.as_secs(),
|
||||
atime.subsec_nanos(),
|
||||
) {
|
||||
Ok(count) => {
|
||||
reply.data(&data[..count]);
|
||||
}
|
||||
@@ -483,8 +487,12 @@ impl<D: Disk> Filesystem for Fuse<D> {
|
||||
}
|
||||
|
||||
fn readlink(&mut self, _req: &Request, ino: u64, reply: ReplyData) {
|
||||
let atime = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
|
||||
let mut data = vec![0; 4096];
|
||||
match self.fs.read_node(ino, 0, &mut data) {
|
||||
match self
|
||||
.fs
|
||||
.read_node(ino, 0, &mut data, atime.as_secs(), atime.subsec_nanos())
|
||||
{
|
||||
Ok(count) => {
|
||||
reply.data(&data[..count]);
|
||||
}
|
||||
@@ -494,7 +502,15 @@ impl<D: Disk> Filesystem for Fuse<D> {
|
||||
}
|
||||
}
|
||||
|
||||
fn rename(&mut self, _req: &Request, orig_parent: u64, name: &OsStr, new_parent: u64, new_name: &OsStr, reply: ReplyEmpty) {
|
||||
fn rename(
|
||||
&mut self,
|
||||
_req: &Request,
|
||||
orig_parent: u64,
|
||||
name: &OsStr,
|
||||
new_parent: u64,
|
||||
new_name: &OsStr,
|
||||
reply: ReplyEmpty,
|
||||
) {
|
||||
let rename_inner = |fs: &mut filesystem::FileSystem<D>| -> syscall::Result<()> {
|
||||
let mut orig = fs.find_node(name.to_str().unwrap(), orig_parent)?;
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use syscall::data::{Map, Stat, TimeSpec};
|
||||
use syscall::error::{Error, Result, EBADF, EINVAL, EISDIR, ENOMEM, EPERM};
|
||||
use syscall::flag::{
|
||||
F_GETFL, F_SETFL, MODE_PERM, O_ACCMODE, O_APPEND, O_RDONLY, O_RDWR, O_WRONLY, PROT_READ,
|
||||
PROT_WRITE, SEEK_CUR, SEEK_END, SEEK_SET, MapFlags,
|
||||
MapFlags, F_GETFL, F_SETFL, MODE_PERM, O_ACCMODE, O_APPEND, O_RDONLY, O_RDWR, O_WRONLY,
|
||||
PROT_READ, PROT_WRITE, SEEK_CUR, SEEK_END, SEEK_SET,
|
||||
};
|
||||
|
||||
use disk::Disk;
|
||||
@@ -214,8 +214,15 @@ impl Fmap {
|
||||
}
|
||||
|
||||
// Read buffer from disk
|
||||
let atime = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
|
||||
let buf = slice::from_raw_parts_mut(address, map.size);
|
||||
let count = match fs.read_node(block, map.offset as u64, buf) {
|
||||
let count = match fs.read_node(
|
||||
block,
|
||||
map.offset as u64,
|
||||
buf,
|
||||
atime.as_secs(),
|
||||
atime.subsec_nanos(),
|
||||
) {
|
||||
Ok(ok) => ok,
|
||||
Err(err) => {
|
||||
free(address);
|
||||
@@ -307,7 +314,14 @@ impl<D: Disk> Resource<D> for FileResource {
|
||||
|
||||
fn read(&mut self, buf: &mut [u8], fs: &mut FileSystem<D>) -> Result<usize> {
|
||||
if self.flags & O_ACCMODE == O_RDWR || self.flags & O_ACCMODE == O_RDONLY {
|
||||
let count = fs.read_node(self.block, self.seek as u64, buf)?;
|
||||
let atime = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
|
||||
let count = fs.read_node(
|
||||
self.block,
|
||||
self.seek as u64,
|
||||
buf,
|
||||
atime.as_secs(),
|
||||
atime.subsec_nanos(),
|
||||
)?;
|
||||
self.seek += count as isize;
|
||||
Ok(count)
|
||||
} else {
|
||||
|
||||
@@ -6,12 +6,12 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use syscall::data::{Map, Stat, StatVfs, TimeSpec};
|
||||
use syscall::error::{
|
||||
Error, Result, EACCES, EBADF, EEXIST, EINVAL, EISDIR, ELOOP, ENOENT, ENOTDIR, ENOTEMPTY,
|
||||
ENOSYS, EPERM, EXDEV,
|
||||
Error, Result, EACCES, EBADF, EEXIST, EINVAL, EISDIR, ELOOP, ENOENT, ENOSYS, ENOTDIR,
|
||||
ENOTEMPTY, EPERM, EXDEV,
|
||||
};
|
||||
use syscall::flag::{
|
||||
MODE_PERM, O_ACCMODE, O_CREAT, O_DIRECTORY, O_EXCL, O_NOFOLLOW, O_RDONLY, O_RDWR, O_STAT,
|
||||
O_SYMLINK, O_TRUNC, O_WRONLY, EventFlags,
|
||||
EventFlags, MODE_PERM, O_ACCMODE, O_CREAT, O_DIRECTORY, O_EXCL, O_NOFOLLOW, O_RDONLY, O_RDWR,
|
||||
O_STAT, O_SYMLINK, O_TRUNC, O_WRONLY,
|
||||
};
|
||||
use syscall::scheme::Scheme;
|
||||
|
||||
@@ -53,8 +53,9 @@ impl<D: Disk> FileScheme<D> {
|
||||
let mut node = node;
|
||||
for _ in 0..32 {
|
||||
// XXX What should the limit be?
|
||||
let atime = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
|
||||
let mut buf = [0; 4096];
|
||||
let count = fs.read_node(node.0, 0, &mut buf)?;
|
||||
let count = fs.read_node(node.0, 0, &mut buf, atime.as_secs(), atime.subsec_nanos())?;
|
||||
let scheme = format!("{}:", &self.name);
|
||||
let canon = canonicalize(
|
||||
&format!("{}{}", scheme, str::from_utf8(url).unwrap()).as_bytes(),
|
||||
@@ -249,10 +250,17 @@ impl<D: Disk> Scheme for FileScheme<D> {
|
||||
&& flags & O_SYMLINK != O_SYMLINK
|
||||
{
|
||||
let mut resolve_nodes = Vec::new();
|
||||
let resolved =
|
||||
self.resolve_symlink(&mut fs, uid, gid, url.as_bytes(), node, &mut resolve_nodes)?;
|
||||
let resolved = self.resolve_symlink(
|
||||
&mut fs,
|
||||
uid,
|
||||
gid,
|
||||
url.as_bytes(),
|
||||
node,
|
||||
&mut resolve_nodes,
|
||||
)?;
|
||||
drop(fs);
|
||||
let resolved_utf8 = str::from_utf8(&resolved).map_err(|_| Error::new(EINVAL))?;
|
||||
let resolved_utf8 =
|
||||
str::from_utf8(&resolved).map_err(|_| Error::new(EINVAL))?;
|
||||
return self.open(resolved_utf8, flags, uid, gid);
|
||||
} else if !node.1.is_symlink() && flags & O_SYMLINK == O_SYMLINK {
|
||||
return Err(Error::new(EINVAL));
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
use std::{fmt, mem, ops, slice, str};
|
||||
use alloc::vec::Vec;
|
||||
use core::{fmt, mem, ops, slice, str};
|
||||
|
||||
use super::Extent;
|
||||
use syscall;
|
||||
|
||||
+7
-3
@@ -93,7 +93,7 @@ fn mmap() {
|
||||
|
||||
let mmap_inner = |write: bool| {
|
||||
let fd = dbg!(syscall::open(
|
||||
path.as_os_str().as_bytes(),
|
||||
path.to_str().unwrap(),
|
||||
syscall::O_CREAT | syscall::O_RDWR | syscall::O_CLOEXEC
|
||||
))
|
||||
.unwrap();
|
||||
@@ -105,7 +105,8 @@ fn mmap() {
|
||||
&syscall::Map {
|
||||
offset: 0,
|
||||
size: 128,
|
||||
flags: syscall::PROT_READ | syscall::PROT_WRITE
|
||||
flags: syscall::PROT_READ | syscall::PROT_WRITE,
|
||||
address: 0,
|
||||
}
|
||||
))
|
||||
.unwrap() as *mut u8,
|
||||
@@ -125,7 +126,10 @@ fn mmap() {
|
||||
|
||||
//TODO: add msync
|
||||
unsafe {
|
||||
assert_eq!(dbg!(syscall::funmap(map.as_mut_ptr() as usize)), Ok(0));
|
||||
assert_eq!(
|
||||
dbg!(syscall::funmap(map.as_mut_ptr() as usize, map.len())),
|
||||
Ok(0)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user