Changes in uspace/srv/fs/ext2fs/ext2fs_ops.c [b72efe8:4e36219] in mainline
- File:
-
- 1 edited
-
uspace/srv/fs/ext2fs/ext2fs_ops.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/ext2fs/ext2fs_ops.c
rb72efe8 r4e36219 187 187 { 188 188 EXT2FS_DBG("(%" PRIun ", -)", devmap_handle); 189 link_t *link; 189 190 ext2fs_instance_t *tmp; 190 191 … … 197 198 } 198 199 199 list_foreach(instance_list, link) {200 for (link = instance_list.next; link != &instance_list; link = link->next) { 200 201 tmp = list_get_instance(link, ext2fs_instance_t, link); 201 202 … … 240 241 } 241 242 242 rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref );243 rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref, 0); 243 244 if (rc != EOK) { 244 245 return rc; … … 478 479 } 479 480 480 rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref );481 rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref, 0); 481 482 if (rc != EOK) { 482 483 EXT2FS_DBG("error %u", rc); … … 818 819 { 819 820 ext2_directory_iterator_t it; 820 aoff64_t cur;821 aoff64_t next; 821 822 uint8_t *buf; 822 823 size_t name_size; … … 824 825 bool found = false; 825 826 826 rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref );827 rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref, pos); 827 828 if (rc != EOK) { 828 829 async_answer_0(callid, rc); … … 831 832 } 832 833 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 837 836 * as these are not used in HelenOS 838 837 */ 839 cur = 0;840 838 while (it.current != NULL) { 841 839 if (it.current->inode == 0) { … … 851 849 } 852 850 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; 874 868 875 869 skip: … … 883 877 } 884 878 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 885 888 rc = ext2_directory_iterator_fini(&it); 886 889 if (rc != EOK) { … … 890 893 891 894 if (found) { 892 async_answer_1(rid, EOK, 1);895 async_answer_1(rid, EOK, next-pos); 893 896 } 894 897 else {
Note:
See TracChangeset
for help on using the changeset viewer.
