Changeset 4e36219 in mainline for uspace/srv
- Timestamp:
- 2011-06-08T19:18:52Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b5085a7, c028b22
- Parents:
- 911ee54
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/ext2fs/ext2fs_ops.c
r911ee54 r4e36219 241 241 } 242 242 243 rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref );243 rc = ext2_directory_iterator_init(&it, fs, eparent->inode_ref, 0); 244 244 if (rc != EOK) { 245 245 return rc; … … 479 479 } 480 480 481 rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref );481 rc = ext2_directory_iterator_init(&it, fs, enode->inode_ref, 0); 482 482 if (rc != EOK) { 483 483 EXT2FS_DBG("error %u", rc); … … 819 819 { 820 820 ext2_directory_iterator_t it; 821 aoff64_t cur;821 aoff64_t next; 822 822 uint8_t *buf; 823 823 size_t name_size; … … 825 825 bool found = false; 826 826 827 rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref );827 rc = ext2_directory_iterator_init(&it, inst->filesystem, inode_ref, pos); 828 828 if (rc != EOK) { 829 829 async_answer_0(callid, rc); … … 832 832 } 833 833 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 834 /* Find next interesting directory entry. 835 * We want to skip . and .. entries 838 836 * as these are not used in HelenOS 839 837 */ 840 cur = 0;841 838 while (it.current != NULL) { 842 839 if (it.current->inode == 0) { … … 852 849 } 853 850 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++; 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; 875 868 876 869 skip: … … 884 877 } 885 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 886 888 rc = ext2_directory_iterator_fini(&it); 887 889 if (rc != EOK) { … … 891 893 892 894 if (found) { 893 async_answer_1(rid, EOK, 1);895 async_answer_1(rid, EOK, next-pos); 894 896 } 895 897 else {
Note:
See TracChangeset
for help on using the changeset viewer.