Changeset 9c0c0e1 in mainline
- Timestamp:
- 2011-10-04T12:18:44Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a23297c
- Parents:
- 01ab41b
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_block_group.h
r01ab41b r9c0c0e1 40 40 */ 41 41 typedef struct ext4_block_group { 42 uint32_t b g_block_bitmap_lo; // Blocks bitmap block43 uint32_t bg_inode_bitmap_lo; // Inodes bitmap block44 uint32_t bg_inode_table_lo; // Inodes table block45 uint16_t bg_free_blocks_count_lo; // Free blocks count46 uint16_t bg_free_inodes_count_lo; // Free inodes count47 uint16_t bg_used_dirs_count_lo; // Directories count48 uint16_t bg_flags; // EXT4_BG_flags (INODE_UNINIT, etc)49 uint32_t bg_reserved[2]; // Likely block/inode bitmap checksum50 uint16_t bg_itable_unused_lo; // Unused inodes count51 uint16_t bg_checksum; // crc16(sb_uuid+group+desc)52 uint32_t b g_block_bitmap_hi; // Blocks bitmap block MSB53 uint32_t bg_inode_bitmap_hi; // Inodes bitmap block MSB54 uint32_t bg_inode_table_hi; // Inodes table block MSB55 uint16_t bg_free_blocks_count_hi; // Free blocks count MSB56 uint16_t bg_free_inodes_count_hi; // Free inodes count MSB57 uint16_t bg_used_dirs_count_hi; // Directories count MSB58 uint16_t bg_itable_unused_hi; // Unused inodes count MSB59 uint32_t bg_reserved2[3]; // Padding42 uint32_t block_bitmap_lo; // Blocks bitmap block 43 uint32_t inode_bitmap_lo; // Inodes bitmap block 44 uint32_t inode_table_lo; // Inodes table block 45 uint16_t free_blocks_count_lo; // Free blocks count 46 uint16_t free_inodes_count_lo; // Free inodes count 47 uint16_t used_dirs_count_lo; // Directories count 48 uint16_t flags; // EXT4_BG_flags (INODE_UNINIT, etc) 49 uint32_t reserved[2]; // Likely block/inode bitmap checksum 50 uint16_t itable_unused_lo; // Unused inodes count 51 uint16_t checksum; // crc16(sb_uuid+group+desc) 52 uint32_t block_bitmap_hi; // Blocks bitmap block MSB 53 uint32_t inode_bitmap_hi; // Inodes bitmap block MSB 54 uint32_t inode_table_hi; // Inodes table block MSB 55 uint16_t free_blocks_count_hi; // Free blocks count MSB 56 uint16_t free_inodes_count_hi; // Free inodes count MSB 57 uint16_t used_dirs_count_hi; // Directories count MSB 58 uint16_t itable_unused_hi; // Unused inodes count MSB 59 uint32_t reserved2[3]; // Padding 60 60 } ext4_group_desc_t; 61 61 -
uspace/lib/ext4/libext4_filesystem.c
r01ab41b r9c0c0e1 52 52 fs->device = service_id; 53 53 54 // TODO block size !!!54 // TODO what does constant 2048 mean? 55 55 rc = block_init(EXCHANGE_SERIALIZE, fs->device, 2048); 56 56 if (rc != EOK) { … … 58 58 } 59 59 60 /* Read superblock from device */ 60 61 rc = ext4_superblock_read_direct(fs->device, &temp_superblock); 61 62 if (rc != EOK) { … … 64 65 } 65 66 67 /* Read block size from superblock and check */ 66 68 block_size = ext4_superblock_get_block_size(temp_superblock); 67 68 69 if (block_size > EXT4_MAX_BLOCK_SIZE) { 69 70 block_fini(fs->device); … … 71 72 } 72 73 74 /* Initialize block caching */ 73 75 rc = block_cache_init(service_id, block_size, 0, CACHE_MODE_WT); 74 76 if (rc != EOK) { … … 77 79 } 78 80 81 /* Return loaded superblock */ 79 82 fs->superblock = temp_superblock; 80 83 81 82 // TODO83 84 return EOK; 84 85 } … … 102 103 * TODO doxy 103 104 */ 104 int ext4_filesystem_check_f lags(ext4_filesystem_t *fs, bool *o_read_only)105 int ext4_filesystem_check_features(ext4_filesystem_t *fs, bool *o_read_only) 105 106 { 106 // TODO 107 /* Feature flags are present in rev 1 and later */ 108 if (ext4_superblock_get_rev_level(fs->superblock) == 0) { 109 *o_read_only = false; 110 return EOK; 111 } 112 113 uint32_t incompatible_features; 114 incompatible_features = ext4_superblock_get_features_incompatible(fs->superblock); 115 incompatible_features &= ~EXT4_FEATURE_INCOMPAT_SUPP; 116 if (incompatible_features > 0) { 117 *o_read_only = true; 118 return ENOTSUP; 119 } 120 121 uint32_t compatible_read_only; 122 compatible_read_only = ext4_superblock_get_features_read_only(fs->superblock); 123 compatible_read_only &= ~EXT4_FEATURE_RO_COMPAT_SUPP; 124 if (compatible_read_only > 0) { 125 *o_read_only = true; 126 } 127 107 128 return EOK; 108 129 } -
uspace/lib/ext4/libext4_filesystem.h
r01ab41b r9c0c0e1 42 42 } ext4_filesystem_t; 43 43 44 // TODO constant value 45 #define EXT4_MAX_BLOCK_SIZE 8096 44 #define EXT4_MAX_BLOCK_SIZE 65536 //64 KiB 45 46 47 /* Compatible features */ 48 // TODO features comments !!! 49 #define EXT4_FEATURE_COMPAT_DIR_PREALLOC 0x0001 50 #define EXT4_FEATURE_COMPAT_IMAGIC_INODES 0x0002 51 #define EXT4_FEATURE_COMPAT_HAS_JOURNAL 0x0004 52 #define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008 53 #define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010 54 #define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020 55 56 /* Read-only compatible features */ 57 // TODO features comments !!! 58 #define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 59 #define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 60 #define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 61 #define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008 62 #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010 63 #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020 64 #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040 65 66 /* Incompatible features */ 67 // TODO features comments !!! 68 #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001 69 #define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002 70 #define EXT4_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */ 71 #define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */ 72 #define EXT4_FEATURE_INCOMPAT_META_BG 0x0010 73 #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */ 74 #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 75 #define EXT4_FEATURE_INCOMPAT_MMP 0x0100 76 #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 77 #define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400 /* EA in inode */ 78 #define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000 /* data in dirent */ 79 80 81 // TODO MODIFY features corresponding with implementation 82 #define EXT4_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR 83 84 #define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \ 85 EXT4_FEATURE_INCOMPAT_RECOVER| \ 86 EXT4_FEATURE_INCOMPAT_META_BG| \ 87 EXT4_FEATURE_INCOMPAT_EXTENTS| \ 88 EXT4_FEATURE_INCOMPAT_64BIT| \ 89 EXT4_FEATURE_INCOMPAT_FLEX_BG) 90 91 #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ 92 EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ 93 EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \ 94 EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \ 95 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \ 96 EXT4_FEATURE_RO_COMPAT_BTREE_DIR |\ 97 EXT4_FEATURE_RO_COMPAT_HUGE_FILE) 98 46 99 47 100 extern int ext4_filesystem_init(ext4_filesystem_t *, service_id_t); 48 101 extern int ext4_filesystem_check_sanity(ext4_filesystem_t *fs); 49 extern int ext4_filesystem_check_f lags(ext4_filesystem_t *, bool *);102 extern int ext4_filesystem_check_features(ext4_filesystem_t *, bool *); 50 103 extern void ext4_filesystem_fini(ext4_filesystem_t *fs); 51 104 -
uspace/lib/ext4/libext4_inode.c
r01ab41b r9c0c0e1 36 36 */ 37 37 38 #include <byteorder.h> 38 39 #include "libext4_inode.h" 39 40 … … 44 45 uint16_t ext4_inode_get_usage_count(ext4_inode_t *inode) 45 46 { 46 // TODO check 47 return 0; 47 return uint16_t_le2host(inode->links_count); 48 48 } 49 49 -
uspace/lib/ext4/libext4_inode.h
r01ab41b r9c0c0e1 37 37 #include <sys/types.h> 38 38 39 // TODO better constant definition !!! 40 #define EXT4_N_BLOCKS 15 39 #define EXT4_DIRECT_BLOCK_COUNT 12 40 #define EXT4_INDIRECT_BLOCK EXT4_DIRECT_BLOCK_COUNT 41 #define EXT4_DOUBLE_INDIRECT_BLOCK (EXT4_INDIRECT_BLOCK + 1) 42 #define EXT4_TRIPPLE_INDIRECT_BLOCK (EXT4_DOUBLE_INDIRECT_BLOCK + 1) 43 #define EXT4_INODE_BLOCKS (EXT4_TRIPPLE_INDIRECT_BLOCK + 1) 41 44 42 45 /* … … 44 47 */ 45 48 typedef struct ext4_inode { 46 uint16_t i_mode; // File mode 47 uint16_t i_uid; // Low 16 bits of owner uid 48 uint32_t i_size_lo; // Size in bytes 49 uint32_t i_atime; // Access time 50 uint32_t i_ctime; // Inode change time 51 uint32_t i_mtime; // Modification time 52 uint32_t i_dtime; // Deletion time 53 uint16_t i_gid; // Low 16 bits of group id 54 uint16_t i_links_count; // Links count 55 uint32_t i_blocks_lo; // Blocks count 56 uint32_t i_flags; // File flags 49 uint16_t mode; // File mode 50 uint16_t uid; // Low 16 bits of owner uid 51 uint32_t size_lo; // Size in bytes 57 52 58 /* 59 union { 60 struct { 61 __le32 l_i_version; 62 } linux1; 63 struct { 64 __u32 h_i_translator; 65 } hurd1; 66 struct { 67 __u32 m_i_reserved1; 68 } masix1; 69 } osd1; 70 */ 53 // TODO Used in HelenOS ??? 54 uint32_t atime; // Access time 55 uint32_t ctime; // Inode change time 56 uint32_t mtime; // Modification time 57 uint32_t dtime; // Deletion time 58 59 uint16_t gid; // Low 16 bits of group id 60 uint16_t links_count; // Links count 61 uint32_t blocks_lo; // Blocks count 62 uint32_t flags; // File flags 71 63 uint32_t unused_osd1; // OS dependent - not used in HelenOS 72 73 uint32_t i_block[EXT4_N_BLOCKS]; // Pointers to blocks 74 uint32_t i_generation; // File version (for NFS) 75 uint32_t i_file_acl_lo; // File ACL 76 uint32_t i_size_high; 77 uint32_t i_obso_faddr; // Obsoleted fragment address 78 79 /* 80 union { 81 struct { 82 __le16 l_i_blocks_high; 83 __le16 l_i_file_acl_high; 84 __le16 l_i_uid_high; 85 __le16 l_i_gid_high; 86 __u32 l_i_reserved2; 87 } linux2; 88 struct { 89 __le16 h_i_reserved1; 90 __u16 h_i_mode_high; 91 __u16 h_i_uid_high; 92 __u16 h_i_gid_high; 93 __u32 h_i_author; 94 } hurd2; 95 struct { 96 __le16 h_i_reserved1; 97 __le16 m_i_file_acl_high; 98 __u32 m_i_reserved2[2]; 99 } masix2; 100 } osd2; 101 */ 102 103 uint32_t unused_osd2[3]; // OS dependent - not used in HelenOS 104 uint16_t i_extra_isize; 105 uint16_t i_pad1; 106 uint32_t i_ctime_extra; // Extra change time (nsec << 2 | epoch) 107 uint32_t i_mtime_extra; // Extra Modification time (nsec << 2 | epoch) 108 uint32_t i_atime_extra; // Extra Access time (nsec << 2 | epoch) 109 uint32_t i_crtime; // File creation time 110 uint32_t i_crtime_extra; // Extra file creation time (nsec << 2 | epoch) 111 uint32_t i_version_hi; // High 32 bits for 64-bit version 64 uint32_t blocks[EXT4_INODE_BLOCKS]; // Pointers to blocks 65 uint32_t generation; // File version (for NFS) 66 uint32_t file_acl_lo; // File ACL 67 uint32_t size_hi; 68 uint32_t obso_faddr; // Obsoleted fragment address 69 uint32_t unused_osd2[3]; // OS dependent - not used in HelenOS 70 uint16_t extra_isize; 71 uint16_t pad1; 72 uint32_t ctime_extra; // Extra change time (nsec << 2 | epoch) 73 uint32_t mtime_extra; // Extra Modification time (nsec << 2 | epoch) 74 uint32_t atime_extra; // Extra Access time (nsec << 2 | epoch) 75 uint32_t crtime; // File creation time 76 uint32_t crtime_extra; // Extra file creation time (nsec << 2 | epoch) 77 uint32_t version_hi; // High 32 bits for 64-bit version 112 78 } __attribute__ ((packed)) ext4_inode_t; 113 79 114 80 115 // TODO check value116 81 #define EXT4_INODE_ROOT_INDEX 2 117 82 -
uspace/lib/ext4/libext4_superblock.c
r01ab41b r9c0c0e1 45 45 * TODO doxy 46 46 */ 47 uint16_t ext 2_superblock_get_magic(ext4_superblock_t *sb)47 uint16_t ext4_superblock_get_magic(ext4_superblock_t *sb) 48 48 { 49 return uint16_t_le2host(sb-> s_magic);49 return uint16_t_le2host(sb->magic); 50 50 } 51 51 … … 55 55 uint32_t ext4_superblock_get_first_block(ext4_superblock_t *sb) 56 56 { 57 return uint32_t_le2host(sb-> s_first_data_block);57 return uint32_t_le2host(sb->first_data_block); 58 58 } 59 59 … … 63 63 uint32_t ext4_superblock_get_block_size_log2(ext4_superblock_t *sb) 64 64 { 65 return uint32_t_le2host(sb-> s_log_block_size);65 return uint32_t_le2host(sb->log_block_size); 66 66 } 67 67 … … 72 72 { 73 73 return 1024 << ext4_superblock_get_block_size_log2(sb); 74 } 75 76 /** 77 * TODO doxy 78 */ 79 uint32_t ext4_superblock_get_rev_level(ext4_superblock_t *sb) 80 { 81 return uint32_t_le2host(sb->rev_level); 82 } 83 84 /** 85 * TODO doxy 86 */ 87 uint32_t ext4_superblock_get_features_compatible(ext4_superblock_t *sb) 88 { 89 return uint32_t_le2host(sb->features_compatible); 90 } 91 92 /** 93 * TODO doxy 94 */ 95 uint32_t ext4_superblock_get_features_incompatible(ext4_superblock_t *sb) 96 { 97 return uint32_t_le2host(sb->features_incompatible); 98 } 99 100 /** 101 * TODO doxy 102 */ 103 uint32_t ext4_superblock_get_features_read_only(ext4_superblock_t *sb) 104 { 105 return uint32_t_le2host(sb->features_read_only); 74 106 } 75 107 … … 107 139 int ext4_superblock_check_sanity(ext4_superblock_t *sb) 108 140 { 109 // TODO 141 if (ext4_superblock_get_magic(sb) != EXT4_SUPERBLOCK_MAGIC) { 142 return ENOTSUP; 143 } 144 145 // TODO more checks !!! 146 110 147 return EOK; 111 148 } -
uspace/lib/ext4/libext4_superblock.h
r01ab41b r9c0c0e1 41 41 */ 42 42 typedef struct ext4_superblock { 43 uint32_t s_inodes_count; // Inodes count43 uint32_t inodes_count; // Inodes count 44 44 uint32_t s_blocks_count_lo; // Blocks count 45 45 uint32_t s_r_blocks_count_lo; // Reserved blocks count 46 uint32_t s_free_blocks_count_lo; // Free blocks count47 uint32_t s_free_inodes_count; // Free inodes count48 uint32_t s_first_data_block; // First Data Block49 uint32_t s_log_block_size; // Block size46 uint32_t free_blocks_count_lo; // Free blocks count 47 uint32_t free_inodes_count; // Free inodes count 48 uint32_t first_data_block; // First Data Block 49 uint32_t log_block_size; // Block size 50 50 uint32_t s_obso_log_frag_size; // Obsoleted fragment size 51 51 uint32_t s_blocks_per_group; // Number of blocks per group … … 54 54 uint32_t s_mtime; // Mount time 55 55 uint32_t s_wtime; // Write time 56 uint16_t s_mnt_count; // Mount count57 uint16_t s_max_mnt_count; // Maximal mount count58 uint16_t s_magic; // Magic signature59 uint16_t s _state; // File system state60 uint16_t s_errors; // Behaviour when detecting errors61 uint16_t s_minor_rev_level; // Minor revision level62 uint32_t s_lastcheck; // Time of last check63 uint32_t s_checkinterval; // Maximum time between checks64 uint32_t s_creator_os; // Creator OS65 uint32_t s_rev_level; // Revision level56 uint16_t mount_count; // Mount count 57 uint16_t max_mount_count; // Maximal mount count 58 uint16_t magic; // Magic signature 59 uint16_t state; // File system state 60 uint16_t errors; // Behaviour when detecting errors 61 uint16_t minor_rev_level; // Minor revision level 62 uint32_t last_check; // Time of last check 63 uint32_t checkinterval; // Maximum time between checks 64 uint32_t creator_os; // Creator OS 65 uint32_t rev_level; // Revision level 66 66 uint16_t s_def_resuid; // Default uid for reserved blocks 67 67 uint16_t s_def_resgid; // Default gid for reserved blocks … … 71 71 uint16_t s_inode_size; // Size of inode structure 72 72 uint16_t s_block_group_nr; // Block group number of this superblock 73 uint32_t s_feature_compat; // Compatible feature set74 uint32_t s_feature_incompat; // Incompatible feature set75 uint32_t s_feature_ro_compat; // Readonly-compatible feature set73 uint32_t features_compatible; // Compatible feature set 74 uint32_t features_incompatible; // Incompatible feature set 75 uint32_t features_read_only; // Readonly-compatible feature set 76 76 uint8_t s_uuid[16]; // 128-bit uuid for volume 77 77 char s_volume_name[16]; // Volume name … … 122 122 uint64_t s_snapshot_r_blocks_count; /* reserved blocks for active snapshot's future use */ 123 123 uint32_t s_snapshot_list; // inode number of the head of the on-disk snapshot list 124 125 //#define EXT4_S_ERR_START offsetof(struct ext4_super_block, s_error_count)126 124 uint32_t s_error_count; // number of fs errors 127 125 uint32_t s_first_error_time; // First time an error happened … … 135 133 uint64_t s_last_error_block; /* block involved of last error */ 136 134 uint8_t s_last_error_func[32]; /* function where the error happened */ 137 //#define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)138 135 uint8_t s_mount_opts[64]; 139 136 uint32_t s_reserved[112]; // Padding to the end of the block … … 141 138 } __attribute__((packed)) ext4_superblock_t; 142 139 143 // TODO constants144 140 #define EXT4_SUPERBLOCK_MAGIC 0xEF53 145 141 #define EXT4_SUPERBLOCK_SIZE 1024 146 142 #define EXT4_SUPERBLOCK_OFFSET 1024 147 143 144 extern uint16_t ext4_superblock_get_magic(ext4_superblock_t *); 145 extern uint32_t ext4_superblock_get_first_block(ext4_superblock_t *); 148 146 extern uint32_t ext4_superblock_get_block_size_log2(ext4_superblock_t *); 149 147 extern uint32_t ext4_superblock_get_block_size(ext4_superblock_t *); 148 extern uint32_t ext4_superblock_get_rev_level(ext4_superblock_t *); 149 extern uint32_t ext4_superblock_get_features_compatible(ext4_superblock_t *); 150 extern uint32_t ext4_superblock_get_features_incompatible(ext4_superblock_t *); 151 extern uint32_t ext4_superblock_get_features_read_only(ext4_superblock_t *); 150 152 151 153 extern int ext4_superblock_read_direct(service_id_t, ext4_superblock_t **); -
uspace/srv/fs/ext4fs/ext4fs_ops.c
r01ab41b r9c0c0e1 41 41 #include <libfs.h> 42 42 #include <malloc.h> 43 #include <stdio.h> 43 44 #include <ipc/loc.h> 44 45 #include "ext4fs.h" … … 46 47 47 48 #define EXT4FS_NODE(node) ((node) ? (ext4fs_node_t *) (node)->data : NULL) 49 #define EXT4FS_DBG(format, ...) {if (true) printf("ext4fs: %s: " format "\n", __FUNCTION__, ##__VA_ARGS__);} 48 50 49 51 typedef struct ext4fs_instance { … … 67 69 static int ext4fs_instance_get(service_id_t, ext4fs_instance_t **); 68 70 static int ext4fs_node_get_core(fs_node_t **, ext4fs_instance_t *, fs_index_t); 69 71 static int ext4fs_node_put_core(ext4fs_node_t *); 70 72 71 73 /* … … 120 122 */ 121 123 124 /** 125 * TODO doxy 126 */ 122 127 int ext4fs_instance_get(service_id_t service_id, ext4fs_instance_t **inst) 123 128 { … … 145 150 } 146 151 152 /** 153 * TODO doxy 154 */ 147 155 int ext4fs_root_get(fs_node_t **rfn, service_id_t service_id) 148 156 { … … 150 158 } 151 159 160 /** 161 * TODO doxy 162 */ 152 163 int ext4fs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component) 153 164 { … … 156 167 } 157 168 169 /** 170 * TODO doxy 171 */ 158 172 int ext4fs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index) 159 173 { 160 // TODO 161 return 0; 162 } 163 174 ext4fs_instance_t *inst = NULL; 175 int rc; 176 177 rc = ext4fs_instance_get(service_id, &inst); 178 if (rc != EOK) { 179 return rc; 180 } 181 182 return ext4fs_node_get_core(rfn, inst, index); 183 } 184 185 /** 186 * TODO doxy 187 */ 164 188 int ext4fs_node_get_core(fs_node_t **rfn, ext4fs_instance_t *inst, 165 189 fs_index_t index) … … 172 196 * TODO doxy 173 197 */ 198 int ext4fs_node_put_core(ext4fs_node_t *enode) { 199 // TODO 200 return EOK; 201 } 202 203 /** 204 * TODO doxy 205 */ 174 206 int ext4fs_node_open(fs_node_t *fn) 175 207 { … … 180 212 int ext4fs_node_put(fs_node_t *fn) 181 213 { 182 // TODO 214 EXT4FS_DBG(""); 215 int rc; 216 ext4fs_node_t *enode = EXT4FS_NODE(fn); 217 218 fibril_mutex_lock(&open_nodes_lock); 219 220 assert(enode->references > 0); 221 enode->references--; 222 if (enode->references == 0) { 223 rc = ext4fs_node_put_core(enode); 224 if (rc != EOK) { 225 fibril_mutex_unlock(&open_nodes_lock); 226 return rc; 227 } 228 } 229 230 fibril_mutex_unlock(&open_nodes_lock); 231 183 232 return EOK; 184 233 } … … 278 327 */ 279 328 329 /** 330 * TODO doxy 331 */ 280 332 static int ext4fs_mounted(service_id_t service_id, const char *opts, 281 333 fs_index_t *index, aoff64_t *size, unsigned *lnkcnt) 282 334 { 335 336 EXT4FS_DBG("Mounting..."); 283 337 284 338 int rc; … … 300 354 } 301 355 302 /* Initialize the filesystem */ 356 EXT4FS_DBG("Basic structures allocated"); 357 358 /* Initialize the filesystem */ 303 359 rc = ext4_filesystem_init(fs, service_id); 304 360 if (rc != EOK) { … … 307 363 return rc; 308 364 } 365 366 EXT4FS_DBG("initialized"); 309 367 310 368 /* Do some sanity checking */ … … 317 375 } 318 376 377 EXT4FS_DBG("Checked and clean"); 378 319 379 /* Check flags */ 320 rc = ext4_filesystem_check_f lags(fs, &read_only);380 rc = ext4_filesystem_check_features(fs, &read_only); 321 381 if (rc != EOK) { 322 382 ext4_filesystem_fini(fs); … … 326 386 } 327 387 388 EXT4FS_DBG("Features checked"); 389 328 390 /* Initialize instance */ 329 391 link_initialize(&inst->link); … … 332 394 inst->open_nodes_count = 0; 333 395 396 EXT4FS_DBG("Instance initialized"); 397 334 398 /* Read root node */ 335 399 fs_node_t *root_node; 336 rc = ext4fs_ node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX);400 rc = ext4fs_root_get(&root_node, inst->service_id); 337 401 if (rc != EOK) { 338 402 ext4_filesystem_fini(fs); … … 343 407 ext4fs_node_t *enode = EXT4FS_NODE(root_node); 344 408 409 EXT4FS_DBG("Root node found"); 410 345 411 /* Add instance to the list */ 346 412 fibril_mutex_lock(&instance_list_mutex); … … 348 414 fibril_mutex_unlock(&instance_list_mutex); 349 415 416 EXT4FS_DBG("Instance added"); 417 350 418 *index = EXT4_INODE_ROOT_INDEX; 351 419 *size = 0; 352 420 *lnkcnt = ext4_inode_get_usage_count(enode->inode_ref->inode); 353 421 422 EXT4FS_DBG("Return values set"); 423 354 424 ext4fs_node_put(root_node); 355 425 356 return EOK; 357 } 358 426 EXT4FS_DBG("Mounting finished"); 427 428 return EOK; 429 } 430 431 /** 432 * TODO doxy 433 */ 359 434 static int ext4fs_unmounted(service_id_t service_id) 360 435 { … … 388 463 } 389 464 465 /** 466 * TODO doxy 467 */ 390 468 static int 391 469 ext4fs_read(service_id_t service_id, fs_index_t index, aoff64_t pos, … … 396 474 } 397 475 476 /** 477 * TODO doxy 478 */ 398 479 static int 399 480 ext4fs_write(service_id_t service_id, fs_index_t index, aoff64_t pos, … … 404 485 } 405 486 487 /** 488 * TODO doxy 489 */ 406 490 static int 407 491 ext4fs_truncate(service_id_t service_id, fs_index_t index, aoff64_t size) … … 411 495 } 412 496 497 /** 498 * TODO doxy 499 */ 413 500 static int ext4fs_close(service_id_t service_id, fs_index_t index) 414 501 { … … 417 504 } 418 505 506 /** 507 * TODO doxy 508 */ 419 509 static int ext4fs_destroy(service_id_t service_id, fs_index_t index) 420 510 { … … 423 513 } 424 514 515 /** 516 * TODO doxy 517 */ 425 518 static int ext4fs_sync(service_id_t service_id, fs_index_t index) 426 519 {
Note:
See TracChangeset
for help on using the changeset viewer.