Struct devices::virtio::fs::passthrough::PassthroughFs
source · pub struct PassthroughFs {Show 14 fields
process_lock: Mutex<()>,
tag: String,
inodes: Mutex<MultikeyBTreeMap<Inode, InodeAltKey, Arc<InodeData>>>,
next_inode: AtomicU64,
handles: Mutex<BTreeMap<u64, Arc<HandleData>>>,
next_handle: AtomicU64,
proc: File,
writeback: AtomicBool,
zero_message_open: AtomicBool,
zero_message_opendir: AtomicBool,
dbus_connection: Option<Mutex<Connection>>,
dbus_fd: Option<RawFd>,
expiring_casefold_lookup_caches: Option<Mutex<ExpiringCasefoldLookupCaches>>,
cfg: Config,
}
Expand description
A file system that simply “passes through” all requests it receives to the underlying file system. To keep the implementation simple it servers the contents of its root directory. Users that wish to serve only a specific directory should set up the environment so that that directory ends up as the root of the file system process. One way to accomplish this is via a combination of mount namespaces and the pivot_root system call.
Fields§
§process_lock: Mutex<()>
§tag: String
§inodes: Mutex<MultikeyBTreeMap<Inode, InodeAltKey, Arc<InodeData>>>
§next_inode: AtomicU64
§handles: Mutex<BTreeMap<u64, Arc<HandleData>>>
§next_handle: AtomicU64
§proc: File
§writeback: AtomicBool
§zero_message_open: AtomicBool
§zero_message_opendir: AtomicBool
§dbus_connection: Option<Mutex<Connection>>
§dbus_fd: Option<RawFd>
§expiring_casefold_lookup_caches: Option<Mutex<ExpiringCasefoldLookupCaches>>
§cfg: Config
Implementations§
source§impl PassthroughFs
impl PassthroughFs
pub fn new(tag: &str, cfg: Config) -> Result<PassthroughFs>
pub fn cfg(&self) -> &Config
pub fn keep_rds(&self) -> Vec<RawDescriptor>
fn rewrite_xattr_name<'xattr>(&self, name: &'xattr CStr) -> Cow<'xattr, CStr>
fn find_inode(&self, inode: Inode) -> Result<Arc<InodeData>>
fn find_handle(&self, handle: u64, inode: Inode) -> Result<Arc<HandleData>>
fn open_fd(&self, fd: RawDescriptor, flags: i32) -> Result<File>
sourcefn update_open_flags(&self, flags: i32) -> i32
fn update_open_flags(&self, flags: i32) -> i32
Modifies the provided open flags based on the writeback caching configuration. Return the updated open flags.
fn open_inode(&self, inode: &InodeData, flags: i32) -> Result<File>
fn increase_inode_refcount(&self, inode_data: &InodeData) -> Inode
fn add_entry( &self, f: File, st: stat64, open_flags: c_int, path: String ) -> Entry
sourcefn lock_casefold_lookup_caches(
&self
) -> Option<MutexGuard<'_, ExpiringCasefoldLookupCaches>>
fn lock_casefold_lookup_caches( &self ) -> Option<MutexGuard<'_, ExpiringCasefoldLookupCaches>>
Acquires lock of expiring_casefold_lookup_caches
if ascii_casefold
is enabled.
fn get_case_unfolded_name( &self, parent: &InodeData, name: &[u8] ) -> Result<Option<CString>>
fn ascii_casefold_lookup( &self, parent: &InodeData, name: &[u8] ) -> Result<Entry>
fn do_lookup(&self, parent: &InodeData, name: &CStr) -> Result<Entry>
fn get_cache_open_options(&self, flags: u32) -> OpenOptions
fn do_lookup_with_casefold_fallback( &self, parent: &InodeData, name: &CStr ) -> Result<Entry>
fn do_open( &self, inode: Inode, flags: u32 ) -> Result<(Option<u64>, OpenOptions)>
fn do_open_at( &self, parent_data: Arc<InodeData>, name: &CStr, inode: Inode, flags: u32 ) -> Result<(Option<u64>, OpenOptions)>
fn do_release(&self, inode: Inode, handle: u64) -> Result<()>
fn do_getattr(&self, inode: &InodeData) -> Result<(stat64, Duration)>
fn do_unlink(&self, parent: &InodeData, name: &CStr, flags: c_int) -> Result<()>
fn do_fsync<F: AsRawDescriptor>(&self, file: &F, datasync: bool) -> Result<()>
fn with_proc_chdir<F, T>(&self, f: F) -> Twhere F: FnOnce() -> T,
fn do_getxattr( &self, inode: &InodeData, name: &CStr, value: &mut [u8] ) -> Result<usize>
fn get_encryption_policy_ex<R: Read>( &self, inode: Inode, handle: u64, r: R ) -> Result<IoctlReply>
fn get_fsxattr(&self, inode: Inode, handle: u64) -> Result<IoctlReply>
fn set_fsxattr<R: Read>( &self, ctx: Context, inode: Inode, handle: u64, r: R ) -> Result<IoctlReply>
fn get_flags(&self, inode: Inode, handle: u64) -> Result<IoctlReply>
fn set_flags<R: Read>( &self, ctx: Context, inode: Inode, handle: u64, r: R ) -> Result<IoctlReply>
fn enable_verity<R: Read>( &self, inode: Inode, handle: u64, r: R ) -> Result<IoctlReply>
fn measure_verity<R: Read>( &self, inode: Inode, handle: u64, r: R, out_size: u32 ) -> Result<IoctlReply>
Trait Implementations§
source§impl Debug for PassthroughFs
impl Debug for PassthroughFs
source§impl FileSystem for PassthroughFs
impl FileSystem for PassthroughFs
§type Inode = u64
type Inode = u64
Represents a location in the filesystem tree and can be used to perform operations that act
on the metadata of a file/directory (e.g.,
getattr
and setattr
). Can also be used as the
starting point for looking up paths in the filesystem tree. An Inode
may support operating
directly on the content of the path that to which it points. FileSystem
implementations
that support this should set the FsOptions::ZERO_MESSAGE_OPEN
option in the return value
of the init
function. On linux based systems, an Inode
is equivalent to opening a file
or directory with the libc::O_PATH
flag. Read more§type DirIter = ReadDir<Box<[u8], Global>>
type DirIter = ReadDir<Box<[u8], Global>>
An iterator over the entries of a directory. See the documentation for
readdir
for more
details.source§fn statfs(&self, _ctx: Context, inode: Inode) -> Result<statvfs64>
fn statfs(&self, _ctx: Context, inode: Inode) -> Result<statvfs64>
Get information about the file system.
source§fn lookup(&self, _ctx: Context, parent: Inode, name: &CStr) -> Result<Entry>
fn lookup(&self, _ctx: Context, parent: Inode, name: &CStr) -> Result<Entry>
Look up a directory entry by name and get its attributes. Read more
source§fn batch_forget(&self, _ctx: Context, requests: Vec<(Inode, u64)>)
fn batch_forget(&self, _ctx: Context, requests: Vec<(Inode, u64)>)
Forget about multiple inodes. Read more
source§fn opendir(
&self,
_ctx: Context,
inode: Inode,
flags: u32
) -> Result<(Option<u64>, OpenOptions)>
fn opendir( &self, _ctx: Context, inode: Inode, flags: u32 ) -> Result<(Option<u64>, OpenOptions)>
Open a directory for reading. Read more
source§fn releasedir(
&self,
_ctx: Context,
inode: Inode,
_flags: u32,
handle: u64
) -> Result<()>
fn releasedir( &self, _ctx: Context, inode: Inode, _flags: u32, handle: u64 ) -> Result<()>
Release an open directory. Read more
source§fn mkdir(
&self,
ctx: Context,
parent: Inode,
name: &CStr,
mode: u32,
umask: u32,
security_ctx: Option<&CStr>
) -> Result<Entry>
fn mkdir( &self, ctx: Context, parent: Inode, name: &CStr, mode: u32, umask: u32, security_ctx: Option<&CStr> ) -> Result<Entry>
Create a directory. Read more
source§fn rmdir(&self, _ctx: Context, parent: Inode, name: &CStr) -> Result<()>
fn rmdir(&self, _ctx: Context, parent: Inode, name: &CStr) -> Result<()>
Remove a directory. Read more
source§fn readdir(
&self,
_ctx: Context,
inode: Inode,
handle: u64,
size: u32,
offset: u64
) -> Result<Self::DirIter>
fn readdir( &self, _ctx: Context, inode: Inode, handle: u64, size: u32, offset: u64 ) -> Result<Self::DirIter>
Read a directory. Read more
source§fn open(
&self,
_ctx: Context,
inode: Inode,
flags: u32
) -> Result<(Option<u64>, OpenOptions)>
fn open( &self, _ctx: Context, inode: Inode, flags: u32 ) -> Result<(Option<u64>, OpenOptions)>
Open a file. Read more
source§fn release(
&self,
_ctx: Context,
inode: Inode,
_flags: u32,
handle: u64,
_flush: bool,
_flock_release: bool,
_lock_owner: Option<u64>
) -> Result<()>
fn release( &self, _ctx: Context, inode: Inode, _flags: u32, handle: u64, _flush: bool, _flock_release: bool, _lock_owner: Option<u64> ) -> Result<()>
Release an open file. Read more
source§fn chromeos_tmpfile(
&self,
ctx: Context,
parent: Self::Inode,
mode: u32,
umask: u32,
security_ctx: Option<&CStr>
) -> Result<Entry>
fn chromeos_tmpfile( &self, ctx: Context, parent: Self::Inode, mode: u32, umask: u32, security_ctx: Option<&CStr> ) -> Result<Entry>
Create an unnamed temporary file.
source§fn create(
&self,
ctx: Context,
parent: Inode,
name: &CStr,
mode: u32,
flags: u32,
umask: u32,
security_ctx: Option<&CStr>
) -> Result<(Entry, Option<u64>, OpenOptions)>
fn create( &self, ctx: Context, parent: Inode, name: &CStr, mode: u32, flags: u32, umask: u32, security_ctx: Option<&CStr> ) -> Result<(Entry, Option<u64>, OpenOptions)>
Create and open a file. Read more
source§fn unlink(&self, _ctx: Context, parent: Inode, name: &CStr) -> Result<()>
fn unlink(&self, _ctx: Context, parent: Inode, name: &CStr) -> Result<()>
Remove a file. Read more
source§fn read<W: Write + ZeroCopyWriter>(
&self,
_ctx: Context,
inode: Inode,
handle: u64,
w: W,
size: u32,
offset: u64,
_lock_owner: Option<u64>,
_flags: u32
) -> Result<usize>
fn read<W: Write + ZeroCopyWriter>( &self, _ctx: Context, inode: Inode, handle: u64, w: W, size: u32, offset: u64, _lock_owner: Option<u64>, _flags: u32 ) -> Result<usize>
Read data from a file. Read more
source§fn write<R: Read + ZeroCopyReader>(
&self,
_ctx: Context,
inode: Inode,
handle: u64,
r: R,
size: u32,
offset: u64,
_lock_owner: Option<u64>,
_delayed_write: bool,
flags: u32
) -> Result<usize>
fn write<R: Read + ZeroCopyReader>( &self, _ctx: Context, inode: Inode, handle: u64, r: R, size: u32, offset: u64, _lock_owner: Option<u64>, _delayed_write: bool, flags: u32 ) -> Result<usize>
Write data to a file. Read more
source§fn getattr(
&self,
_ctx: Context,
inode: Inode,
_handle: Option<u64>
) -> Result<(stat64, Duration)>
fn getattr( &self, _ctx: Context, inode: Inode, _handle: Option<u64> ) -> Result<(stat64, Duration)>
Get attributes for a file / directory. Read more
source§fn setattr(
&self,
_ctx: Context,
inode: Inode,
attr: stat64,
handle: Option<u64>,
valid: SetattrValid
) -> Result<(stat64, Duration)>
fn setattr( &self, _ctx: Context, inode: Inode, attr: stat64, handle: Option<u64>, valid: SetattrValid ) -> Result<(stat64, Duration)>
Set attributes for a file / directory. Read more
source§fn rename(
&self,
_ctx: Context,
olddir: Inode,
oldname: &CStr,
newdir: Inode,
newname: &CStr,
flags: u32
) -> Result<()>
fn rename( &self, _ctx: Context, olddir: Inode, oldname: &CStr, newdir: Inode, newname: &CStr, flags: u32 ) -> Result<()>
Rename a file / directory. Read more
source§fn mknod(
&self,
ctx: Context,
parent: Inode,
name: &CStr,
mode: u32,
rdev: u32,
umask: u32,
security_ctx: Option<&CStr>
) -> Result<Entry>
fn mknod( &self, ctx: Context, parent: Inode, name: &CStr, mode: u32, rdev: u32, umask: u32, security_ctx: Option<&CStr> ) -> Result<Entry>
Create a file node. Read more
source§fn link(
&self,
_ctx: Context,
inode: Inode,
newparent: Inode,
newname: &CStr
) -> Result<Entry>
fn link( &self, _ctx: Context, inode: Inode, newparent: Inode, newname: &CStr ) -> Result<Entry>
Create a hard link. Read more
source§fn symlink(
&self,
ctx: Context,
linkname: &CStr,
parent: Inode,
name: &CStr,
security_ctx: Option<&CStr>
) -> Result<Entry>
fn symlink( &self, ctx: Context, linkname: &CStr, parent: Inode, name: &CStr, security_ctx: Option<&CStr> ) -> Result<Entry>
Create a symbolic link. Read more
source§fn flush(
&self,
_ctx: Context,
inode: Inode,
handle: u64,
_lock_owner: u64
) -> Result<()>
fn flush( &self, _ctx: Context, inode: Inode, handle: u64, _lock_owner: u64 ) -> Result<()>
Flush the contents of a file. Read more
source§fn fsync(
&self,
_ctx: Context,
inode: Inode,
datasync: bool,
handle: u64
) -> Result<()>
fn fsync( &self, _ctx: Context, inode: Inode, datasync: bool, handle: u64 ) -> Result<()>
Synchronize file contents. Read more
source§fn fsyncdir(
&self,
_ctx: Context,
inode: Inode,
datasync: bool,
handle: u64
) -> Result<()>
fn fsyncdir( &self, _ctx: Context, inode: Inode, datasync: bool, handle: u64 ) -> Result<()>
Synchronize the contents of a directory. Read more
source§fn access(&self, ctx: Context, inode: Inode, mask: u32) -> Result<()>
fn access(&self, ctx: Context, inode: Inode, mask: u32) -> Result<()>
Check file access permissions. Read more
source§fn setxattr(
&self,
_ctx: Context,
inode: Inode,
name: &CStr,
value: &[u8],
flags: u32
) -> Result<()>
fn setxattr( &self, _ctx: Context, inode: Inode, name: &CStr, value: &[u8], flags: u32 ) -> Result<()>
Set an extended attribute. Read more
source§fn getxattr(
&self,
_ctx: Context,
inode: Inode,
name: &CStr,
size: u32
) -> Result<GetxattrReply>
fn getxattr( &self, _ctx: Context, inode: Inode, name: &CStr, size: u32 ) -> Result<GetxattrReply>
Get an extended attribute. Read more
source§fn listxattr(
&self,
_ctx: Context,
inode: Inode,
size: u32
) -> Result<ListxattrReply>
fn listxattr( &self, _ctx: Context, inode: Inode, size: u32 ) -> Result<ListxattrReply>
List extended attribute names. Read more
source§fn removexattr(&self, _ctx: Context, inode: Inode, name: &CStr) -> Result<()>
fn removexattr(&self, _ctx: Context, inode: Inode, name: &CStr) -> Result<()>
Remove an extended attribute. Read more
source§fn fallocate(
&self,
_ctx: Context,
inode: Inode,
handle: u64,
mode: u32,
offset: u64,
length: u64
) -> Result<()>
fn fallocate( &self, _ctx: Context, inode: Inode, handle: u64, mode: u32, offset: u64, length: u64 ) -> Result<()>
Allocate requested space for file data. Read more
source§fn ioctl<R: Read>(
&self,
ctx: Context,
inode: Inode,
handle: u64,
_flags: IoctlFlags,
cmd: u32,
_arg: u64,
in_size: u32,
out_size: u32,
r: R
) -> Result<IoctlReply>
fn ioctl<R: Read>( &self, ctx: Context, inode: Inode, handle: u64, _flags: IoctlFlags, cmd: u32, _arg: u64, in_size: u32, out_size: u32, r: R ) -> Result<IoctlReply>
Perform an ioctl on a file or directory. Read more
source§fn copy_file_range(
&self,
ctx: Context,
inode_src: Inode,
handle_src: u64,
offset_src: u64,
inode_dst: Inode,
handle_dst: u64,
offset_dst: u64,
length: u64,
flags: u64
) -> Result<usize>
fn copy_file_range( &self, ctx: Context, inode_src: Inode, handle_src: u64, offset_src: u64, inode_dst: Inode, handle_dst: u64, offset_dst: u64, length: u64, flags: u64 ) -> Result<usize>
Copy a range of data from one file to another Read more
source§fn set_up_mapping<M: Mapper>(
&self,
_ctx: Context,
inode: Self::Inode,
_handle: Self::Handle,
file_offset: u64,
mem_offset: u64,
size: usize,
prot: u32,
mapper: M
) -> Result<()>
fn set_up_mapping<M: Mapper>( &self, _ctx: Context, inode: Self::Inode, _handle: Self::Handle, file_offset: u64, mem_offset: u64, size: usize, prot: u32, mapper: M ) -> Result<()>
Set up memory mappings. Read more
source§fn remove_mapping<M: Mapper>(
&self,
msgs: &[RemoveMappingOne],
mapper: M
) -> Result<()>
fn remove_mapping<M: Mapper>( &self, msgs: &[RemoveMappingOne], mapper: M ) -> Result<()>
Remove memory mappings. Read more
source§fn atomic_open(
&self,
ctx: Context,
parent: Self::Inode,
name: &CStr,
mode: u32,
flags: u32,
umask: u32,
security_ctx: Option<&CStr>
) -> Result<(Entry, Option<Self::Handle>, OpenOptions)>
fn atomic_open( &self, ctx: Context, parent: Self::Inode, name: &CStr, mode: u32, flags: u32, umask: u32, security_ctx: Option<&CStr> ) -> Result<(Entry, Option<Self::Handle>, OpenOptions)>
Lookup and open/create the file Read more
source§fn max_buffer_size(&self) -> u32
fn max_buffer_size(&self) -> u32
Maximum size of the buffer that the filesystem can generate data to, including the header.
This corresponds to max_write in the initialization.
Auto Trait Implementations§
impl RefUnwindSafe for PassthroughFs
impl Send for PassthroughFs
impl Sync for PassthroughFs
impl Unpin for PassthroughFs
impl UnwindSafe for PassthroughFs
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.