Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
fs_file_system_t Struct Reference

File System interface structure. More...

#include <fs_sys.h>

Data Fields

File operations
int(* open )(struct fs_file_t *filp, const char *fs_path, fs_mode_t flags)
 Opens or creates a file, depending on flags given.
 
ssize_t(* read )(struct fs_file_t *filp, void *dest, size_t nbytes)
 Reads nbytes number of bytes.
 
ssize_t(* write )(struct fs_file_t *filp, const void *src, size_t nbytes)
 Writes nbytes number of bytes.
 
int(* lseek )(struct fs_file_t *filp, off_t off, int whence)
 Moves the file position to a new location in the file.
 
off_t(* tell )(struct fs_file_t *filp)
 Retrieves the current position in the file.
 
int(* truncate )(struct fs_file_t *filp, off_t length)
 Truncates/expands the file to the new length.
 
int(* sync )(struct fs_file_t *filp)
 Flushes the cache of an open file.
 
int(* close )(struct fs_file_t *filp)
 Flushes the associated stream and closes the file.
 
Directory operations
int(* opendir )(struct fs_dir_t *dirp, const char *fs_path)
 Opens an existing directory specified by the path.
 
int(* readdir )(struct fs_dir_t *dirp, struct fs_dirent *entry)
 Reads directory entries of an open directory.
 
int(* closedir )(struct fs_dir_t *dirp)
 Closes an open directory.
 
File system level operations
int(* mount )(struct fs_mount_t *mountp)
 Mounts a file system.
 
int(* unmount )(struct fs_mount_t *mountp)
 Unmounts a file system.
 
int(* unlink )(struct fs_mount_t *mountp, const char *name)
 Deletes the specified file or directory.
 
int(* rename )(struct fs_mount_t *mountp, const char *from, const char *to)
 Renames a file or directory.
 
int(* mkdir )(struct fs_mount_t *mountp, const char *name)
 Creates a new directory using specified path.
 
int(* stat )(struct fs_mount_t *mountp, const char *path, struct fs_dirent *entry)
 Checks the status of a file or directory specified by the path.
 
int(* statvfs )(struct fs_mount_t *mountp, const char *path, struct fs_statvfs *stat)
 Returns the total and available space on the file system volume.
 
int(* mkfs )(uintptr_t dev_id, void *cfg, int flags)
 Formats a device to specified file system type.
 

Detailed Description

File System interface structure.

Field Documentation

◆ close

int(* fs_file_system_t::close) (struct fs_file_t *filp)

Flushes the associated stream and closes the file.

Parameters
filpFile to close.
Returns
0 on success, negative errno code on fail.

◆ closedir

int(* fs_file_system_t::closedir) (struct fs_dir_t *dirp)

Closes an open directory.

Parameters
dirpDirectory to close.
Returns
0 on success, negative errno code on fail.

◆ lseek

int(* fs_file_system_t::lseek) (struct fs_file_t *filp, off_t off, int whence)

Moves the file position to a new location in the file.

Parameters
filpFile to move.
offRelative offset from the position specified by whence.
whencePosition in the file. Possible values: SEEK_CUR, SEEK_SET, SEEK_END.
Returns
New position in the file or negative errno code on fail.

◆ mkdir

int(* fs_file_system_t::mkdir) (struct fs_mount_t *mountp, const char *name)

Creates a new directory using specified path.

Parameters
mountpMount point.
namePath to the directory to create.
Returns
0 on success, negative errno code on fail.

◆ mkfs

int(* fs_file_system_t::mkfs) (uintptr_t dev_id, void *cfg, int flags)

Formats a device to specified file system type.

Available only if CONFIG_FILE_SYSTEM_MKFS is enabled.

Parameters
dev_idDevice identifier.
cfgFile system configuration.
flagsFormatting flags.
Returns
0 on success, negative errno code on fail.
Note
This operation destroys existing data on the target device.

◆ mount

int(* fs_file_system_t::mount) (struct fs_mount_t *mountp)

Mounts a file system.

Parameters
mountpMount point.
Returns
0 on success, negative errno code on fail.

◆ open

int(* fs_file_system_t::open) (struct fs_file_t *filp, const char *fs_path, fs_mode_t flags)

Opens or creates a file, depending on flags given.

Parameters
filpFile to open/create.
fs_pathPath to the file.
flagsFlags for opening/creating the file.
Returns
0 on success, negative errno code on fail.

◆ opendir

int(* fs_file_system_t::opendir) (struct fs_dir_t *dirp, const char *fs_path)

Opens an existing directory specified by the path.

Parameters
dirpDirectory to open.
fs_pathPath to the directory.
Returns
0 on success, negative errno code on fail.

◆ read

ssize_t(* fs_file_system_t::read) (struct fs_file_t *filp, void *dest, size_t nbytes)

Reads nbytes number of bytes.

Parameters
filpFile to read from.
destDestination buffer.
nbytesNumber of bytes to read.
Returns
Number of bytes read on success, negative errno code on fail.

◆ readdir

int(* fs_file_system_t::readdir) (struct fs_dir_t *dirp, struct fs_dirent *entry)

Reads directory entries of an open directory.

Parameters
dirpDirectory to read from.
entryNext directory entry in the dirp directory.
Returns
0 on success, negative errno code on fail.

◆ rename

int(* fs_file_system_t::rename) (struct fs_mount_t *mountp, const char *from, const char *to)

Renames a file or directory.

Parameters
mountpMount point.
fromPath to the file or directory to rename.
toNew name of the file or directory.
Returns
0 on success, negative errno code on fail.

◆ stat

int(* fs_file_system_t::stat) (struct fs_mount_t *mountp, const char *path, struct fs_dirent *entry)

Checks the status of a file or directory specified by the path.

Parameters
mountpMount point.
pathPath to the file or directory.
entryDirectory entry.
Returns
0 on success, negative errno code on fail.

◆ statvfs

int(* fs_file_system_t::statvfs) (struct fs_mount_t *mountp, const char *path, struct fs_statvfs *stat)

Returns the total and available space on the file system volume.

Parameters
mountpMount point.
pathPath to the file or directory.
statFile system statistics.
Returns
0 on success, negative errno code on fail.

◆ sync

int(* fs_file_system_t::sync) (struct fs_file_t *filp)

Flushes the cache of an open file.

Parameters
filpFile to flush.
Returns
0 on success, negative errno code on fail.

◆ tell

off_t(* fs_file_system_t::tell) (struct fs_file_t *filp)

Retrieves the current position in the file.

Parameters
filpFile to get the current position from.
Returns
Current position in the file or negative errno code on fail.

◆ truncate

int(* fs_file_system_t::truncate) (struct fs_file_t *filp, off_t length)

Truncates/expands the file to the new length.

Parameters
filpFile to truncate/expand.
lengthNew length of the file.
Returns
0 on success, negative errno code on fail.

◆ unlink

int(* fs_file_system_t::unlink) (struct fs_mount_t *mountp, const char *name)

Deletes the specified file or directory.

Parameters
mountpMount point.
namePath to the file or directory to delete.
Returns
0 on success, negative errno code on fail.

◆ unmount

int(* fs_file_system_t::unmount) (struct fs_mount_t *mountp)

Unmounts a file system.

Parameters
mountpMount point.
Returns
0 on success, negative errno code on fail.

◆ write

ssize_t(* fs_file_system_t::write) (struct fs_file_t *filp, const void *src, size_t nbytes)

Writes nbytes number of bytes.

Parameters
filpFile to write to.
srcSource buffer.
nbytesNumber of bytes to write.
Returns
Number of bytes written on success, negative errno code on fail.

The documentation for this struct was generated from the following file: