improve readdir & make root permissions a bit more normal

This commit is contained in:
OMGeeky
2024-04-15 18:59:04 +02:00
parent 4c77bd1ba1
commit 7f67afa229
4 changed files with 29 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
use crate::ipc::gdriver_service::SETTINGS;
use crate::prelude::*;
use crate::time_utils::time_now;
use serde::{Deserialize, Serialize};
use std::{collections::BTreeMap, fs::File, path::Path};
@@ -21,17 +22,19 @@ pub struct Metadata {
pub extra_attributes: BTreeMap<Vec<u8>, Vec<u8>>,
}
const PERMISSIONS_RWXRWXRWX: u16 = 0b111_111_111; // 511;
impl Metadata {
pub fn root() -> Self {
Self {
id: ROOT_ID.clone(),
state: FileState::Root,
size: 0,
last_accessed: (0, 0),
last_modified: (0, 0),
last_metadata_changed: (0, 0),
last_accessed: time_now(),
last_modified: time_now(),
last_metadata_changed: time_now(),
kind: FileKind::Directory,
permissions: 0,
permissions: PERMISSIONS_RWXRWXRWX,
extra_attributes: Default::default(),
}
}

View File

@@ -37,3 +37,7 @@ pub fn time_from_system_time(system_time: &SystemTime) -> (i64, u32) {
),
}
}
pub fn time_now() -> (i64, u32) {
time_from_system_time(&SystemTime::now())
}