Changes in / [5c96b2a:ff4f073] in mainline
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/ext2info/ext2info.c
r5c96b2a rff4f073 586 586 ext2_directory_iterator_t it; 587 587 size_t name_size; 588 uint32_t inode; 588 589 589 590 printf(" Directory contents:\n"); … … 600 601 printf(" "); 601 602 print_data(&it.current->name, name_size); 602 printf(" --> %u\n", it.current->inode); 603 604 inode = ext2_directory_entry_ll_get_inode(it.current); 605 printf(" --> %u\n", inode); 603 606 604 607 rc = ext2_directory_iterator_next(&it); -
uspace/lib/ext2/libext2_directory.c
r5c96b2a rff4f073 40 40 #include <assert.h> 41 41 42 static int ext2_directory_iterator_set(ext2_directory_iterator_t *it, 43 uint32_t block_size); 44 42 45 /** 43 46 * Get inode number for the directory entry … … 90 93 int rc; 91 94 uint32_t block_id; 95 uint32_t block_size; 96 92 97 it->inode_ref = inode_ref; 93 98 it->fs = fs; … … 105 110 } 106 111 107 it->current = it->current_block->data;108 it->current_offset = 0;109 110 return EOK;112 block_size = ext2_superblock_get_block_size(fs->superblock); 113 114 it->current_offset = 0; 115 return ext2_directory_iterator_set(it, block_size); 111 116 } 112 117 … … 126 131 uint32_t next_block_phys_idx; 127 132 uint32_t block_size; 128 uint32_t offset_in_block;129 133 130 134 assert(it->current != NULL); … … 175 179 } 176 180 177 offset_in_block = (it->current_offset + skip) % block_size; 181 it->current_offset += skip; 182 return ext2_directory_iterator_set(it, block_size); 183 } 184 185 static int ext2_directory_iterator_set(ext2_directory_iterator_t *it, 186 uint32_t block_size) 187 { 188 uint32_t offset_in_block = it->current_offset % block_size; 189 190 it->current = NULL; 178 191 179 192 /* Ensure proper alignment */ 180 193 if ((offset_in_block % 4) != 0) { 181 it->current = NULL;182 194 return EIO; 183 195 } … … 185 197 /* Ensure that the core of the entry does not overflow the block */ 186 198 if (offset_in_block > block_size - 8) { 187 it->current = NULL; 188 return EIO; 189 } 190 191 it->current = it->current_block->data + offset_in_block; 192 it->current_offset += skip; 199 return EIO; 200 } 201 202 ext2_directory_entry_ll_t *entry = it->current_block->data + offset_in_block; 193 203 194 204 /* Ensure that the whole entry does not overflow the block */ 195 skip = ext2_directory_entry_ll_get_entry_length(it->current); 196 if (offset_in_block + skip > block_size) { 197 it->current = NULL; 205 uint16_t length = ext2_directory_entry_ll_get_entry_length(entry); 206 if (offset_in_block + length > block_size) { 198 207 return EIO; 199 208 } … … 201 210 /* Ensure the name length is not too large */ 202 211 if (ext2_directory_entry_ll_get_name_length(it->fs->superblock, 203 it->current) > skip-8) {204 it->current = NULL;205 return EIO;206 }207 212 entry) > length-8) { 213 return EIO; 214 } 215 216 it->current = entry; 208 217 return EOK; 209 218 } -
uspace/lib/ext2/libext2_filesystem.c
r5c96b2a rff4f073 42 42 #include <malloc.h> 43 43 #include <assert.h> 44 #include <byteorder.h> 44 45 45 46 /** … … 369 370 370 371 assert(offset_in_block < block_ids_per_block); 371 current_block = ((uint32_t*)block->data)[offset_in_block];372 current_block = uint32_t_le2host(((uint32_t*)block->data)[offset_in_block]); 372 373 373 374 rc = block_put(block); -
uspace/lib/ext2/libext2_superblock.c
r5c96b2a rff4f073 184 184 return EXT2_REV0_INODE_SIZE; 185 185 } 186 return uint 32_t_le2host(sb->inode_size);186 return uint16_t_le2host(sb->inode_size); 187 187 } 188 188 -
uspace/srv/fs/ext2fs/ext2fs_ops.c
r5c96b2a rff4f073 232 232 size_t component_size; 233 233 bool found = false; 234 uint32_t inode; 234 235 235 236 fs = eparent->instance->filesystem; … … 254 255 255 256 while (it.current != NULL) { 257 inode = ext2_directory_entry_ll_get_inode(it.current); 258 256 259 /* ignore empty directory entries */ 257 if (i t.current->inode != 0) {260 if (inode != 0) { 258 261 name_size = ext2_directory_entry_ll_get_name_length(fs->superblock, 259 262 it.current); … … 262 265 name_size) == 0) { 263 266 rc = ext2fs_node_get_core(rfn, eparent->instance, 264 i t.current->inode);267 inode); 265 268 if (rc != EOK) { 266 269 ext2_directory_iterator_fini(&it);
Note:
See TracChangeset
for help on using the changeset viewer.