riot_sys::bindgen

Struct vfs_file_ops

Source
#[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

Source§

fn clone(&self) -> vfs_file_ops

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for vfs_file_ops

Source§

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

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

impl Default for vfs_file_ops

Source§

fn default() -> vfs_file_ops

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

impl Copy for vfs_file_ops

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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>,

Source§

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

Source§

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.

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