Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2757 → Rev 2758

/trunk/uspace/lib/libfs/libfs.c
145,6 → 145,7
if (last < next)
last += PLB_SIZE;
 
void *par = NULL;
void *cur = ops->root_get();
void *tmp = ops->child_get(cur);
 
206,6 → 207,7
}
 
/* descend one level */
par = cur;
cur = tmp;
tmp = ops->child_get(tmp);
}
260,7 → 262,7
/* handle hit */
if (lflag & L_DESTROY) {
unsigned old_lnkcnt = ops->lnkcnt_get(cur);
int res = ops->unlink(cur);
int res = ops->unlink(par, cur);
ipc_answer_5(rid, (ipcarg_t)res, fs_handle, dev_handle,
ops->index_get(cur), ops->size_get(cur), old_lnkcnt);
return;
/trunk/uspace/lib/libfs/libfs.h
46,7 → 46,7
void * (* create)(int);
void (* destroy)(void *);
bool (* link)(void *, void *, const char *);
int (* unlink)(void *);
int (* unlink)(void *, void *);
unsigned long (* index_get)(void *);
unsigned long (* size_get)(void *);
unsigned (* lnkcnt_get)(void *);
/trunk/uspace/srv/fs/tmpfs/tmpfs.h
45,7 → 45,6
typedef struct tmpfs_dentry {
unsigned long index; /**< TMPFS node index. */
link_t dh_link; /**< Dentries hash table link. */
struct tmpfs_dentry *parent;
struct tmpfs_dentry *sibling;
struct tmpfs_dentry *child;
char *name;
/trunk/uspace/srv/fs/tmpfs/tmpfs_ops.c
70,7 → 70,7
static bool tmpfs_match(void *, const char *);
static void *tmpfs_create_node(int);
static bool tmpfs_link_node(void *, void *, const char *);
static int tmpfs_unlink_node(void *);
static int tmpfs_unlink_node(void *, void *);
static void tmpfs_destroy_node(void *);
 
/* Implementation of helper functions. */
170,7 → 170,6
static void tmpfs_dentry_initialize(tmpfs_dentry_t *dentry)
{
dentry->index = 0;
dentry->parent = NULL;
dentry->sibling = NULL;
dentry->child = NULL;
dentry->name = NULL;
250,37 → 249,36
} else {
parentp->child = childp;
}
childp->parent = parentp;
 
return true;
}
 
int tmpfs_unlink_node(void *nodeptr)
int tmpfs_unlink_node(void *prnt, void *chld)
{
tmpfs_dentry_t *dentry = (tmpfs_dentry_t *)nodeptr;
tmpfs_dentry_t *parentp = (tmpfs_dentry_t *)prnt;
tmpfs_dentry_t *childp = (tmpfs_dentry_t *)chld;
 
if (dentry->child)
if (!parentp)
return EBUSY;
 
if (childp->child)
return ENOTEMPTY;
 
if (!dentry->parent)
return EBUSY;
 
if (dentry->parent->child == dentry) {
dentry->parent->child = dentry->sibling;
if (parentp->child == childp) {
parentp->child = childp->sibling;
} else {
/* TODO: consider doubly linked list for organizing siblings. */
tmpfs_dentry_t *tmp = dentry->parent->child;
while (tmp->sibling != dentry)
tmpfs_dentry_t *tmp = parentp->child;
while (tmp->sibling != childp)
tmp = tmp->sibling;
tmp->sibling = dentry->sibling;
tmp->sibling = childp->sibling;
}
dentry->sibling = NULL;
dentry->parent = NULL;
childp->sibling = NULL;
 
free(dentry->name);
dentry->name = NULL;
free(childp->name);
childp->name = NULL;
 
dentry->lnkcnt--;
childp->lnkcnt--;
 
return EOK;
}