Changeset e4f8c77 in mainline for uspace/srv/fs/ext2fs/ext2fs_ops.c


Ignore:
Timestamp:
2011-07-13T22:39:18Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6910c8
Parents:
5974661 (diff), 8ecef91 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix.

File:
1 edited

Legend:

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

    r5974661 re4f8c77  
    187187{
    188188        EXT2FS_DBG("(%" PRIun ", -)", devmap_handle);
    189         link_t *link;
    190189        ext2fs_instance_t *tmp;
    191190       
     
    198197        }
    199198
    200         for (link = instance_list.next; link != &instance_list; link = link->next) {
     199        list_foreach(instance_list, link) {
    201200                tmp = list_get_instance(link, ext2fs_instance_t, link);
    202201               
     
    241240        }
    242241       
    243         rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref);
     242        rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref, 0);
    244243        if (rc != EOK) {
    245244                return rc;
     
    479478        }
    480479       
    481         rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref);
     480        rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref, 0);
    482481        if (rc != EOK) {
    483482                EXT2FS_DBG("error %u", rc);
     
    819818{
    820819        ext2_directory_iterator_t it;
    821         aoff64_t cur;
     820        aoff64_t next;
    822821        uint8_t *buf;
    823822        size_t name_size;
     
    825824        bool found = false;
    826825       
    827         rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref);
     826        rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref, pos);
    828827        if (rc != EOK) {
    829828                async_answer_0(callid, rc);
     
    832831        }
    833832       
    834         /* Find the index we want to read
    835          * Note that we need to iterate and count as
    836          * the underlying structure is a linked list
    837          * Moreover, we want to skip . and .. entries
     833        /* Find next interesting directory entry.
     834         * We want to skip . and .. entries
    838835         * as these are not used in HelenOS
    839836         */
    840         cur = 0;
    841837        while (it.current != NULL) {
    842838                if (it.current->inode == 0) {
     
    852848                }
    853849               
    854                 /* Is this the dir entry we want to read? */
    855                 if (cur == pos) {
    856                         /* The on-disk entry does not contain \0 at the end
    857                          * end of entry name, so we copy it to new buffer
    858                          * and add the \0 at the end
    859                          */
    860                         buf = malloc(name_size+1);
    861                         if (buf == NULL) {
    862                                 ext2_directory_iterator_fini(&it);
    863                                 async_answer_0(callid, ENOMEM);
    864                                 async_answer_0(rid, ENOMEM);
    865                                 return;
    866                         }
    867                         memcpy(buf, &it.current->name, name_size);
    868                         *(buf+name_size) = 0;
    869                         found = true;
    870                         (void) async_data_read_finalize(callid, buf, name_size+1);
    871                         free(buf);
    872                         break;
    873                 }
    874                 cur++;
     850                /* The on-disk entry does not contain \0 at the end
     851                        * end of entry name, so we copy it to new buffer
     852                        * and add the \0 at the end
     853                        */
     854                buf = malloc(name_size+1);
     855                if (buf == NULL) {
     856                        ext2_directory_iterator_fini(&it);
     857                        async_answer_0(callid, ENOMEM);
     858                        async_answer_0(rid, ENOMEM);
     859                        return;
     860                }
     861                memcpy(buf, &it.current->name, name_size);
     862                *(buf+name_size) = 0;
     863                found = true;
     864                (void) async_data_read_finalize(callid, buf, name_size+1);
     865                free(buf);
     866                break;
    875867               
    876868skip:
     
    884876        }
    885877       
     878        if (found) {
     879                rc = ext2_directory_iterator_next(&it);
     880                if (rc != EOK) {
     881                        async_answer_0(rid, rc);
     882                        return;
     883                }
     884                next = it.current_offset;
     885        }
     886       
    886887        rc = ext2_directory_iterator_fini(&it);
    887888        if (rc != EOK) {
     
    891892       
    892893        if (found) {
    893                 async_answer_1(rid, EOK, 1);
     894                async_answer_1(rid, EOK, next-pos);
    894895        }
    895896        else {
Note: See TracChangeset for help on using the changeset viewer.