Prechádzať zdrojové kódy

Removed unneeded crates.

Matthew Carr 2 rokov pred
rodič
commit
67a5d64f4e

+ 0 - 31
Cargo.lock

@@ -259,7 +259,6 @@ dependencies = [
  "env_logger",
  "foreign-types",
  "fuse-backend-rs",
- "harness",
  "lazy_static",
  "libc",
  "log",
@@ -303,17 +302,6 @@ dependencies = [
  "zerocopy",
 ]
 
-[[package]]
-name = "btnode"
-version = "0.1.0"
-dependencies = [
- "btlib",
- "btserde",
- "env_logger",
- "harness",
- "log",
-]
-
 [[package]]
 name = "btserde"
 version = "0.1.0"
@@ -853,17 +841,6 @@ version = "1.8.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
 
-[[package]]
-name = "harness"
-version = "0.0.1"
-dependencies = [
- "btserde",
- "ctor",
- "env_logger",
- "log",
- "serde",
-]
-
 [[package]]
 name = "hashbrown"
 version = "0.12.3"
@@ -1938,14 +1915,6 @@ dependencies = [
  "winapi-util",
 ]
 
-[[package]]
-name = "test-harness"
-version = "0.1.0"
-dependencies = [
- "btserde",
- "harness",
-]
-
 [[package]]
 name = "textwrap"
 version = "0.11.0"

+ 2 - 5
Cargo.toml

@@ -1,15 +1,12 @@
 [workspace]
 members = [
     "crates/btlib",
-    "crates/btnode",
     "crates/btmsg",
     "crates/btserde",
-    "crates/harness",
-    "crates/test-harness",
-    "crates/btfuse",
     "crates/swtpm-harness",
-    "crates/btfs",
     "crates/btfproto",
+    "crates/btfuse",
+    "crates/btfs",
 ]
 
 [profile.bench]

+ 7 - 9
TODO.txt

@@ -35,7 +35,7 @@ Create a struct which digests data written to it before passing it to an underly
 Create a struct called WritecapBody to contain the fields of Writecap which go into the signature
 calculation so that WritecapSigInput is no longer required.
 
-- 12, 8, mdcarr941@gmail.com, 2ebb8a,
+!- 12, 8, mdcarr941@gmail.com, 2ebb8a,
 Create a struct for managing the directory used to store blocks in the file system. Design and
 implement an API for creating, opening, moving, copying, deleting and linking blocks. This API must
 be codified by a trait to allow the implementation to be changed in the future.
@@ -49,7 +49,7 @@ Refactor btlib so that most of the types are in their own modules. This is
 needed to encourage modularity and weak coupling, as it reduces the amount of code that fields
 and helper functions are visible to.
 
-- 15, 13, mdcarr941@gmail.com, 58d1f6, 
+!- 15, 13, mdcarr941@gmail.com, 58d1f6, 
 Create a new crate which implements a FUSE daemon.
 
 !- 16, 5, mdcarr941@gmail.com, 866533,
@@ -74,12 +74,6 @@ Integrate with tokio and add async methods to all of the stream types.
 Rewrite BlockPath to be more efficient by ensuring that all characters in a path are contiguous
 in memory.
 
-- 21, 13, mdcarr941@gmail.com, fd4356,
-Create a type to hold a pipeline of streams. New traits will need to be added for each of the
-components of the pipeline to implement. Require that the last pipeline component be a particular
-sub-type of this trait. This will allow me to get rid of the dyn Block objects, as they can be
-replaced by instances of this pipeline type.
-
 !- 22, 8, mdcarr941@gmail.com, fe2ffc, mdcarr941@gmail.com, fe2ffc
 Add a new fields to BlockMeta which stores data encrypted using the block key. This information must
 include:
@@ -101,4 +95,8 @@ store the hash of BlockMetaSecrets that was computed just after decryption.
 Move `BlockRecord.frags` into `BlockMetaSecrets`.
 
 - 25, 2, mdcarr941@gmail.com, 02d8cb,
-Implement `Blocktree::batch_forget`.
+Implement `Blocktree::batch_forget`.
+
+- 26, 13, mdcarr941@gmail.com, 44a6ef,
+Implement a timeout mechanism in LocalFs which will purge handles and locks that have not been
+accessed for a configured period of time.

+ 0 - 1
crates/btlib/Cargo.toml

@@ -8,7 +8,6 @@ edition = "2021"
 
 [dependencies]
 btserde = { path = "../btserde" }
-harness = { path = "../harness" }
 swtpm-harness = { path = "../swtpm-harness" }
 serde = { version = "^1.0.136", features = ["derive"] }
 serde-big-array = { version = "^0.4.1" }

+ 0 - 13
crates/btnode/Cargo.toml

@@ -1,13 +0,0 @@
-[package]
-name = "btnode"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-btlib = { path = "../btlib" }
-btserde = { path = "../btserde" }
-harness = { path = "../harness" }
-env_logger = "0.9.0"
-log = "0.4.17"

+ 0 - 7
crates/btnode/README.md

@@ -1,7 +0,0 @@
-## Overview
-This crate implements a blocktree node. It is responsible for the following:
-  * Managing the blocktree data structures in the filesystem.
-  * Communicating over the network with other nodes.
-  * Running programs in their own separate sandbox processes. 
-  * Routing HTTP request to programs which have registered handlers.
-  * Receiving orders from its parent via stdin.

+ 0 - 45
crates/btnode/src/main.rs

@@ -1,45 +0,0 @@
-use btserde::{read_from, write_to};
-use harness::Message;
-use log::{error, info};
-use std::io::{self, BufWriter, Write};
-
-#[allow(dead_code)]
-fn send<W: Write>(stdout: &mut BufWriter<W>, msg: &Message) {
-    if let Err(err) = write_to(msg, &mut *stdout) {
-        error!("Failed to serialize message {:?}", err);
-        return;
-    }
-    if let Err(err) = stdout.flush() {
-        error!("Failed to flush stdout {:?}", err);
-    }
-}
-
-fn main() {
-    env_logger::init();
-    let stdin = io::stdin();
-    let mut in_lock = stdin.lock();
-    let stdout = io::stdout();
-    let mut out_lock = BufWriter::new(stdout.lock());
-    loop {
-        let message: Message = match read_from(&mut in_lock) {
-            Err(err) => {
-                error!("Failed to read from stdin {:?}", err);
-                continue;
-            }
-            Ok(message) => message,
-        };
-        match message {
-            Message::Echo(_) => {
-                info!("responding to echo request: {:?}", message);
-                if let Err(err) = write_to(&message, &mut out_lock) {
-                    error!("Failed to serialize message {:?}", err);
-                    return;
-                }
-                if let Err(err) = out_lock.flush() {
-                    error!("Failed to flush stdout {:?}", err);
-                }
-            }
-            Message::Halt => break,
-        }
-    }
-}

+ 0 - 15
crates/harness/Cargo.toml

@@ -1,15 +0,0 @@
-[package]
-name = "harness"
-version = "0.0.1"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-btserde = { path = "../btserde" }
-serde = { version = "^1.0.136", features = ["derive"] }
-log = "0.4.17"
-
-[dev-dependencies]
-env_logger = "0.9.0"
-ctor = "0.1.22"

+ 0 - 145
crates/harness/src/lib.rs

@@ -1,145 +0,0 @@
-use btserde::{self, read_from, write_to};
-use log::error;
-use serde::{Deserialize, Serialize};
-use std::{
-    io::{prelude::*, BufReader, BufWriter},
-    process::{Child, ChildStdin, Command, Stdio},
-    sync::mpsc::{channel, Receiver},
-    time::Duration,
-};
-
-#[derive(Serialize, Deserialize, Debug)]
-pub enum Message {
-    /// An echo request. This should elicit an identical reply.
-    Echo(String),
-    /// Orders the node to halt.
-    Halt,
-}
-
-pub struct Node {
-    child: Child,
-    stdin: BufWriter<ChildStdin>,
-    message_rx: Receiver<Message>,
-}
-
-impl Node {
-    pub fn new() -> Result<Node, std::io::Error> {
-        let mut child = Command::new("btnode")
-            .stdin(Stdio::piped())
-            .stdout(Stdio::piped())
-            .stderr(Stdio::inherit())
-            .spawn()?;
-        let stdin = BufWriter::new(child.stdin.take().unwrap());
-        let mut stdout = BufReader::new(child.stdout.take().unwrap());
-        let (message_tx, message_rx) = channel();
-        std::thread::spawn(move || loop {
-            match read_from(&mut stdout) {
-                Ok(msg) => {
-                    match message_tx.send(msg) {
-                        Ok(_) => (),
-                        // Break if the receiver is dead.
-                        Err(_) => break,
-                    }
-                }
-                // Break if the child is has exited.
-                Err(btserde::Error::Eof) => break,
-                Err(btserde::Error::Io(io_err)) => match io_err.kind() {
-                    std::io::ErrorKind::UnexpectedEof => break,
-                    _ => error!("IO error ocurred: {:?}", io_err),
-                },
-                Err(err) => error!("Failed to deserialize child message {:?}", err),
-            };
-        });
-        Ok(Node {
-            child,
-            stdin,
-            message_rx,
-        })
-    }
-
-    pub fn send(&mut self, msg: &Message) -> btserde::Result<()> {
-        write_to(&msg, &mut self.stdin)?;
-        self.stdin.flush().map_err(btserde::Error::Io)?;
-        Ok(())
-    }
-
-    pub fn receive(&mut self, timeout: Duration) -> Option<Message> {
-        match self.message_rx.recv_timeout(timeout) {
-            Ok(msg) => Some(msg),
-            Err(err) => {
-                eprintln!("Failed to receive message from thread. Error: {err:?}");
-                None
-            }
-        }
-    }
-
-    pub fn halt(mut self) -> Result<(), NodeHaltError> {
-        self.send(&Message::Halt).unwrap();
-        match self.child.wait() {
-            Ok(status) => {
-                let code = status.code();
-                if code == Some(0) {
-                    Ok(())
-                } else {
-                    Err(NodeHaltError::NonZeroExitCode(code))
-                }
-            }
-            Err(err) => Err(NodeHaltError::Io(err)),
-        }
-    }
-}
-
-#[derive(Debug)]
-pub enum NodeHaltError {
-    /// The node exited with a non-zero or non-existent status code.
-    NonZeroExitCode(Option<i32>),
-    /// An IO error was encountered.
-    Io(std::io::Error),
-}
-
-impl Drop for Node {
-    fn drop(&mut self) {
-        let _ = self.child.kill();
-    }
-}
-
-#[cfg(test)]
-mod test {
-    use super::*;
-    use ctor::ctor;
-    use log::info;
-
-    #[ctor]
-    fn test_init() {
-        use env_logger::{self, Env};
-        env_logger::init_from_env(Env::default().default_filter_or("debug"));
-        info!("Using cargo to install btnode...");
-        let success = Command::new("cargo")
-            .args(["install", "--path", "../btnode"])
-            .status()
-            .expect("failed to invoke cargo")
-            .success();
-        assert!(success, "failed to build btnode");
-    }
-
-    #[test]
-    fn message_echo() {
-        let mut node = Node::new().unwrap();
-        for k in 0..7 {
-            let expected = format!("Rep number {}", k);
-            node.send(&Message::Echo(expected.clone())).unwrap();
-            let reply = node.receive(Duration::from_millis(100)).unwrap();
-            let reply_payload = match reply {
-                Message::Echo(actual) => Some(actual),
-                _ => None,
-            };
-            assert_eq!(Some(expected), reply_payload);
-        }
-    }
-
-    #[test]
-    fn message_halt() {
-        let node = Node::new().unwrap();
-        node.halt().unwrap();
-    }
-}

+ 0 - 10
crates/test-harness/Cargo.toml

@@ -1,10 +0,0 @@
-[package]
-name = "test-harness"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-btserde = { path = "../btserde" }
-harness = { path = "../harness" }

+ 0 - 1
crates/test-harness/src/lib.rs

@@ -1 +0,0 @@
-