Phase 3完成:FUSE完整重构以支持fuse-t
Some checks failed
Test / build (push) Has been cancelled
Test / test (push) Has been cancelled

核心成果:
- fuse-t库成功纳入项目(build.rs + Cargo.toml)
- fuse-backend-rs API完整实现(270行代码)
- FileSystem trait完整重写(lookup/getattr/read/readdir/open/release/opendir/releasedir/statfs)
- ZeroCopyWriter API正确集成(write_from方法)
- 服务循环正确实现(get_request + handle_message)

技术实现:
- 依赖:fuse-backend-rs(fusedev + fuse-t features)
- 链接:fuse-t库(pkg-config + DiskArbitration framework)
- 数据库:find_node_id_by_parent方法新增
- API:DirEntry/Entry/stat64正确使用
- 服务:FuseSession/FuseChannel正确集成

编译状态:
- 8警告,0错误
- 成功编译markbase-fuse库和main程序

状态:Phase 3完整实施完成
This commit is contained in:
Warren
2026-06-13 16:33:13 +08:00
parent ceadeef329
commit c2e3984ac8
6 changed files with 586 additions and 299 deletions

View File

@@ -2,7 +2,6 @@ use anyhow::Result;
use clap::{Parser, Subcommand};
use std::path::PathBuf;
use std::sync::Arc;
use std::sync::Mutex;
#[derive(Parser)]
#[command(name = "markbase-fuse", about = "MarkBase FUSE Mount Tool")]
@@ -43,7 +42,8 @@ fn main() -> Result<()> {
}
fn mount_user(user: String, tree_type: String, dir: PathBuf) -> Result<()> {
use fuse::mount;
use fuse_backend_rs::api::server::Server;
use fuse_backend_rs::transport::FuseSession;
use markbase_fuse::MarkBaseFs;
use std::env::current_dir;
@@ -61,7 +61,7 @@ fn mount_user(user: String, tree_type: String, dir: PathBuf) -> Result<()> {
std::fs::create_dir_all(&dir)?;
}
println!("=== MarkBase FUSE (fuse crate + FUSE-T) ===");
println!("=== MarkBase FUSE (fuse-backend-rs + fuse-t) ===");
println!("User: {}", user);
println!("Tree Type: {}", tree_type);
println!("Database: {}", db_path.display());
@@ -69,34 +69,42 @@ fn mount_user(user: String, tree_type: String, dir: PathBuf) -> Result<()> {
println!("");
let fs = MarkBaseFs::new(&db_path.to_string_lossy(), &tree_type)?;
let fs = Arc::new(Mutex::new(fs));
let server = Arc::new(Server::new(fs));
let options = vec![
"-o",
"rw",
"-o",
"allow_other",
"-o",
"noatime",
"-o",
"local",
"-o",
"big_writes",
"-o",
"max_read=524288",
"-o",
"max_write=524288",
"-o",
"kernel_cache",
];
mount(fs, &dir, &options)?;
let mut session = FuseSession::new(&dir, "markbase", "markbase-fuse", false)?;
session.mount()?;
println!("Mounted successfully!");
println!("Press Ctrl+C to unmount...");
let mut channel = session.new_channel()?;
let ebadf = std::io::Error::from_raw_os_error(libc::EBADF);
loop {
if let Some((reader, writer)) = channel.get_request()? {
if let Err(e) = server.handle_message(reader, writer.into(), None, None) {
match e {
fuse_backend_rs::Error::EncodeMessage(e) if e.kind() == std::io::ErrorKind::Other => {
break;
}
_ => {
eprintln!("Handling fuse message failed: {:?}", e);
continue;
}
}
}
} else {
println!("fuse server exits");
break;
}
}
session.umount()?;
println!("Unmounted successfully");
Ok(())
}
fn unmount_user(dir: PathBuf) -> Result<()> {
println!("Unmounting: {}", dir.display());
@@ -104,4 +112,4 @@ fn unmount_user(dir: PathBuf) -> Result<()> {
println!("Unmounted successfully");
Ok(())
}
}