Changeset 7b6d98b in mainline for uspace/srv/fs/tmpfs/tmpfs_ops.c


Ignore:
Timestamp:
2008-03-05T22:11:57Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
739d00a
Parents:
3ca7059
Message:

No need to keep the parent pointer in the TMPFS node. Moreover, other file
systems won't have it either. Finally, if TMPFS is to support hardlinks, there
can be multiple parents.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r3ca7059 r7b6d98b  
    7171static void *tmpfs_create_node(int);
    7272static bool tmpfs_link_node(void *, void *, const char *);
    73 static int tmpfs_unlink_node(void *);
     73static int tmpfs_unlink_node(void *, void *);
    7474static void tmpfs_destroy_node(void *);
    7575
     
    171171{
    172172        dentry->index = 0;
    173         dentry->parent = NULL;
    174173        dentry->sibling = NULL;
    175174        dentry->child = NULL;
     
    251250                parentp->child = childp;
    252251        }
    253         childp->parent = parentp;
    254252
    255253        return true;
    256254}
    257255
    258 int tmpfs_unlink_node(void *nodeptr)
    259 {
    260         tmpfs_dentry_t *dentry = (tmpfs_dentry_t *)nodeptr;
    261 
    262         if (dentry->child)
     256int tmpfs_unlink_node(void *prnt, void *chld)
     257{
     258        tmpfs_dentry_t *parentp = (tmpfs_dentry_t *)prnt;
     259        tmpfs_dentry_t *childp = (tmpfs_dentry_t *)chld;
     260
     261        if (!parentp)
     262                return EBUSY;
     263
     264        if (childp->child)
    263265                return ENOTEMPTY;
    264266
    265         if (!dentry->parent)
    266                 return EBUSY;
    267 
    268         if (dentry->parent->child == dentry) {
    269                 dentry->parent->child = dentry->sibling;
     267        if (parentp->child == childp) {
     268                parentp->child = childp->sibling;
    270269        } else {
    271270                /* TODO: consider doubly linked list for organizing siblings. */
    272                 tmpfs_dentry_t *tmp = dentry->parent->child;
    273                 while (tmp->sibling != dentry)
     271                tmpfs_dentry_t *tmp = parentp->child;
     272                while (tmp->sibling != childp)
    274273                        tmp = tmp->sibling;
    275                 tmp->sibling = dentry->sibling;
    276         }
    277         dentry->sibling = NULL;
    278         dentry->parent = NULL;
    279 
    280         free(dentry->name);
    281         dentry->name = NULL;
    282 
    283         dentry->lnkcnt--;
     274                tmp->sibling = childp->sibling;
     275        }
     276        childp->sibling = NULL;
     277
     278        free(childp->name);
     279        childp->name = NULL;
     280
     281        childp->lnkcnt--;
    284282
    285283        return EOK;
Note: See TracChangeset for help on using the changeset viewer.