Server implemented. Linux client implemented.
This commit is contained in:
12
furumi-common/Cargo.toml
Normal file
12
furumi-common/Cargo.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "furumi-common"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
prost = "0.13.5"
|
||||
tonic = "0.12.3"
|
||||
|
||||
[build-dependencies]
|
||||
protobuf-src = "2.1.1"
|
||||
tonic-build = "0.12.3"
|
||||
12
furumi-common/build.rs
Normal file
12
furumi-common/build.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("cargo:rerun-if-changed=proto/virtualfs.proto");
|
||||
unsafe {
|
||||
std::env::set_var("PROTOC", protobuf_src::protoc());
|
||||
}
|
||||
|
||||
tonic_build::configure()
|
||||
.build_server(true)
|
||||
.build_client(true)
|
||||
.compile_protos(&["proto/virtualfs.proto"], &["proto"])?;
|
||||
Ok(())
|
||||
}
|
||||
41
furumi-common/proto/virtualfs.proto
Normal file
41
furumi-common/proto/virtualfs.proto
Normal file
@@ -0,0 +1,41 @@
|
||||
syntax = "proto3";
|
||||
package virtualfs;
|
||||
|
||||
message PathRequest {
|
||||
string path = 1;
|
||||
}
|
||||
|
||||
message AttrResponse {
|
||||
uint64 size = 1;
|
||||
uint32 mode = 2; // Permissions and file type
|
||||
uint64 mtime = 3; // Modification time
|
||||
// ... other standard stat attributes
|
||||
}
|
||||
|
||||
message DirEntry {
|
||||
string name = 1;
|
||||
uint32 type = 2; // File or Directory, mapping roughly to libc::DT_REG, libc::DT_DIR, etc.
|
||||
}
|
||||
|
||||
message ReadRequest {
|
||||
string path = 1;
|
||||
uint64 offset = 2;
|
||||
uint32 size = 3;
|
||||
// Optional requested chunk size. If 0, the server uses its default chunk size.
|
||||
uint32 chunk_size = 4;
|
||||
}
|
||||
|
||||
message FileChunk {
|
||||
bytes data = 1;
|
||||
}
|
||||
|
||||
service RemoteFileSystem {
|
||||
// Get file or directory attributes (size, permissions, timestamps). Maps to stat/getattr.
|
||||
rpc GetAttr (PathRequest) returns (AttrResponse);
|
||||
|
||||
// List directory contents. Uses Server Streaming to handle massively large directories efficiently.
|
||||
rpc ReadDir (PathRequest) returns (stream DirEntry);
|
||||
|
||||
// Read chunks of a file. Uses Server Streaming for efficient chunk delivery based on offset/size.
|
||||
rpc ReadFile (ReadRequest) returns (stream FileChunk);
|
||||
}
|
||||
3
furumi-common/src/lib.rs
Normal file
3
furumi-common/src/lib.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub mod proto {
|
||||
tonic::include_proto!("virtualfs");
|
||||
}
|
||||
Reference in New Issue
Block a user