Loading...
Searching...
No Matches

VFS layer API declarations. More...

Detailed Description

VFS layer API declarations.

Author
Joakim NohlgÄrd joaki.nosp@m.m.no.nosp@m.hlgar.nosp@m.d@ei.nosp@m.stec..nosp@m.se

Definition in file vfs.h.

#include <stdint.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/statvfs.h>
#include "sched.h"
#include "clist.h"
#include "iolist.h"
#include "macros/utils.h"
#include "mtd.h"
#include "xfa.h"
+ Include dependency graph for vfs.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vfs_file_system_t
 A file system driver. More...
 
struct  vfs_mount_struct
 A mounted file system. More...
 
struct  vfs_file_t
 Information about an open file. More...
 
struct  vfs_DIR
 Internal representation of a file system directory entry. More...
 
struct  vfs_dirent_t
 User facing directory entry. More...
 
struct  vfs_file_ops
 Operations on open files. More...
 
struct  vfs_dir_ops
 Operations on open directories. More...
 
struct  vfs_file_system_ops
 Operations on mounted file systems. More...
 

Macros

#define MAX6(a, b, c, d, e, f)   MAX(MAX(MAX(MAX((a), (b)), MAX((c), (d))), (e)), (f))
 MAX6 Function to get the largest of 6 values.
 
#define VFS_MAX_OPEN_FILES   (16)
 Maximum number of simultaneous open files.
 
#define VFS_DIR_BUFFER_SIZE
 Size of buffer space in vfs_DIR.
 
#define VFS_FILE_BUFFER_SIZE
 Size of buffer space in vfs_file_t.
 
#define VFS_NAME_MAX   (31)
 Maximum length of the name in a vfs_dirent_t (not including terminating null)
 
#define VFS_ANY_FD   (-1)
 Used with vfs_bind to bind to any available fd number.
 
#define VFS_MTD(mtd)   { .dev = &mtd.base }
 Helper macro for VFS_AUTO_MOUNT.
 
#define VFS_AUTO_MOUNT(type, mtd, path, idx)
 Define an automatic mountpoint.
 
#define VFS_FS_FLAG_WANT_ABS_PATH   (1 << 0)
 File system always wants the full VFS path.
 

Typedefs

typedef struct vfs_file_ops vfs_file_ops_t
 struct vfs_file_ops typedef
 
typedef struct vfs_dir_ops vfs_dir_ops_t
 struct vfs_dir_ops typedef
 
typedef struct vfs_file_system_ops vfs_file_system_ops_t
 struct vfs_file_system_ops typedef
 
typedef struct vfs_mount_struct vfs_mount_t
 struct vfs_mount_struct typedef
 

Functions

void vfs_bind_stdio (void)
 Allocate and bind file descriptors for STDIN, STDERR, and STDOUT.
 
int vfs_close (int fd)
 Close an open file.
 
int vfs_fcntl (int fd, int cmd, int arg)
 Query/set options on an open file.
 
int vfs_fstat (int fd, struct stat *buf)
 Get status of an open file.
 
int vfs_fstatvfs (int fd, struct statvfs *buf)
 Get file system status of the file system containing an open file.
 
int vfs_dstatvfs (vfs_DIR *dirp, struct statvfs *buf)
 Get file system status of the file system containing an open directory.
 
off_t vfs_lseek (int fd, off_t off, int whence)
 Seek to position in file.
 
int vfs_open (const char *name, int flags, mode_t mode)
 Open a file.
 
ssize_t vfs_read (int fd, void *dest, size_t count)
 Read bytes from an open file.
 
ssize_t vfs_readline (int fd, char *dest, size_t count)
 Read a line from an open text file.
 
ssize_t vfs_write (int fd, const void *src, size_t count)
 Write bytes to an open file.
 
ssize_t vfs_write_iol (int fd, const iolist_t *iolist)
 Write bytes from an iolist to an open file.
 
int vfs_fsync (int fd)
 Synchronize a file on storage Any pending writes are written out to storage.
 
int vfs_opendir (vfs_DIR *dirp, const char *dirname)
 Open a directory for reading with readdir.
 
int vfs_readdir (vfs_DIR *dirp, vfs_dirent_t *entry)
 Read a single entry from the open directory dirp and advance the read position by one.
 
int vfs_closedir (vfs_DIR *dirp)
 Close an open directory.
 
int vfs_format (vfs_mount_t *mountp)
 Format a file system.
 
int vfs_format_by_path (const char *path)
 Format a file system.
 
int vfs_mount (vfs_mount_t *mountp)
 Mount a file system.
 
int vfs_mount_by_path (const char *path)
 Mount a file system with a pre-configured mount path.
 
int vfs_unmount_by_path (const char *path, bool force)
 Unmount a file system with a pre-configured mount path.
 
int vfs_rename (const char *from_path, const char *to_path)
 Rename a file.
 
int vfs_umount (vfs_mount_t *mountp, bool force)
 Unmount a mounted file system.
 
int vfs_unlink (const char *name)
 Unlink (delete) a file from a mounted file system.
 
int vfs_mkdir (const char *name, mode_t mode)
 Create a directory on the file system.
 
int vfs_rmdir (const char *name)
 Remove a directory from the file system.
 
int vfs_stat (const char *restrict path, struct stat *restrict buf)
 Get file status.
 
int vfs_statvfs (const char *restrict path, struct statvfs *restrict buf)
 Get file system status.
 
int vfs_bind (int fd, int flags, const vfs_file_ops_t *f_op, void *private_data)
 Allocate a new file descriptor and give it file operations.
 
int vfs_normalize_path (char *buf, const char *path, size_t buflen)
 Normalize a path.
 
const vfs_mount_tvfs_iterate_mounts (const vfs_mount_t *cur)
 Iterate through all mounted file systems.
 
bool vfs_iterate_mount_dirs (vfs_DIR *dir)
 Iterate through all mounted file systems by their root directories.
 
const vfs_file_tvfs_file_get (int fd)
 Get information about the file for internal purposes.
 
int vfs_sysop_stat_from_fstat (vfs_mount_t *mountp, const char *restrict path, struct stat *restrict buf)
 Implementation of stat using fstat
 

Variables

const vfs_file_ops_t mtd_vfs_ops
 MTD driver for VFS.
 
#define FATFS_VFS_DIR_BUFFER_SIZE   (1)
 VFS parameters for FAT.
 
#define FATFS_VFS_FILE_BUFFER_SIZE   (1)
 
#define LITTLEFS_VFS_DIR_BUFFER_SIZE   (1)
 VFS parameters for littlefs.
 
#define LITTLEFS_VFS_FILE_BUFFER_SIZE   (1)
 
#define LITTLEFS2_VFS_DIR_BUFFER_SIZE   (1)
 VFS parameters for littlefs2.
 
#define LITTLEFS2_VFS_FILE_BUFFER_SIZE   (1)
 
#define SPIFFS_VFS_DIR_BUFFER_SIZE   (1)
 VFS parameters for spiffs.
 
#define SPIFFS_VFS_FILE_BUFFER_SIZE   (1)
 
#define LWEXT4_VFS_DIR_BUFFER_SIZE   (308)
 VFS parameters for lwext4.
 
#define LWEXT4_VFS_FILE_BUFFER_SIZE   (32)
 sizeof(ext4_file)
 
#define NANOCOAP_FS_VFS_DIR_BUFFER_SIZE    (4 + CONFIG_SOCK_URLPATH_MAXLEN)
 VFS parameters for nanoCoAP FS.
 
#define NANOCOAP_FS_VFS_FILE_BUFFER_SIZE    (4 + CONFIG_SOCK_URLPATH_MAXLEN)
 sizeof(nanocoap_fs_file_t)