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


Ignore:
Timestamp:
2011-06-19T14:38:59Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
74464e8
Parents:
1d1bb0f
Message:

Separate list_t typedef from link_t (user-space part).

  • list_t represents lists
  • Use list_first(), list_last(), list_empty() where appropriate
  • Use list_foreach() where possible
  • assert_link_not_used()
  • usb_hid_report_path_free() shall not unlink the path, caller must do it
File:
1 edited

Legend:

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

    r1d1bb0f rb72efe8  
    8585static int tmpfs_has_children(bool *has_children, fs_node_t *fn)
    8686{
    87         *has_children = !list_empty(&TMPFS_NODE(fn)->cs_head);
     87        *has_children = !list_empty(&TMPFS_NODE(fn)->cs_list);
    8888        return EOK;
    8989}
     
    180180            nh_link);
    181181
    182         while (!list_empty(&nodep->cs_head)) {
    183                 tmpfs_dentry_t *dentryp = list_get_instance(nodep->cs_head.next,
    184                     tmpfs_dentry_t, link);
     182        while (!list_empty(&nodep->cs_list)) {
     183                tmpfs_dentry_t *dentryp = list_get_instance(
     184                    list_first(&nodep->cs_list), tmpfs_dentry_t, link);
    185185
    186186                assert(nodep->type == TMPFS_DIRECTORY);
     
    214214        nodep->data = NULL;
    215215        link_initialize(&nodep->nh_link);
    216         list_initialize(&nodep->cs_head);
     216        list_initialize(&nodep->cs_list);
    217217}
    218218
     
    262262{
    263263        tmpfs_node_t *parentp = TMPFS_NODE(pfn);
    264         link_t *lnk;
    265 
    266         for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
    267             lnk = lnk->next) {
     264
     265        list_foreach(parentp->cs_list, lnk) {
    268266                tmpfs_dentry_t *dentryp;
    269267                dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
     
    353351       
    354352        assert(!nodep->lnkcnt);
    355         assert(list_empty(&nodep->cs_head));
     353        assert(list_empty(&nodep->cs_list));
    356354
    357355        unsigned long key[] = {
     
    373371        tmpfs_node_t *childp = TMPFS_NODE(cfn);
    374372        tmpfs_dentry_t *dentryp;
    375         link_t *lnk;
    376373
    377374        assert(parentp->type == TMPFS_DIRECTORY);
    378375
    379376        /* Check for duplicit entries. */
    380         for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
    381             lnk = lnk->next) {
     377        list_foreach(parentp->cs_list, lnk) {
    382378                dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
    383379                if (!str_cmp(dentryp->name, nm))
     
    401397        dentryp->node = childp;
    402398        childp->lnkcnt++;
    403         list_append(&dentryp->link, &parentp->cs_head);
     399        list_append(&dentryp->link, &parentp->cs_list);
    404400
    405401        return EOK;
     
    411407        tmpfs_node_t *childp = NULL;
    412408        tmpfs_dentry_t *dentryp;
    413         link_t *lnk;
    414409
    415410        if (!parentp)
    416411                return EBUSY;
    417412       
    418         for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
    419             lnk = lnk->next) {
     413        list_foreach(parentp->cs_list, lnk) {
    420414                dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
    421415                if (!str_cmp(dentryp->name, nm)) {
     
    423417                        assert(FS_NODE(childp) == cfn);
    424418                        break;
    425                 }       
     419                }
    426420        }
    427421
     
    429423                return ENOENT;
    430424               
    431         if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_head))
     425        if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_list))
    432426                return ENOTEMPTY;
    433427
     
    550544                tmpfs_dentry_t *dentryp;
    551545                link_t *lnk;
    552                 aoff64_t i;
    553546               
    554547                assert(nodep->type == TMPFS_DIRECTORY);
     
    559552                 * hash table.
    560553                 */
    561                 for (i = 0, lnk = nodep->cs_head.next;
    562                     (i < pos) && (lnk != &nodep->cs_head);
    563                     i++, lnk = lnk->next)
    564                         ;
    565 
    566                 if (lnk == &nodep->cs_head) {
     554                lnk = list_nth(&nodep->cs_list, pos);
     555               
     556                if (lnk == NULL) {
    567557                        async_answer_0(callid, ENOENT);
    568558                        async_answer_1(rid, ENOENT, 0);
Note: See TracChangeset for help on using the changeset viewer.