Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2729 → Rev 2730

/trunk/uspace/srv/fs/tmpfs/tmpfs_ops.c
58,6 → 58,9
 
#define DENTRIES_BUCKETS 256
 
#define TMPFS_GET_INDEX(x) (((tmpfs_dentry_t *)(x))->index)
#define TMPFS_GET_LNKCNT(x) 1
 
/*
* Hash table of all directory entries.
*/
127,30 → 130,34
 
/** Compare one component of path to a directory entry.
*
* @param dentry Directory entry to compare the path component with.
* @param nodep Node to compare the path component with.
* @param component Array of characters holding component name.
*
* @return True on match, false otherwise.
*/
static bool match_component(tmpfs_dentry_t *dentry, const char *component)
static bool match_component(void *nodep, const char *component)
{
tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) nodep;
 
return !strcmp(dentry->name, component);
}
 
static unsigned long create_node(tmpfs_dentry_t *dentry,
static void *create_node(void *nodep,
const char *component, int lflag)
{
tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) nodep;
 
assert(dentry->type == TMPFS_DIRECTORY);
assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
 
tmpfs_dentry_t *node = malloc(sizeof(tmpfs_dentry_t));
if (!node)
return 0;
return NULL;
size_t len = strlen(component);
char *name = malloc(len + 1);
if (!name) {
free(node);
return 0;
return NULL;
}
strcpy(name, component);
 
175,10 → 182,10
 
/* Insert the new node into the dentry hash table. */
hash_table_insert(&dentries, &node->index, &node->dh_link);
return node->index;
return (void *) node;
}
 
static int destroy_component(tmpfs_dentry_t *dentry)
static int destroy_component(void *nodeptr)
{
return EPERM;
}
241,12 → 248,13
ipc_answer_0(rid, ENOTDIR);
return;
}
unsigned long index = create_node(dcur,
void *nodep = create_node(dcur,
component, lflag);
if (index > 0) {
ipc_answer_4(rid, EOK,
if (nodep) {
ipc_answer_5(rid, EOK,
tmpfs_reg.fs_handle, dev_handle,
index, 0);
TMPFS_GET_INDEX(nodep), 0,
TMPFS_GET_LNKCNT(nodep));
} else {
ipc_answer_0(rid, ENOSPC);
}
288,11 → 296,11
component[len] = '\0';
len = 0;
unsigned long index;
index = create_node(dcur, component, lflag);
if (index) {
ipc_answer_4(rid, EOK, tmpfs_reg.fs_handle,
dev_handle, index, 0);
void *nodep = create_node(dcur, component, lflag);
if (nodep) {
ipc_answer_5(rid, EOK, tmpfs_reg.fs_handle,
dev_handle, TMPFS_GET_INDEX(nodep), 0,
TMPFS_GET_LNKCNT(nodep));
} else {
ipc_answer_0(rid, ENOSPC);
}
321,8 → 329,8
return;
}
 
ipc_answer_4(rid, EOK, tmpfs_reg.fs_handle, dev_handle, dcur->index,
dcur->size);
ipc_answer_5(rid, EOK, tmpfs_reg.fs_handle, dev_handle, dcur->index,
dcur->size, TMPFS_GET_LNKCNT(dcur));
}
 
void tmpfs_read(ipc_callid_t rid, ipc_call_t *request)
/trunk/uspace/srv/vfs/vfs.h
173,6 → 173,7
typedef struct {
vfs_triplet_t triplet;
size_t size;
unsigned lnkcnt;
} vfs_lookup_res_t;
 
/**
181,7 → 182,16
*/
typedef struct {
VFS_TRIPLET; /**< Identity of the node. */
unsigned refcnt; /**< Usage counter. */
 
/**
* Usage counter. This includes, but is not limited to, all vfs_file_t
* structures that reference this node.
*/
unsigned refcnt;
/** Number of names this node has in the file system namespace. */
unsigned lnkcnt;
 
link_t nh_link; /**< Node hash-table link. */
size_t size; /**< Cached size of the file. */
 
/trunk/uspace/srv/vfs/vfs_node.c
148,6 → 148,7
node->dev_handle = result->triplet.fs_handle;
node->index = result->triplet.index;
node->size = result->size;
node->lnkcnt = result->lnkcnt;
link_initialize(&node->nh_link);
rwlock_initialize(&node->contents_rwlock);
hash_table_insert(&nodes, key, &node->nh_link);
156,6 → 157,7
}
 
assert(node->size == result->size);
assert(node->lnkcnt == result->lnkcnt);
 
_vfs_node_addref(node);
futex_up(&nodes_futex);
/trunk/uspace/srv/vfs/vfs_lookup.c
168,6 → 168,7
result->triplet.dev_handle = (int) IPC_GET_ARG2(answer);
result->triplet.index = (int) IPC_GET_ARG3(answer);
result->size = (size_t) IPC_GET_ARG4(answer);
result->lnkcnt = (unsigned) IPC_GET_ARG5(answer);
}
 
return rc;