Changeset ce13577 in mainline
- Timestamp:
- 2011-02-16T08:20:59Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5352d72
- Parents:
- d241aae
- Location:
- uspace/lib/ext2
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext2/Makefile
rd241aae rce13577 37 37 libext2_filesystem.c \ 38 38 libext2_superblock.c \ 39 libext2_block_group.c 39 libext2_block_group.c \ 40 libext2_inode.c 40 41 41 42 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/ext2/libext2.h
rd241aae rce13577 39 39 #include "libext2_superblock.h" 40 40 #include "libext2_block_group.h" 41 #include "libext2_inode.h" 41 42 #include "libext2_filesystem.h" 42 43 -
uspace/lib/ext2/libext2_filesystem.c
rd241aae rce13577 37 37 #include "libext2_superblock.h" 38 38 #include "libext2_block_group.h" 39 #include "libext2_inode.h" 39 40 #include <errno.h> 40 41 #include <libblock.h> … … 170 171 171 172 /** 173 * Get a reference to inode 174 * 175 * @param fs Pointer to filesystem information 176 * @param index The index number of the inode 177 * @param ref Pointer where to store pointer to inode reference 178 * 179 * @return EOK on success or negative error code on failure 180 */ 181 int ext2_filesystem_get_inode_ref(ext2_filesystem_t *fs, uint32_t index, 182 ext2_inode_ref_t **ref) 183 { 184 int rc; 185 aoff64_t block_id; 186 uint32_t block_group; 187 uint32_t offset_in_group; 188 uint32_t inodes_per_group; 189 uint32_t inode_table_start; 190 uint16_t inode_size; 191 uint32_t block_size; 192 ext2_block_group_ref_t *bg_ref; 193 ext2_inode_ref_t *newref; 194 195 newref = malloc(sizeof(ext2_inode_ref_t)); 196 if (newref == NULL) { 197 return ENOMEM; 198 } 199 200 inodes_per_group = ext2_superblock_get_inodes_per_group(fs->superblock); 201 202 // inode numbers are 1-based 203 index -= 1; 204 block_group = index / inodes_per_group; 205 offset_in_group = index % inodes_per_group; 206 207 rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg_ref); 208 if (rc != EOK) { 209 free(newref); 210 return rc; 211 } 212 213 inode_table_start = ext2_block_group_get_inode_table_first_block( 214 bg_ref->block_group); 215 216 inode_size = ext2_superblock_get_inode_size(fs->superblock); 217 block_size = ext2_superblock_get_block_size(fs->superblock); 218 219 block_id = inode_table_start + ((index * inode_size) / block_size); 220 221 rc = block_get(&newref->block, fs->device, block_id, 0); 222 if (rc != EOK) { 223 free(newref); 224 return rc; 225 } 226 227 newref->inode = newref->block->data + offset_in_group; 228 229 *ref = newref; 230 231 return EOK; 232 } 233 234 /** 235 * Free a reference to inode 236 * 237 * @param ref Pointer to inode reference to free 238 * 239 * @return EOK on success or negative error code on failure 240 */ 241 int ext2_filesystem_put_inode_ref(ext2_inode_ref_t *ref) 242 { 243 int rc; 244 245 rc = block_put(ref->block); 246 free(ref); 247 248 return rc; 249 } 250 251 /** 172 252 * Finalize an instance of filesystem 173 253 * -
uspace/lib/ext2/libext2_filesystem.h
rd241aae rce13577 40 40 #include "libext2_superblock.h" 41 41 #include "libext2_block_group.h" 42 #include "libext2_inode.h" 42 43 43 44 typedef struct ext2_filesystem { … … 56 57 ext2_block_group_ref_t **); 57 58 extern int ext2_filesystem_put_block_group_ref(ext2_block_group_ref_t *); 59 extern int ext2_filesystem_get_inode_ref(ext2_filesystem_t *, uint32_t, 60 ext2_inode_ref_t **); 61 extern int ext2_filesystem_put_inode_ref(ext2_inode_ref_t *); 58 62 extern void ext2_filesystem_fini(ext2_filesystem_t *); 59 63
Note:
See TracChangeset
for help on using the changeset viewer.