Operations on open files.
More...
Operations on open files.
Similar, but not equal, to struct file_operations in Linux
Definition at line 464 of file vfs.h.
#include <vfs.h>
|
| int(* | close )(vfs_file_t *filp) |
| | Close an open file.
|
| |
| int(* | fcntl )(vfs_file_t *filp, int cmd, int arg) |
| | Query/set options on an open file.
|
| |
| int(* | fstat )(vfs_file_t *filp, struct stat *buf) |
| | Get status of an open file.
|
| |
| off_t(* | lseek )(vfs_file_t *filp, off_t off, int whence) |
| | Seek to position in file.
|
| |
| int(* | open )(vfs_file_t *filp, const char *name, int flags, mode_t mode) |
| | Attempt to open a file in the file system at rel_path.
|
| |
| ssize_t(* | read )(vfs_file_t *filp, void *dest, size_t nbytes) |
| | Read bytes from an open file.
|
| |
| ssize_t(* | write )(vfs_file_t *filp, const void *src, size_t nbytes) |
| | Write bytes to an open file.
|
| |
| int(* | fsync )(vfs_file_t *filp) |
| | Synchronize a file on storage Any pending writes are written out to storage.
|
| |
◆ close
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
-EINTR a special return code, the file is still considered closed.
- Parameters
-
| [in] | filp | pointer to open file |
- Return values
-
| 0 | on success |
| <0 | on error, the file is considered closed anyway |
Definition at line 483 of file vfs.h.
◆ fcntl
| int(* vfs_file_ops::fcntl) (vfs_file_t *filp, int cmd, int arg) |
Query/set options on an open file.
- Parameters
-
| [in] | filp | pointer to open file |
| [in] | cmd | fcntl command, see man 3p fcntl |
| [in] | arg | argument to fcntl command, see man 3p fcntl |
- Return values
-
Definition at line 495 of file vfs.h.
◆ fstat
| int(* vfs_file_ops::fstat) (vfs_file_t *filp, struct stat *buf) |
Get status of an open file.
- Parameters
-
| [in] | filp | pointer to open file |
| [out] | buf | pointer to stat struct to fill |
- Return values
-
Definition at line 506 of file vfs.h.
◆ fsync
Synchronize a file on storage Any pending writes are written out to storage.
- Parameters
-
| [in] | filp | pointer to open file |
- Return values
-
Definition at line 589 of file vfs.h.
◆ lseek
| off_t(* vfs_file_ops::lseek) (vfs_file_t *filp, off_t off, int whence) |
Seek to position in file.
whence determines the function of the seek and should be set to one of the following values:
SEEK_SET: Seek to absolute offset off
SEEK_CUR: Seek to current location + off
SEEK_END: Seek to end of file + off
- Parameters
-
| [in] | filp | pointer to open file |
| [in] | off | seek offset |
| [in] | whence | determines the seek method, see detailed description |
- Returns
- the new seek location in the file on success
- Return values
-
Definition at line 525 of file vfs.h.
◆ open
| int(* vfs_file_ops::open) (vfs_file_t *filp, const char *name, int flags, mode_t mode) |
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 *filp so that filp->f_op points to the mounted file system's vfs_file_ops_t. filp->private_data.ptr will be initialized to NULL, filp->pos will be set to 0.
- Note
name is an absolute path inside the file system, abs_path is the path to the file in the VFS, example: abs_path = "/mnt/hd/foo/bar", name = "/foo/bar"
-
name and abs_path may point to different locations within the same const char array and the strings may overlap
- Parameters
-
| [in] | filp | pointer to open file |
| [in] | name | null-terminated name of the file to open, relative to the file system root, including a leading slash |
| [in] | flags | flags for opening, see man 2 open, man 3p open |
| [in] | mode | mode for creating a new file, see man 2 open, man 3p open |
- Return values
-
Definition at line 554 of file vfs.h.
◆ read
| ssize_t(* vfs_file_ops::read) (vfs_file_t *filp, void *dest, size_t nbytes) |
Read bytes from an open file.
- Parameters
-
| [in] | filp | pointer to open file |
| [in] | dest | pointer to destination buffer |
| [in] | nbytes | maximum number of bytes to read |
- Returns
- number of bytes read on success
- Return values
-
Definition at line 566 of file vfs.h.
◆ write
| ssize_t(* vfs_file_ops::write) (vfs_file_t *filp, const void *src, size_t nbytes) |
Write bytes to an open file.
- Parameters
-
| [in] | filp | pointer to open file |
| [in] | src | pointer to source buffer |
| [in] | nbytes | maximum number of bytes to write |
- Returns
- number of bytes written on success
- Return values
-
Definition at line 578 of file vfs.h.
The documentation for this struct was generated from the following file: