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