Changeset e4f8c77 in mainline for uspace/srv/fs/ext2fs/ext2fs_ops.c
- Timestamp:
- 2011-07-13T22:39:18Z (13 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/ext2fs/ext2fs_ops.c
r5974661 re4f8c77 187 187 { 188 188 EXT2FS_DBG("(%" PRIun ", -)", devmap_handle); 189 link_t *link;190 189 ext2fs_instance_t *tmp; 191 190 … … 198 197 } 199 198 200 for (link = instance_list.next; link != &instance_list; link = link->next) {199 list_foreach(instance_list, link) { 201 200 tmp = list_get_instance(link, ext2fs_instance_t, link); 202 201 … … 241 240 } 242 241 243 rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref );242 rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref, 0); 244 243 if (rc != EOK) { 245 244 return rc; … … 479 478 } 480 479 481 rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref );480 rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref, 0); 482 481 if (rc != EOK) { 483 482 EXT2FS_DBG("error %u", rc); … … 819 818 { 820 819 ext2_directory_iterator_t it; 821 aoff64_t cur;820 aoff64_t next; 822 821 uint8_t *buf; 823 822 size_t name_size; … … 825 824 bool found = false; 826 825 827 rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref );826 rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref, pos); 828 827 if (rc != EOK) { 829 828 async_answer_0(callid, rc); … … 832 831 } 833 832 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 838 835 * as these are not used in HelenOS 839 836 */ 840 cur = 0;841 837 while (it.current != NULL) { 842 838 if (it.current->inode == 0) { … … 852 848 } 853 849 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; 875 867 876 868 skip: … … 884 876 } 885 877 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 886 887 rc = ext2_directory_iterator_fini(&it); 887 888 if (rc != EOK) { … … 891 892 892 893 if (found) { 893 async_answer_1(rid, EOK, 1);894 async_answer_1(rid, EOK, next-pos); 894 895 } 895 896 else {
Note:
See TracChangeset
for help on using the changeset viewer.