summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: babac6a1c4c07b8982df39d8aa7d901ea9a22254 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
extern crate fuse;
extern crate libc;
extern crate v1;

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 {
    data: SimpleFsData,
}

impl Filesystem for MemFs {
    fn lookup(&mut self, _req: &Request, _parent: u64, _name: &OsStr,
              reply: ReplyEntry) {
        reply.error(ENOENT);
    }

    fn getattr(&mut self, _req: &Request, _ino: u64, reply: ReplyAttr) {
        reply.error(ENOENT);
    }

    fn read(&mut self, _req: &Request, _ino: u64, _fh: u64, _offset: u64,
            _size: u32, reply: ReplyData) {
        reply.error(ENOENT);
    }
    fn readdir (&mut self, _req: &Request, ino: u64, _fh: u64, offset: u64,
                reply: ReplyDirectory) {
        reply.error(ENOENT);
    }
}

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!("{:?}", get_data1());
    match std::env::args_os().nth(1) {
        Some(mountpoint) => mount(&mountpoint),
        None => usage(),
    }
}