Skip to content

Commit

Permalink
implement fallocate/ioctl
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Oct 4, 2017
1 parent 58bda94 commit 168fa33
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use time::Timespec;
pub use kernel::FUSE_ROOT_ID;
pub use kernel::consts;
pub use reply::{Reply, ReplyEmpty, ReplyData, ReplyEntry, ReplyAttr, ReplyOpen};
pub use reply::{ReplyWrite, ReplyStatfs, ReplyCreate, ReplyLock, ReplyBmap, ReplyDirectory};
pub use reply::{ReplyWrite, ReplyStatfs, ReplyCreate, ReplyLock, ReplyBmap, ReplyDirectory, ReplyIoctl};
pub use reply::ReplyXattr;
#[cfg(target_os = "macos")]
pub use reply::ReplyXTimes;
Expand Down Expand Up @@ -349,6 +349,16 @@ pub trait Filesystem {
reply.error(ENOSYS);
}

/// control device
fn ioctl(&mut self, _req: &Request, _ino: u64, _fh: u64, _flags: u32, _cmd: u32, _arg: u64, _in_size: u32, _out_size: u32, _blocksize: u32, _idx: u64, reply: ReplyIoctl) {
reply.error(ENOSYS);
}

/// Preallocate or deallocate space to a file
fn fallocate(&mut self, _req: &Request, _ino: u64, _fh: u64, _offset: i64, _length: i64, _mode: i32, reply: ReplyEmpty) {
reply.error(ENOSYS);
}

/// macOS only: Rename the volume. Set fuse_init_out.flags during init to
/// FUSE_VOL_RENAME to enable
#[cfg(target_os = "macos")]
Expand Down
22 changes: 22 additions & 0 deletions src/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,28 @@ impl ReplyBmap {
}
}

pub struct ReplyIoctl {
reply: ReplyRaw<()>,
}

impl Reply for ReplyIoctl {
fn new<S: ReplySender>(unique: u64, sender: S) -> ReplyIoctl {
ReplyIoctl { reply: Reply::new(unique, sender) }
}
}

impl ReplyIoctl {
//// Reply to a request with the iovec
//pub fn iovec(mut self, data: &[u8]) {
// self.reply.send(0, &[data]);
//}

/// Reply to a request with the given error code
pub fn error(self, err: c_int) {
self.reply.error(err);
}
}

///
/// Directory reply
///
Expand Down
23 changes: 17 additions & 6 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,19 +385,29 @@ impl<'a> Request<'a> {
se.filesystem.bmap(self, self.header.nodeid, arg.blocksize, arg.block, self.reply());
},
FUSE_IOCTL => {
unimplemented!()
let arg: &fuse_ioctl_in = data.fetch();
self.reply::<ReplyEmpty>().error(ENOSYS);
//debug!("IOCTL({}) ino {:#018x}, fh {}, flags {}, cmd {}, in_size {}, out_size {}", self.header.unique, self.header.nodeid, arg.fh, arg.flags, arg.cmd, arg.in_size, arg.out_size);
//se.filesystem.ioctl(self, self.header.nodeid, arg.fh, arg.flags, arg.cmd, arg.in_size, arg.out_size, self.reply());
},
FUSE_POLL => {
unimplemented!()
let arg: &fuse_poll_in = data.fetch();
//debug!("IOCTL({}) ino {:#018x}, fh {}, flags {}, in_size {}, out_size {}", self.header.unique, self.header.nodeid, arg.fh, arg.in_size, arg.out_size);
//se.filesystem.poll(self, self.header.nodeid, arg.fh, arg.flags, arg.in_size, arg.out_size, self.reply());
self.reply::<ReplyEmpty>().error(ENOSYS);
},
FUSE_NOTIFY_REPLY => {
unimplemented!()
let arg: &fuse_notify_retrieve_in = data.fetch();
self.reply::<ReplyEmpty>().error(ENOSYS);
},
FUSE_BATCH_FORGET => {
unimplemented!()
let arg: &fuse_batch_forget_in = data.fetch();
self.reply::<ReplyEmpty>().error(ENOSYS);
},
FUSE_FALLOCATE => {
unimplemented!()
let arg: &fuse_fallocate_in = data.fetch();
debug!("FALLOCATE({}) ino {:#018x}, fh {}, offset {}, length {}, mode {}", self.header.unique, self.header.nodeid, arg.fh, arg.offset, arg.length, arg.mode);
se.filesystem.fallocate(self, self.header.nodeid, arg.fh, arg.offset, arg.length, arg.mode, self.reply());
},
#[cfg(target_os = "macos")]
FUSE_SETVOLNAME => {
Expand All @@ -419,7 +429,8 @@ impl<'a> Request<'a> {
se.filesystem.getxtimes(self, self.header.nodeid, self.reply());
},
CUSE_INIT => {
unimplemented!()
let arg: &cuse_init_in = data.fetch();
self.reply::<ReplyEmpty>().error(ENOSYS);
},
}
}
Expand Down

0 comments on commit 168fa33

Please sign in to comment.