|
|
@ -91,7 +91,6 @@ macro_rules! try_vfs {
|
|
|
|
|
|
|
|
|
|
|
|
impl<T: vfs::FileSystem> Filesystem for VfsWrapper<T> {
|
|
|
|
impl<T: vfs::FileSystem> Filesystem for VfsWrapper<T> {
|
|
|
|
fn lookup(&mut self, _req: &Request, parent: u64, name: &OsStr, reply: ReplyEntry) {
|
|
|
|
fn lookup(&mut self, _req: &Request, parent: u64, name: &OsStr, reply: ReplyEntry) {
|
|
|
|
info!("lookup parent={} name={}", parent, name.to_str().unwrap());
|
|
|
|
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(parent));
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(parent));
|
|
|
|
let target = try_vfs!(reply, inode.lookup(name.to_str().unwrap()));
|
|
|
|
let target = try_vfs!(reply, inode.lookup(name.to_str().unwrap()));
|
|
|
|
let info = try_vfs!(reply, target.info());
|
|
|
|
let info = try_vfs!(reply, target.info());
|
|
|
@ -101,7 +100,6 @@ impl<T: vfs::FileSystem> Filesystem for VfsWrapper<T> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn getattr(&mut self, _req: &Request, ino: u64, reply: ReplyAttr) {
|
|
|
|
fn getattr(&mut self, _req: &Request, ino: u64, reply: ReplyAttr) {
|
|
|
|
info!("getattr ino={}", ino);
|
|
|
|
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let info = try_vfs!(reply, inode.info());
|
|
|
|
let info = try_vfs!(reply, inode.info());
|
|
|
|
let attr = Self::trans_attr(info);
|
|
|
|
let attr = Self::trans_attr(info);
|
|
|
@ -110,7 +108,6 @@ impl<T: vfs::FileSystem> Filesystem for VfsWrapper<T> {
|
|
|
|
|
|
|
|
|
|
|
|
fn mknod(&mut self, _req: &Request, parent: u64, name: &OsStr, mode: u32, _rdev: u32, reply: ReplyEntry) {
|
|
|
|
fn mknod(&mut self, _req: &Request, parent: u64, name: &OsStr, mode: u32, _rdev: u32, reply: ReplyEntry) {
|
|
|
|
let name = name.to_str().unwrap();
|
|
|
|
let name = name.to_str().unwrap();
|
|
|
|
info!("mknod parent={} name={} mode={}", parent, name, mode);
|
|
|
|
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(parent));
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(parent));
|
|
|
|
let target = try_vfs!(reply, inode.create(name, vfs::FileType::File));
|
|
|
|
let target = try_vfs!(reply, inode.create(name, vfs::FileType::File));
|
|
|
|
let info = try_vfs!(reply, target.info());
|
|
|
|
let info = try_vfs!(reply, target.info());
|
|
|
@ -121,7 +118,6 @@ impl<T: vfs::FileSystem> Filesystem for VfsWrapper<T> {
|
|
|
|
|
|
|
|
|
|
|
|
fn mkdir(&mut self, _req: &Request, parent: u64, name: &OsStr, mode: u32, reply: ReplyEntry) {
|
|
|
|
fn mkdir(&mut self, _req: &Request, parent: u64, name: &OsStr, mode: u32, reply: ReplyEntry) {
|
|
|
|
let name = name.to_str().unwrap();
|
|
|
|
let name = name.to_str().unwrap();
|
|
|
|
info!("mkdir parent={} name={} mode={}", parent, name, mode);
|
|
|
|
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(parent));
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(parent));
|
|
|
|
let target = try_vfs!(reply, inode.create(name, vfs::FileType::Dir));
|
|
|
|
let target = try_vfs!(reply, inode.create(name, vfs::FileType::Dir));
|
|
|
|
let info = try_vfs!(reply, target.info());
|
|
|
|
let info = try_vfs!(reply, target.info());
|
|
|
@ -131,21 +127,18 @@ impl<T: vfs::FileSystem> Filesystem for VfsWrapper<T> {
|
|
|
|
|
|
|
|
|
|
|
|
fn unlink(&mut self, _req: &Request, parent: u64, name: &OsStr, reply: ReplyEmpty) {
|
|
|
|
fn unlink(&mut self, _req: &Request, parent: u64, name: &OsStr, reply: ReplyEmpty) {
|
|
|
|
let name = name.to_str().unwrap();
|
|
|
|
let name = name.to_str().unwrap();
|
|
|
|
info!("unlink parent={} name={}", parent, name);
|
|
|
|
|
|
|
|
let parent = try_vfs!(reply, self.get_inode(parent));
|
|
|
|
let parent = try_vfs!(reply, self.get_inode(parent));
|
|
|
|
try_vfs!(reply, parent.unlink(name));
|
|
|
|
try_vfs!(reply, parent.unlink(name));
|
|
|
|
reply.ok();
|
|
|
|
reply.ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn rmdir(&mut self, req: &Request, parent: u64, name: &OsStr, reply: ReplyEmpty) {
|
|
|
|
fn rmdir(&mut self, req: &Request, parent: u64, name: &OsStr, reply: ReplyEmpty) {
|
|
|
|
info!("rmdir -> unlink");
|
|
|
|
|
|
|
|
self.unlink(req, parent, name, reply);
|
|
|
|
self.unlink(req, parent, name, reply);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn rename(&mut self, _req: &Request, parent: u64, name: &OsStr, newparent: u64, newname: &OsStr, reply: ReplyEmpty) {
|
|
|
|
fn rename(&mut self, _req: &Request, parent: u64, name: &OsStr, newparent: u64, newname: &OsStr, reply: ReplyEmpty) {
|
|
|
|
let name = name.to_str().unwrap();
|
|
|
|
let name = name.to_str().unwrap();
|
|
|
|
let newname = newname.to_str().unwrap();
|
|
|
|
let newname = newname.to_str().unwrap();
|
|
|
|
info!("rename parent={} name={} newparent={} newname={}", parent, name, newparent, newname);
|
|
|
|
|
|
|
|
if parent == newparent {
|
|
|
|
if parent == newparent {
|
|
|
|
let parent = try_vfs!(reply, self.get_inode(parent));
|
|
|
|
let parent = try_vfs!(reply, self.get_inode(parent));
|
|
|
|
try_vfs!(reply, parent.rename(name, newname));
|
|
|
|
try_vfs!(reply, parent.rename(name, newname));
|
|
|
@ -159,7 +152,6 @@ impl<T: vfs::FileSystem> Filesystem for VfsWrapper<T> {
|
|
|
|
|
|
|
|
|
|
|
|
fn link(&mut self, _req: &Request, ino: u64, newparent: u64, newname: &OsStr, reply: ReplyEntry) {
|
|
|
|
fn link(&mut self, _req: &Request, ino: u64, newparent: u64, newname: &OsStr, reply: ReplyEntry) {
|
|
|
|
let newname = newname.to_str().unwrap();
|
|
|
|
let newname = newname.to_str().unwrap();
|
|
|
|
info!("link ino={} newparent={} newname={}", ino, newparent, newname);
|
|
|
|
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let newparent = try_vfs!(reply, self.get_inode(newparent));
|
|
|
|
let newparent = try_vfs!(reply, self.get_inode(newparent));
|
|
|
|
try_vfs!(reply, newparent.link(newname, inode));
|
|
|
|
try_vfs!(reply, newparent.link(newname, inode));
|
|
|
@ -169,7 +161,6 @@ impl<T: vfs::FileSystem> Filesystem for VfsWrapper<T> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn read(&mut self, _req: &Request, ino: u64, _fh: u64, offset: i64, size: u32, reply: ReplyData) {
|
|
|
|
fn read(&mut self, _req: &Request, ino: u64, _fh: u64, offset: i64, size: u32, reply: ReplyData) {
|
|
|
|
info!("read ino={} offset={} size={}", ino, offset, size);
|
|
|
|
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let mut data = Vec::<u8>::new();
|
|
|
|
let mut data = Vec::<u8>::new();
|
|
|
|
data.resize(size as usize, 0);
|
|
|
|
data.resize(size as usize, 0);
|
|
|
@ -178,28 +169,24 @@ impl<T: vfs::FileSystem> Filesystem for VfsWrapper<T> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn write(&mut self, _req: &Request, ino: u64, _fh: u64, offset: i64, data: &[u8], flags: u32, reply: ReplyWrite) {
|
|
|
|
fn write(&mut self, _req: &Request, ino: u64, _fh: u64, offset: i64, data: &[u8], flags: u32, reply: ReplyWrite) {
|
|
|
|
info!("write ino={} offset={} size={} flags={}", ino, offset, data.len(), flags);
|
|
|
|
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let len = try_vfs!(reply, inode.write_at(offset as usize, data));
|
|
|
|
let len = try_vfs!(reply, inode.write_at(offset as usize, data));
|
|
|
|
reply.written(len as u32);
|
|
|
|
reply.written(len as u32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn flush(&mut self, _req: &Request, ino: u64, _fh: u64, _lock_owner: u64, reply: ReplyEmpty) {
|
|
|
|
fn flush(&mut self, _req: &Request, ino: u64, _fh: u64, _lock_owner: u64, reply: ReplyEmpty) {
|
|
|
|
info!("flush ino={}", ino);
|
|
|
|
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
try_vfs!(reply, inode.sync());
|
|
|
|
try_vfs!(reply, inode.sync());
|
|
|
|
reply.ok();
|
|
|
|
reply.ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn fsync(&mut self, _req: &Request, ino: u64, _fh: u64, _datasync: bool, reply: ReplyEmpty) {
|
|
|
|
fn fsync(&mut self, _req: &Request, ino: u64, _fh: u64, _datasync: bool, reply: ReplyEmpty) {
|
|
|
|
info!("fsync ino={}", ino);
|
|
|
|
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
try_vfs!(reply, inode.sync());
|
|
|
|
try_vfs!(reply, inode.sync());
|
|
|
|
reply.ok();
|
|
|
|
reply.ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn readdir(&mut self, _req: &Request, ino: u64, _fh: u64, offset: i64, mut reply: ReplyDirectory) {
|
|
|
|
fn readdir(&mut self, _req: &Request, ino: u64, _fh: u64, offset: i64, mut reply: ReplyDirectory) {
|
|
|
|
info!("readdir ino={}, offset={}", ino, offset);
|
|
|
|
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let inode = try_vfs!(reply, self.get_inode(ino));
|
|
|
|
let info = try_vfs!(reply, inode.info());
|
|
|
|
let info = try_vfs!(reply, inode.info());
|
|
|
|
let count = info.size;
|
|
|
|
let count = info.size;
|
|
|
|