summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2017-05-12 21:33:06 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2017-05-12 21:33:06 -0400
commit503145f4dfc16001ebbba6c0ace5ce505c151a71 (patch)
treeafdd0961d1722068e5c6c1e3d59eba2d6fe01514
parent35f5d3c514b640d3b99c643890bb4a655025994d (diff)
Restructure project.
-rw-r--r--Cargo.toml (renamed from v1/Cargo.toml)0
-rw-r--r--default.nix16
-rw-r--r--src/data.rs16
-rw-r--r--src/lib.rs (renamed from v1/src/lib.rs)0
-rw-r--r--src/main.rs (renamed from v1/src/main.rs)24
-rw-r--r--v1/src/data.rs13
6 files changed, 47 insertions, 22 deletions
diff --git a/v1/Cargo.toml b/Cargo.toml
index a126a80..a126a80 100644
--- a/v1/Cargo.toml
+++ b/Cargo.toml
diff --git a/default.nix b/default.nix
index 65d93ef..99e7ecd 100644
--- a/default.nix
+++ b/default.nix
@@ -1,8 +1,16 @@
with import <nixpkgs> {};
-
+with rustPlatform;
{
- rustenv = stdenv.mkDerivation {
- name = "rust";
- buildInputs = [ rustStable.rustc rustStable.cargo fuse pkgconfig ];
+ rafs1 = buildRustPackage rec {
+ name = "rafs-${version}";
+ version = "0.1";
+ buildInputs = [ fuse pkgconfig glibc ];
+ logLevel = "debug";
+ src = fetchgit {
+ url = "https://git.orbekk.com/git/rafs.git"
+ rev = "35f5d3c514b640d3b99c643890bb4a655025994d";
+ sha256 = "1i5nr70jdqhfjmpnmcgnsyinh7rd3gaz2ka0adi9x5z0dx1ijg6g";
+ };
+ depsSha256 = "1i5nr70jdqhfjmpnmcgnsyinh7rd3gaz2ka0adi9x5z0dx1ijg6g";
};
}
diff --git a/src/data.rs b/src/data.rs
new file mode 100644
index 0000000..f652a13
--- /dev/null
+++ b/src/data.rs
@@ -0,0 +1,16 @@
+pub static MESSAGE: &'static str = "Hello";
+
+#[derive(Debug)]
+pub enum SimpleFsData {
+ File(u64, String),
+ Directory(u64, Vec<(String, SimpleFsData)>)
+}
+
+// pub static HELLO: &'static SimpleFsData =
+// SimpleFsData:File("hello.txt", "Hello World");
+
+pub fn get_data1() -> SimpleFsData {
+ SimpleFsData::Directory(
+ 1, vec!(("hello".to_string(),
+ SimpleFsData::File(2, "Hello, World!".to_string()))))
+}
diff --git a/v1/src/lib.rs b/src/lib.rs
index 7a345e4..7a345e4 100644
--- a/v1/src/lib.rs
+++ b/src/lib.rs
diff --git a/v1/src/main.rs b/src/main.rs
index 29196b0..babac6a 100644
--- a/v1/src/main.rs
+++ b/src/main.rs
@@ -2,12 +2,15 @@ extern crate fuse;
extern crate libc;
extern crate v1;
-use v1::data::MESSAGE;
+use v1::data::get_data1;
+use v1::data::SimpleFsData;
use fuse::{Filesystem, Request, ReplyEntry, ReplyAttr, ReplyDirectory, ReplyData};
use libc::ENOENT;
use std::ffi::OsStr;
-struct MemFs;
+struct MemFs {
+ data: SimpleFsData,
+}
impl Filesystem for MemFs {
fn lookup(&mut self, _req: &Request, _parent: u64, _name: &OsStr,
@@ -29,8 +32,19 @@ impl Filesystem for MemFs {
}
}
+fn usage() {
+ println!("{} <mountpoint>", std::env::args().nth(0).unwrap());
+}
+
+fn mount(mountpoint: &OsStr) {
+ let fs = MemFs { data: get_data1() };
+ fuse::mount(fs, &mountpoint, &[]).unwrap()
+}
+
fn main() {
- println!("{}", MESSAGE);
- let mountpoint = std::env::args_os().nth(1).unwrap();
- fuse::mount(MemFs, &mountpoint, &[]).unwrap();
+ println!("{:?}", get_data1());
+ match std::env::args_os().nth(1) {
+ Some(mountpoint) => mount(&mountpoint),
+ None => usage(),
+ }
}
diff --git a/v1/src/data.rs b/v1/src/data.rs
deleted file mode 100644
index 4b1da5a..0000000
--- a/v1/src/data.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-pub static MESSAGE: &'static str = "Hello";
-
-pub enum SimpleFsData {
- File(String, String),
- Directory(String, Vec<SimpleFsData>)
-}
-
-// pub static HELLO: &'static SimpleFsData =
-// SimpleFsData:File("hello.txt", "Hello World");
-
-pub fn getData1() -> SimpleFsData {
- SimpleFsData::File("hello.txt".to_string(), "Hello".to_string())
-}