Changeset 01ab41b in mainline
- Timestamp:
- 2011-10-03T11:57:14Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9c0c0e1
- Parents:
- 54935cf6
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_filesystem.c
r54935cf6 r01ab41b 37 37 38 38 #include <errno.h> 39 #include <malloc.h> 39 40 #include "libext4_filesystem.h" 40 41 42 /** 43 * TODO doxy 44 */ 41 45 int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id) 42 46 { 47 48 int rc; 49 ext4_superblock_t *temp_superblock; 50 size_t block_size; 51 52 fs->device = service_id; 53 54 // TODO block size !!! 55 rc = block_init(EXCHANGE_SERIALIZE, fs->device, 2048); 56 if (rc != EOK) { 57 return rc; 58 } 59 60 rc = ext4_superblock_read_direct(fs->device, &temp_superblock); 61 if (rc != EOK) { 62 block_fini(fs->device); 63 return rc; 64 } 65 66 block_size = ext4_superblock_get_block_size(temp_superblock); 67 68 if (block_size > EXT4_MAX_BLOCK_SIZE) { 69 block_fini(fs->device); 70 return ENOTSUP; 71 } 72 73 rc = block_cache_init(service_id, block_size, 0, CACHE_MODE_WT); 74 if (rc != EOK) { 75 block_fini(fs->device); 76 return rc; 77 } 78 79 fs->superblock = temp_superblock; 80 81 43 82 // TODO 44 83 return EOK; 45 84 } 46 85 86 /** 87 * TODO doxy 88 */ 47 89 int ext4_filesystem_check_sanity(ext4_filesystem_t *fs) 48 90 { 49 // TODO 91 int rc; 92 93 rc = ext4_superblock_check_sanity(fs->superblock); 94 if (rc != EOK) { 95 return rc; 96 } 97 50 98 return EOK; 51 99 } 52 100 101 /** 102 * TODO doxy 103 */ 53 104 int ext4_filesystem_check_flags(ext4_filesystem_t *fs, bool *o_read_only) 54 105 { … … 57 108 } 58 109 110 /** 111 * TODO doxy 112 */ 59 113 void ext4_filesystem_fini(ext4_filesystem_t *fs) 60 114 { 61 // TODO 115 free(fs->superblock); 116 block_fini(fs->device); 62 117 } 63 118 -
uspace/lib/ext4/libext4_filesystem.h
r54935cf6 r01ab41b 42 42 } ext4_filesystem_t; 43 43 44 // TODO constant value 45 #define EXT4_MAX_BLOCK_SIZE 8096 46 44 47 extern int ext4_filesystem_init(ext4_filesystem_t *, service_id_t); 45 48 extern int ext4_filesystem_check_sanity(ext4_filesystem_t *fs); -
uspace/lib/ext4/libext4_inode.c
r54935cf6 r01ab41b 39 39 40 40 // TODO check return type 41 /** 42 * TODO doxy 43 */ 41 44 uint16_t ext4_inode_get_usage_count(ext4_inode_t *inode) 42 45 { 43 // TODO 46 // TODO check 44 47 return 0; 45 48 } -
uspace/lib/ext4/libext4_superblock.c
r54935cf6 r01ab41b 36 36 */ 37 37 38 #include <byteorder.h> 39 #include <errno.h> 40 #include <libblock.h> 41 #include <malloc.h> 38 42 #include "libext4_superblock.h" 39 43 44 /** 45 * TODO doxy 46 */ 47 uint16_t ext2_superblock_get_magic(ext4_superblock_t *sb) 48 { 49 return uint16_t_le2host(sb->s_magic); 50 } 51 52 /** 53 * TODO doxy 54 */ 55 uint32_t ext4_superblock_get_first_block(ext4_superblock_t *sb) 56 { 57 return uint32_t_le2host(sb->s_first_data_block); 58 } 59 60 /** 61 * TODO doxy 62 */ 63 uint32_t ext4_superblock_get_block_size_log2(ext4_superblock_t *sb) 64 { 65 return uint32_t_le2host(sb->s_log_block_size); 66 } 67 68 /** 69 * TODO doxy 70 */ 71 uint32_t ext4_superblock_get_block_size(ext4_superblock_t *sb) 72 { 73 return 1024 << ext4_superblock_get_block_size_log2(sb); 74 } 75 76 77 /** 78 * TODO doxy 79 */ 80 int ext4_superblock_read_direct(service_id_t service_id, 81 ext4_superblock_t **superblock) 82 { 83 void *data; 84 int rc; 85 86 data = malloc(EXT4_SUPERBLOCK_SIZE); 87 if (data == NULL) { 88 return ENOMEM; 89 } 90 91 rc = block_read_bytes_direct(service_id, EXT4_SUPERBLOCK_OFFSET, 92 EXT4_SUPERBLOCK_SIZE, data); 93 94 if (rc != EOK) { 95 free(data); 96 return rc; 97 } 98 99 (*superblock) = data; 100 101 return EOK; 102 } 103 104 /** 105 * TODO doxy 106 */ 107 int ext4_superblock_check_sanity(ext4_superblock_t *sb) 108 { 109 // TODO 110 return EOK; 111 } 40 112 41 113 /** -
uspace/lib/ext4/libext4_superblock.h
r54935cf6 r01ab41b 34 34 #define LIBEXT4_LIBEXT4_SUPERBLOCK_H_ 35 35 36 #include <libblock.h> 36 37 #include <sys/types.h> 37 38 … … 140 141 } __attribute__((packed)) ext4_superblock_t; 141 142 143 // TODO constants 144 #define EXT4_SUPERBLOCK_MAGIC 0xEF53 145 #define EXT4_SUPERBLOCK_SIZE 1024 146 #define EXT4_SUPERBLOCK_OFFSET 1024 147 148 extern uint32_t ext4_superblock_get_block_size_log2(ext4_superblock_t *); 149 extern uint32_t ext4_superblock_get_block_size(ext4_superblock_t *); 150 151 extern int ext4_superblock_read_direct(service_id_t, ext4_superblock_t **); 152 extern int ext4_superblock_check_sanity(ext4_superblock_t *); 142 153 143 154 #endif -
uspace/srv/fs/ext4fs/ext4fs_ops.c
r54935cf6 r01ab41b 98 98 99 99 /** 100 * TODO comment100 * TODO doxy 101 101 */ 102 102 int ext4fs_global_init(void) … … 106 106 } 107 107 108 /** 109 * TODO doxy 110 */ 108 111 int ext4fs_global_fini(void) 109 112 { … … 144 147 int ext4fs_root_get(fs_node_t **rfn, service_id_t service_id) 145 148 { 146 // TODO 147 return 0; 149 return ext4fs_node_get(rfn, service_id, EXT4_INODE_ROOT_INDEX); 148 150 } 149 151 … … 167 169 } 168 170 171 /** 172 * TODO doxy 173 */ 169 174 int ext4fs_node_open(fs_node_t *fn) 170 175 { 171 // TODO 176 // TODO stateless operation 172 177 return EOK; 173 178 }
Note:
See TracChangeset
for help on using the changeset viewer.