Subversion Repositories HelenOS

Compare Revisions

Regard whitespace Rev 2769 → Rev 2770

/trunk/uspace/lib/libfs/libfs.c
134,14 → 134,14
* @param rid Request ID of the VFS_LOOKUP request.
* @param request VFS_LOOKUP request data itself.
*/
void libfs_lookup(libfs_ops_t *ops, int fs_handle, ipc_callid_t rid,
void libfs_lookup(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
ipc_call_t *request)
{
unsigned next = IPC_GET_ARG1(*request);
unsigned last = IPC_GET_ARG2(*request);
int dev_handle = IPC_GET_ARG3(*request);
dev_handle_t dev_handle = IPC_GET_ARG3(*request);
int lflag = IPC_GET_ARG4(*request);
int index = IPC_GET_ARG5(*request); /* when L_LINK specified */
fs_index_t index = IPC_GET_ARG5(*request); /* when L_LINK specified */
 
if (last < next)
last += PLB_SIZE;
/trunk/uspace/lib/libfs/libfs.h
43,13 → 43,13
 
typedef struct {
bool (* match)(void *, void *, const char *);
void * (* node_get)(int, int, unsigned long);
void * (* node_get)(fs_handle_t, dev_handle_t, fs_index_t);
void * (* create)(int);
void (* destroy)(void *);
bool (* link)(void *, void *, const char *);
int (* unlink)(void *, void *);
unsigned long (* index_get)(void *);
unsigned long (* size_get)(void *);
fs_index_t (* index_get)(void *);
size_t (* size_get)(void *);
unsigned (* lnkcnt_get)(void *);
void *(* child_get)(void *);
void *(* sibling_get)(void *);
74,7 → 74,7
extern void node_del_mp(int, unsigned long);
extern bool node_is_mp(int, unsigned long);
 
extern void libfs_lookup(libfs_ops_t *, int, ipc_callid_t, ipc_call_t *);
extern void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
 
#endif
 
/trunk/uspace/srv/fs/tmpfs/tmpfs.h
43,7 → 43,7
#define dprintf(...) printf(__VA_ARGS__)
 
typedef struct tmpfs_dentry {
unsigned long index; /**< TMPFS node index. */
fs_index_t index; /**< TMPFS node index. */
link_t dh_link; /**< Dentries hash table link. */
struct tmpfs_dentry *sibling;
struct tmpfs_dentry *child;
/trunk/uspace/srv/fs/tmpfs/tmpfs_ops.c
70,7 → 70,7
 
/* Forward declarations of static functions. */
static bool tmpfs_match(void *, void *, const char *);
static void *tmpfs_node_get(int, int, unsigned long);
static void *tmpfs_node_get(fs_handle_t, dev_handle_t, fs_index_t);
static void *tmpfs_create_node(int);
static bool tmpfs_link_node(void *, void *, const char *);
static int tmpfs_unlink_node(void *, void *);
77,12 → 77,12
static void tmpfs_destroy_node(void *);
 
/* Implementation of helper functions. */
static unsigned long tmpfs_index_get(void *nodep)
static fs_index_t tmpfs_index_get(void *nodep)
{
return ((tmpfs_dentry_t *) nodep)->index;
}
 
static unsigned long tmpfs_size_get(void *nodep)
static size_t tmpfs_size_get(void *nodep)
{
return ((tmpfs_dentry_t *) nodep)->size;
}
169,7 → 169,7
.remove_callback = dentries_remove_callback
};
 
unsigned tmpfs_next_index = 1;
fs_index_t tmpfs_next_index = 1;
 
typedef struct {
char *name;
262,9 → 262,11
return !strcmp(namep->name, component);
}
 
void *tmpfs_node_get(int fs_handle, int dev_handle, unsigned long index)
void *
tmpfs_node_get(fs_handle_t fs_handle, dev_handle_t dev_handle, fs_index_t index)
{
link_t *lnk = hash_table_find(&dentries, &index);
unsigned long key = index;
link_t *lnk = hash_table_find(&dentries, &key);
if (!lnk)
return NULL;
return hash_table_get_instance(lnk, tmpfs_dentry_t, dh_link);
289,7 → 291,8
node->type = TMPFS_FILE;
 
/* Insert the new node into the dentry hash table. */
hash_table_insert(&dentries, &node->index, &node->dh_link);
unsigned long key = node->index;
hash_table_insert(&dentries, &key, &node->dh_link);
return (void *) node;
}
 
369,8 → 372,8
assert(!dentry->child);
assert(!dentry->sibling);
 
unsigned long index = dentry->index;
hash_table_remove(&dentries, &index, 1);
unsigned long key = dentry->index;
hash_table_remove(&dentries, &key, 1);
 
hash_table_destroy(&dentry->names);
 
391,15 → 394,16
 
void tmpfs_read(ipc_callid_t rid, ipc_call_t *request)
{
int dev_handle = IPC_GET_ARG1(*request);
unsigned long index = IPC_GET_ARG2(*request);
off_t pos = IPC_GET_ARG3(*request);
dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
off_t pos = (off_t)IPC_GET_ARG3(*request);
 
/*
* Lookup the respective dentry.
*/
link_t *hlp;
hlp = hash_table_find(&dentries, &index);
unsigned long key = index;
hlp = hash_table_find(&dentries, &key);
if (!hlp) {
ipc_answer_0(rid, ENOENT);
return;
463,15 → 467,16
 
void tmpfs_write(ipc_callid_t rid, ipc_call_t *request)
{
int dev_handle = IPC_GET_ARG1(*request);
unsigned long index = IPC_GET_ARG2(*request);
off_t pos = IPC_GET_ARG3(*request);
dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
off_t pos = (off_t)IPC_GET_ARG3(*request);
 
/*
* Lookup the respective dentry.
*/
link_t *hlp;
hlp = hash_table_find(&dentries, &index);
unsigned long key = index;
hlp = hash_table_find(&dentries, &key);
if (!hlp) {
ipc_answer_0(rid, ENOENT);
return;
523,15 → 528,16
 
void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request)
{
int dev_handle = IPC_GET_ARG1(*request);
unsigned long index = IPC_GET_ARG2(*request);
size_t size = IPC_GET_ARG3(*request);
dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
size_t size = (off_t)IPC_GET_ARG3(*request);
 
/*
* Lookup the respective dentry.
*/
link_t *hlp;
hlp = hash_table_find(&dentries, &index);
unsigned long key = index;
hlp = hash_table_find(&dentries, &key);
if (!hlp) {
ipc_answer_0(rid, ENOENT);
return;
560,11 → 566,12
 
void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request)
{
int dev_handle = IPC_GET_ARG1(*request);
unsigned long index = IPC_GET_ARG2(*request);
dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
 
link_t *hlp;
hlp = hash_table_find(&dentries, &index);
unsigned long key = index;
hlp = hash_table_find(&dentries, &key);
if (!hlp) {
ipc_answer_0(rid, ENOENT);
return;
/trunk/uspace/srv/vfs/vfs_ops.c
53,7 → 53,7
#include <vfs/canonify.h>
 
/* Forward declarations of static functions. */
static int vfs_truncate_internal(int, int, unsigned long, size_t);
static int vfs_truncate_internal(fs_handle_t, dev_handle_t, fs_index_t, size_t);
 
/**
* This rwlock prevents the race between a triplet-to-VFS-node resolution and a
68,7 → 68,9
.index = 0,
};
 
static int lookup_root(int fs_handle, int dev_handle, vfs_lookup_res_t *result)
static int
lookup_root(fs_handle_t fs_handle, dev_handle_t dev_handle,
vfs_lookup_res_t *result)
{
vfs_pair_t altroot = {
.fs_handle = fs_handle,
80,7 → 82,7
 
void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
{
int dev_handle;
dev_handle_t dev_handle;
vfs_node_t *mp_node = NULL;
 
/*
88,7 → 90,7
* translation for us, thus the device handle will arrive as ARG1
* in the request.
*/
dev_handle = IPC_GET_ARG1(*request);
dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
 
/*
* For now, don't make use of ARG2 and ARG3, but they can be used to
127,7 → 129,7
* Check if we know a file system with the same name as is in fs_name.
* This will also give us its file system handle.
*/
int fs_handle = fs_name_to_handle(fs_name, true);
fs_handle_t fs_handle = fs_name_to_handle(fs_name, true);
if (!fs_handle) {
ipc_answer_0(rid, ENOENT);
return;
571,8 → 573,9
ipc_answer_0(rid, EINVAL);
}
 
int vfs_truncate_internal(int fs_handle, int dev_handle, unsigned long index,
size_t size)
int
vfs_truncate_internal(fs_handle_t fs_handle, dev_handle_t dev_handle,
fs_index_t index, size_t size)
{
ipcarg_t rc;
int fs_phone;
/trunk/uspace/srv/vfs/vfs_register.c
294,7 → 294,7
* In reply to the VFS_REGISTER request, we assign the client file
* system a global file system handle.
*/
fs_info->fs_handle = (int) atomic_postinc(&fs_handle_next);
fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next);
ipc_answer_1(rid, EOK, (ipcarg_t) fs_info->fs_handle);
fibril_dec_sercount();
311,7 → 311,7
* @return Phone over which a multi-call request can be safely
* sent. Return 0 if no phone was found.
*/
int vfs_grab_phone(int handle)
int vfs_grab_phone(fs_handle_t handle)
{
/*
* For now, we don't try to be very clever and very fast.
386,7 → 386,7
*
* @return File system handle or zero if file system not found.
*/
int fs_name_to_handle(char *name, bool lock)
fs_handle_t fs_name_to_handle(char *name, bool lock)
{
int handle = 0;
/trunk/uspace/srv/vfs/vfs.h
46,6 → 46,11
 
#define IPC_METHOD_TO_VFS_OP(m) ((m) - VFS_FIRST)
 
/* Basic types. */
typedef int16_t fs_handle_t;
typedef int16_t dev_handle_t;
typedef uint32_t fs_index_t;
 
typedef enum {
VFS_READ = VFS_FIRST,
VFS_WRITE,
106,7 → 111,7
typedef struct {
link_t fs_link;
vfs_info_t vfs_info;
int fs_handle;
fs_handle_t fs_handle;
futex_t phone_futex; /**< Phone serializing futex. */
ipcarg_t phone;
} fs_info_t;
115,8 → 120,8
* VFS_PAIR uniquely represents a file system instance.
*/
#define VFS_PAIR \
int fs_handle; \
int dev_handle;
fs_handle_t fs_handle; \
dev_handle_t dev_handle;
 
/**
* VFS_TRIPLET uniquely identifies a file system node (e.g. directory, file) but
127,7 → 132,7
*/
#define VFS_TRIPLET \
VFS_PAIR; \
uint64_t index;
fs_index_t index;
 
typedef struct {
VFS_PAIR;
256,10 → 261,10
/** Holding this rwlock prevents changes in file system namespace. */
extern rwlock_t namespace_rwlock;
 
extern int vfs_grab_phone(int);
extern int vfs_grab_phone(fs_handle_t);
extern void vfs_release_phone(int);
 
extern int fs_name_to_handle(char *, bool);
extern fs_handle_t fs_name_to_handle(char *, bool);
 
extern int vfs_lookup_internal(char *, int, vfs_lookup_res_t *, vfs_pair_t *,
...);
/trunk/uspace/srv/vfs/vfs_lookup.c
82,12 → 82,12
if (!path)
return EINVAL;
uint64_t index = 0;
fs_index_t index = 0;
if (lflag & L_LINK) {
va_list ap;
 
va_start(ap, altroot);
index = va_arg(ap, uint64_t);
index = va_arg(ap, fs_index_t);
va_end(ap);
}
177,9 → 177,9
futex_up(&plb_futex);
 
if ((rc == EOK) && result) {
result->triplet.fs_handle = (int) IPC_GET_ARG1(answer);
result->triplet.dev_handle = (int) IPC_GET_ARG2(answer);
result->triplet.index = (uint64_t) IPC_GET_ARG3(answer);
result->triplet.fs_handle = (fs_handle_t) IPC_GET_ARG1(answer);
result->triplet.dev_handle = (dev_handle_t) IPC_GET_ARG2(answer);
result->triplet.index = (fs_index_t) IPC_GET_ARG3(answer);
result->size = (size_t) IPC_GET_ARG4(answer);
result->lnkcnt = (unsigned) IPC_GET_ARG5(answer);
}