Skip to content

Commit

Permalink
Merge pull request #68 from Sherlock-Holo/write_flags_in_write_op
Browse files Browse the repository at this point in the history
feat: add write_flags arguments in the write method
  • Loading branch information
Sherlock-Holo authored Feb 20, 2023
2 parents b390cb9 + 1f0d6c8 commit 567d54f
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fuse3"
version = "0.6.1"
version = "0.7.0"
authors = ["Sherlock Holo <[email protected]>"]
edition = "2021"
readme = "README.md"
Expand Down
1 change: 1 addition & 0 deletions examples/src/memfs/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ impl Filesystem for Fs {
_fh: u64,
offset: u64,
mut data: &[u8],
_write_flags: u32,
_flags: u32,
) -> Result<ReplyWrite> {
let inner = self.0.read().await;
Expand Down
4 changes: 3 additions & 1 deletion examples/src/path_memfs/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ impl PathFilesystem for Fs {
_fh: u64,
offset: u64,
data: &[u8],
_write_flags: u32,
_flags: u32,
) -> Result<ReplyWrite> {
let path = path.ok_or_else(Errno::new_not_exist)?.to_string_lossy();
Expand Down Expand Up @@ -861,8 +862,9 @@ impl PathFilesystem for Fs {
.read(req, from_path, fh_in, offset_in, length as _)
.await?;

// write_flags set to 0 because we don't care it in this example implement
let ReplyWrite { written } = self
.write(req, to_path, fh_out, offset_out, &data.data, flags as _)
.write(req, to_path, fh_out, offset_out, &data.data, 0, flags as _)
.await?;

Ok(ReplyCopyFileRange {
Expand Down
2 changes: 2 additions & 0 deletions src/path/inode_path_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ where
fh: u64,
offset: u64,
data: &[u8],
write_flags: u32,
flags: u32,
) -> Result<ReplyWrite> {
let path = self
Expand All @@ -589,6 +590,7 @@ where
fh,
offset,
data,
write_flags,
flags,
)
.await
Expand Down
6 changes: 5 additions & 1 deletion src/path/path_filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,18 @@ pub trait PathFilesystem {
/// exception to this is when the file has been opened in `direct_io` mode, in which case the
/// return value of the write system call will reflect the return value of this operation. `fh`
/// will contain the value set by the open method, or will be undefined if the open method
/// didn't set any value. when `path` is None, it means the path may be deleted.
/// didn't set any value. When `path` is None, it means the path may be deleted. When
/// `write_flags` contains [`FUSE_WRITE_CACHE`](crate::raw::flags::FUSE_WRITE_CACHE), means the
/// write operation is a delay write.
#[allow(clippy::too_many_arguments)]
async fn write(
&self,
req: Request,
path: Option<&OsStr>,
fh: u64,
offset: u64,
data: &[u8],
write_flags: u32,
flags: u32,
) -> Result<ReplyWrite> {
Err(libc::ENOSYS.into())
Expand Down
6 changes: 5 additions & 1 deletion src/raw/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,18 @@ pub trait Filesystem {
/// exception to this is when the file has been opened in `direct_io` mode, in which case the
/// return value of the write system call will reflect the return value of this operation. `fh`
/// will contain the value set by the open method, or will be undefined if the open method
/// didn't set any value.
/// didn't set any value. When `write_flags` contains
/// [`FUSE_WRITE_CACHE`](crate::raw::flags::FUSE_WRITE_CACHE), means the write operation is a
/// delay write.
#[allow(clippy::too_many_arguments)]
async fn write(
&self,
req: Request,
inode: Inode,
fh: u64,
offset: u64,
data: &[u8],
write_flags: u32,
flags: u32,
) -> Result<ReplyWrite> {
Err(libc::ENOSYS.into())
Expand Down
12 changes: 12 additions & 0 deletions src/raw/flags.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//! request flags.

pub use crate::raw::abi::FUSE_IOCTL_32BIT;
pub use crate::raw::abi::FUSE_IOCTL_COMPAT;
pub use crate::raw::abi::FUSE_IOCTL_DIR;
pub use crate::raw::abi::FUSE_IOCTL_MAX_IOV;
pub use crate::raw::abi::FUSE_IOCTL_RETRY;
pub use crate::raw::abi::FUSE_IOCTL_UNRESTRICTED;
pub use crate::raw::abi::FUSE_POLL_SCHEDULE_NOTIFY;
pub use crate::raw::abi::FUSE_READ_LOCKOWNER;
pub use crate::raw::abi::FUSE_WRITE_CACHE;
pub use crate::raw::abi::FUSE_WRITE_LOCKOWNER;
1 change: 1 addition & 0 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub use session::{MountHandle, Session};
pub(crate) mod abi;
mod connection;
mod filesystem;
pub mod flags;
pub mod reply;
mod request;
pub(crate) mod session;
Expand Down
1 change: 1 addition & 0 deletions src/raw/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,7 @@ impl<FS: Filesystem + Send + Sync + 'static> Session<FS> {
write_in.fh,
write_in.offset,
&data,
write_in.write_flags,
write_in.flags,
)
.await
Expand Down

0 comments on commit 567d54f

Please sign in to comment.