Changeset 7b6d98b in mainline


Ignore:
Timestamp:
2008-03-05T22:11:57Z (16 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.

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libfs/libfs.c

    r3ca7059 r7b6d98b  
    146146                last += PLB_SIZE;
    147147
     148        void *par = NULL;
    148149        void *cur = ops->root_get();
    149150        void *tmp = ops->child_get(cur);
     
    207208
    208209                /* descend one level */
     210                par = cur;
    209211                cur = tmp;
    210212                tmp = ops->child_get(tmp);
     
    261263        if (lflag & L_DESTROY) {
    262264                unsigned old_lnkcnt = ops->lnkcnt_get(cur);
    263                 int res = ops->unlink(cur);
     265                int res = ops->unlink(par, cur);
    264266                ipc_answer_5(rid, (ipcarg_t)res, fs_handle, dev_handle,
    265267                    ops->index_get(cur), ops->size_get(cur), old_lnkcnt);
  • uspace/lib/libfs/libfs.h

    r3ca7059 r7b6d98b  
    4747        void (* destroy)(void *);
    4848        bool (* link)(void *, void *, const char *);
    49         int (* unlink)(void *);
     49        int (* unlink)(void *, void *);
    5050        unsigned long (* index_get)(void *);
    5151        unsigned long (* size_get)(void *);
  • uspace/srv/fs/tmpfs/tmpfs.h

    r3ca7059 r7b6d98b  
    4646        unsigned long index;    /**< TMPFS node index. */
    4747        link_t dh_link;         /**< Dentries hash table link. */
    48         struct tmpfs_dentry *parent;
    4948        struct tmpfs_dentry *sibling;
    5049        struct tmpfs_dentry *child;
  • 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.