Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
fs.h File Reference
#include <sys/types.h>
#include <zephyr/sys/dlist.h>
#include <zephyr/fs/fs_interface.h>

Go to the source code of this file.

Data Structures

struct  fs_mount_t
 File system mount info structure. More...
 
struct  fs_dirent
 Structure to receive file or directory information. More...
 
struct  fs_statvfs
 Structure to receive volume statistics. More...
 

Macros

#define FS_MOUNT_FLAG_NO_FORMAT   BIT(0)
 Flag prevents formatting device if requested file system not found.
 
#define FS_MOUNT_FLAG_READ_ONLY   BIT(1)
 Flag makes mounted file system read-only.
 
#define FS_MOUNT_FLAG_AUTOMOUNT   BIT(2)
 Flag used in pre-defined mount structures that are to be mounted on startup.
 
#define FS_MOUNT_FLAG_USE_DISK_ACCESS   BIT(3)
 Flag requests file system driver to use Disk Access API.
 
#define FSTAB_ENTRY_DT_MOUNT_FLAGS(node_id)
 Get the common mount flags for an fstab entry.
 
#define FS_FSTAB_ENTRY(node_id)   _CONCAT(z_fsmp_, node_id)
 The name under which a zephyr,fstab entry mount structure is defined.
 
#define FS_FSTAB_DECLARE_ENTRY(node_id)    extern struct fs_mount_t FS_FSTAB_ENTRY(node_id)
 Generate a declaration for the externally defined fstab entry.
 
fs_open open and creation mode flags
#define FS_O_READ   0x01
 Open for read flag.
 
#define FS_O_WRITE   0x02
 Open for write flag.
 
#define FS_O_RDWR   (FS_O_READ | FS_O_WRITE)
 Open for read-write flag combination.
 
#define FS_O_MODE_MASK   0x03
 Bitmask for read and write flags.
 
#define FS_O_CREATE   0x10
 Create file if it does not exist.
 
#define FS_O_APPEND   0x20
 Open/create file for append.
 
#define FS_O_TRUNC   0x40
 Truncate the file while opening.
 
#define FS_O_FLAGS_MASK   0x70
 Bitmask for open/create flags.
 
#define FS_O_MASK   (FS_O_MODE_MASK | FS_O_FLAGS_MASK)
 Bitmask for open flags.
 
fs_seek whence parameter values
#define FS_SEEK_SET   0
 Seek from the beginning of file.
 
#define FS_SEEK_CUR   1
 Seek from a current position.
 
#define FS_SEEK_END   2
 Seek from the end of file.
 

Enumerations

enum  fs_dir_entry_type { FS_DIR_ENTRY_FILE = 0 , FS_DIR_ENTRY_DIR }
 Enumeration for directory entry types. More...
 
enum  { FS_FATFS = 0 , FS_LITTLEFS , FS_EXT2 , FS_TYPE_EXTERNAL_BASE }
 Enumeration to uniquely identify file system types. More...
 

Functions

static void fs_file_t_init (struct fs_file_t *zfp)
 Initialize fs_file_t object.
 
static void fs_dir_t_init (struct fs_dir_t *zdp)
 Initialize fs_dir_t object.
 
int fs_open (struct fs_file_t *zfp, const char *file_name, fs_mode_t flags)
 Open or create file.
 
int fs_close (struct fs_file_t *zfp)
 Close file.
 
int fs_unlink (const char *path)
 Unlink file.
 
int fs_rename (const char *from, const char *to)
 Rename file or directory.
 
ssize_t fs_read (struct fs_file_t *zfp, void *ptr, size_t size)
 Read file.
 
ssize_t fs_write (struct fs_file_t *zfp, const void *ptr, size_t size)
 Write file.
 
int fs_seek (struct fs_file_t *zfp, off_t offset, int whence)
 Seek file.
 
off_t fs_tell (struct fs_file_t *zfp)
 Get current file position.
 
int fs_truncate (struct fs_file_t *zfp, off_t length)
 Truncate or extend an open file to a given size.
 
int fs_sync (struct fs_file_t *zfp)
 Flush cached write data buffers of an open file.
 
int fs_mkdir (const char *path)
 Directory create.
 
int fs_opendir (struct fs_dir_t *zdp, const char *path)
 Directory open.
 
int fs_readdir (struct fs_dir_t *zdp, struct fs_dirent *entry)
 Directory read entry.
 
int fs_closedir (struct fs_dir_t *zdp)
 Directory close.
 
int fs_mount (struct fs_mount_t *mp)
 Mount filesystem.
 
int fs_unmount (struct fs_mount_t *mp)
 Unmount filesystem.
 
int fs_readmount (int *index, const char **name)
 Get path of mount point at index.
 
int fs_stat (const char *path, struct fs_dirent *entry)
 File or directory status.
 
int fs_statvfs (const char *path, struct fs_statvfs *stat)
 Retrieves statistics of the file system volume.
 
int fs_mkfs (int fs_type, uintptr_t dev_id, void *cfg, int flags)
 Create fresh file system.
 
int fs_register (int type, const struct fs_file_system_t *fs)
 Register a file system.
 
int fs_unregister (int type, const struct fs_file_system_t *fs)
 Unregister a file system.