PebbleOS v4.44.0-105-g1dd754433
Loading...
Searching...
No Matches
fs.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <pbl/fs/fs_sys.h>
#include <pbl/util/bits.h>
#include <sys/types.h>

Data Structures

struct  pbl_fs_dirent
 Directory entry, see pbl_fs_readdir() and pbl_fs_stat(). More...
 
struct  pbl_fs_statvfs
 Space of a file system, see pbl_fs_statvfs(). More...
 
struct  pbl_fs_file
 An open file, see pbl_fs_open(). More...
 
struct  pbl_fs_dir
 An open directory, see pbl_fs_opendir(). More...
 

Macros

#define PBL_FS_NAME_MAX   255
 Maximum length of a file name, without the NUL terminator.
 
#define PBL_FS_O_READ   PBL_BIT(0)
 Open for reading.
 
#define PBL_FS_O_WRITE   PBL_BIT(1)
 Open for writing.
 
#define PBL_FS_O_RDWR   (PBL_FS_O_READ | PBL_FS_O_WRITE)
 Open for reading and writing.
 
#define PBL_FS_O_CREATE   PBL_BIT(2)
 Create the file, empty, if it does not exist.
 
#define PBL_FS_O_REPLACE   PBL_BIT(3)
 Write a new, empty version of the file that replaces the current one on close.
 
#define PBL_FS_O_FORMAT(n)   PBL_BIT(16 + (n))
 Format-specific open flag n, from 0 to 15.
 
#define PBL_FS_SEEK_SET   0
 pbl_fs_seek() from the start of the file.
 
#define PBL_FS_SEEK_CUR   1
 pbl_fs_seek() from the current position.
 
#define PBL_FS_SEEK_END   2
 pbl_fs_seek() from the end of the file.
 
#define PBL_FS_WATCH_CLOSED   PBL_BIT(0)
 pbl_fs_watch_add() event: a file opened for writing was closed.
 
#define PBL_FS_WATCH_REMOVED   PBL_BIT(1)
 pbl_fs_watch_add() event: the file was removed.
 
#define PBL_FS_WATCH_ALL   (PBL_FS_WATCH_CLOSED | PBL_FS_WATCH_REMOVED)
 pbl_fs_watch_add() events: all of them.
 

Typedefs

typedef void(* pbl_fs_watch_cb_t) (void *user_data)
 Callback of pbl_fs_watch_add().
 

Enumerations

enum  pbl_fs_dir_entry_type { PBL_FS_DIR_ENTRY_FILE , PBL_FS_DIR_ENTRY_DIR }
 Type of a directory entry. More...
 

Functions

int pbl_fs_mount (struct pbl_fs_mount *mp)
 Mount a file system.
 
int pbl_fs_unmount (struct pbl_fs_mount *mp)
 Unmount a file system.
 
int pbl_fs_format (const char *mnt_point)
 Erase every file of a mounted file system.
 
int pbl_fs_open (struct pbl_fs_file *file, const char *path, uint32_t flags)
 Open a file.
 
ssize_t pbl_fs_read (struct pbl_fs_file *file, void *buf, size_t len)
 Read from the current position, then advance it.
 
ssize_t pbl_fs_write (struct pbl_fs_file *file, const void *buf, size_t len)
 Write at the current position, then advance it.
 
off_t pbl_fs_seek (struct pbl_fs_file *file, off_t offset, int whence)
 Set the current position.
 
off_t pbl_fs_tell (struct pbl_fs_file *file)
 Get the current position.
 
off_t pbl_fs_size (struct pbl_fs_file *file)
 Get the size of an open file.
 
int pbl_fs_truncate (struct pbl_fs_file *file, off_t length)
 Set the size of a file.
 
int pbl_fs_sync (struct pbl_fs_file *file)
 Flush cached data of a file to the storage.
 
int pbl_fs_close (struct pbl_fs_file *file)
 Close a file.
 
int pbl_fs_unlink (const char *path)
 Remove a file.
 
int pbl_fs_rename (const char *from, const char *to)
 Rename a file, replacing to if it exists.
 
int pbl_fs_mkdir (const char *path)
 Create a directory.
 
int pbl_fs_stat (const char *path, struct pbl_fs_dirent *entry)
 Get the type and size of a file or directory.
 
int pbl_fs_statvfs (const char *path, struct pbl_fs_statvfs *stat)
 Get the space of the file system holding a path.
 
int pbl_fs_opendir (struct pbl_fs_dir *dir, const char *path)
 Open a directory.
 
int pbl_fs_readdir (struct pbl_fs_dir *dir, struct pbl_fs_dirent *entry)
 Read the next entry of a directory.
 
int pbl_fs_closedir (struct pbl_fs_dir *dir)
 Close a directory.
 
struct pbl_fs_watch * pbl_fs_watch_add (const char *path, uint32_t events, pbl_fs_watch_cb_t cb, void *user_data)
 Watch a file for changes.
 
void pbl_fs_watch_remove (struct pbl_fs_watch *watch)
 Stop watching a file.