From bdd01bd70e031accfd4acda1220e1f3d01a80924 Mon Sep 17 00:00:00 2001 From: Moritz Gmeiner Date: Sat, 2 Aug 2025 17:22:32 +0200 Subject: [PATCH] implemented setattr (properly) --- Cargo.lock | 2 + fat-bits/Cargo.toml | 1 + fat-bits/src/datetime.rs | 22 ++-- fat-bits/src/dir.rs | 142 +++++++++++----------- fat-fuse/Cargo.toml | 1 + fat-fuse/src/fuse.rs | 253 ++++++++++++++++++++++++++++----------- fat-fuse/src/inode.rs | 130 +++++++++++++------- fat-fuse/src/lib.rs | 4 +- 8 files changed, 356 insertions(+), 199 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f0d44bf..83fc35b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -238,6 +238,7 @@ dependencies = [ "chrono", "compact_str", "enum_dispatch", + "log", "static_assertions", "thiserror 2.0.12", ] @@ -255,6 +256,7 @@ name = "fat-fuse" version = "0.1.0" dependencies = [ "anyhow", + "bitflags", "chrono", "compact_string", "fat-bits", diff --git a/fat-bits/Cargo.toml b/fat-bits/Cargo.toml index 45ec5d4..6c53e1f 100644 --- a/fat-bits/Cargo.toml +++ b/fat-bits/Cargo.toml @@ -12,5 +12,6 @@ chrono = { version = "0.4.41", default-features = false, features = [ ] } compact_str = "0.9.0" enum_dispatch = "0.3.13" +log = "0.4.27" static_assertions = "1.1.0" thiserror = "2.0.12" diff --git a/fat-bits/src/datetime.rs b/fat-bits/src/datetime.rs index ecc5309..74f43ea 100644 --- a/fat-bits/src/datetime.rs +++ b/fat-bits/src/datetime.rs @@ -1,8 +1,8 @@ use std::time::SystemTime; -use chrono::{DateTime, Datelike, NaiveDate, NaiveTime, Timelike, Utc}; +use chrono::{DateTime, Datelike, Local, NaiveDate, NaiveTime, Timelike}; -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Date { repr: u16, } @@ -22,8 +22,7 @@ impl Date { Ok(date) } - #[allow(dead_code)] - pub fn from_day_month_year(day: u8, month: u8, year: u16) -> anyhow::Result { + fn from_day_month_year(day: u8, month: u8, year: u16) -> anyhow::Result { anyhow::ensure!(day <= 31, "invalid day: {}", day); anyhow::ensure!(month <= 12, "invalid month: {}", month); anyhow::ensure!(1980 <= year && year <= 2107, "invalid year: {}", year); @@ -33,10 +32,7 @@ impl Date { Ok(Date { repr }) } - #[allow(dead_code)] - pub fn from_system_time(time: SystemTime) -> anyhow::Result { - let datetime: DateTime = time.into(); - + pub fn from_datetime(datetime: DateTime) -> anyhow::Result { let date = datetime.date_naive(); Date::from_day_month_year( @@ -67,7 +63,7 @@ impl Date { } } -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Time { repr: u16, } @@ -79,8 +75,7 @@ impl Time { Ok(time) } - #[allow(dead_code)] - pub fn from_seconds_minutes_hours(seconds: u8, minutes: u8, hours: u8) -> anyhow::Result