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 <stdatomic.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/statvfs.h>
#include "sched.h"
#include "clist.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 VFS_MAX_OPEN_FILES   (16)
 Maximum number of simultaneous open files.
 
#define VFS_DIR_BUFFER_SIZE
 Size of buffer space in vfs_DIR. More...
 
#define VFS_FILE_BUFFER_SIZE
 Size of buffer space in vfs_file_t. More...
 
#define VFS_NAME_MAX   (31)
 Maximum length of the name in a vfs_dirent_t (not including terminating null) More...
 
#define VFS_ANY_FD   (-1)
 Used with vfs_bind to bind to any available fd number.
 

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. More...
 
int vfs_close (int fd)
 Close an open file. More...
 
int vfs_fcntl (int fd, int cmd, int arg)
 Query/set options on an open file. More...
 
int vfs_fstat (int fd, struct stat *buf)
 Get status of an open file. More...
 
int vfs_fstatvfs (int fd, struct statvfs *buf)
 Get file system status of the file system containing an open file. More...
 
off_t vfs_lseek (int fd, off_t off, int whence)
 Seek to position in file. More...
 
int vfs_open (const char *name, int flags, mode_t mode)
 Open a file. More...
 
ssize_t vfs_read (int fd, void *dest, size_t count)
 Read bytes from an open file. More...
 
ssize_t vfs_write (int fd, const void *src, size_t count)
 Write bytes to an open file. More...
 
int vfs_opendir (vfs_DIR *dirp, const char *dirname)
 Open a directory for reading with readdir. More...
 
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. More...
 
int vfs_closedir (vfs_DIR *dirp)
 Close an open directory. More...
 
int vfs_format (vfs_mount_t *mountp)
 Format a file system. More...
 
int vfs_mount (vfs_mount_t *mountp)
 Mount a file system. More...
 
int vfs_rename (const char *from_path, const char *to_path)
 Rename a file. More...
 
int vfs_umount (vfs_mount_t *mountp)
 Unmount a mounted file system. More...
 
int vfs_unlink (const char *name)
 Unlink (delete) a file from a mounted file system. More...
 
int vfs_mkdir (const char *name, mode_t mode)
 Create a directory on the file system. More...
 
int vfs_rmdir (const char *name)
 Remove a directory from the file system. More...
 
int vfs_stat (const char *restrict path, struct stat *restrict buf)
 Get file status. More...
 
int vfs_statvfs (const char *restrict path, struct statvfs *restrict buf)
 Get file system status. More...
 
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. More...
 
int vfs_normalize_path (char *buf, const char *path, size_t buflen)
 Normalize a path. More...
 
const vfs_mount_tvfs_iterate_mounts (const vfs_mount_t *cur)
 Iterate through all mounted file systems. More...
 
const vfs_file_tvfs_file_get (int fd)
 Get information about the file for internal purposes. More...
 
int vfs_sysop_stat_from_fstat (vfs_mount_t *mountp, const char *restrict path, struct stat *restrict buf)
 Implementation of stat using fstat More...
 
#define _MAX(a, b)   ((a) > (b) ? (a) : (b))
 MAX functions for internal use.
 
#define MAX4(a, b, c, d)   _MAX(_MAX((a), (b)), _MAX((c),(d)))
 
#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)