mirror of
https://github.com/OMGeeky/gdriver2.git
synced 2025-12-27 06:29:37 +01:00
improve readdir & make root permissions a bit more normal
This commit is contained in:
@@ -183,6 +183,23 @@ impl fuser::Filesystem for Filesystem {
|
||||
) {
|
||||
let id = self.get_id_from_ino(ino);
|
||||
info!("Reading dir: {id:?}/{ino}");
|
||||
let mut counter = 0;
|
||||
if offset == 0 {
|
||||
counter += 1;
|
||||
let full = reply.add(ino, counter, fuser::FileType::Directory, ".");
|
||||
if full {
|
||||
reply.ok();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if offset + counter == 1 {
|
||||
counter += 1;
|
||||
let full = reply.add(0, counter, fuser::FileType::Directory, "..");
|
||||
if full {
|
||||
reply.ok();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if let Err(e) = utils::update::update(self) {
|
||||
error!("Got an error during update in readdir: {}", e);
|
||||
dbg!(e);
|
||||
@@ -193,10 +210,9 @@ impl fuser::Filesystem for Filesystem {
|
||||
match id {
|
||||
None => {}
|
||||
Some(id) => {
|
||||
let result = utils::readdir::readdir(self, id.clone(), offset as u64);
|
||||
let result = utils::readdir::readdir(self, id.clone(), (offset + counter) as u64);
|
||||
match result {
|
||||
Ok(entries) => {
|
||||
let mut counter = 0;
|
||||
for entry in entries {
|
||||
let ino = self.get_ino_from_id(entry.id);
|
||||
counter += 1;
|
||||
|
||||
@@ -77,10 +77,6 @@ fn parse_xattr_namespace(key: &[u8]) -> StdResult<XattrNamespace, c_int> {
|
||||
|
||||
return Err(libc::ENOTSUP);
|
||||
}
|
||||
fn time_now() -> (i64, u32) {
|
||||
time_from_system_time(&SystemTime::now())
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub(crate) struct InodeAttributes {
|
||||
pub inode: Inode,
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user