#[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, abs_path: *const c_char) -> 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, abs_path: *const c_char) -> 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 @param[in] abs_path null-terminated name of the file to open, relative to the VFS root (“/”)

@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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.