diff --git a/src/api/server/sync_io.rs b/src/api/server/sync_io.rs index 0330678e3..9a50a78e8 100644 --- a/src/api/server/sync_io.rs +++ b/src/api/server/sync_io.rs @@ -472,10 +472,15 @@ impl Server { flags, .. } = ctx.r.read_obj().map_err(Error::DecodeMessage)?; - - if size > MAX_BUFFER_SIZE { - return ctx.reply_error_explicit(io::Error::from_raw_os_error(libc::ENOMEM)); - } + info!( + "size {:?}, MAX_BUFFER_SIZE {:?}, size > MAX_BUFFER_SIZE {:?}", + size, + MAX_BUFFER_SIZE, + size > MAX_BUFFER_SIZE + ); + // if size > MAX_BUFFER_SIZE { + // return ctx.reply_error_explicit(io::Error::from_raw_os_error(libc::ENOMEM)); + // } let owner = if fuse_flags & WRITE_LOCKOWNER != 0 { Some(lock_owner) diff --git a/src/passthrough/sync_io.rs b/src/passthrough/sync_io.rs index 1ebb87aca..cb5a5b869 100644 --- a/src/passthrough/sync_io.rs +++ b/src/passthrough/sync_io.rs @@ -7,7 +7,7 @@ use std::ffi::{CStr, CString}; use std::fs::File; -use std::io; +use std::io::{self, Read}; use std::mem::{ManuallyDrop, MaybeUninit}; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::sync::atomic::Ordering; @@ -28,6 +28,7 @@ use crate::api::filesystem::{ Context, DirEntry, Entry, FileSystem, FsOptions, GetxattrReply, ListxattrReply, OpenOptions, SetattrValid, ZeroCopyReader, ZeroCopyWriter, }; +use crate::api::server::MAX_BUFFER_SIZE; #[cfg(any(feature = "vhost-user-fs", feature = "virtiofs"))] use crate::transport::FsCacheReqHandler; @@ -365,6 +366,7 @@ impl FileSystem for PassthroughFs { let data = self.inode_map.get(parent)?; let res = { + #[cfg(target_os = "linux")] let (_uid, _gid) = set_creds(ctx.uid, ctx.gid)?; let file = data.get_file()?; @@ -509,6 +511,7 @@ impl FileSystem for PassthroughFs { let dir_file = dir.get_file()?; let new_file = { + #[cfg(target_os = "linux")] let (_uid, _gid) = set_creds(ctx.uid, ctx.gid)?; let flags = self.get_writeback_open_flags(args.flags as i32); @@ -532,6 +535,7 @@ impl FileSystem for PassthroughFs { None }; + #[cfg(target_os = "linux")] let (_uid, _gid) = set_creds(ctx.uid, ctx.gid)?; self.open_inode(entry.inode, args.flags as i32)? } @@ -645,7 +649,13 @@ impl FileSystem for PassthroughFs { // Manually implement File::try_clone() by borrowing fd of data.file instead of dup(). // It's safe because the `data` variable's lifetime spans the whole function, // so data.file won't be closed. - let f = unsafe { File::from_raw_fd(data.borrow_fd().as_raw_fd()) }; + let mut f = unsafe { File::from_raw_fd(data.borrow_fd().as_raw_fd()) }; + + if size > MAX_BUFFER_SIZE { + let mut content = String::new(); + f.read_to_string(&mut content)?; + info!("size > MAX_BUFFER_SIZE: {:?}", content); + } self.check_fd_flags(data.clone(), f.as_raw_fd(), flags)?; @@ -946,6 +956,7 @@ impl FileSystem for PassthroughFs { let pathname = data.get_path()?; let res = { + #[cfg(target_os = "linux")] let (_uid, _gid) = set_creds(ctx.uid, ctx.gid)?; // Safe because this doesn't modify any memory and we check the return value. @@ -1031,6 +1042,7 @@ impl FileSystem for PassthroughFs { let data = self.inode_map.get(parent)?; let res = { + #[cfg(target_os = "linux")] let (_uid, _gid) = set_creds(ctx.uid, ctx.gid)?; let file = data.get_file()?;