#[repr(C)]pub struct vfs_file_ops {
pub close: Option<unsafe extern "C" fn(filp: *mut vfs_file_t) -> c_int>,
pub fcntl: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, cmd: c_int, arg: c_int) -> c_int>,
pub fstat: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, buf: *mut stat) -> c_int>,
pub lseek: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, off: off_t, whence: c_int) -> off_t>,
pub open: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, name: *const c_char, flags: c_int, mode: mode_t) -> c_int>,
pub read: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, dest: *mut c_void, nbytes: size_t) -> ssize_t>,
pub write: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, src: *const c_void, nbytes: size_t) -> ssize_t>,
pub fsync: Option<unsafe extern "C" fn(filp: *mut vfs_file_t) -> c_int>,
}
Expand description
@brief Operations on open files
Similar, but not equal, to struct file_operations in Linux
Fields§
§close: Option<unsafe extern "C" fn(filp: *mut vfs_file_t) -> c_int>
@brief Close an open file
This function must perform any necessary clean ups and flush any internal buffers in the file system driver.
If an error occurs, the file will still be considered closed by the VFS layer. Therefore, the proper clean up must still be performed by the file system driver before returning any error code.
@note This implementation does not consider @c -EINTR a special return code, the file is still considered closed.
@param[in] filp pointer to open file
@return 0 on success @return <0 on error, the file is considered closed anyway
fcntl: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, cmd: c_int, arg: c_int) -> c_int>
@brief Query/set options on an open file
@param[in] filp pointer to open file @param[in] cmd fcntl command, see man 3p fcntl @param[in] arg argument to fcntl command, see man 3p fcntl
@return 0 on success @return <0 on error
fstat: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, buf: *mut stat) -> c_int>
@brief Get status of an open file
@param[in] filp pointer to open file @param[out] buf pointer to stat struct to fill
@return 0 on success @return <0 on error
lseek: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, off: off_t, whence: c_int) -> off_t>
@brief Seek to position in file
@p whence determines the function of the seek and should be set to one of the following values:
- @c SEEK_SET: Seek to absolute offset @p off
- @c SEEK_CUR: Seek to current location + @p off
- @c SEEK_END: Seek to end of file + @p off
@param[in] filp pointer to open file @param[in] off seek offset @param[in] whence determines the seek method, see detailed description
@return the new seek location in the file on success @return <0 on error
open: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, name: *const c_char, flags: c_int, mode: mode_t) -> c_int>
@brief Attempt to open a file in the file system at rel_path
A file system driver should perform the necessary checks for file existence etc in this function.
The VFS layer will initialize the contents of @p *filp so that @c filp->f_op points to the mounted file system’s @c vfs_file_ops_t. @c filp->private_data.ptr will be initialized to NULL, @c filp->pos will be set to 0.
@note @p name is an absolute path inside the file system, @p abs_path is the path to the file in the VFS, example: @p abs_path = “/mnt/hd/foo/bar”, @p name = “/foo/bar”
@note @p name and @p abs_path may point to different locations within the same const char array and the strings may overlap
@param[in] filp pointer to open file @param[in] name null-terminated name of the file to open, relative to the file system root, including a leading slash @param[in] flags flags for opening, see man 2 open, man 3p open @param[in] mode mode for creating a new file, see man 2 open, man 3p open
@return 0 on success @return <0 on error
read: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, dest: *mut c_void, nbytes: size_t) -> ssize_t>
@brief Read bytes from an open file
@param[in] filp pointer to open file @param[in] dest pointer to destination buffer @param[in] nbytes maximum number of bytes to read
@return number of bytes read on success @return <0 on error
write: Option<unsafe extern "C" fn(filp: *mut vfs_file_t, src: *const c_void, nbytes: size_t) -> ssize_t>
@brief Write bytes to an open file
@param[in] filp pointer to open file @param[in] src pointer to source buffer @param[in] nbytes maximum number of bytes to write
@return number of bytes written on success @return <0 on error
fsync: Option<unsafe extern "C" fn(filp: *mut vfs_file_t) -> c_int>
@brief Synchronize a file on storage Any pending writes are written out to storage.
@param[in] filp pointer to open file
@return 0 on success @return <0 on error
Trait Implementations§
Source§impl Clone for vfs_file_ops
impl Clone for vfs_file_ops
Source§fn clone(&self) -> vfs_file_ops
fn clone(&self) -> vfs_file_ops
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for vfs_file_ops
impl Debug for vfs_file_ops
Source§impl Default for vfs_file_ops
impl Default for vfs_file_ops
Source§fn default() -> vfs_file_ops
fn default() -> vfs_file_ops
impl Copy for vfs_file_ops
Auto Trait Implementations§
impl Freeze for vfs_file_ops
impl RefUnwindSafe for vfs_file_ops
impl Send for vfs_file_ops
impl Sync for vfs_file_ops
impl Unpin for vfs_file_ops
impl UnwindSafe for vfs_file_ops
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes