Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2586 → Rev 2587

/trunk/uspace/srv/vfs/vfs_mount.c
46,17 → 46,17
#include "vfs.h"
 
atomic_t rootfs_futex = FUTEX_INITIALIZER;
vfs_node_t rootfs = { 0 };
vfs_triplet_t rootfs = {
.fs_handle = 0,
.dev_handle = 0,
.index = 0,
};
 
static int lookup_root(int fs_handle, int dev_handle, vfs_node_t *root)
static int lookup_root(int fs_handle, int dev_handle, vfs_triplet_t *root)
{
vfs_node_t altroot = {
vfs_pair_t altroot = {
.fs_handle = fs_handle,
.dev_handle = dev_handle,
/*
* At this point, we don't know what is the index of the root
* node. Finally, that's what this function is about.
*/
};
 
return vfs_lookup_internal("/", strlen("/"), root, &altroot);
138,7 → 138,7
* Lookup the root node of the filesystem being mounted.
*/
int rc;
vfs_node_t mounted_root;
vfs_triplet_t mounted_root;
rc = lookup_root(fs_handle, dev_handle, &mounted_root);
if (rc != EOK) {
free(buf);
149,7 → 149,7
/*
* Finally, we need to resolve the path to the mountpoint.
*/
vfs_node_t mp;
vfs_triplet_t mp;
futex_down(&rootfs_futex);
if (rootfs.fs_handle) {
/*
/trunk/uspace/srv/vfs/vfs.h
99,17 → 99,38
} fs_info_t;
 
/**
* Instances of this type represent a file system node (e.g. directory, file).
* They are abstracted away from any file system implementation and contain just
* enough bits to uniquely identify the object in its file system instance.
* VFS_PAIR uniquely represents a file system instance.
*/
#define VFS_PAIR \
int fs_handle; \
int dev_handle;
 
/**
* VFS_TRIPLET uniquely identifies a file system node (e.g. directory, file) but
* doesn't contain any state. For a stateful structure, see vfs_node_t.
*
* @note fs_handle, dev_handle and index are meant to be returned in one
* IPC reply.
*/
#define VFS_TRIPLET \
VFS_PAIR; \
uint64_t index;
 
typedef struct {
int fs_handle; /**< Global file system ID. */
int dev_handle; /**< Global mount device devno. */
uint64_t index; /**< Index of the node on its file system. */
VFS_PAIR;
} vfs_pair_t;
 
typedef struct {
VFS_TRIPLET;
} vfs_triplet_t;
 
/**
* Instances of this type represent an active, in-memory VFS node and any state
* which may be associated with it.
*/
typedef struct {
VFS_TRIPLET; /**< Identity of the node. */
atomic_t refcnt; /**< Usage counter. */
} vfs_node_t;
 
/**
128,7 → 149,7
 
extern link_t fs_head; /**< List of registered file systems. */
 
extern vfs_node_t rootfs; /**< Root node of the root file system. */
extern vfs_triplet_t rootfs; /**< Root node of the root file system. */
 
#define MAX_PATH_LEN (64 * 1024)
 
150,7 → 171,7
 
extern int fs_name_to_handle(char *, bool);
 
extern int vfs_lookup_internal(char *, size_t, vfs_node_t *, vfs_node_t *);
extern int vfs_lookup_internal(char *, size_t, vfs_triplet_t *, vfs_pair_t *);
 
#define MAX_OPEN_FILES 128
 
/trunk/uspace/srv/vfs/vfs_lookup.c
61,10 → 61,10
*
* @return EOK on success or an error code from errno.h.
*/
int vfs_lookup_internal(char *path, size_t len, vfs_node_t *result,
vfs_node_t *altroot)
int vfs_lookup_internal(char *path, size_t len, vfs_triplet_t *result,
vfs_pair_t *altroot)
{
vfs_node_t *root;
vfs_pair_t *root;
 
if (!len)
return EINVAL;
72,7 → 72,7
if (altroot)
root = altroot;
else
root = &rootfs;
root = (vfs_pair_t *) &rootfs;
 
if (!root->fs_handle)
return ENOENT;