Changeset 4bfad34 in mainline for uspace/lib/ext4/src/filesystem.c
- Timestamp:
- 2017-05-11T22:07:09Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- be39fc6
- Parents:
- 71fe4723
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/src/filesystem.c
r71fe4723 r4bfad34 32 32 */ 33 33 /** 34 * @file libext4_filesystem.c34 * @file filesystem.c 35 35 * @brief More complex filesystem operations. 36 36 */ … … 42 42 #include <crypto.h> 43 43 #include <ipc/vfs.h> 44 #include <libfs.h> 44 45 #include <stdlib.h> 45 46 #include "ext4/balloc.h" … … 50 51 #include "ext4/ialloc.h" 51 52 #include "ext4/inode.h" 53 #include "ext4/ops.h" 52 54 #include "ext4/superblock.h" 55 56 static int ext4_filesystem_check_features(ext4_filesystem_t *, bool *); 53 57 54 58 /** Initialize filesystem and read all needed data. … … 56 60 * @param fs Filesystem instance to be initialized 57 61 * @param service_id Identifier if device with the filesystem 58 * 59 * @return Error code 60 * 61 */ 62 int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id, 63 enum cache_mode cmode) 62 * @param cmode Cache mode 63 * @param read_only Place to store read only flag 64 * @param index Output value - index of root node 65 * @param size Output value - size of root node 66 * @param lnkcnt Output value - link count of root node 67 * 68 * @return Error code 69 * 70 */ 71 int ext4_filesystem_init(ext4_filesystem_t *fs, ext4fs_instance_t *inst, 72 service_id_t service_id, enum cache_mode cmode, aoff64_t *size) 64 73 { 65 74 int rc; … … 118 127 goto err_2; 119 128 129 /* Check flags */ 130 bool read_only; 131 rc = ext4_filesystem_check_features(fs, &read_only); 132 if (rc != EOK) 133 goto err_2; 134 135 /* Read root node */ 136 fs_node_t *root_node; 137 rc = ext4fs_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX); 138 if (rc != EOK) 139 goto err_2; 140 120 141 /* Mark system as mounted */ 121 142 ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_ERROR_FS); 122 143 rc = ext4_superblock_write_direct(fs->device, fs->superblock); 123 144 if (rc != EOK) 124 goto err_ 2;145 goto err_3; 125 146 126 147 uint16_t mnt_count = ext4_superblock_get_mount_count(fs->superblock); 127 148 ext4_superblock_set_mount_count(fs->superblock, mnt_count + 1); 128 149 150 ext4fs_node_t *enode = EXT4FS_NODE(root_node); 151 152 *size = ext4_inode_get_size(fs->superblock, enode->inode_ref->inode); 153 154 ext4fs_node_put(root_node); 129 155 return EOK; 130 156 err_3: 157 ext4fs_node_put(root_node); 131 158 err_2: 132 159 block_cache_fini(fs->device); … … 169 196 * 170 197 * @param fs Filesystem to be checked 171 * @param read_only Flag if filesystem should be mounted only for reading 172 * 173 * @return Error code 174 * 175 */ 176 int ext4_filesystem_check_features(ext4_filesystem_t *fs, bool *read_only) 198 * @param read_only Place to write flag saying whether filesystem 199 * should be mounted only for reading 200 * 201 * @return Error code 202 * 203 */ 204 static int ext4_filesystem_check_features(ext4_filesystem_t *fs, 205 bool *read_only) 177 206 { 178 207 /* Feature flags are present only in higher revisions */
Note:
See TracChangeset
for help on using the changeset viewer.