Skip to content
Snippets Groups Projects
Commit 00321594 authored by Jeremy Soller's avatar Jeremy Soller Committed by GitHub
Browse files

Merge pull request #20 from ids1024/fuse

Symlinks in fuse
parents 97652cc6 f582c60f
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ extern crate time;
use redoxfs;
use std::path::Path;
use std::os::unix::ffi::OsStrExt;
use self::fuse::{FileType, FileAttr, Filesystem, Request, ReplyData, ReplyEntry, ReplyAttr, ReplyCreate, ReplyDirectory, ReplyEmpty, ReplyStatfs, ReplyWrite};
use self::time::Timespec;
......@@ -28,6 +29,8 @@ fn node_attr(node: &(u64, redoxfs::Node)) -> FileAttr {
crtime: CREATE_TIME,
kind: if node.1.is_dir() {
FileType::Directory
} else if node.1.is_symlink() {
FileType::Symlink
} else {
FileType::RegularFile
},
......@@ -252,4 +255,34 @@ impl Filesystem for Fuse {
}
}
}
fn symlink(&mut self, _req: &Request, parent_block: u64, name: &Path, link: &Path, reply: ReplyEntry) {
match self.fs.create_node(redoxfs::Node::MODE_SYMLINK | 0o777, name.to_str().unwrap(), parent_block) {
Ok(node) => {
match self.fs.write_node(node.0, 0, link.as_os_str().as_bytes()) {
Ok(_count) => {
reply.entry(&TTL, &node_attr(&node), 0);
},
Err(err) => {
reply.error(err.errno as i32);
}
}
},
Err(error) => {
reply.error(error.errno as i32);
}
}
}
fn readlink(&mut self, _req: &Request, ino: u64, reply: ReplyData) {
let mut data = vec![0; 4096];
match self.fs.read_node(ino, 0, &mut data) {
Ok(count) => {
reply.data(&data[..count]);
},
Err(err) => {
reply.error(err.errno as i32);
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment