idk backup

This commit is contained in:
2026-01-25 12:24:06 +01:00
parent 2523e3b4fe
commit 667d127a03
17 changed files with 1030 additions and 60 deletions

View File

@@ -107,12 +107,16 @@ impl fuser::Filesystem for DriveFilesystem {
trace!("details: {e:?}");
libc::EBADMSG
})?;
info!(
"Is online: {}",
send_request!(self.gdriver_client.is_online(current_context())).unwrap_or(false)
);
Ok(())
}
//endregion
//region lookup
fn lookup(&mut self, _req: &Request<'_>, parent: u64, name: &OsStr, reply: ReplyEntry) {
dbg!(&parent, &name);
if name.to_str().unwrap().contains('/') {
todo!("The name in lookup can contain multiple path segments, not just a single name, directly under the parent")
}
@@ -123,12 +127,15 @@ impl fuser::Filesystem for DriveFilesystem {
}
Err(e) => {
error!("Got an error during lookup: {e:?}");
dbg!(&e);
match e {
FilesystemError::Rpc(_) => reply.error(libc::EREMOTEIO),
FilesystemError::IO(_) => reply.error(libc::EIO),
FilesystemError::Service(_) | FilesystemError::NotFound => {
reply.error(libc::ENOENT)
FilesystemError::Service(e) => {
dbg!(e);
reply.error(libc::EBADE);
}
FilesystemError::NotFound => reply.error(libc::ENOENT),
FilesystemError::Other(e) => {
dbg!(e);
todo!("Handle other errors and decide what error code should be used here")
@@ -140,7 +147,7 @@ impl fuser::Filesystem for DriveFilesystem {
//endregion
//region open
fn open(&mut self, _req: &Request<'_>, ino: u64, flags: i32, reply: ReplyOpen) {
let data = utils::lookup::open(self, ino, HandleFlags::from(flags));
let data = utils::open(self, ino, HandleFlags::from(flags));
match data {
Ok((file_header, flags)) => {
reply.opened(file_header, flags.into());
@@ -163,7 +170,10 @@ impl fuser::Filesystem for DriveFilesystem {
}
mod errors {
use std::backtrace::Backtrace;
use std::error::Error;
use std::io;
use std::path::PathBuf;
use tarpc::client::RpcError;
@@ -176,7 +186,7 @@ mod errors {
#[error("Could not find entity specified")]
NotFound,
#[error("IO Error")]
IO(#[source] Box<dyn Error>),
IO(#[from] io::Error),
#[error("Service returned Error: {0}")]
Service(#[from] GDriverServiceError),
#[error("Some other error occurred: {0}")]
@@ -247,18 +257,17 @@ mod utils {
.get_metadata_for_file(current_context(), id.clone()))?
.map_err(GDriverServiceError::from)?;
let meta_path = fs.gdriver_settings.get_metadata_file_path(&id);
let metadata = read_inode_attributes_from_meta_file(&meta_path, ino, open_file_handles)
.map_err(FilesystemError::IO)?;
let metadata =
read_inode_attributes_from_meta_file(&meta_path, ino, open_file_handles)?;
Ok(metadata)
}
pub(crate) fn open(
fs: &mut DriveFilesystem,
inode: Inode,
flags: HandleFlags,
) -> StdResult<(FileHandle, HandleFlags), FilesystemError> {
dbg!(&fs, inode, flags);
todo!()
}
}
pub(crate) fn open(
fs: &mut DriveFilesystem,
inode: Inode,
flags: HandleFlags,
) -> StdResult<(FileHandle, HandleFlags), FilesystemError> {
dbg!(&fs, inode, flags);
todo!()
}
}

View File

@@ -137,7 +137,7 @@ pub(crate) fn read_inode_attributes_from_meta_file(
meta_path: &Path,
inode: Inode,
open_file_handles: u64,
) -> Result<InodeAttributes> {
) -> StdResult<InodeAttributes, std::io::Error> {
let metadata = read_metadata_file(meta_path)?;
Ok(read_inode_attributes_from_metadata(
metadata,

View File

@@ -5,6 +5,7 @@ use std::{error::Error, net::IpAddr, result::Result as StdResult};
use crate::filesystem::DriveFilesystem;
use crate::service::create_client;
use gdriver_common::ipc::gdriver_service::GDriverServiceClient;
use gdriver_common::tracing_subscriber::{init_tracing, test_tracing};
use gdriver_common::{ipc::sample::*, prelude::*};
use tarpc::{client, tokio_serde::formats::Json};
@@ -12,16 +13,16 @@ type Result<T> = StdResult<T, Box<dyn Error>>;
#[tokio::main]
async fn main() -> Result<()> {
init_tracing();
test_tracing();
println!("Hello, world!");
let config = &CONFIGURATION;
println!("Config: {:?}", **config);
let client: GDriverServiceClient = create_client(config.ip, config.port).await?;
let fs = DriveFilesystem::new(client);
mount2(
fs,
Path::new("/tmp/gdriver"),
&[MountOption::RW, MountOption::AutoUnmount],
)?;
let mountpoint = Path::new("/tmp/gdriver");
std::fs::create_dir_all(mountpoint)?;
mount2(fs, mountpoint, &[MountOption::RW, MountOption::AutoUnmount])?;
// service::start().await?;
Ok(())