16#ifndef CARDSIGHT_VFS_H
17#define CARDSIGHT_VFS_H
27#define VFS_NAME_MAX 255
29#define VFS_PATH_MAX 512
31#define VFS_BLK_NAME 32
34#define VFS_O_READ 0x01
36#define VFS_O_WRITE 0x02
38#define VFS_O_CREATE 0x04
40#define VFS_O_EXCL 0x08
42#define VFS_O_TRUNC 0x10
44#define VFS_O_APPEND 0x20
47#define VFS_FS_NODEV 0x1
49#define VFS_FS_READ_ONLY 0x2
51#define VFS_MOUNT_READ_ONLY 0x1
53#define VFS_MOUNT_PROBE 0x2
101 int (*
open)(
void *priv,
const char *path, uint32_t
flags,
void **file);
102 int (*
read)(
void *file,
void *buffer,
size_t length);
103 int (*
write)(
void *file,
const void *buffer,
size_t length);
104 int64_t (*
seek)(
void *file, int64_t offset,
int whence);
110 int (*
mkdir)(
void *priv,
const char *path);
111 int (*
unlink)(
void *priv,
const char *path);
112 int (*
rmdir)(
void *priv,
const char *path);
113 int (*
rename)(
void *priv,
const char *from,
const char *to);
114 int (*
opendir)(
void *priv,
const char *path,
void **dir);
117 int (*
statfs)(
void *priv, uint64_t *total, uint64_t *free_bytes);
262int vfs_read(
int descriptor,
void *buffer,
size_t length);
272int vfs_write(
int descriptor,
const void *buffer,
size_t length);
282int64_t
vfs_lseek(
int descriptor, int64_t offset,
int whence);
Block devices: disks made by a driver, the partitions found in their table, and the checked transfers...
#define BDEV_LABEL_LEN
Longest partition label in bytes.
Definition blkdev.h:26
One openable view of a disk: the whole disk or one partition.
Definition blkdev.h:60
One directory entry as returned by vfs_readdir().
Definition vfs.h:70
struct vfs_stat st
Definition vfs.h:72
char name[VFS_NAME_MAX+1]
Definition vfs.h:71
Operations a file system type provides to the VFS.
Definition vfs.h:94
int(* statfs)(void *priv, uint64_t *total, uint64_t *free_bytes)
Definition vfs.h:117
int(* umount)(void *priv)
Definition vfs.h:98
int(* format)(struct block_device *bdev, const char *label, uint32_t arg)
Definition vfs.h:100
int(* fstat)(void *file, struct vfs_stat *st)
Definition vfs.h:108
int(* stat)(void *priv, const char *path, struct vfs_stat *st)
Definition vfs.h:109
int(* rename)(void *priv, const char *from, const char *to)
Definition vfs.h:113
int(* unlink)(void *priv, const char *path)
Definition vfs.h:111
int(* volume_info)(void *priv, struct vfs_volume_info *info)
Definition vfs.h:118
int64_t(* seek)(void *file, int64_t offset, int whence)
Definition vfs.h:104
uint32_t flags
Definition vfs.h:96
int(* write)(void *file, const void *buffer, size_t length)
Definition vfs.h:103
int(* opendir)(void *priv, const char *path, void **dir)
Definition vfs.h:114
int(* close)(void *file)
Definition vfs.h:107
int(* flush)(void *file)
Definition vfs.h:106
int(* sync)(void *priv)
Definition vfs.h:99
int(* mkdir)(void *priv, const char *path)
Definition vfs.h:110
int(* open)(void *priv, const char *path, uint32_t flags, void **file)
Definition vfs.h:101
int(* closedir)(void *dir)
Definition vfs.h:116
int(* mount)(struct block_device *bdev, uint32_t flags, void **priv)
Definition vfs.h:97
int(* readdir)(void *dir, struct vfs_dirent *entry)
Definition vfs.h:115
const char * name
Definition vfs.h:95
int(* truncate)(void *file, uint64_t size)
Definition vfs.h:105
int(* rmdir)(void *priv, const char *path)
Definition vfs.h:112
int(* read)(void *file, void *buffer, size_t length)
Definition vfs.h:102
One entry of the mount table.
Definition vfs.h:419
char blk[VFS_BLK_NAME]
Definition vfs.h:421
char target[VFS_NAME_MAX+1]
Definition vfs.h:420
const char * fstype
Definition vfs.h:422
uint32_t open_count
Definition vfs.h:423
Metadata of a file or directory.
Definition vfs.h:58
uint64_t alloc_size
Definition vfs.h:60
uint64_t size
Definition vfs.h:59
bool read_only
Definition vfs.h:62
bool dir
Definition vfs.h:61
uint16_t time
Definition vfs.h:64
uint16_t date
Definition vfs.h:63
Description of a volume found by vfs_probe().
Definition vfs.h:78
uint64_t free_bytes
Definition vfs.h:82
bool read_only
Definition vfs.h:85
char label[BDEV_LABEL_LEN]
Definition vfs.h:80
uint64_t total_bytes
Definition vfs.h:81
uint32_t cluster_bytes
Definition vfs.h:84
uint64_t used_inodes
Definition vfs.h:83
char fstype[16]
Definition vfs.h:79
int64_t vfs_lseek(int descriptor, int64_t offset, int whence)
Move the file position of an open descriptor.
int vfs_probe(const char *blk, struct vfs_volume_info *info)
Probe an unmounted block device.
int vfs_mount(const char *blk, const char *target, const char *fstype)
Mount a block device or a nodev file system at a target with default flags.
int vfs_rename(const char *from, const char *to)
Rename or move an entry.
int vfs_unregister(const struct vfs_fs *fs)
Remove a file system type from the VFS.
struct vfs_dir * vfs_opendir(const char *path, int *error)
Open a directory.
int vfs_mount_get(uint32_t index, struct vfs_mount_info *info)
Report one mount table entry by ordinal.
int vfs_fsync(int descriptor)
Flush an open file to its medium.
int vfs_umount(const char *target)
Unmount the file system at a target.
int vfs_sync_mount(const char *target)
Flush every file on one mount.
int vfs_unlink(const char *path)
Remove a file.
int vfs_rmdir(const char *path)
Remove an empty directory.
int vfs_ext_register(void)
Register the ext types: ext2, ext3, ext4.
#define VFS_NAME_MAX
Longest file name, excluding the terminating zero.
Definition vfs.h:27
void vfs_os_unlock(void)
Release the recursive VFS lock.
int vfs_register(const struct vfs_fs *fs)
Add a file system type to the VFS.
void vfs_set_format_progress(void(*callback)(void *context, uint64_t done, uint64_t total), void *context)
Observe vfs_format() progress.
int vfs_ff_register(void)
Register the FatFs types: fat, fat32, exfat.
int vfs_write(int descriptor, const void *buffer, size_t length)
Write to an open descriptor.
int vfs_mkdir(const char *path)
Create a directory.
int vfs_fstat(int descriptor, struct vfs_stat *st)
Report the metadata of an open file.
int vfs_mount_ex(const char *blk, const char *target, const char *fstype, uint32_t flags)
Mount a block device or a nodev file system at a target.
int vfs_open(const char *path, uint32_t flags)
Open a file and return a VFS descriptor.
int vfs_ftruncate(int descriptor, uint64_t size)
Resize an open file.
int vfs_readdir(struct vfs_dir *dir, struct vfs_dirent *entry)
Read the next entry of an open directory.
int vfs_sync(void)
Write everything out on every mount.
void vfs_format_expect(struct block_device *bdev, uint64_t sectors)
Declare how many sectors the running format will write.
int vfs_stat(const char *path, struct vfs_stat *st)
Report the metadata of a path.
int vfs_close(int descriptor)
Close a descriptor.
int vfs_statfs(const char *path, uint64_t *total, uint64_t *free_bytes)
Report the capacity of the file system holding a path.
int vfs_format(const char *blk, const char *fstype, const char *label, uint32_t arg)
Make a new file system on an unmounted block device.
int vfs_read(int descriptor, void *buffer, size_t length)
Read from an open descriptor.
void vfs_os_lock(void)
Take the recursive VFS lock, waiting without a bound.
#define VFS_BLK_NAME
Longest block device name in a mount description.
Definition vfs.h:31
void vfs_closedir(struct vfs_dir *dir)
Close a directory and free its wrapper.
void vfs_format_report_write(struct block_device *bdev, uint64_t sectors)
Report sectors written by a formatter.