Files | |
file | devfs.c |
Devices file system. | |
file | devfs_ops.c |
Implementation of VFS operations for the devfs file system server. | |
file | fat.c |
FAT file system driver for HelenOS. | |
file | fat_dentry.c |
Functions that work with FAT directory entries. | |
file | fat_fat.c |
Functions that manipulate the File Allocation Tables. | |
file | fat_idx.c |
Layer for translating FAT entities to VFS node indices. | |
file | fat_ops.c |
Implementation of VFS operations for the FAT file system server. | |
file | loader.h |
Program loader interface. | |
file | mkfat.c |
Tool for creating new FAT file systems. | |
file | pcb.h |
Program Control Block interface. | |
file | tmpfs.c |
File system driver for in-memory file system. | |
file | tmpfs_dump.c |
Support for loading TMPFS file system dump. | |
file | tmpfs_ops.c |
Implementation of VFS operations for the TMPFS file system server. | |
file | vfs_file.c |
Various operations on files have their home in this file. | |
file | vfs_lookup.c |
file | vfs_node.c |
Various operations on VFS nodes have their home in this file. | |
file | vfs_ops.c |
Operations that VFS offers to its clients. | |
file | vfs_register.c |
Data Structures | |
struct | devfs_node_t |
struct | device_t |
Opened devices structure. More... | |
struct | fat_bs |
struct | fat_bs |
struct | fat_cfg |
Configurable file-system parameters. More... | |
struct | fat_dentry_t |
struct | fat_idx_t |
FAT index structure. More... | |
struct | fat_node |
FAT in-core node. More... | |
struct | fat_params |
Derived file-system parameters. More... | |
struct | freed_t |
Each instance of this type describes one interval of freed VFS indices. More... | |
struct | fs_info_t |
A structure like this will be allocated for each registered file system. More... | |
struct | loader_t |
Abstraction of a loader connection. More... | |
struct | pcb_t |
Program Control Block. More... | |
struct | plb_entry_t |
Each instance of this type describes one path lookup in progress. More... | |
struct | rdentry |
struct | refcnt_data |
struct | tmpfs_dentry |
struct | tmpfs_node |
struct | unused_t |
Each instance of this type describes state of all VFS indices that are currently unused. More... | |
struct | vfs_client_data_t |
struct | vfs_file_t |
Instances of this type represent an open file. More... | |
struct | vfs_lookup_res_t |
struct | vfs_node_t |
Instances of this type represent an active, in-memory VFS node and any state which may be associated with it. More... | |
struct | vfs_pair_t |
struct | vfs_triplet_t |
Defines | |
#define | BPC(bs) (BPS((bs)) * SPC((bs))) |
#define | BPS(bs) uint16_t_le2host((bs)->bps) |
#define | BS_BLOCK 0 |
#define | BS_BLOCK 0 |
#define | BS_SIZE 512 |
#define | BS_SIZE 512 |
#define | CLBN2PBN(bs, cl, bn) (SSA((bs)) + ((cl) - FAT_CLST_FIRST) * SPC((bs)) + (bn) % SPC((bs))) |
#define | DEVICES_BUCKETS 256 |
#define | DEVICES_KEY_HANDLE 0 |
#define | DEVICES_KEYS 1 |
#define | DIRENT_SIZE 32 |
#define | div_round_up(a, b) (((a) + (b) - 1) / (b)) |
Divide and round up. | |
#define | dprintf() |
#define | DPS(bs) (BPS((bs)) / sizeof(fat_dentry_t)) |
#define | FAT1 0 |
#define | FAT_ATTR_RDONLY (1 << 0) |
#define | FAT_ATTR_SUBDIR (1 << 4) |
#define | FAT_ATTR_VOLLABEL (1 << 3) |
#define | FAT_CLST_BAD 0xfff7 |
#define | FAT_CLST_FIRST 0x0002 |
#define | FAT_CLST_LAST1 0xfff8 |
#define | FAT_CLST_LAST8 0xffff |
#define | FAT_CLST_RES0 0x0000 |
#define | FAT_CLST_RES1 0x0001 |
#define | FAT_CLST_ROOT FAT_CLST_RES1 |
#define | FAT_CLST_ROOTPAR FAT_CLST_RES0 |
#define | fat_clusters_get(numc, bs, dh, fc) fat_cluster_walk((bs), (dh), (fc), NULL, (numc), (uint16_t) -1) |
#define | FAT_DENTRY_DOT 0x2e |
#define | FAT_DENTRY_E5_ESC 0x05 |
#define | FAT_DENTRY_ERASED 0xe5 |
#define | FAT_DENTRY_UNUSED 0x00 |
#define | FAT_EXT_LEN 3 |
#define | FAT_EXT_PAD " " |
#define | FAT_LCASE_LOWER_EXT 0x10 |
#define | FAT_LCASE_LOWER_NAME 0x08 |
#define | FAT_NAME_DOT ". " |
#define | FAT_NAME_DOT_DOT ".. " |
#define | FAT_NAME_LEN 8 |
#define | FAT_NODE(node) ((node) ? (fat_node_t *) (node)->data : NULL) |
#define | FAT_PAD ' ' |
#define | FATCNT(bs) (bs)->fatcnt |
#define | FILES (VFS_DATA->files) |
#define | FS_NODE(node) ((node) ? (node)->bp : NULL) |
#define | FS_NODE(node) ((node) ? (node)->bp : NULL) |
#define | KEY_DEV_HANDLE 1 |
#define | KEY_FS_HANDLE 0 |
#define | KEY_INDEX 2 |
#define | max(a, b) ((a) > (b) ? (a) : (b)) |
#define | MAX_MNTOPTS_LEN 256 |
#define | MAX_OPEN_FILES 128 |
#define | min(a, b) ((a) < (b) ? (a) : (b)) |
#define | min(a, b) ((a) < (b) ? (a) : (b)) |
#define | min(a, b) ((a) < (b) ? (a) : (b)) |
#define | NAME "vfs" |
#define | NAME "tmpfs" |
#define | NAME "fat" |
#define | NAME "devfs" |
#define | NAME "mkfat" |
#define | NODES_BUCKETS (1 << NODES_BUCKETS_LOG) |
#define | NODES_BUCKETS 256 |
#define | NODES_BUCKETS_LOG 8 |
#define | NODES_KEY_DEV 0 |
#define | NODES_KEY_INDEX 1 |
#define | RDE(bs) uint16_t_le2host((bs)->root_ent_max) |
#define | RDS(bs) |
#define | RSCNT(bs) uint16_t_le2host((bs)->rscnt) |
#define | SF(bs) uint16_t_le2host((bs)->sec_per_fat) |
#define | SPC(bs) (bs)->spc |
#define | SSA(bs) (RSCNT((bs)) + FATCNT((bs)) * SF((bs)) + RDS(bs)) |
#define | TMPFS_COMM_SIZE 1024 |
#define | TMPFS_NODE(node) ((node) ? (tmpfs_node_t *)(node)->data : NULL) |
#define | TMPFS_SOME_ROOT 0 |
All root nodes have index 0. | |
#define | TS(bs) |
#define | UIH_BUCKETS (1 << UIH_BUCKETS_LOG) |
#define | UIH_BUCKETS_LOG 12 |
#define | UIH_DH_KEY 0 |
#define | UIH_INDEX_KEY 1 |
#define | UPH_BUCKETS (1 << UPH_BUCKETS_LOG) |
#define | UPH_BUCKETS_LOG 12 |
#define | UPH_DH_KEY 0 |
#define | UPH_PDI_KEY 2 |
#define | UPH_PFC_KEY 1 |
#define | VFS_DATA ((vfs_client_data_t *) async_client_data_get()) |
#define | VFS_PAIR |
VFS_PAIR uniquely represents a file system instance. | |
#define | VFS_TRIPLET |
VFS_TRIPLET uniquely identifies a file system node (e.g. | |
Typedefs | |
typedef void(*) | entry_point_t (void) |
typedef fat_cfg | fat_cfg_t |
Configurable file-system parameters. | |
typedef uint16_t | fat_cluster_t |
typedef fat_node | fat_node_t |
FAT in-core node. | |
typedef fat_params | fat_params_t |
Derived file-system parameters. | |
Enumerations | |
enum | { , media_descriptor = 0xF8 } |
Predefined file-system parameters. More... | |
enum | fat_dentry_clsf_t |
enum | fat_node_type_t |
enum | tmpfs_dentry_type_t |
enum | vfs_node_type |
Functions | |
int | _fat_block_get (block_t **block, fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t fcl, fat_cluster_t *clp, aoff64_t bn, int flags) |
Read block from file located on a FAT file system. | |
static void | _vfs_node_addref (vfs_node_t *node) |
void | devfs_close (ipc_callid_t rid, ipc_call_t *request) |
static void | devfs_connection (ipc_callid_t iid, ipc_call_t *icall) |
static int | devfs_create_node (fs_node_t **rfn, devmap_handle_t devmap_handle, int lflag) |
void | devfs_destroy (ipc_callid_t rid, ipc_call_t *request) |
static int | devfs_destroy_node (fs_node_t *fn) |
static devmap_handle_t | devfs_device_get (fs_node_t *fn) |
static int | devfs_has_children (bool *has_children, fs_node_t *fn) |
static fs_index_t | devfs_index_get (fs_node_t *fn) |
bool | devfs_init (void) |
static bool | devfs_is_directory (fs_node_t *fn) |
static bool | devfs_is_file (fs_node_t *fn) |
static int | devfs_link_node (fs_node_t *pfn, fs_node_t *cfn, const char *nm) |
static unsigned int | devfs_lnkcnt_get (fs_node_t *fn) |
void | devfs_lookup (ipc_callid_t rid, ipc_call_t *request) |
static int | devfs_match (fs_node_t **rfn, fs_node_t *pfn, const char *component) |
void | devfs_mount (ipc_callid_t rid, ipc_call_t *request) |
void | devfs_mounted (ipc_callid_t rid, ipc_call_t *request) |
static int | devfs_node_get (fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index) |
static int | devfs_node_get_internal (fs_node_t **rfn, devmap_handle_type_t type, devmap_handle_t handle) |
static int | devfs_node_open (fs_node_t *fn) |
static int | devfs_node_put (fs_node_t *fn) |
void | devfs_open_node (ipc_callid_t rid, ipc_call_t *request) |
static char | devfs_plb_get_char (unsigned pos) |
void | devfs_read (ipc_callid_t rid, ipc_call_t *request) |
static int | devfs_root_get (fs_node_t **rfn, devmap_handle_t devmap_handle) |
static aoff64_t | devfs_size_get (fs_node_t *fn) |
void | devfs_stat (ipc_callid_t rid, ipc_call_t *request) |
void | devfs_sync (ipc_callid_t rid, ipc_call_t *request) |
void | devfs_truncate (ipc_callid_t rid, ipc_call_t *request) |
static int | devfs_unlink_node (fs_node_t *pfn, fs_node_t *cfn, const char *nm) |
void | devfs_unmount (ipc_callid_t rid, ipc_call_t *request) |
void | devfs_unmounted (ipc_callid_t rid, ipc_call_t *request) |
void | devfs_write (ipc_callid_t rid, ipc_call_t *request) |
static int | devices_compare (unsigned long key[], hash_count_t keys, link_t *item) |
static hash_index_t | devices_hash (unsigned long key[]) |
static void | devices_remove_callback (link_t *item) |
int | fat_alloc_clusters (fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned nclsts, fat_cluster_t *mcl, fat_cluster_t *lcl) |
Allocate clusters in all copies of FAT. | |
int | fat_alloc_shadow_clusters (fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t *lifo, unsigned nclsts) |
Replay the allocatoin of clusters in all shadow instances of FAT. | |
int | fat_append_clusters (fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl, fat_cluster_t lcl) |
Append a cluster chain to the last file cluster in all FATs. | |
int | fat_block_get (block_t **block, struct fat_bs *bs, fat_node_t *nodep, aoff64_t bn, int flags) |
Read block from file located on a FAT file system. | |
static int | fat_blocks_write (struct fat_params const *par, devmap_handle_t handle) |
Create file system with the given parameters. | |
static void | fat_bootsec_create (struct fat_params const *par, struct fat_bs *bs) |
Construct boot sector with the given parameters. | |
int | fat_chop_clusters (fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t lcl) |
Chop off node clusters in all copies of FAT. | |
fat_dentry_clsf_t | fat_classify_dentry (const fat_dentry_t *d) |
void | fat_close (ipc_callid_t, ipc_call_t *) |
int | fat_cluster_walk (fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t firstc, fat_cluster_t *lastc, uint16_t *numc, uint16_t max_clusters) |
Walk the cluster chain. | |
static void | fat_connection (ipc_callid_t iid, ipc_call_t *icall) |
This connection fibril processes VFS requests from VFS. | |
static int | fat_create_node (fs_node_t **, devmap_handle_t, int) |
void | fat_dentry_name_get (const fat_dentry_t *d, char *buf) |
void | fat_dentry_name_set (fat_dentry_t *d, const char *name) |
bool | fat_dentry_name_verify (const char *name) |
int | fat_dentry_namecmp (char *name, const char *component) |
Compare path component with the name read from the dentry. | |
void | fat_destroy (ipc_callid_t, ipc_call_t *) |
static int | fat_destroy_node (fs_node_t *) |
static devmap_handle_t | fat_device_get (fs_node_t *node) |
int | fat_fill_gap (fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl, aoff64_t pos) |
Fill the gap between EOF and a new file position. | |
int | fat_free_clusters (fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t firstc) |
Free clusters forming a cluster chain in all copies of FAT. | |
int | fat_get_cluster (fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned fatno, fat_cluster_t clst, fat_cluster_t *value) |
Get cluster from the first FAT. | |
static int | fat_has_children (bool *, fs_node_t *) |
static int | fat_idx_create (fat_idx_t **fidxp, devmap_handle_t devmap_handle) |
void | fat_idx_destroy (fat_idx_t *idx) |
Destroy the index structure. | |
void | fat_idx_fini (void) |
void | fat_idx_fini_by_devmap_handle (devmap_handle_t) |
fat_idx_t * | fat_idx_get_by_index (devmap_handle_t, fs_index_t) |
fat_idx_t * | fat_idx_get_by_pos (devmap_handle_t, fat_cluster_t, unsigned) |
int | fat_idx_get_new (fat_idx_t **, devmap_handle_t) |
void | fat_idx_hashin (fat_idx_t *) |
void | fat_idx_hashout (fat_idx_t *) |
int | fat_idx_init (void) |
int | fat_idx_init_by_devmap_handle (devmap_handle_t) |
static bool | fat_index_alloc (devmap_handle_t devmap_handle, fs_index_t *index) |
Allocate a VFS index which is not currently in use. | |
static void | fat_index_free (devmap_handle_t devmap_handle, fs_index_t index) |
Free a VFS index, which is no longer in use. | |
static fs_index_t | fat_index_get (fs_node_t *) |
static bool | fat_is_directory (fs_node_t *) |
static bool | fat_is_file (fs_node_t *node) |
static int | fat_link (fs_node_t *, fs_node_t *, const char *) |
static unsigned | fat_lnkcnt_get (fs_node_t *) |
void | fat_lookup (ipc_callid_t, ipc_call_t *) |
static int | fat_match (fs_node_t **, fs_node_t *, const char *) |
void | fat_mount (ipc_callid_t, ipc_call_t *) |
void | fat_mounted (ipc_callid_t, ipc_call_t *) |
static int | fat_node_fini_by_devmap_handle (devmap_handle_t devmap_handle) |
static int | fat_node_get (fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index) |
Instantiate a FAT in-core node. | |
static int | fat_node_get_core (fat_node_t **nodepp, fat_idx_t *idxp) |
Internal version of fat_node_get(). | |
static int | fat_node_get_new (fat_node_t **nodepp) |
static void | fat_node_initialize (fat_node_t *node) |
static int | fat_node_open (fs_node_t *) |
static int | fat_node_put (fs_node_t *) |
static int | fat_node_sync (fat_node_t *node) |
void | fat_open_node (ipc_callid_t, ipc_call_t *) |
static int | fat_params_compute (struct fat_cfg const *cfg, struct fat_params *par) |
Derive sizes of different filesystem structures. | |
static char | fat_plb_get_char (unsigned) |
void | fat_read (ipc_callid_t, ipc_call_t *) |
static int | fat_root_get (fs_node_t **, devmap_handle_t) |
int | fat_sanity_check (fat_bs_t *bs, devmap_handle_t devmap_handle) |
Perform basic sanity checks on the file system. | |
int | fat_set_cluster (fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned fatno, fat_cluster_t clst, fat_cluster_t value) |
Set cluster in one instance of FAT. | |
static aoff64_t | fat_size_get (fs_node_t *) |
void | fat_stat (ipc_callid_t, ipc_call_t *) |
void | fat_sync (ipc_callid_t, ipc_call_t *) |
void | fat_truncate (ipc_callid_t, ipc_call_t *) |
static int | fat_unlink (fs_node_t *, fs_node_t *, const char *) |
void | fat_unmount (ipc_callid_t, ipc_call_t *) |
void | fat_unmounted (ipc_callid_t, ipc_call_t *) |
void | fat_write (ipc_callid_t, ipc_call_t *) |
int | fat_zero_cluster (struct fat_bs *bs, devmap_handle_t devmap_handle, fat_cluster_t c) |
FIBRIL_MUTEX_INITIALIZE (nodes_mutex) | |
Mutex protecting the VFS node hash table. | |
static | FIBRIL_MUTEX_INITIALIZE (ffn_mutex) |
Mutex protecting the list of cached free FAT nodes. | |
static | FIBRIL_MUTEX_INITIALIZE (used_lock) |
Mutex protecting the up_hash and ui_hash. | |
static | FIBRIL_MUTEX_INITIALIZE (unused_lock) |
Mutex protecting the list of unused structures. | |
static | FIBRIL_MUTEX_INITIALIZE (fat_alloc_lock) |
The fat_alloc_lock mutex protects all copies of the File Allocation Table during allocation of clusters. | |
static | FIBRIL_MUTEX_INITIALIZE (devices_mutex) |
Hash table mutex. | |
FIBRIL_RWLOCK_INITIALIZE (namespace_rwlock) | |
This rwlock prevents the race between a triplet-to-VFS-node resolution and a concurrent VFS operation which modifies the file system namespace. | |
vfs_info_t * | fs_handle_to_info (fs_handle_t handle) |
Find the VFS info structure. | |
fs_handle_t | fs_name_to_handle (char *name, bool lock) |
Convert file system name to its handle. | |
static int | idx_compare (unsigned long key[], hash_count_t keys, link_t *item) |
static hash_index_t | idx_hash (unsigned long key[]) |
static void | idx_remove_callback (link_t *item) |
static bool | is_d_char (const char ch) |
LIST_INITIALIZE (plb_head) | |
PLB entry ring buffer. | |
static | LIST_INITIALIZE (ffn_head) |
List of cached free FAT nodes. | |
static | LIST_INITIALIZE (unused_head) |
List of unused structures. | |
void | loader_abort (loader_t *) |
Cancel the loader session. | |
loader_t * | loader_connect (void) |
int | loader_get_task_id (loader_t *, task_id_t *) |
Get ID of the new task. | |
int | loader_load_program (loader_t *) |
Instruct loader to load the program. | |
int | loader_run (loader_t *) |
Instruct loader to execute the program. | |
int | loader_set_args (loader_t *, const char *const []) |
Set command-line arguments for the program. | |
int | loader_set_cwd (loader_t *) |
Set current working directory for the loaded task. | |
int | loader_set_files (loader_t *, fdi_node_t *const []) |
Set preset files for the program. | |
int | loader_set_pathname (loader_t *, const char *) |
Set pathname of the program to load. | |
int | loader_spawn (const char *) |
Connect to a new program loader. | |
int | main (int argc, char *argv[]) |
Main entry point. | |
int | main (int argc, char **argv) |
static int | nodes_compare (unsigned long key[], hash_count_t keys, link_t *item) |
static hash_index_t | nodes_hash (unsigned long key[]) |
static void | nodes_remove_callback (link_t *item) |
static int | pos_compare (unsigned long key[], hash_count_t keys, link_t *item) |
static hash_index_t | pos_hash (unsigned long key[]) |
static void | pos_remove_callback (link_t *item) |
static void | refcnt_visitor (link_t *item, void *arg) |
static void | syntax_print (void) |
void | tmpfs_close (ipc_callid_t, ipc_call_t *) |
static void | tmpfs_connection (ipc_callid_t iid, ipc_call_t *icall) |
This connection fibril processes VFS requests from VFS. | |
static int | tmpfs_create_node (fs_node_t **, devmap_handle_t, int) |
static void | tmpfs_dentry_initialize (tmpfs_dentry_t *dentryp) |
void | tmpfs_destroy (ipc_callid_t, ipc_call_t *) |
static int | tmpfs_destroy_node (fs_node_t *) |
static devmap_handle_t | tmpfs_device_get (fs_node_t *fn) |
static int | tmpfs_has_children (bool *has_children, fs_node_t *fn) |
static fs_index_t | tmpfs_index_get (fs_node_t *fn) |
bool | tmpfs_init (void) |
static void | tmpfs_instance_done (devmap_handle_t devmap_handle) |
static bool | tmpfs_instance_init (devmap_handle_t devmap_handle) |
static bool | tmpfs_is_directory (fs_node_t *fn) |
static bool | tmpfs_is_file (fs_node_t *fn) |
static int | tmpfs_link_node (fs_node_t *, fs_node_t *, const char *) |
static unsigned | tmpfs_lnkcnt_get (fs_node_t *fn) |
void | tmpfs_lookup (ipc_callid_t, ipc_call_t *) |
static int | tmpfs_match (fs_node_t **, fs_node_t *, const char *) |
void | tmpfs_mount (ipc_callid_t, ipc_call_t *) |
void | tmpfs_mounted (ipc_callid_t, ipc_call_t *) |
static int | tmpfs_node_get (fs_node_t **, devmap_handle_t, fs_index_t) |
static void | tmpfs_node_initialize (tmpfs_node_t *nodep) |
static int | tmpfs_node_open (fs_node_t *) |
static int | tmpfs_node_put (fs_node_t *) |
void | tmpfs_open_node (ipc_callid_t, ipc_call_t *) |
static char | tmpfs_plb_get_char (unsigned pos) |
void | tmpfs_read (ipc_callid_t, ipc_call_t *) |
bool | tmpfs_restore (devmap_handle_t) |
static bool | tmpfs_restore_recursion (devmap_handle_t dev, size_t *bufpos, size_t *buflen, aoff64_t *pos, fs_node_t *pfn) |
static int | tmpfs_root_get (fs_node_t **rfn, devmap_handle_t devmap_handle) |
static aoff64_t | tmpfs_size_get (fs_node_t *fn) |
void | tmpfs_stat (ipc_callid_t, ipc_call_t *) |
void | tmpfs_sync (ipc_callid_t, ipc_call_t *) |
void | tmpfs_truncate (ipc_callid_t, ipc_call_t *) |
static int | tmpfs_unlink_node (fs_node_t *, fs_node_t *, const char *) |
void | tmpfs_unmount (ipc_callid_t, ipc_call_t *) |
void | tmpfs_unmounted (ipc_callid_t, ipc_call_t *) |
void | tmpfs_write (ipc_callid_t, ipc_call_t *) |
static void | try_coalesce_intervals (link_t *l, link_t *r, link_t *cur) |
If possible, coalesce two intervals of freed indices. | |
static unused_t * | unused_find (devmap_handle_t devmap_handle, bool lock) |
static void | unused_initialize (unused_t *u, devmap_handle_t devmap_handle) |
void * | vfs_client_data_create (void) |
void | vfs_client_data_destroy (void *) |
void | vfs_close (ipc_callid_t, ipc_call_t *) |
static void | vfs_connection (ipc_callid_t iid, ipc_call_t *icall) |
void | vfs_dup (ipc_callid_t, ipc_call_t *) |
int | vfs_fd_alloc (bool desc) |
Allocate a file descriptor. | |
int | vfs_fd_assign (vfs_file_t *file, int fd) |
Assign a file to a file descriptor. | |
int | vfs_fd_free (int fd) |
Release file descriptor. | |
static void | vfs_file_addref (vfs_file_t *file) |
Increment reference count of VFS file structure. | |
static int | vfs_file_close_remote (vfs_file_t *file) |
Close the file in the endpoint FS server. | |
static int | vfs_file_delref (vfs_file_t *file) |
Decrement reference count of VFS file structure. | |
vfs_file_t * | vfs_file_get (int fd) |
Find VFS file structure for a given file descriptor. | |
void | vfs_file_put (vfs_file_t *file) |
Stop using a file structure. | |
static void | vfs_files_done (void) |
Cleanup the table of open files. | |
static bool | vfs_files_init (void) |
Initialize the table of open files. | |
void | vfs_fstat (ipc_callid_t, ipc_call_t *) |
int | vfs_grab_phone (fs_handle_t handle) |
For a given file system handle, implement policy for allocating a phone. | |
static bool | vfs_info_sane (vfs_info_t *info) |
Verify the VFS info structure. | |
int | vfs_lookup_internal (char *path, int lflag, vfs_lookup_res_t *result, vfs_pair_t *altroot,...) |
Perform a path lookup. | |
void | vfs_mkdir (ipc_callid_t, ipc_call_t *) |
void | vfs_mount (ipc_callid_t, ipc_call_t *) |
static void | vfs_mount_internal (ipc_callid_t rid, devmap_handle_t devmap_handle, fs_handle_t fs_handle, char *mp, char *opts) |
void | vfs_node_addref (vfs_node_t *node) |
Increment reference count of a VFS node. | |
void | vfs_node_delref (vfs_node_t *node) |
Decrement reference count of a VFS node. | |
void | vfs_node_forget (vfs_node_t *node) |
Forget node. | |
vfs_node_t * | vfs_node_get (vfs_lookup_res_t *result) |
Find VFS node. | |
void | vfs_node_put (vfs_node_t *node) |
Return VFS node when no longer needed by the caller. | |
bool | vfs_nodes_init (void) |
Initialize the VFS node hash table. | |
unsigned | vfs_nodes_refcount_sum_get (fs_handle_t, devmap_handle_t) |
void | vfs_open (ipc_callid_t, ipc_call_t *) |
void | vfs_open_node (ipc_callid_t, ipc_call_t *) |
int | vfs_open_node_internal (vfs_lookup_res_t *result) |
Perform a node open operation. | |
static void | vfs_rdwr (ipc_callid_t rid, ipc_call_t *request, bool read) |
void | vfs_read (ipc_callid_t, ipc_call_t *) |
void | vfs_register (ipc_callid_t rid, ipc_call_t *request) |
VFS_REGISTER protocol function. | |
void | vfs_release_phone (fs_handle_t handle, int phone) |
Tell VFS that the phone is not needed anymore. | |
void | vfs_rename (ipc_callid_t, ipc_call_t *) |
void | vfs_seek (ipc_callid_t, ipc_call_t *) |
void | vfs_stat (ipc_callid_t, ipc_call_t *) |
void | vfs_sync (ipc_callid_t, ipc_call_t *) |
void | vfs_truncate (ipc_callid_t, ipc_call_t *) |
static int | vfs_truncate_internal (fs_handle_t, devmap_handle_t, fs_index_t, aoff64_t) |
void | vfs_unlink (ipc_callid_t, ipc_call_t *) |
void | vfs_unmount (ipc_callid_t, ipc_call_t *) |
void | vfs_write (ipc_callid_t, ipc_call_t *) |
Variables | |
pcb_t * | __pcb |
A pointer to the program control block. | |
libfs_ops_t | devfs_libfs_ops |
libfs operations | |
fs_reg_t | devfs_reg |
fs_reg_t | devfs_reg |
static vfs_info_t | devfs_vfs_info |
static hash_table_t | devices |
Hash table of opened devices. | |
static hash_table_operations_t | devices_ops |
libfs_ops_t | fat_libfs_ops |
libfs operations | |
fs_reg_t | fat_reg |
fs_reg_t | fat_reg |
vfs_info_t | fat_vfs_info |
atomic_t | fs_handle_next |
link_t | fs_head |
List of registered file systems. | |
fibril_rwlock_t | namespace_rwlock |
Holding this rwlock prevents changes in file system namespace. | |
hash_table_t | nodes |
VFS node hash table containing all active, in-memory VFS nodes. | |
hash_table_t | nodes |
Hash table of all TMPFS nodes. | |
hash_table_operations_t | nodes_ops |
VFS node hash table operations. | |
hash_table_operations_t | nodes_ops |
TMPFS nodes hash table operations. | |
uint8_t * | plb = NULL |
Path Lookup Buffer. | |
uint8_t * | plb |
Path Lookup Buffer. | |
link_t | plb_head |
List of active PLB entries. | |
fibril_mutex_t | plb_mutex |
Mutex protecting plb and plb_head. | |
vfs_pair_t | rootfs |
Root file system. | |
vfs_pair_t | rootfs |
Root file system. | |
libfs_ops_t | tmpfs_libfs_ops |
libfs operations | |
libfs_ops_t | tmpfs_libfs_ops |
libfs operations | |
fs_index_t | tmpfs_next_index = 1 |
Global counter for assigning node indices. | |
fs_reg_t | tmpfs_reg |
fs_reg_t | tmpfs_reg |
vfs_info_t | tmpfs_vfs_info |
static hash_table_t | ui_hash |
Global hash table of all used fat_idx_t structures. | |
static hash_table_operations_t | uih_ops |
static hash_table_t | up_hash |
Global hash table of all used fat_idx_t structures. | |
static hash_table_operations_t | uph_ops |
#define VFS_TRIPLET |
Value:
VFS_PAIR; \ fs_index_t index;
directory, file) but doesn't contain any state. For a stateful structure, see vfs_node_t.
anonymous enum |
int _fat_block_get | ( | block_t ** | block, | |
fat_bs_t * | bs, | |||
devmap_handle_t | devmap_handle, | |||
fat_cluster_t | fcl, | |||
fat_cluster_t * | clp, | |||
aoff64_t | bn, | |||
int | flags | |||
) |
Read block from file located on a FAT file system.
block | Pointer to a block pointer for storing result. | |
bs | Buffer holding the boot sector of the file system. | |
devmap_handle | Device handle of the file system. | |
fcl | First cluster used by the file. Can be zero if the file is empty. | |
clp | If not NULL, address where the cluster containing bn will be stored. stored | |
bn | Block number. | |
flags | Flags passed to libblock. |
int fat_alloc_clusters | ( | fat_bs_t * | bs, | |
devmap_handle_t | devmap_handle, | |||
unsigned | nclsts, | |||
fat_cluster_t * | mcl, | |||
fat_cluster_t * | lcl | |||
) |
Allocate clusters in all copies of FAT.
This function will attempt to allocate the requested number of clusters in all instances of the FAT. The FAT will be altered so that the allocated clusters form an independent chain (i.e. a chain which does not belong to any file yet).
bs | Buffer holding the boot sector of the file system. | |
devmap_handle | Device handle of the file system. | |
nclsts | Number of clusters to allocate. | |
mcl | Output parameter where the first cluster in the chain will be returned. | |
lcl | Output parameter where the last cluster in the chain will be returned. |
int fat_alloc_shadow_clusters | ( | fat_bs_t * | bs, | |
devmap_handle_t | devmap_handle, | |||
fat_cluster_t * | lifo, | |||
unsigned | nclsts | |||
) |
Replay the allocatoin of clusters in all shadow instances of FAT.
bs | Buffer holding the boot sector of the file system. | |
devmap_handle | Device handle of the file system. | |
lifo | Chain of allocated clusters. | |
nclsts | Number of clusters in the lifo chain. |
int fat_append_clusters | ( | fat_bs_t * | bs, | |
fat_node_t * | nodep, | |||
fat_cluster_t | mcl, | |||
fat_cluster_t | lcl | |||
) |
Append a cluster chain to the last file cluster in all FATs.
bs | Buffer holding the boot sector of the file system. | |
nodep | Node representing the file. | |
mcl | First cluster of the cluster chain to append. | |
lcl | Last cluster of the cluster chain to append. |
int fat_block_get | ( | block_t ** | block, | |
struct fat_bs * | bs, | |||
fat_node_t * | nodep, | |||
aoff64_t | bn, | |||
int | flags | |||
) |
Read block from file located on a FAT file system.
block | Pointer to a block pointer for storing result. | |
bs | Buffer holding the boot sector of the file system. | |
nodep | FAT node. | |
bn | Block number. | |
flags | Flags passed to libblock. |
int fat_chop_clusters | ( | fat_bs_t * | bs, | |
fat_node_t * | nodep, | |||
fat_cluster_t | lcl | |||
) |
Chop off node clusters in all copies of FAT.
bs | Buffer holding the boot sector of the file system. | |
nodep | FAT node where the chopping will take place. | |
lcl | Last cluster which will remain in the node. If this argument is FAT_CLST_RES0, then all clusters will be chopped off. |
int fat_cluster_walk | ( | fat_bs_t * | bs, | |
devmap_handle_t | devmap_handle, | |||
fat_cluster_t | firstc, | |||
fat_cluster_t * | lastc, | |||
uint16_t * | numc, | |||
uint16_t | max_clusters | |||
) |
Walk the cluster chain.
bs | Buffer holding the boot sector for the file. | |
devmap_handle | Device handle of the device with the file. | |
firstc | First cluster to start the walk with. | |
lastc | If non-NULL, output argument hodling the last cluster number visited. | |
numc | If non-NULL, output argument holding the number of clusters seen during the walk. | |
max_clusters | Maximum number of clusters to visit. |
static void fat_connection | ( | ipc_callid_t | iid, | |
ipc_call_t * | icall | |||
) | [static] |
This connection fibril processes VFS requests from VFS.
In order to support simultaneous VFS requests, our design is as follows. The connection fibril accepts VFS requests from VFS. If there is only one instance of the fibril, VFS will need to serialize all VFS requests it sends to FAT. To overcome this bottleneck, VFS can send FAT the IPC_M_CONNECT_ME_TO call. In that case, a new connection fibril will be created, which in turn will accept the call. Thus, a new phone will be opened for VFS.
There are few issues with this arrangement. First, VFS can run out of available phones. In that case, VFS can close some other phones or use one phone for more serialized requests. Similarily, FAT can refuse to duplicate the connection. VFS should then just make use of already existing phones and route its requests through them. To avoid paying the fibril creation price upon each request, FAT might want to keep the connections open after the request has been completed.
int fat_dentry_namecmp | ( | char * | name, | |
const char * | component | |||
) |
Compare path component with the name read from the dentry.
This function compares the path component with the name read from the dentry. The comparison is case insensitive and tolerates a mismatch on the trailing dot character at the end of the name (i.e. when there is a dot, but no extension).
name | Node name read from the dentry. | |
component | Path component. |
Definition at line 62 of file fat_dentry.c.
int fat_fill_gap | ( | fat_bs_t * | bs, | |
fat_node_t * | nodep, | |||
fat_cluster_t | mcl, | |||
aoff64_t | pos | |||
) |
Fill the gap between EOF and a new file position.
bs | Buffer holding the boot sector for nodep. | |
nodep | FAT node with the gap. | |
mcl | First cluster in an independent cluster chain that will be later appended to the end of the node's own cluster chain. If pos is still in the last allocated cluster, this argument is ignored. | |
pos | Position in the last node block. |
int fat_free_clusters | ( | fat_bs_t * | bs, | |
devmap_handle_t | devmap_handle, | |||
fat_cluster_t | firstc | |||
) |
Free clusters forming a cluster chain in all copies of FAT.
bs | Buffer hodling the boot sector of the file system. | |
devmap_handle | Device handle of the file system. | |
firstc | First cluster in the chain which is to be freed. |
int fat_get_cluster | ( | fat_bs_t * | bs, | |
devmap_handle_t | devmap_handle, | |||
unsigned | fatno, | |||
fat_cluster_t | clst, | |||
fat_cluster_t * | value | |||
) |
Get cluster from the first FAT.
bs | Buffer holding the boot sector for the file system. | |
devmap_handle | Device handle for the file system. | |
clst | Cluster which to get. | |
value | Output argument holding the value of the cluster. |
void fat_idx_destroy | ( | fat_idx_t * | idx | ) |
static int fat_node_get_core | ( | fat_node_t ** | nodepp, | |
fat_idx_t * | idxp | |||
) | [static] |
static int fat_params_compute | ( | struct fat_cfg const * | cfg, | |
struct fat_params * | par | |||
) | [static] |
int fat_sanity_check | ( | fat_bs_t * | bs, | |
devmap_handle_t | devmap_handle | |||
) |
int fat_set_cluster | ( | fat_bs_t * | bs, | |
devmap_handle_t | devmap_handle, | |||
unsigned | fatno, | |||
fat_cluster_t | clst, | |||
fat_cluster_t | value | |||
) |
Set cluster in one instance of FAT.
bs | Buffer holding the boot sector for the file system. | |
devmap_handle | Device handle for the file system. | |
fatno | Number of the FAT instance where to make the change. | |
clst | Cluster which is to be set. | |
value | Value to set the cluster with. |
static FIBRIL_MUTEX_INITIALIZE | ( | fat_alloc_lock | ) | [static] |
The fat_alloc_lock mutex protects all copies of the File Allocation Table during allocation of clusters.
The lock does not have to be held durring deallocation of clusters.
vfs_info_t * fs_handle_to_info | ( | fs_handle_t | handle | ) |
Find the VFS info structure.
handle | FS handle for which the VFS info structure is sought. |
Definition at line 339 of file vfs_register.c.
fs_handle_t fs_name_to_handle | ( | char * | name, | |
bool | lock | |||
) |
Convert file system name to its handle.
name | File system name. | |
lock | If true, the function will lock and unlock the fs_head_lock. |
Definition at line 315 of file vfs_register.c.
void loader_abort | ( | loader_t * | ldr | ) |
Cancel the loader session.
Tells the loader not to load any program and terminate. After using this function, no further operations must be performed on the loader structure. It should be de-allocated using free().
ldr | Loader connection structure. |
int loader_load_program | ( | loader_t * | ldr | ) |
int loader_run | ( | loader_t * | ldr | ) |
Instruct loader to execute the program.
Note that this function blocks until the loader actually replies so you cannot expect this function to return if you are debugging the task and its thread is stopped.
After using this function, no further operations must be performed on the loader structure. It should be de-allocated using free().
ldr | Loader connection structure. |
int loader_set_args | ( | loader_t * | ldr, | |
const char *const | argv[] | |||
) |
Set command-line arguments for the program.
Sets the vector of command-line arguments to be passed to the loaded program. By convention, the very first argument is typically the same as the command used to execute the program.
ldr | Loader connection structure. | |
argv | NULL-terminated array of pointers to arguments. |
int loader_set_cwd | ( | loader_t * | ldr | ) |
int loader_set_files | ( | loader_t * | ldr, | |
fdi_node_t *const | files[] | |||
) |
Set preset files for the program.
Sets the vector of preset files to be passed to the loaded program. By convention, the first three files represent stdin, stdout and stderr respectively.
ldr | Loader connection structure. | |
files | NULL-terminated array of pointers to files. |
int loader_set_pathname | ( | loader_t * | ldr, | |
const char * | path | |||
) |
Set pathname of the program to load.
Sets the name of the program file to load. The name can be relative to the current working directory (it will be absolutized before sending to the loader).
ldr | Loader connection structure. | |
path | Pathname of the program file. |
int loader_spawn | ( | const char * | name | ) |
Connect to a new program loader.
Spawns a new program loader task and returns the connection structure.
name | Symbolic name to set on the newly created task. |
int main | ( | int | argc, | |
char * | argv[] | |||
) |
static void tmpfs_connection | ( | ipc_callid_t | iid, | |
ipc_call_t * | icall | |||
) | [static] |
This connection fibril processes VFS requests from VFS.
In order to support simultaneous VFS requests, our design is as follows. The connection fibril accepts VFS requests from VFS. If there is only one instance of the fibril, VFS will need to serialize all VFS requests it sends to FAT. To overcome this bottleneck, VFS can send TMPFS the IPC_M_CONNECT_ME_TO call. In that case, a new connection fibril will be created, which in turn will accept the call. Thus, a new phone will be opened for VFS.
There are few issues with this arrangement. First, VFS can run out of available phones. In that case, VFS can close some other phones or use one phone for more serialized requests. Similarily, TMPFS can refuse to duplicate the connection. VFS should then just make use of already existing phones and route its requests through them. To avoid paying the fibril creation price upon each request, TMPFS might want to keep the connections open after the request has been completed.
int vfs_fd_alloc | ( | bool | desc | ) |
Allocate a file descriptor.
desc | If true, look for an available file descriptor in a descending order. |
Definition at line 174 of file vfs_file.c.
int vfs_fd_assign | ( | vfs_file_t * | file, | |
int | fd | |||
) |
Assign a file to a file descriptor.
file | File to assign. | |
fd | File descriptor to assign to. |
Definition at line 254 of file vfs_file.c.
int vfs_fd_free | ( | int | fd | ) |
Release file descriptor.
fd | File descriptor being released. |
Definition at line 225 of file vfs_file.c.
static void vfs_file_addref | ( | vfs_file_t * | file | ) | [static] |
Increment reference count of VFS file structure.
file | File structure that will have reference count incremented. |
Definition at line 134 of file vfs_file.c.
static int vfs_file_delref | ( | vfs_file_t * | file | ) | [static] |
Decrement reference count of VFS file structure.
file | File structure that will have reference count decremented. |
Definition at line 146 of file vfs_file.c.
vfs_file_t * vfs_file_get | ( | int | fd | ) |
Find VFS file structure for a given file descriptor.
fd | File descriptor. |
Definition at line 278 of file vfs_file.c.
void vfs_file_put | ( | vfs_file_t * | file | ) |
Stop using a file structure.
file | VFS file structure. |
Definition at line 301 of file vfs_file.c.
int vfs_grab_phone | ( | fs_handle_t | handle | ) |
For a given file system handle, implement policy for allocating a phone.
handle | File system handle. |
Definition at line 256 of file vfs_register.c.
static bool vfs_info_sane | ( | vfs_info_t * | info | ) | [static] |
Verify the VFS info structure.
info | Info structure to be verified. |
Definition at line 68 of file vfs_register.c.
int vfs_lookup_internal | ( | char * | path, | |
int | lflag, | |||
vfs_lookup_res_t * | result, | |||
vfs_pair_t * | altroot, | |||
... | ||||
) |
Perform a path lookup.
path | Path to be resolved; it must be a NULL-terminated string. | |
lflag | Flags to be used during lookup. | |
result | Empty structure where the lookup result will be stored. Can be NULL. | |
altroot | If non-empty, will be used instead of rootfs as the root of the whole VFS tree. |
Definition at line 68 of file vfs_lookup.c.
void vfs_node_addref | ( | vfs_node_t * | node | ) |
Increment reference count of a VFS node.
node | VFS node that will have its refcnt incremented. |
Definition at line 89 of file vfs_node.c.
void vfs_node_delref | ( | vfs_node_t * | node | ) |
Decrement reference count of a VFS node.
This function handles the case when the reference count drops to zero.
node | VFS node that will have its refcnt decremented. |
Definition at line 102 of file vfs_node.c.
void vfs_node_forget | ( | vfs_node_t * | node | ) |
Forget node.
This function will remove the node from the node hash table and deallocate its memory, regardless of the node's reference count.
node | Node to be forgotten. |
Definition at line 148 of file vfs_node.c.
vfs_node_t * vfs_node_get | ( | vfs_lookup_res_t * | result | ) |
Find VFS node.
This function will try to lookup the given triplet in the VFS node hash table. In case the triplet is not found there, a new VFS node is created. In any case, the VFS node will have its reference count incremented. Every node returned by this call should be eventually put back by calling vfs_node_put() on it.
result | Populated lookup result structure. |
Definition at line 173 of file vfs_node.c.
void vfs_node_put | ( | vfs_node_t * | node | ) |
Return VFS node when no longer needed by the caller.
This function will remove the reference on the VFS node created by vfs_node_get(). This function can only be called as a closing bracket to the preceding vfs_node_get() call.
node | VFS node being released. |
Definition at line 228 of file vfs_node.c.
bool vfs_nodes_init | ( | void | ) |
Initialize the VFS node hash table.
Definition at line 75 of file vfs_node.c.
int vfs_open_node_internal | ( | vfs_lookup_res_t * | result | ) |
Perform a node open operation.
Definition at line 208 of file vfs_lookup.c.
void vfs_register | ( | ipc_callid_t | rid, | |
ipc_call_t * | request | |||
) |
VFS_REGISTER protocol function.
rid | Hash of the call with the request. | |
request | Call structure with the request. |
Definition at line 109 of file vfs_register.c.
void vfs_release_phone | ( | fs_handle_t | handle, | |
int | phone | |||
) |
Tell VFS that the phone is not needed anymore.
phone | Phone to FS task. |
Definition at line 288 of file vfs_register.c.
Global counter for assigning node indices.
Shared by all instances.
Definition at line 63 of file tmpfs_ops.c.
hash_table_t ui_hash [static] |
hash_table_t up_hash [static] |