Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/ext2fs/ext2fs_ops.c

    rb72efe8 r4e36219  
    187187{
    188188        EXT2FS_DBG("(%" PRIun ", -)", devmap_handle);
     189        link_t *link;
    189190        ext2fs_instance_t *tmp;
    190191       
     
    197198        }
    198199
    199         list_foreach(instance_list, link) {
     200        for (link = instance_list.next; link != &instance_list; link = link->next) {
    200201                tmp = list_get_instance(link, ext2fs_instance_t, link);
    201202               
     
    240241        }
    241242       
    242         rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref);
     243        rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref, 0);
    243244        if (rc != EOK) {
    244245                return rc;
     
    478479        }
    479480       
    480         rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref);
     481        rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref, 0);
    481482        if (rc != EOK) {
    482483                EXT2FS_DBG("error %u", rc);
     
    818819{
    819820        ext2_directory_iterator_t it;
    820         aoff64_t cur;
     821        aoff64_t next;
    821822        uint8_t *buf;
    822823        size_t name_size;
     
    824825        bool found = false;
    825826       
    826         rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref);
     827        rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref, pos);
    827828        if (rc != EOK) {
    828829                async_answer_0(callid, rc);
     
    831832        }
    832833       
    833         /* Find the index we want to read
    834          * Note that we need to iterate and count as
    835          * the underlying structure is a linked list
    836          * Moreover, we want to skip . and .. entries
     834        /* Find next interesting directory entry.
     835         * We want to skip . and .. entries
    837836         * as these are not used in HelenOS
    838837         */
    839         cur = 0;
    840838        while (it.current != NULL) {
    841839                if (it.current->inode == 0) {
     
    851849                }
    852850               
    853                 /* Is this the dir entry we want to read? */
    854                 if (cur == pos) {
    855                         /* The on-disk entry does not contain \0 at the end
    856                          * end of entry name, so we copy it to new buffer
    857                          * and add the \0 at the end
    858                          */
    859                         buf = malloc(name_size+1);
    860                         if (buf == NULL) {
    861                                 ext2_directory_iterator_fini(&it);
    862                                 async_answer_0(callid, ENOMEM);
    863                                 async_answer_0(rid, ENOMEM);
    864                                 return;
    865                         }
    866                         memcpy(buf, &it.current->name, name_size);
    867                         *(buf+name_size) = 0;
    868                         found = true;
    869                         (void) async_data_read_finalize(callid, buf, name_size+1);
    870                         free(buf);
    871                         break;
    872                 }
    873                 cur++;
     851                /* The on-disk entry does not contain \0 at the end
     852                        * end of entry name, so we copy it to new buffer
     853                        * and add the \0 at the end
     854                        */
     855                buf = malloc(name_size+1);
     856                if (buf == NULL) {
     857                        ext2_directory_iterator_fini(&it);
     858                        async_answer_0(callid, ENOMEM);
     859                        async_answer_0(rid, ENOMEM);
     860                        return;
     861                }
     862                memcpy(buf, &it.current->name, name_size);
     863                *(buf+name_size) = 0;
     864                found = true;
     865                (void) async_data_read_finalize(callid, buf, name_size+1);
     866                free(buf);
     867                break;
    874868               
    875869skip:
     
    883877        }
    884878       
     879        if (found) {
     880                rc = ext2_directory_iterator_next(&it);
     881                if (rc != EOK) {
     882                        async_answer_0(rid, rc);
     883                        return;
     884                }
     885                next = it.current_offset;
     886        }
     887       
    885888        rc = ext2_directory_iterator_fini(&it);
    886889        if (rc != EOK) {
     
    890893       
    891894        if (found) {
    892                 async_answer_1(rid, EOK, 1);
     895                async_answer_1(rid, EOK, next-pos);
    893896        }
    894897        else {
Note: See TracChangeset for help on using the changeset viewer.