Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
fs.h File Reference
#include <sys/types.h>
#include <sys/dlist.h>
#include <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)
 
#define FS_MOUNT_FLAG_READ_ONLY   BIT(1)
 
#define FS_MOUNT_FLAG_AUTOMOUNT   BIT(2)
 
#define FSTAB_ENTRY_DT_MOUNT_FLAGS(node_id)
 
#define FS_FSTAB_ENTRY(node_id)   _CONCAT(z_fsmp_, node_id)
 The name under which a zephyr,fstab entry mount structure is defined. More...
 
#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. More...
 
fs_open open and creation mode flags
#define FS_O_READ   0x01
 
#define FS_O_WRITE   0x02
 
#define FS_O_RDWR   (FS_O_READ | FS_O_WRITE)
 
#define FS_O_MODE_MASK   0x03
 
#define FS_O_CREATE   0x10
 
#define FS_O_APPEND   0x20
 
#define FS_O_FLAGS_MASK   0x30
 
#define FS_O_MASK   (FS_O_MODE_MASK | FS_O_FLAGS_MASK)
 
fs_seek whence parameter values
#define FS_SEEK_SET   0
 
#define FS_SEEK_CUR   1
 
#define FS_SEEK_END   2
 

Enumerations

enum  fs_dir_entry_type { FS_DIR_ENTRY_FILE = 0 , FS_DIR_ENTRY_DIR }
 
enum  { FS_FATFS = 0 , FS_LITTLEFS , 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. More...
 
static void fs_dir_t_init (struct fs_dir_t *zdp)
 Initialize fs_dir_t object. More...
 
int fs_open (struct fs_file_t *zfp, const char *file_name, fs_mode_t flags)
 Open or create file. More...
 
int fs_close (struct fs_file_t *zfp)
 Close file. More...
 
int fs_unlink (const char *path)
 Unlink file. More...
 
int fs_rename (const char *from, const char *to)
 Rename file or directory. More...
 
ssize_t fs_read (struct fs_file_t *zfp, void *ptr, size_t size)
 Read file. More...
 
ssize_t fs_write (struct fs_file_t *zfp, const void *ptr, size_t size)
 Write file. More...
 
int fs_seek (struct fs_file_t *zfp, off_t offset, int whence)
 Seek file. More...
 
off_t fs_tell (struct fs_file_t *zfp)
 Get current file position. More...
 
int fs_truncate (struct fs_file_t *zfp, off_t length)
 Truncate or extend an open file to a given size. More...
 
int fs_sync (struct fs_file_t *zfp)
 Flush cached write data buffers of an open file. More...
 
int fs_mkdir (const char *path)
 Directory create. More...
 
int fs_opendir (struct fs_dir_t *zdp, const char *path)
 Directory open. More...
 
int fs_readdir (struct fs_dir_t *zdp, struct fs_dirent *entry)
 Directory read entry. More...
 
int fs_closedir (struct fs_dir_t *zdp)
 Directory close. More...
 
int fs_mount (struct fs_mount_t *mp)
 Mount filesystem. More...
 
int fs_unmount (struct fs_mount_t *mp)
 Unmount filesystem. More...
 
int fs_readmount (int *index, const char **name)
 Get path of mount point at index. More...
 
int fs_stat (const char *path, struct fs_dirent *entry)
 File or directory status. More...
 
int fs_statvfs (const char *path, struct fs_statvfs *stat)
 Retrieves statistics of the file system volume. More...
 
int fs_register (int type, const struct fs_file_system_t *fs)
 Register a file system. More...
 
int fs_unregister (int type, const struct fs_file_system_t *fs)
 Unregister a file system. More...