Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2924 → Rev 2925

/branches/tracing/uspace/srv/fs/tmpfs/tmpfs_ops.c
69,12 → 69,13
*/
 
/* Forward declarations of static functions. */
static bool tmpfs_match(void *, void *, const char *);
static void *tmpfs_node_get(fs_handle_t, dev_handle_t, fs_index_t);
static void *tmpfs_match(void *, const char *);
static void *tmpfs_node_get(dev_handle_t, fs_index_t);
static void tmpfs_node_put(void *);
static void *tmpfs_create_node(int);
static bool tmpfs_link_node(void *, void *, const char *);
static int tmpfs_unlink_node(void *, void *);
static void tmpfs_destroy_node(void *);
static int tmpfs_destroy_node(void *);
 
/* Implementation of helper functions. */
static fs_index_t tmpfs_index_get(void *nodep)
92,18 → 93,13
return ((tmpfs_dentry_t *) nodep)->lnkcnt;
}
 
static void *tmpfs_child_get(void *nodep)
static bool tmpfs_has_children(void *nodep)
{
return ((tmpfs_dentry_t *) nodep)->child;
return ((tmpfs_dentry_t *) nodep)->child != NULL;
}
 
static void *tmpfs_sibling_get(void *nodep)
static void *tmpfs_root_get(dev_handle_t dev_handle)
{
return ((tmpfs_dentry_t *) nodep)->sibling;
}
 
static void *tmpfs_root_get(void)
{
return root;
}
 
126,6 → 122,7
libfs_ops_t tmpfs_libfs_ops = {
.match = tmpfs_match,
.node_get = tmpfs_node_get,
.node_put = tmpfs_node_put,
.create = tmpfs_create_node,
.destroy = tmpfs_destroy_node,
.link = tmpfs_link_node,
133,8 → 130,7
.index_get = tmpfs_index_get,
.size_get = tmpfs_size_get,
.lnkcnt_get = tmpfs_lnkcnt_get,
.child_get = tmpfs_child_get,
.sibling_get = tmpfs_sibling_get,
.has_children = tmpfs_has_children,
.root_get = tmpfs_root_get,
.plb_get_char = tmpfs_plb_get_char,
.is_directory = tmpfs_is_directory,
243,27 → 239,36
 
/** Compare one component of path to a directory entry.
*
* @param prnt Node from which we descended.
* @param chld Node to compare the path component with.
* @param parentp Pointer to node from which we descended.
* @param childp Pointer to node to compare the path component with.
* @param component Array of characters holding component name.
*
* @return True on match, false otherwise.
*/
bool tmpfs_match(void *prnt, void *chld, const char *component)
static bool
tmpfs_match_one(tmpfs_dentry_t *parentp, tmpfs_dentry_t *childp,
const char *component)
{
tmpfs_dentry_t *parentp = (tmpfs_dentry_t *) prnt;
tmpfs_dentry_t *childp = (tmpfs_dentry_t *) chld;
 
unsigned long key = (unsigned long) parentp;
link_t *hlp = hash_table_find(&childp->names, &key);
assert(hlp);
tmpfs_name_t *namep = hash_table_get_instance(hlp, tmpfs_name_t, link);
 
return !strcmp(namep->name, component);
}
 
void *tmpfs_match(void *prnt, const char *component)
{
tmpfs_dentry_t *parentp = (tmpfs_dentry_t *) prnt;
tmpfs_dentry_t *childp = parentp->child;
 
while (childp && !tmpfs_match_one(parentp, childp, component))
childp = childp->sibling;
 
return (void *) childp;
}
 
void *
tmpfs_node_get(fs_handle_t fs_handle, dev_handle_t dev_handle, fs_index_t index)
tmpfs_node_get(dev_handle_t dev_handle, fs_index_t index)
{
unsigned long key = index;
link_t *lnk = hash_table_find(&dentries, &key);
272,6 → 277,11
return hash_table_get_instance(lnk, tmpfs_dentry_t, dh_link);
}
 
void tmpfs_node_put(void *node)
{
/* nothing to do */
}
 
void *tmpfs_create_node(int lflag)
{
assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
364,7 → 374,7
return EOK;
}
 
void tmpfs_destroy_node(void *nodep)
int tmpfs_destroy_node(void *nodep)
{
tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) nodep;
380,6 → 390,7
if (dentry->type == TMPFS_FILE)
free(dentry->data);
free(dentry);
return EOK;
}
 
void tmpfs_lookup(ipc_callid_t rid, ipc_call_t *request)
568,6 → 579,7
{
dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
int rc;
 
link_t *hlp;
unsigned long key = index;
578,8 → 590,8
}
tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t,
dh_link);
tmpfs_destroy_node(dentry);
ipc_answer_0(rid, EOK);
rc = tmpfs_destroy_node(dentry);
ipc_answer_0(rid, rc);
}
 
/**