pub struct PassthroughFs {
Show 17 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>>, permission_paths: RwLock<Vec<PermissionData>>, xattr_paths: RwLock<Vec<XattrData>>, cfg: Config, root_dir: String,
}
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>>§permission_paths: RwLock<Vec<PermissionData>>§xattr_paths: RwLock<Vec<XattrData>>§cfg: Config§root_dir: String

Implementations§

source§

impl PassthroughFs

source

pub fn new(tag: &str, cfg: Config) -> Result<PassthroughFs>

source

fn set_permission_path(&mut self)

source

pub fn set_root_dir(&mut self, shared_dir: String) -> Result<()>

source

pub fn cfg(&self) -> &Config

source

pub fn keep_rds(&self) -> Vec<RawDescriptor>

source

fn rewrite_xattr_name<'xattr>(&self, name: &'xattr CStr) -> Cow<'xattr, CStr>

source

fn find_inode(&self, inode: Inode) -> Result<Arc<InodeData>>

source

fn find_handle(&self, handle: u64, inode: Inode) -> Result<Arc<HandleData>>

source

fn open_fd(&self, fd: RawDescriptor, flags: i32) -> Result<File>

source

fn update_open_flags(&self, flags: i32) -> i32

Modifies the provided open flags based on the writeback caching configuration. Return the updated open flags.

source

fn open_inode(&self, inode: &InodeData, flags: i32) -> Result<File>

source

fn increase_inode_refcount(&self, inode_data: &InodeData) -> Inode

source

fn add_entry( &self, f: File, st: stat64, open_flags: c_int, path: String ) -> Entry

source

fn lock_casefold_lookup_caches( &self ) -> Option<MutexGuard<'_, ExpiringCasefoldLookupCaches>>

Acquires lock of expiring_casefold_lookup_caches if ascii_casefold is enabled.

source

fn get_case_unfolded_name( &self, parent: &InodeData, name: &[u8] ) -> Result<Option<CString>>

source

fn ascii_casefold_lookup( &self, parent: &InodeData, name: &[u8] ) -> Result<Entry>

source

fn do_lookup(&self, parent: &InodeData, name: &CStr) -> Result<Entry>

source

fn get_cache_open_options(&self, flags: u32) -> OpenOptions

source

fn do_lookup_with_casefold_fallback( &self, parent: &InodeData, name: &CStr ) -> Result<Entry>

source

fn do_open( &self, inode: Inode, flags: u32 ) -> Result<(Option<u64>, OpenOptions)>

source

fn do_open_at( &self, parent_data: Arc<InodeData>, name: &CStr, inode: Inode, flags: u32 ) -> Result<(Option<u64>, OpenOptions)>

source

fn do_release(&self, inode: Inode, handle: u64) -> Result<()>

source

fn do_getattr(&self, inode: &InodeData) -> Result<(stat64, Duration)>

source

fn do_fsync<F: AsRawDescriptor>(&self, file: &F, datasync: bool) -> Result<()>

source

fn with_proc_chdir<F, T>(&self, f: F) -> T
where F: FnOnce() -> T,

source

fn do_getxattr( &self, inode: &InodeData, name: &CStr, value: &mut [u8] ) -> Result<usize>

source

fn get_encryption_policy_ex<R: Read>( &self, inode: Inode, handle: u64, r: R ) -> Result<IoctlReply>

source

fn get_fsxattr(&self, inode: Inode, handle: u64) -> Result<IoctlReply>

source

fn set_fsxattr<R: Read>( &self, ctx: Context, inode: Inode, handle: u64, r: R ) -> Result<IoctlReply>

source

fn get_flags(&self, inode: Inode, handle: u64) -> Result<IoctlReply>

source

fn set_flags<R: Read>( &self, ctx: Context, inode: Inode, handle: u64, r: R ) -> Result<IoctlReply>

source

fn enable_verity<R: Read>( &self, inode: Inode, handle: u64, r: R ) -> Result<IoctlReply>

source

fn measure_verity<R: Read>( &self, inode: Inode, handle: u64, r: R, out_size: u32 ) -> Result<IoctlReply>

source§

impl PassthroughFs

source

fn find_and_set_ugid_permission( &self, st: &mut stat64, path: &str, is_root_path: bool ) -> bool

source

fn set_permission_from_data(&self, st: &mut stat64, perm_data: &PermissionData)

source

fn set_ugid_permission(&self, st: &mut stat64, path: &str)

Set permission according to path

source

fn change_ugid_creds( &self, ctx: &Context, parent_data: &InodeData, name: &CStr ) -> (u32, u32)

Set host uid/gid to configured value according to path

source

fn find_ugid_creds_for_path( &self, path: &str, is_root_path: bool ) -> Option<(u32, u32)>

source§

impl PassthroughFs

source

fn string_from_u8_slice(&self, buf: &[u8]) -> Result<String>

Convert u8 slice to string

source

fn set_permission(&self, st: &mut stat64, path: &str)

Set permission according to path

source

fn change_creds( &self, ctx: &Context, parent_data: &InodeData, name: &CStr ) -> (u32, u32)

Set host uid/gid to configured value according to path

source

fn read_permission_data<R: Read>(&self, r: R) -> Result<PermissionData>

source

fn set_permission_by_path<R: Read>(&self, r: R) -> IoctlReply

Sets uid/gid/umask for all files and directories under a specific path.

This ioctl does not correspond to any upstream FUSE feature. It is used for arcvm It associates the specified path with the provide uid, gid, and umask values within the filesystem metadata.

During subsequent lookup operations, the stored uid/gid/umask values are retrieved and applied to all files and directories found under the registered path. Before sending file stat information to the client, the uid and gid are substituted by guest_uid and guest_gid if the file falls under the registered path. The file mode is masked by the umask.

When the guest creates a file within the specified path, the file gid/uid stat in host will be overwritten to host_uid and host_gid values.

This functionality enables dynamic configuration of ownership and permissions for a specific directory hierarchy within the filesystem.

§Notes
  • This method affects all existing and future files under the registered path.
  • The original file ownership and permissions are overridden by the provided values.
  • The registered path should not be renamed
  • Refer go/remove-mount-passthrough-fuse for more design details
source

fn get_xattr_by_path(&self, path: &str, name: &str) -> Option<String>

source

fn skip_host_set_xattr(&self, path: &str, name: &str) -> bool

source

fn read_xattr_data<R: Read>(&self, r: R) -> Result<XattrData>

source

fn set_xattr_by_path<R: Read>(&self, r: R) -> IoctlReply

Sets xattr value for all files and directories under a specific path.

This ioctl does not correspond to any upstream FUSE feature. It is used for arcvm. It associates the specified path and xattr name with a value.

When the getxattr is called for the specified path and name, the predefined value is returned.

§Notes
  • This method affects all existing and future files under the registered path.
  • The SECURITY_CONTEXT feature will be disabled if this ioctl is enabled.
  • The registered path should not be renamed
  • Refer go/remove-mount-passthrough-fuse for more design details
source

fn do_getxattr_with_filter( &self, data: Arc<InodeData>, name: Cow<'_, CStr>, buf: &mut [u8] ) -> Result<usize>

Trait Implementations§

source§

impl Debug for PassthroughFs

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FileSystem for PassthroughFs

§

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 Handle = u64

Represents a file or directory that is open for reading/writing.
§

type DirIter = ReadDir<Box<[u8]>>

An iterator over the entries of a directory. See the documentation for readdir for more details.
source§

fn init(&self, capable: FsOptions) -> Result<FsOptions>

Initialize the file system. Read more
source§

fn destroy(&self)

Clean up the file system. Read more
source§

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>

Look up a directory entry by name and get its attributes. Read more
source§

fn forget(&self, _ctx: Context, inode: Inode, count: u64)

Forget about an inode. Read more
source§

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)>

Open a directory for reading. Read more
source§

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>

Create a directory. Read more
source§

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>

Read a directory. Read more
source§

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<()>

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>

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)>

Create and open a file. Read more
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>

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>

Write data to a file. Read more
source§

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)>

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<()>

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>

Create a file node. Read more
Create a hard link. Read more
Create a symbolic link. Read more
Read a symbolic link.
source§

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<()>

Synchronize file contents. Read more
source§

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<()>

Check file access permissions. Read more
source§

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>

Get an extended attribute. Read more
source§

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<()>

Remove an extended attribute. Read more
source§

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>

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>

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<()>

Set up memory mappings. Read more
source§

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)>

Lookup and open/create the file Read more
source§

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.
source§

fn getlk(&self) -> Result<(), Error>

TODO: support this
source§

fn setlk(&self) -> Result<(), Error>

TODO: support this
source§

fn setlkw(&self) -> Result<(), Error>

TODO: support this
source§

fn bmap(&self) -> Result<(), Error>

TODO: support this
source§

fn poll(&self) -> Result<(), Error>

TODO: support this
source§

fn notify_reply(&self) -> Result<(), Error>

TODO: support this
source§

fn lseek(&self) -> Result<(), Error>

TODO: support this

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

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>) -> Rc<dyn Any>

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)

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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V