Changes in uspace/srv/fs/ext2fs/ext2fs_ops.c [4e36219:b72efe8] in mainline
- File:
-
- 1 edited
-
uspace/srv/fs/ext2fs/ext2fs_ops.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/ext2fs/ext2fs_ops.c
r4e36219 rb72efe8 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 , 0);242 rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref); 244 243 if (rc != EOK) { 245 244 return rc; … … 479 478 } 480 479 481 rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref , 0);480 rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref); 482 481 if (rc != EOK) { 483 482 EXT2FS_DBG("error %u", rc); … … 819 818 { 820 819 ext2_directory_iterator_t it; 821 aoff64_t next;820 aoff64_t cur; 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 , pos);826 rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref); 828 827 if (rc != EOK) { 829 828 async_answer_0(callid, rc); … … 832 831 } 833 832 834 /* Find next interesting directory entry. 835 * We want to skip . and .. entries 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 836 837 * as these are not used in HelenOS 837 838 */ 839 cur = 0; 838 840 while (it.current != NULL) { 839 841 if (it.current->inode == 0) { … … 849 851 } 850 852 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; 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; 861 872 } 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; 873 cur++; 868 874 869 875 skip: … … 877 883 } 878 884 885 rc = ext2_directory_iterator_fini(&it); 886 if (rc != EOK) { 887 async_answer_0(rid, rc); 888 return; 889 } 890 879 891 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 888 rc = ext2_directory_iterator_fini(&it); 889 if (rc != EOK) { 890 async_answer_0(rid, rc); 891 return; 892 } 893 894 if (found) { 895 async_answer_1(rid, EOK, next-pos); 892 async_answer_1(rid, EOK, 1); 896 893 } 897 894 else {
Note:
See TracChangeset
for help on using the changeset viewer.
