From faa0a1a1194bac41d8e05efd0108e0c1821fa543 Mon Sep 17 00:00:00 2001 From: sevki Date: Mon, 25 Mar 2024 21:05:52 +0000 Subject: [PATCH] REFACTOR!: merge all the creates --- Cargo.lock | 28 +- Cargo.toml | 19 +- .../LICENSE => LICENSE.rust-p9 | 0 rust-toolchain | 2 +- src/async_wire_format.rs | 8 +- src/lib.rs | 27 +- src/log.rs | 7 +- .../rust-p9/src => src}/protocol/messages.rs | 133 ++-- .../rust-p9/src => src}/protocol/mod.rs | 0 .../src => src}/protocol/wire_format.rs | 5 +- src/server/mod.rs | 1 - src/server/ninep_2000_l.rs | 58 +- src/server/proxy.rs | 8 +- src/server/server_tests.rs | 2 +- src/server/ufs.rs | 3 +- src/server/x509_fs.rs | 629 ------------------ src/service.rs | 16 +- .../rust-p9/src/server => src/ufs}/mod.rs | 2 +- .../src/server => src/ufs}/read_dir.rs | 0 .../rust-p9/src/server => src/ufs}/tests.rs | 0 third_party/p9_wire_format_derive/Cargo.toml | 8 +- third_party/p9_wire_format_derive/src/lib.rs | 4 +- third_party/rust-p9/.gitignore | 1 - third_party/rust-p9/CONTRIBUTING.md | 33 - third_party/rust-p9/Cargo.lock | 93 --- third_party/rust-p9/Cargo.toml | 21 - third_party/rust-p9/LICENSE | 27 - third_party/rust-p9/OWNERS | 3 - third_party/rust-p9/README.md | 19 - third_party/rust-p9/src/fuzzing.rs | 14 - third_party/rust-p9/src/lib.rs | 30 - 31 files changed, 151 insertions(+), 1050 deletions(-) rename third_party/p9_wire_format_derive/LICENSE => LICENSE.rust-p9 (100%) rename {third_party/rust-p9/src => src}/protocol/messages.rs (92%) rename {third_party/rust-p9/src => src}/protocol/mod.rs (100%) rename {third_party/rust-p9/src => src}/protocol/wire_format.rs (99%) delete mode 100644 src/server/x509_fs.rs rename {third_party/rust-p9/src/server => src/ufs}/mod.rs (99%) rename {third_party/rust-p9/src/server => src/ufs}/read_dir.rs (100%) rename {third_party/rust-p9/src/server => src/ufs}/tests.rs (100%) delete mode 100644 third_party/rust-p9/.gitignore delete mode 100644 third_party/rust-p9/CONTRIBUTING.md delete mode 100644 third_party/rust-p9/Cargo.lock delete mode 100644 third_party/rust-p9/Cargo.toml delete mode 100644 third_party/rust-p9/LICENSE delete mode 100644 third_party/rust-p9/OWNERS delete mode 100644 third_party/rust-p9/README.md delete mode 100644 third_party/rust-p9/src/fuzzing.rs delete mode 100644 third_party/rust-p9/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 5163301..d1bed01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -757,8 +757,7 @@ dependencies = [ "futures", "futures-util", "genfs", - "jetstream_p9", - "jetstream_p9_wire_format_derive", + "jetstream_wire_format_derive", "lazy_static", "libc", "parking_lot", @@ -782,20 +781,8 @@ dependencies = [ ] [[package]] -name = "jetstream_p9" -version = "0.6.0" -dependencies = [ - "genfs", - "jetstream_p9_wire_format_derive", - "libc", - "serde", - "serde_bytes", - "tokio", -] - -[[package]] -name = "jetstream_p9_wire_format_derive" -version = "0.6.0" +name = "jetstream_wire_format_derive" +version = "0.5.1" dependencies = [ "pretty_assertions", "proc-macro2", @@ -1529,15 +1516,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde_bytes" -version = "0.11.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" -dependencies = [ - "serde", -] - [[package]] name = "serde_derive" version = "1.0.197" diff --git a/Cargo.toml b/Cargo.toml index 9fcdc4d..d64df53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,10 +8,18 @@ repository = "https://github.com/sevki/jetstream" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + + +[features] +default = ["async"] + +filesystem = [] +client = [] +async = [] + [dependencies] futures = "0.3.30" -jetstream_p9_wire_format_derive = { path = "./third_party/p9_wire_format_derive", version = "0.6.0" } -jetstream_p9 = { version = "0.6.0", path = "./third_party/rust-p9" } +jetstream_wire_format_derive = { path = "./third_party/p9_wire_format_derive", version = "0.5.1" } tokio = { version = "1.35.1", features = ["full"] } anyhow = "1.0.81" async-trait = "0.1.78" @@ -28,7 +36,7 @@ crc64 = "2.0.0" tuple-map = "0.4.0" futures-util = "0.3.30" colored = "2.1.0" -serde = "1.0.196" +serde = { version = "1.0.196", features = ["derive"] } lazy_static = "1.4.0" tower = "0.4.13" bytes = "1.6.0" @@ -41,10 +49,6 @@ crc16 = "0.4.0" slog-envlogger = "2.2.0" tokio-vsock = "0.5.0" -[features] -filesystem = [] -client = [] - [build-dependencies] bindgen = "0.69" pkg-config = "0.3" @@ -55,6 +59,5 @@ which = "6.0.0" [workspace] members = [ - "third_party/rust-p9", "third_party/p9_wire_format_derive", ] diff --git a/third_party/p9_wire_format_derive/LICENSE b/LICENSE.rust-p9 similarity index 100% rename from third_party/p9_wire_format_derive/LICENSE rename to LICENSE.rust-p9 diff --git a/rust-toolchain b/rust-toolchain index 9c3a667..af70436 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "1.75" +channel = "1.75.0" components = [ "rustfmt", "clippy", "llvm-tools-preview", "rust-src" ] diff --git a/src/async_wire_format.rs b/src/async_wire_format.rs index 372c5cd..9e2b327 100644 --- a/src/async_wire_format.rs +++ b/src/async_wire_format.rs @@ -3,7 +3,7 @@ use std::{ io::{self}, }; -use jetstream_p9::WireFormat; +use crate::protocol::WireFormat; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; @@ -71,11 +71,11 @@ impl AsyncWireFormatExt for T {} mod tests { use std::{pin::Pin, time::Duration}; - #[allow(unused_imports)] - use jetstream_p9::*; #[allow(unused_imports)] use std::io::Cursor; + #[allow(unused_imports)] + use crate::protocol::*; use tokio::time::sleep; use super::*; @@ -90,7 +90,7 @@ mod tests { fn new(delay: Duration, inner: tokio::io::DuplexStream) -> Self { Self { delay, - inner: inner, + inner, } } } diff --git a/src/lib.rs b/src/lib.rs index 52e8e97..92e61a8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,7 @@ //! - [jsonrpc](https://www.jsonrpc.org/) //! - [tarpc](https://crates.io/crates/tarpc) //! -//! ## [License](LICENSE) +//! ## [License](../LICENSE) //! //! BSD-3-Clause @@ -40,14 +40,33 @@ )] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -pub use jetstream_p9::protocol; +#[macro_use] +extern crate jetstream_wire_format_derive; +#[cfg(feature = "async")] pub mod async_wire_format; -pub mod log; - #[cfg(feature = "client")] pub mod client; #[cfg(feature = "filesystem")] pub mod filesystem; pub mod server; pub mod service; +pub mod protocol; +pub mod ufs; + +pub mod log; + +pub use jetstream_wire_format_derive::JetStreamWireFormat; + +#[macro_export] +macro_rules! syscall { + ($e:expr) => {{ + let res = $e; + if res < 0 { + Err(std::io::Error::last_os_error()) + } else { + Ok(res) + } + }}; +} + diff --git a/src/log.rs b/src/log.rs index 5c7eca2..475cd83 100644 --- a/src/log.rs +++ b/src/log.rs @@ -10,7 +10,7 @@ fn get_module_colour(module: &str) -> Color { // crc16 is a good hash for this let hash = crc16::State::::calculate(module.as_bytes()); let hash = hash.add(5); - let color = match hash % 6 { + match hash % 6 { 0 => Color::Red, 1 => Color::Green, 2 => Color::Yellow, @@ -18,8 +18,7 @@ fn get_module_colour(module: &str) -> Color { 4 => Color::Magenta, 5 => Color::Cyan, _ => Color::White, - }; - color + } } #[allow(dead_code)] @@ -72,7 +71,7 @@ pub(crate) fn drain() -> slog::Fuse< .set_underline(true) .set_fg(Some(Color::White)), )?; - let _ = write!(buffer, "{}:{}", loc.to_string(), r.location().line); + let _ = write!(buffer, "{}:{}", loc, r.location().line); buffer.reset()?; buffer.set_color( ColorSpec::new().set_fg(Some(level)).set_intense(true), diff --git a/third_party/rust-p9/src/protocol/messages.rs b/src/protocol/messages.rs similarity index 92% rename from third_party/rust-p9/src/protocol/messages.rs rename to src/protocol/messages.rs index 41860e8..9116ee1 100644 --- a/third_party/rust-p9/src/protocol/messages.rs +++ b/src/protocol/messages.rs @@ -315,49 +315,49 @@ impl Tframe { } } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tversion { pub msize: u32, pub version: String, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tflush { pub oldtag: u16, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Twalk { pub fid: u32, pub newfid: u32, pub wnames: Vec, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tread { pub fid: u32, pub offset: u64, pub count: u32, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Twrite { pub fid: u32, pub offset: u64, pub data: Data, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tclunk { pub fid: u32, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tremove { pub fid: u32, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tauth { pub afid: u32, pub uname: String, @@ -365,7 +365,7 @@ pub struct Tauth { pub n_uname: u32, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tattach { pub fid: u32, pub afid: u32, @@ -374,18 +374,18 @@ pub struct Tattach { pub n_uname: u32, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tstatfs { pub fid: u32, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tlopen { pub fid: u32, pub flags: u32, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tlcreate { pub fid: u32, pub name: String, @@ -394,7 +394,7 @@ pub struct Tlcreate { pub gid: u32, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tsymlink { pub fid: u32, pub name: String, @@ -402,7 +402,7 @@ pub struct Tsymlink { pub gid: u32, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Tmknod { pub dfid: u32, pub name: String, @@ -412,28 +412,25 @@ pub struct Tmknod { pub gid: u32, } -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Trename { pub fid: u32, pub dfid: u32, pub name: String, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Treadlink { pub fid: u32, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Tgetattr { pub fid: u32, pub request_mask: u64, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Tsetattr { pub fid: u32, pub valid: u32, @@ -447,16 +444,14 @@ pub struct Tsetattr { pub mtime_nsec: u64, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Txattrwalk { pub fid: u32, pub newfid: u32, pub name: String, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Txattrcreate { pub fid: u32, pub name: String, @@ -464,23 +459,20 @@ pub struct Txattrcreate { pub flags: u32, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Treaddir { pub fid: u32, pub offset: u64, pub count: u32, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Tfsync { pub fid: u32, pub datasync: u32, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Tlock { pub fid: u32, pub type_: u8, @@ -491,8 +483,7 @@ pub struct Tlock { pub client_id: String, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Tgetlock { pub fid: u32, pub type_: u8, @@ -502,16 +493,14 @@ pub struct Tgetlock { pub client_id: String, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Tlink { pub dfid: u32, pub fid: u32, pub name: String, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Tmkdir { pub dfid: u32, pub name: String, @@ -519,8 +508,7 @@ pub struct Tmkdir { pub gid: u32, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Trenameat { pub olddirfid: u32, pub oldname: String, @@ -528,8 +516,7 @@ pub struct Trenameat { pub newname: String, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Tunlinkat { pub dirfd: u32, pub name: String, @@ -741,15 +728,14 @@ impl WireFormat for Rframe { } } -#[derive(Debug, Copy, Clone, P9WireFormat)] +#[derive(Debug, Copy, Clone, JetStreamWireFormat)] pub struct Qid { pub ty: u8, pub version: u32, pub path: u64, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Dirent { pub qid: Qid, pub offset: u64, @@ -757,51 +743,43 @@ pub struct Dirent { pub name: String, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rversion { pub msize: u32, pub version: String, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rwalk { pub wqids: Vec, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rread { pub data: Data, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rwrite { pub count: u32, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rauth { pub aqid: Qid, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rattach { pub qid: Qid, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rlerror { pub ecode: u32, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rstatfs { pub ty: u32, pub bsize: u32, @@ -814,40 +792,34 @@ pub struct Rstatfs { pub namelen: u32, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rlopen { pub qid: Qid, pub iounit: u32, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rlcreate { pub qid: Qid, pub iounit: u32, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rsymlink { pub qid: Qid, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rmknod { pub qid: Qid, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rreadlink { pub target: String, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rgetattr { pub valid: u64, pub qid: Qid, @@ -871,26 +843,22 @@ pub struct Rgetattr { pub data_version: u64, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rxattrwalk { pub size: u64, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rreaddir { pub data: Data, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rlock { pub status: u8, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rgetlock { pub type_: u8, pub start: u64, @@ -899,14 +867,13 @@ pub struct Rgetlock { pub client_id: String, } -#[derive(Debug, P9WireFormat)] - +#[derive(Debug, JetStreamWireFormat)] pub struct Rmkdir { pub qid: Qid, } // Rerror -#[derive(Debug, P9WireFormat)] +#[derive(Debug, JetStreamWireFormat)] pub struct Rerror { pub ename: String, } diff --git a/third_party/rust-p9/src/protocol/mod.rs b/src/protocol/mod.rs similarity index 100% rename from third_party/rust-p9/src/protocol/mod.rs rename to src/protocol/mod.rs diff --git a/third_party/rust-p9/src/protocol/wire_format.rs b/src/protocol/wire_format.rs similarity index 99% rename from third_party/rust-p9/src/protocol/wire_format.rs rename to src/protocol/wire_format.rs index 53e92a0..6525fa7 100644 --- a/third_party/rust-p9/src/protocol/wire_format.rs +++ b/src/protocol/wire_format.rs @@ -138,6 +138,7 @@ impl WireFormat for Vec { #[derive(PartialEq, Eq, Clone)] pub struct Data(pub Vec); + // The maximum length of a data buffer that we support. In practice the server's max message // size should prevent us from reading too much data so this check is mainly to ensure a // malicious client cannot trick us into allocating massive amounts of memory. @@ -573,7 +574,7 @@ mod test { .expect_err("long vector"); } - #[derive(Debug, PartialEq, P9WireFormat)] + #[derive(Debug, PartialEq, JetStreamWireFormat)] struct Item { a: u64, b: String, @@ -657,7 +658,7 @@ mod test { assert_eq!(expected, actual); } - #[derive(Debug, PartialEq, P9WireFormat)] + #[derive(Debug, PartialEq, JetStreamWireFormat)] struct Nested { item: Item, val: Vec, diff --git a/src/server/mod.rs b/src/server/mod.rs index e05b829..c512fab 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -2,6 +2,5 @@ pub mod ninep_2000_l; pub mod proxy; pub mod quic_server; pub mod ufs; -pub mod x509_fs; mod server_tests; diff --git a/src/server/ninep_2000_l.rs b/src/server/ninep_2000_l.rs index 1e21166..de5ab15 100644 --- a/src/server/ninep_2000_l.rs +++ b/src/server/ninep_2000_l.rs @@ -1,6 +1,6 @@ use std::io; -use jetstream_p9::*; +use crate::protocol::*; /// 9p #[async_trait::async_trait] @@ -8,7 +8,7 @@ pub trait NineP200L: Send + Sync { /// The version message is the first message sent on a connection. It is used to negotiate the /// 9P protocol version and maximum message size. async fn version( - self: &mut Self, + &'life0 mut self, tag: u16, version: &Tversion, ) -> io::Result; @@ -16,166 +16,166 @@ pub trait NineP200L: Send + Sync { /// The auth message is used to authenticate a user to the server. It is sent after the version /// message and before any other messages. /// The auth message is optional and may be ignored by the server. - async fn auth(self: &mut Self, tag: u16, auth: &Tauth) + async fn auth(&'life0 mut self, tag: u16, auth: &Tauth) -> io::Result; /// The flush message is used to flush pending I/O requests. - async fn flush(self: &mut Self, tag: u16, flush: &Tflush) + async fn flush(&'life0 mut self, tag: u16, flush: &Tflush) -> io::Result<()>; /// The walk message is used to traverse the file system hierarchy. It is sent by the client and /// responded to by the server. - async fn walk(self: &mut Self, tag: u16, walk: &Twalk) + async fn walk(&'life0 mut self, tag: u16, walk: &Twalk) -> io::Result; /// The read message is used to read data from a file. - async fn read(self: &mut Self, tag: u16, read: &Tread) + async fn read(&'life0 mut self, tag: u16, read: &Tread) -> io::Result; /// The write message is used to write data to a file. async fn write( - self: &mut Self, + &'life0 mut self, tag: u16, write: &Twrite, ) -> io::Result; /// The clunk message is used to release a fid. - async fn clunk(self: &mut Self, tag: u16, clunk: &Tclunk) + async fn clunk(&'life0 mut self, tag: u16, clunk: &Tclunk) -> io::Result<()>; /// The remove message is used to remove a file. async fn remove( - self: &mut Self, + &'life0 mut self, tag: u16, remove: &Tremove, ) -> io::Result<()>; /// The attach message is used to associate a fid with a file. async fn attach( - self: &mut Self, + &'life0 mut self, tag: u16, attach: &Tattach, ) -> io::Result; /// The statfs message is used to retrieve file system information. async fn statfs( - self: &mut Self, + &'life0 mut self, tag: u16, statfs: &Tstatfs, ) -> io::Result; /// The lopen message is used to open a file. async fn lopen( - self: &mut Self, + &'life0 mut self, tag: u16, lopen: &Tlopen, ) -> io::Result; /// The lcreate message is used to create a file. async fn lcreate( - self: &mut Self, + &'life0 mut self, tag: u16, lcreate: &Tlcreate, ) -> io::Result; /// The symlink message is used to create a symbolic link. async fn symlink( - self: &mut Self, + &'life0 mut self, tag: u16, symlink: &Tsymlink, ) -> io::Result; /// The mknod message is used to create a device file. async fn mknod( - self: &mut Self, + &'life0 mut self, tag: u16, mknod: &Tmknod, ) -> io::Result; /// The rename message is used to rename a file. async fn rename( - self: &mut Self, + &'life0 mut self, tag: u16, rename: &Trename, ) -> io::Result<()>; /// The readlink message is used to read the target of a symbolic link. async fn readlink( - self: &mut Self, + &'life0 mut self, tag: u16, readlink: &Treadlink, ) -> io::Result; /// The getattr message is used to retrieve file attributes. async fn get_attr( - self: &mut Self, + &'life0 mut self, tag: u16, get_attr: &Tgetattr, ) -> io::Result; /// The setattr message is used to set file attributes. async fn set_attr( - self: &mut Self, + &'life0 mut self, tag: u16, set_attr: &Tsetattr, ) -> io::Result<()>; /// The xattrwalk message is used to traverse extended attributes. async fn xattr_walk( - self: &mut Self, + &'life0 mut self, tag: u16, xattr_walk: &Txattrwalk, ) -> io::Result; /// The xattrcreate message is used to create an extended attribute. async fn xattr_create( - self: &mut Self, + &'life0 mut self, tag: u16, xattr_create: &Txattrcreate, ) -> io::Result<()>; /// The readdir message is used to read a directory. async fn readdir( - self: &mut Self, + &'life0 mut self, tag: u16, readdir: &Treaddir, ) -> io::Result; /// The fsync message is used to synchronize a file's data and metadata. - async fn fsync(self: &mut Self, tag: u16, fsync: &Tfsync) + async fn fsync(&'life0 mut self, tag: u16, fsync: &Tfsync) -> io::Result<()>; /// The lock message is used to lock a file. - async fn lock(self: &mut Self, tag: u16, lock: &Tlock) + async fn lock(&'life0 mut self, tag: u16, lock: &Tlock) -> io::Result; /// The getlock message is used to retrieve a file's locks. async fn get_lock( - self: &mut Self, + &'life0 mut self, tag: u16, get_lock: &Tgetlock, ) -> io::Result; /// The link message is used to create a hard link. - async fn link(self: &mut Self, tag: u16, link: &Tlink) -> io::Result<()>; + async fn link(&'life0 mut self, tag: u16, link: &Tlink) -> io::Result<()>; /// The mkdir message is used to create a directory. async fn mkdir( - self: &mut Self, + &'life0 mut self, tag: u16, mkdir: &Tmkdir, ) -> io::Result; /// The renameat message is used to rename a file. async fn rename_at( - self: &mut Self, + &'life0 mut self, tag: u16, rename_at: &Trenameat, ) -> io::Result<()>; /// The unlinkat message is used to remove a file. async fn unlink_at( - self: &mut Self, + &'life0 mut self, tag: u16, unlink_at: &Tunlinkat, ) -> io::Result<()>; diff --git a/src/server/proxy.rs b/src/server/proxy.rs index c989d90..6a8f9cb 100644 --- a/src/server/proxy.rs +++ b/src/server/proxy.rs @@ -1,7 +1,7 @@ use std::{net::SocketAddr, path::Path, fmt::Debug}; use anyhow::Ok; -use jetstream_p9::{Rframe, Tframe}; +use crate::protocol::{Rframe, Tframe}; use s2n_quic::{ client::{Client, Connect}, provider::tls, @@ -116,7 +116,7 @@ impl ListenerStream for tokio::net::UnixListener { type Stream = tokio::net::UnixStream; type Addr = tokio::net::unix::SocketAddr; async fn accept(&mut self) -> std::io::Result<(Self::Stream, Self::Addr)> { - tokio::net::UnixListener::accept(&mut self).await + tokio::net::UnixListener::accept(self).await } } @@ -125,7 +125,7 @@ impl ListenerStream for VsockListener { type Stream = tokio_vsock::VsockStream; type Addr = VsockAddr; async fn accept(&mut self) -> std::io::Result<(Self::Stream, Self::Addr)> { - VsockListener::accept(&mut self).await + VsockListener::accept(self).await } } @@ -174,7 +174,7 @@ where } } else if let std::io::Result::Ok(tframe) = tframe { debug!("Sending to up_stream {:?}", tframe); - let _ = tframe.encode_async(&mut tx).await.unwrap(); + tframe.encode_async(&mut tx).await.unwrap(); } } // write and send to down_stream diff --git a/src/server/server_tests.rs b/src/server/server_tests.rs index cf7e8d9..985a27c 100644 --- a/src/server/server_tests.rs +++ b/src/server/server_tests.rs @@ -9,7 +9,7 @@ mod tests { }, service::ninepecho::{self, EchoService}, }; - use jetstream_p9::{Rframe, Tframe, Tmessage, Tversion}; + use crate::protocol::{Rframe, Tframe, Tmessage, Tversion}; use s2n_quic::{provider::tls, Server}; use slog_scope::debug; use std::{ diff --git a/src/server/ufs.rs b/src/server/ufs.rs index 4b2bb8b..241add6 100644 --- a/src/server/ufs.rs +++ b/src/server/ufs.rs @@ -1,7 +1,8 @@ use std::{collections::btree_map, path::PathBuf}; -use jetstream_p9::{server::Server, Rframe, Tframe}; +use crate::protocol::{Rframe, Tframe}; +use crate::ufs::Server; use crate::{service::JetStreamService, service::Message}; pub struct Handle { diff --git a/src/server/x509_fs.rs b/src/server/x509_fs.rs deleted file mode 100644 index bb160e1..0000000 --- a/src/server/x509_fs.rs +++ /dev/null @@ -1,629 +0,0 @@ -use std::io; - -use jetstream_p9::messages::*; - -use crate::server::ninep_2000_l::NineP200L; - -struct X509Fs; - -impl NineP200L for X509Fs { - /// The version message is the first message sent on a connection. It is used to negotiate the - /// 9P protocol version and maximum message size. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn version<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _version: &'life1 Tversion, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The auth message is used to authenticate a user to the server. It is sent after the version - /// message and before any other messages. - /// The auth message is optional and may be ignored by the server. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn auth<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _auth: &'life1 Tauth, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The flush message is used to flush pending I/O requests. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn flush<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _flush: &'life1 Tflush, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The walk message is used to traverse the file system hierarchy. It is sent by the client and - /// responded to by the server. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn walk<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _walk: &'life1 Twalk, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The read message is used to read data from a file. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn read<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _read: &'life1 Tread, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The write message is used to write data to a file. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn write<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _write: &'life1 Twrite, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The clunk message is used to release a fid. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn clunk<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _clunk: &'life1 Tclunk, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The remove message is used to remove a file. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn remove<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _remove: &'life1 Tremove, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The attach message is used to associate a fid with a file. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn attach<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _attach: &'life1 Tattach, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The statfs message is used to retrieve file system information. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn statfs<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _statfs: &'life1 Tstatfs, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The lopen message is used to open a file. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn lopen<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _lopen: &'life1 Tlopen, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The lcreate message is used to create a file. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn lcreate<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _lcreate: &'life1 Tlcreate, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The symlink message is used to create a symbolic link. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn symlink<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _symlink: &'life1 Tsymlink, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The mknod message is used to create a device file. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn mknod<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _mknod: &'life1 Tmknod, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The rename message is used to rename a file. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn rename<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _rename: &'life1 Trename, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The readlink message is used to read the target of a symbolic link. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn readlink<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _readlink: &'life1 Treadlink, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The getattr message is used to retrieve file attributes. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn get_attr<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _get_attr: &'life1 Tgetattr, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The setattr message is used to set file attributes. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn set_attr<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _set_attr: &'life1 Tsetattr, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The xattrwalk message is used to traverse extended attributes. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn xattr_walk<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _xattr_walk: &'life1 Txattrwalk, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The xattrcreate message is used to create an extended attribute. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn xattr_create<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _xattr_create: &'life1 Txattrcreate, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The readdir message is used to read a directory. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn readdir<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _readdir: &'life1 Treaddir, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The fsync message is used to synchronize a file\'s data and metadata. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn fsync<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _fsync: &'life1 Tfsync, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The lock message is used to lock a file. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn lock<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _lock: &'life1 Tlock, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The getlock message is used to retrieve a file\'s locks. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn get_lock<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _get_lock: &'life1 Tgetlock, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The link message is used to create a hard link. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn link<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _link: &'life1 Tlink, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The mkdir message is used to create a directory. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn mkdir<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _mkdir: &'life1 Tmkdir, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The renameat message is used to rename a file. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn rename_at<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _rename_at: &'life1 Trenameat, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } - - /// The unlinkat message is used to remove a file. - #[must_use] - #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] - fn unlink_at<'life0, 'life1, 'async_trait>( - self: &'life0 mut Self, - _tag: u16, - _unlink_at: &'life1 Tunlinkat, - ) -> ::core::pin::Pin< - Box< - dyn ::core::future::Future> - + ::core::marker::Send - + 'async_trait, - >, - > - where - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() - } -} diff --git a/src/service.rs b/src/service.rs index 8a9b646..f4786ad 100644 --- a/src/service.rs +++ b/src/service.rs @@ -4,12 +4,12 @@ use std::{ task::{Context, Poll}, }; +use crate::protocol::{Rframe, Rmessage, Tframe, WireFormat}; use bytes::{BufMut, Bytes, BytesMut}; use futures::prelude::*; -use jetstream_p9::{Rframe, Rmessage, Tframe, WireFormat}; use tower::Service; -pub use jetstream_p9_wire_format_derive::P9WireFormat; +pub use jetstream_wire_format_derive::JetStreamWireFormat; /// Message trait for JetStream messages, which need to implement the `WireFormat` trait. pub trait Message: WireFormat + Send + Sync {} @@ -19,6 +19,7 @@ pub trait Message: WireFormat + Send + Sync {} pub trait JetStreamService: Send + Sync + Sized { + #[allow(clippy::type_complexity)] fn call( &mut self, req: Req, @@ -67,12 +68,12 @@ impl JetStreamService for NinePServiceImpl { #[derive(Debug, Clone, Copy)] pub struct Radar; -#[derive(Debug, Clone, P9WireFormat)] +#[derive(Debug, Clone, JetStreamWireFormat)] struct Ping(u8); impl Message for Ping {} -#[derive(Debug, Clone, P9WireFormat)] +#[derive(Debug, Clone, JetStreamWireFormat)] struct Pong(u8); impl Message for Pong {} @@ -111,7 +112,7 @@ pub mod ninepecho { Box::pin(async move { Ok(Rframe { tag: 0, - msg: Rmessage::Version(jetstream_p9::Rversion { + msg: Rmessage::Version(crate::protocol::Rversion { msize: 0, version: "9P2000".to_string(), }), @@ -165,7 +166,10 @@ pub trait ConvertWireFormat: WireFormat { /// Implements the `ConvertWireFormat` trait for types that implement `jetstream_p9::WireFormat`. /// This trait provides methods for converting the type to and from bytes. -impl ConvertWireFormat for T { +impl ConvertWireFormat for T +where + T: WireFormat, +{ /// Converts the type to bytes. /// Returns a `Bytes` object containing the encoded bytes. fn to_bytes(&self) -> Bytes { diff --git a/third_party/rust-p9/src/server/mod.rs b/src/ufs/mod.rs similarity index 99% rename from third_party/rust-p9/src/server/mod.rs rename to src/ufs/mod.rs index 2d88967..ce1ec2a 100644 --- a/third_party/rust-p9/src/server/mod.rs +++ b/src/ufs/mod.rs @@ -756,7 +756,7 @@ impl Server { // Now walk the tree and break on the first error, if any. let expected_len = walk.wnames.len(); let mut mds = Vec::with_capacity(expected_len); - let names: Vec = walk.wnames.iter().map(|s| s.clone()).collect(); + let names: Vec = walk.wnames.to_vec(); match do_walk( &self.proc, diff --git a/third_party/rust-p9/src/server/read_dir.rs b/src/ufs/read_dir.rs similarity index 100% rename from third_party/rust-p9/src/server/read_dir.rs rename to src/ufs/read_dir.rs diff --git a/third_party/rust-p9/src/server/tests.rs b/src/ufs/tests.rs similarity index 100% rename from third_party/rust-p9/src/server/tests.rs rename to src/ufs/tests.rs diff --git a/third_party/p9_wire_format_derive/Cargo.toml b/third_party/p9_wire_format_derive/Cargo.toml index cd407f5..4ab5896 100644 --- a/third_party/p9_wire_format_derive/Cargo.toml +++ b/third_party/p9_wire_format_derive/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "jetstream_p9_wire_format_derive" -version = "0.6.0" +name = "jetstream_wire_format_derive" +version = "0.5.1" authors = ["The ChromiumOS Authors"] license = "BSD-3-Clause" description = "Supporting proc-macro for the `p9` crate." -repository = "https://github.com/google/rust-p9" -readme = "../rust-p9/README.md" +repository = "https://github.com/sevki/jetstream" +readme = "../../README.md" [dependencies] # rust analyzer doesn't understand the `quote` macro from `proc-macro2` so we diff --git a/third_party/p9_wire_format_derive/src/lib.rs b/third_party/p9_wire_format_derive/src/lib.rs index 785cb20..ac79db9 100644 --- a/third_party/p9_wire_format_derive/src/lib.rs +++ b/third_party/p9_wire_format_derive/src/lib.rs @@ -26,7 +26,7 @@ use syn::Fields; use syn::Ident; /// The function that derives the actual implementation. -#[proc_macro_derive(P9WireFormat)] +#[proc_macro_derive(JetStreamWireFormat)] pub fn p9_wire_format( input: proc_macro::TokenStream, ) -> proc_macro::TokenStream { @@ -37,7 +37,7 @@ pub fn p9_wire_format( fn p9_wire_format_inner(input: DeriveInput) -> TokenStream { if !input.generics.params.is_empty() { return quote! { - compile_error!("derive(P9WireFormat) does not support generic parameters"); + compile_error!("derive(JetStreamWireFormat) does not support generic parameters"); }; } diff --git a/third_party/rust-p9/.gitignore b/third_party/rust-p9/.gitignore deleted file mode 100644 index eb5a316..0000000 --- a/third_party/rust-p9/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target diff --git a/third_party/rust-p9/CONTRIBUTING.md b/third_party/rust-p9/CONTRIBUTING.md deleted file mode 100644 index b16bd94..0000000 --- a/third_party/rust-p9/CONTRIBUTING.md +++ /dev/null @@ -1,33 +0,0 @@ -# How to contribute - -We'd love to accept your patches and contributions to this project. - -## Before you begin - -### Sign our Contributor License Agreement - -Contributions to this project must be accompanied by a -[Contributor License Agreement](https://cla.developers.google.com/about) (CLA). -You (or your employer) retain the copyright to your contribution; this simply -gives us permission to use and redistribute your contributions as part of the -project. - -If you or your current employer have already signed the Google CLA (even if it -was for a different project), you probably don't need to do it again. - -Visit to see your current agreements or to -sign a new one. - -### Review our community guidelines - -This project follows -[Google's Open Source Community Guidelines](https://opensource.google/conduct/). - -## Contribution process - -### Code reviews - -All submissions, including submissions by project members, require review. We -use GitHub pull requests for this purpose. Consult -[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more -information on using pull requests. diff --git a/third_party/rust-p9/Cargo.lock b/third_party/rust-p9/Cargo.lock deleted file mode 100644 index 4305beb..0000000 --- a/third_party/rust-p9/Cargo.lock +++ /dev/null @@ -1,93 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "libc" -version = "0.2.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - -[[package]] -name = "p9" -version = "0.2.3" -dependencies = [ - "libc", - "p9_wire_format_derive", - "serde", -] - -[[package]] -name = "p9_wire_format_derive" -version = "0.2.3" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "proc-macro2" -version = "1.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "serde" -version = "1.0.177" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63ba2516aa6bf82e0b19ca8b50019d52df58455d3cf9bdaf6315225fdd0c560a" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.177" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "401797fe7833d72109fedec6bfcbe67c0eed9b99772f26eb8afd261f0abc6fd3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.27", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" diff --git a/third_party/rust-p9/Cargo.toml b/third_party/rust-p9/Cargo.toml deleted file mode 100644 index 8f0e3ec..0000000 --- a/third_party/rust-p9/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "jetstream_p9" -version = "0.6.0" -authors = ["The ChromiumOS Authors"] -edition = "2021" -license = "BSD-3-Clause" -description = "Server implementation of the 9p file system protocol" -repository = "https://github.com/google/rust-p9" - -[target.'cfg(unix)'.dependencies] -libc = "0.2" -serde = { version = "1.0", features = ["derive"] } -jetstream_p9_wire_format_derive = { path = "../p9_wire_format_derive", version = "0.6.0" } - -[features] -trace = [] - -[dependencies] -genfs = "0.1.4" -serde_bytes = "0.11.14" -tokio = { version = "1.29.0", features = ["full"] } diff --git a/third_party/rust-p9/LICENSE b/third_party/rust-p9/LICENSE deleted file mode 100644 index f6d41c6..0000000 --- a/third_party/rust-p9/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The ChromiumOS Authors -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/third_party/rust-p9/OWNERS b/third_party/rust-p9/OWNERS deleted file mode 100644 index 7868b29..0000000 --- a/third_party/rust-p9/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -# This file exists so it can be passed to fuzzer_install in dev-rust/p9. -denniskempin@google.com -dverkamp@chromium.org diff --git a/third_party/rust-p9/README.md b/third_party/rust-p9/README.md deleted file mode 100644 index 1220c3d..0000000 --- a/third_party/rust-p9/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# p9 - Server implementation of the [9p] file system protocol - -This directory contains the protocol definition and a server implementation of the [9p] file system -protocol. - -- [wire_format_derive] - A [procedural macro] that derives the serialization and de-serialization - implementation for a struct into the [9p] wire format. -- [src/protocol] - Defines all the messages used in the [9p] protocol. Also implements serialization - and de-serialization for some base types (integers, strings, vectors) that form the foundation of - all [9p] messages. Wire format implementations for all other messages are derived using the - `wire_format_derive` macro. -- [src/server] - Implements a full [9p] server, carrying out file system requests on behalf of - clients. - -[9p]: http://man.cat-v.org/plan_9/5/intro -[procedural macro]: https://doc.rust-lang.org/proc_macro/index.html -[src/protocol]: src/protocol/ -[src/server]: src/server/ -[wire_format_derive]: p9_wire_format_derive/ diff --git a/third_party/rust-p9/src/fuzzing.rs b/third_party/rust-p9/src/fuzzing.rs deleted file mode 100644 index 0c2fc70..0000000 --- a/third_party/rust-p9/src/fuzzing.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2018 The ChromiumOS Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -use std::io::Cursor; - -use crate::protocol::Tframe; -use crate::protocol::WireFormat; - -pub fn tframe_decode(bytes: &[u8]) { - let mut cursor = Cursor::new(bytes); - - while Tframe::decode(&mut cursor).is_ok() {} -} diff --git a/third_party/rust-p9/src/lib.rs b/third_party/rust-p9/src/lib.rs deleted file mode 100644 index 1fd4fdc..0000000 --- a/third_party/rust-p9/src/lib.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2018 The ChromiumOS Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#![cfg(unix)] - -extern crate libc; - -#[macro_use] -extern crate jetstream_p9_wire_format_derive; - -pub mod protocol; -pub mod server; - -pub mod fuzzing; - -pub use server::*; -pub use protocol::*; - -#[macro_export] -macro_rules! syscall { - ($e:expr) => {{ - let res = $e; - if res < 0 { - Err(std::io::Error::last_os_error()) - } else { - Ok(res) - } - }}; -}