src/pxar/fuse.rs: impl opendir callback for fuse

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2019-09-09 18:27:29 +02:00 committed by Dietmar Maurer
parent 2c5fd378d3
commit 7eb9848ba7

View File

@ -453,11 +453,19 @@ extern "C" fn read(req: Request, inode: u64, size: size_t, offset: c_int, _filei
}); });
} }
extern "C" fn opendir(req: Request, inode: u64, _fileinfo: MutPtr) { /// Open the directory referenced by the given inode for reading.
run_in_context(req, inode, |_decoder, _ino_offset| { ///
// code goes here /// This simply checks if the inode references a valid directory, no internal
/// state identifies the directory as opened.
extern "C" fn opendir(req: Request, inode: u64, fileinfo: MutPtr) {
run_in_context(req, inode, |mut decoder, ino_offset| {
let (attr, _) = stat(&mut decoder, ino_offset).map_err(|_| libc::ENOENT)?;
if attr.st_mode & libc::S_IFMT != libc::S_IFDIR {
return Err(libc::ENOENT);
}
let _ret = unsafe { fuse_reply_open(req, fileinfo) };
Err(libc::ENOENT) Ok(())
}); });
} }