Changes in / [02082f3:e48947e] in mainline
- Location:
- uspace
- Files:
-
- 1 added
- 1 deleted
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/init.c
r02082f3 re48947e 316 316 } 317 317 318 /* Make sure tmpfs isrunning. */318 /* Make sure file systems are running. */ 319 319 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) 320 320 srv_start("/srv/tmpfs"); 321 321 if (str_cmp(STRING(RDFMT), "exfat") != 0) 322 srv_start("/srv/exfat"); 323 if (str_cmp(STRING(RDFMT), "fat") != 0) 324 srv_start("/srv/fat"); 325 srv_start("/srv/cdfs"); 322 326 srv_start("/srv/mfs"); 323 327 -
uspace/lib/c/include/types/vol.h
r02082f3 re48947e 52 52 fs_fat, 53 53 fs_minix, 54 fs_ext4 54 fs_ext4, 55 fs_cdfs 55 56 } vol_fstype_t; 56 57 -
uspace/lib/ext4/include/ext4/filesystem.h
r02082f3 re48947e 36 36 37 37 #include <block.h> 38 #include "ext4/fstypes.h" 38 39 #include "ext4/types.h" 39 40 40 extern int ext4_filesystem_ init(ext4_filesystem_t *, service_id_t,41 enum cache_mode); 42 extern int ext4_filesystem_fini(ext4_filesystem_t*);43 extern int ext4_filesystem_c heck_features(ext4_filesystem_t *, bool*);41 extern int ext4_filesystem_probe(service_id_t); 42 extern int ext4_filesystem_open(ext4_instance_t *, service_id_t, 43 enum cache_mode, aoff64_t *, ext4_filesystem_t **); 44 extern int ext4_filesystem_close(ext4_filesystem_t *); 44 45 extern uint32_t ext4_filesystem_blockaddr2_index_in_group(ext4_superblock_t *, 45 46 uint32_t); -
uspace/lib/ext4/include/ext4/ops.h
r02082f3 re48947e 35 35 36 36 #include <libfs.h> 37 #include "ext4/fstypes.h" 37 38 38 extern vfs_out_ops_t ext4 fs_ops;39 extern libfs_ops_t ext4 fs_libfs_ops;39 extern vfs_out_ops_t ext4_ops; 40 extern libfs_ops_t ext4_libfs_ops; 40 41 41 extern int ext4fs_global_init(void); 42 extern int ext4fs_global_fini(void); 42 extern int ext4_global_init(void); 43 extern int ext4_global_fini(void); 44 45 extern int ext4_node_get_core(fs_node_t **, ext4_instance_t *, fs_index_t); 46 extern int ext4_node_put(fs_node_t *); 43 47 44 48 -
uspace/lib/ext4/src/balloc.c
r02082f3 re48947e 31 31 */ 32 32 /** 33 * @file libext4_balloc.c33 * @file balloc.c 34 34 * @brief Physical block allocator. 35 35 */ -
uspace/lib/ext4/src/bitmap.c
r02082f3 re48947e 31 31 */ 32 32 /** 33 * @file libext4_bitmap.c33 * @file bitmap.c 34 34 * @brief Ext4 bitmap operations. 35 35 */ -
uspace/lib/ext4/src/block_group.c
r02082f3 re48947e 32 32 */ 33 33 /** 34 * @file libext4_block_group.c34 * @file block_group.c 35 35 * @brief Ext4 block group structure operations. 36 36 */ -
uspace/lib/ext4/src/directory.c
r02082f3 re48947e 32 32 */ 33 33 /** 34 * @file libext4_directory.c34 * @file directory.c 35 35 * @brief Ext4 directory structure operations. 36 36 */ -
uspace/lib/ext4/src/directory_index.c
r02082f3 re48947e 31 31 */ 32 32 /** 33 * @file libext4_directory_index.c33 * @file directory_index.c 34 34 * @brief Ext4 directory index operations. 35 35 */ -
uspace/lib/ext4/src/extent.c
r02082f3 re48947e 31 31 */ 32 32 /** 33 * @file libext4_extent.c33 * @file extent.c 34 34 * @brief Ext4 extent structures operations. 35 35 */ -
uspace/lib/ext4/src/filesystem.c
r02082f3 re48947e 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" 53 55 54 /** Initialize filesystem and read all needed data. 56 static int ext4_filesystem_check_features(ext4_filesystem_t *, bool *); 57 58 /** Initialize filesystem for opening. 59 * 60 * But do not mark mounted just yet. 55 61 * 56 62 * @param fs Filesystem instance to be initialized 57 * @param service_id Identifier if device with the filesystem 63 * @param service_id Block device to open 64 * @param cmode Cache mode 58 65 * 59 66 * @return Error code 60 67 * 61 68 */ 62 int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id,69 static int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id, 63 70 enum cache_mode cmode) 64 71 { … … 113 120 goto err_2; 114 121 } 115 122 116 123 rc = ext4_superblock_check_sanity(fs->superblock); 117 124 if (rc != EOK) 118 125 goto err_2; 119 126 120 /* Mark system as mounted*/121 ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_ERROR_FS);122 rc = ext4_ superblock_write_direct(fs->device, fs->superblock);127 /* Check flags */ 128 bool read_only; 129 rc = ext4_filesystem_check_features(fs, &read_only); 123 130 if (rc != EOK) 124 131 goto err_2; 125 132 126 uint16_t mnt_count = ext4_superblock_get_mount_count(fs->superblock);127 ext4_superblock_set_mount_count(fs->superblock, mnt_count + 1);128 129 133 return EOK; 130 131 134 err_2: 132 135 block_cache_fini(fs->device); … … 139 142 } 140 143 141 /** Destroy filesystem instance (used by unmount operation). 144 /** Finalize filesystem. 145 * 146 * @param fs Filesystem to be finalized 147 * 148 */ 149 static void ext4_filesystem_fini(ext4_filesystem_t *fs) 150 { 151 /* Release memory space for superblock */ 152 free(fs->superblock); 153 154 /* Finish work with block library */ 155 block_cache_fini(fs->device); 156 block_fini(fs->device); 157 } 158 159 /** Probe filesystem. 160 * 161 * @param service_id Block device to probe 162 * 163 * @return EOK or negative error code. 164 * 165 */ 166 int ext4_filesystem_probe(service_id_t service_id) 167 { 168 ext4_filesystem_t *fs = NULL; 169 int rc; 170 171 fs = calloc(1, sizeof(ext4_filesystem_t)); 172 if (fs == NULL) 173 return ENOMEM; 174 175 /* Initialize the file system for opening */ 176 rc = ext4_filesystem_init(fs, service_id, CACHE_MODE_WT); 177 if (rc != EOK) { 178 free(fs); 179 return rc; 180 } 181 182 ext4_filesystem_fini(fs); 183 return EOK; 184 } 185 186 /** Open filesystem and read all needed data. 187 * 188 * @param fs Filesystem to be initialized 189 * @param inst Instance 190 * @param service_id Identifier if device with the filesystem 191 * @param cmode Cache mode 192 * @param size Output value - size of root node 193 * 194 * @return Error code 195 * 196 */ 197 int ext4_filesystem_open(ext4_instance_t *inst, service_id_t service_id, 198 enum cache_mode cmode, aoff64_t *size, ext4_filesystem_t **rfs) 199 { 200 ext4_filesystem_t *fs = NULL; 201 fs_node_t *root_node = NULL; 202 int rc; 203 204 fs = calloc(1, sizeof(ext4_filesystem_t)); 205 if (fs == NULL) { 206 rc = ENOMEM; 207 goto error; 208 } 209 210 inst->filesystem = fs; 211 212 /* Initialize the file system for opening */ 213 rc = ext4_filesystem_init(fs, service_id, cmode); 214 if (rc != EOK) 215 goto error; 216 217 /* Read root node */ 218 rc = ext4_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX); 219 if (rc != EOK) 220 goto error; 221 222 /* Mark system as mounted */ 223 ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_ERROR_FS); 224 rc = ext4_superblock_write_direct(fs->device, fs->superblock); 225 if (rc != EOK) 226 goto error; 227 228 uint16_t mnt_count = ext4_superblock_get_mount_count(fs->superblock); 229 ext4_superblock_set_mount_count(fs->superblock, mnt_count + 1); 230 231 ext4_node_t *enode = EXT4_NODE(root_node); 232 233 *size = ext4_inode_get_size(fs->superblock, enode->inode_ref->inode); 234 235 ext4_node_put(root_node); 236 *rfs = fs; 237 return EOK; 238 error: 239 if (root_node != NULL) 240 ext4_node_put(root_node); 241 242 if (fs != NULL) { 243 ext4_filesystem_fini(fs); 244 free(fs); 245 } 246 247 return rc; 248 } 249 250 /** Close filesystem. 142 251 * 143 252 * @param fs Filesystem to be destroyed 144 253 * 145 * @return Error code 146 * 147 */ 148 int ext4_filesystem_fini(ext4_filesystem_t *fs) 254 * @return EOK or negative error code. On error the state of the file 255 * system is unchanged. 256 * 257 */ 258 int ext4_filesystem_close(ext4_filesystem_t *fs) 149 259 { 150 260 /* Write the superblock to the device */ 151 261 ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_VALID_FS); 152 262 int rc = ext4_superblock_write_direct(fs->device, fs->superblock); 153 154 /* Release memory space for superblock */ 155 free(fs->superblock); 156 157 /* Finish work with block library */ 158 block_cache_fini(fs->device); 159 block_fini(fs->device); 160 161 return rc; 263 if (rc != EOK) 264 return rc; 265 266 ext4_filesystem_fini(fs); 267 return EOK; 162 268 } 163 269 … … 169 275 * 170 276 * @param fs Filesystem to be checked 171 * @param read_only Flag if filesystem should be mounted only for reading 277 * @param read_only Place to write flag saying whether filesystem 278 * should be mounted only for reading 172 279 * 173 280 * @return Error code 174 281 * 175 282 */ 176 int ext4_filesystem_check_features(ext4_filesystem_t *fs, bool *read_only) 283 static int ext4_filesystem_check_features(ext4_filesystem_t *fs, 284 bool *read_only) 177 285 { 178 286 /* Feature flags are present only in higher revisions */ -
uspace/lib/ext4/src/hash.c
r02082f3 re48947e 31 31 */ 32 32 /** 33 * @file libext4_hash.c33 * @file hash.c 34 34 * @brief Hashing algorithms for ext4 HTree. 35 35 */ -
uspace/lib/ext4/src/ialloc.c
r02082f3 re48947e 31 31 */ 32 32 /** 33 * @file libext4_ialloc.c33 * @file ialloc.c 34 34 * @brief I-node (de)allocation operations. 35 35 */ -
uspace/lib/ext4/src/inode.c
r02082f3 re48947e 32 32 */ 33 33 /** 34 * @file libext4_inode.c34 * @file inode.c 35 35 * @brief Ext4 i-node structure operations. 36 36 */ -
uspace/lib/ext4/src/ops.c
r02082f3 re48947e 32 32 */ 33 33 /** 34 * @file ext4fs_ops.c34 * @file ops.c 35 35 * @brief Operations for ext4 filesystem. 36 36 */ 37 37 38 #include <adt/hash_table.h> 39 #include <adt/hash.h> 38 40 #include <errno.h> 39 #include <ext4/libext4.h>40 41 #include <fibril_synch.h> 41 42 #include <libfs.h> 42 43 #include <macros.h> 43 44 #include <malloc.h> 44 #include < adt/hash_table.h>45 #include < adt/hash.h>45 #include <mem.h> 46 #include <str.h> 46 47 #include <ipc/loc.h> 48 #include "ext4/balloc.h" 49 #include "ext4/directory.h" 50 #include "ext4/directory_index.h" 51 #include "ext4/extent.h" 52 #include "ext4/inode.h" 47 53 #include "ext4/ops.h" 48 //#include "../../vfs/vfs.h" 49 50 #define EXT4FS_NODE(node) \ 51 ((node) ? (ext4fs_node_t *) (node)->data : NULL) 52 53 /** 54 * Type for holding an instance of mounted partition. 55 */ 56 typedef struct ext4fs_instance { 57 link_t link; 58 service_id_t service_id; 59 ext4_filesystem_t *filesystem; 60 unsigned int open_nodes_count; 61 } ext4fs_instance_t; 62 63 /** 64 * Type for wrapping common fs_node and add some useful pointers. 65 */ 66 typedef struct ext4fs_node { 67 ext4fs_instance_t *instance; 68 ext4_inode_ref_t *inode_ref; 69 fs_node_t *fs_node; 70 ht_link_t link; 71 unsigned int references; 72 } ext4fs_node_t; 54 #include "ext4/filesystem.h" 55 #include "ext4/fstypes.h" 56 #include "ext4/superblock.h" 73 57 74 58 /* Forward declarations of auxiliary functions */ 75 59 76 static int ext4 fs_read_directory(ipc_callid_t, aoff64_t, size_t,77 ext4 fs_instance_t *, ext4_inode_ref_t *, size_t *);78 static int ext4 fs_read_file(ipc_callid_t, aoff64_t, size_t, ext4fs_instance_t *,60 static int ext4_read_directory(ipc_callid_t, aoff64_t, size_t, 61 ext4_instance_t *, ext4_inode_ref_t *, size_t *); 62 static int ext4_read_file(ipc_callid_t, aoff64_t, size_t, ext4_instance_t *, 79 63 ext4_inode_ref_t *, size_t *); 80 static bool ext4fs_is_dots(const uint8_t *, size_t); 81 static int ext4fs_instance_get(service_id_t, ext4fs_instance_t **); 82 static int ext4fs_node_get_core(fs_node_t **, ext4fs_instance_t *, fs_index_t); 83 static int ext4fs_node_put_core(ext4fs_node_t *); 64 static bool ext4_is_dots(const uint8_t *, size_t); 65 static int ext4_instance_get(service_id_t, ext4_instance_t **); 84 66 85 67 /* Forward declarations of ext4 libfs operations. */ 86 68 87 static int ext4 fs_root_get(fs_node_t **, service_id_t);88 static int ext4 fs_match(fs_node_t **, fs_node_t *, const char *);89 static int ext4 fs_node_get(fs_node_t **, service_id_t, fs_index_t);90 static int ext4 fs_node_open(fs_node_t *);91 static int ext4fs_node_put(fs_node_t *);92 static int ext4 fs_create_node(fs_node_t **, service_id_t, int);93 static int ext4 fs_destroy_node(fs_node_t *);94 static int ext4 fs_link(fs_node_t *, fs_node_t *, const char *);95 static int ext4 fs_unlink(fs_node_t *, fs_node_t *, const char *);96 static int ext4 fs_has_children(bool *, fs_node_t *);97 static fs_index_t ext4 fs_index_get(fs_node_t *);98 static aoff64_t ext4 fs_size_get(fs_node_t *);99 static unsigned ext4 fs_lnkcnt_get(fs_node_t *);100 static bool ext4 fs_is_directory(fs_node_t *);101 static bool ext4 fs_is_file(fs_node_t *node);102 static service_id_t ext4 fs_service_get(fs_node_t *node);103 static int ext4 fs_size_block(service_id_t, uint32_t *);104 static int ext4 fs_total_block_count(service_id_t, uint64_t *);105 static int ext4 fs_free_block_count(service_id_t, uint64_t *);69 static int ext4_root_get(fs_node_t **, service_id_t); 70 static int ext4_match(fs_node_t **, fs_node_t *, const char *); 71 static int ext4_node_get(fs_node_t **, service_id_t, fs_index_t); 72 static int ext4_node_open(fs_node_t *); 73 int ext4_node_put(fs_node_t *); 74 static int ext4_create_node(fs_node_t **, service_id_t, int); 75 static int ext4_destroy_node(fs_node_t *); 76 static int ext4_link(fs_node_t *, fs_node_t *, const char *); 77 static int ext4_unlink(fs_node_t *, fs_node_t *, const char *); 78 static int ext4_has_children(bool *, fs_node_t *); 79 static fs_index_t ext4_index_get(fs_node_t *); 80 static aoff64_t ext4_size_get(fs_node_t *); 81 static unsigned ext4_lnkcnt_get(fs_node_t *); 82 static bool ext4_is_directory(fs_node_t *); 83 static bool ext4_is_file(fs_node_t *node); 84 static service_id_t ext4_service_get(fs_node_t *node); 85 static int ext4_size_block(service_id_t, uint32_t *); 86 static int ext4_total_block_count(service_id_t, uint64_t *); 87 static int ext4_free_block_count(service_id_t, uint64_t *); 106 88 107 89 /* Static variables */ … … 127 109 static size_t open_nodes_hash(const ht_link_t *item) 128 110 { 129 ext4 fs_node_t *enode = hash_table_get_inst(item, ext4fs_node_t, link);111 ext4_node_t *enode = hash_table_get_inst(item, ext4_node_t, link); 130 112 return hash_combine(enode->instance->service_id, enode->inode_ref->index); 131 113 } … … 134 116 { 135 117 node_key_t *key = (node_key_t *)key_arg; 136 ext4 fs_node_t *enode = hash_table_get_inst(item, ext4fs_node_t, link);118 ext4_node_t *enode = hash_table_get_inst(item, ext4_node_t, link); 137 119 138 120 return key->service_id == enode->instance->service_id … … 156 138 * 157 139 */ 158 int ext4 fs_global_init(void)140 int ext4_global_init(void) 159 141 { 160 142 if (!hash_table_create(&open_nodes, 0, 0, &open_nodes_ops)) … … 170 152 * @return Error code 171 153 */ 172 int ext4 fs_global_fini(void)154 int ext4_global_fini(void) 173 155 { 174 156 hash_table_destroy(&open_nodes); … … 188 170 * 189 171 */ 190 int ext4 fs_instance_get(service_id_t service_id, ext4fs_instance_t **inst)172 int ext4_instance_get(service_id_t service_id, ext4_instance_t **inst) 191 173 { 192 174 fibril_mutex_lock(&instance_list_mutex); … … 197 179 } 198 180 199 list_foreach(instance_list, link, ext4 fs_instance_t, tmp) {181 list_foreach(instance_list, link, ext4_instance_t, tmp) { 200 182 if (tmp->service_id == service_id) { 201 183 *inst = tmp; … … 217 199 * 218 200 */ 219 int ext4 fs_root_get(fs_node_t **rfn, service_id_t service_id)220 { 221 return ext4 fs_node_get(rfn, service_id, EXT4_INODE_ROOT_INDEX);201 int ext4_root_get(fs_node_t **rfn, service_id_t service_id) 202 { 203 return ext4_node_get(rfn, service_id, EXT4_INODE_ROOT_INDEX); 222 204 } 223 205 … … 233 215 * 234 216 */ 235 int ext4 fs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)236 { 237 ext4 fs_node_t *eparent = EXT4FS_NODE(pfn);217 int ext4_match(fs_node_t **rfn, fs_node_t *pfn, const char *component) 218 { 219 ext4_node_t *eparent = EXT4_NODE(pfn); 238 220 ext4_filesystem_t *fs = eparent->instance->filesystem; 239 221 … … 257 239 /* Load node from search result */ 258 240 uint32_t inode = ext4_directory_entry_ll_get_inode(result.dentry); 259 rc = ext4 fs_node_get_core(rfn, eparent->instance, inode);241 rc = ext4_node_get_core(rfn, eparent->instance, inode); 260 242 if (rc != EOK) 261 243 goto exit; … … 280 262 * 281 263 */ 282 int ext4 fs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)283 { 284 ext4 fs_instance_t *inst;285 int rc = ext4 fs_instance_get(service_id, &inst);286 if (rc != EOK) 287 return rc; 288 289 return ext4 fs_node_get_core(rfn, inst, index);264 int ext4_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index) 265 { 266 ext4_instance_t *inst; 267 int rc = ext4_instance_get(service_id, &inst); 268 if (rc != EOK) 269 return rc; 270 271 return ext4_node_get_core(rfn, inst, index); 290 272 } 291 273 … … 299 281 * 300 282 */ 301 int ext4 fs_node_get_core(fs_node_t **rfn, ext4fs_instance_t *inst,283 int ext4_node_get_core(fs_node_t **rfn, ext4_instance_t *inst, 302 284 fs_index_t index) 303 285 { … … 311 293 312 294 ht_link_t *already_open = hash_table_find(&open_nodes, &key); 313 ext4 fs_node_t *enode = NULL;295 ext4_node_t *enode = NULL; 314 296 if (already_open) { 315 enode = hash_table_get_inst(already_open, ext4 fs_node_t, link);297 enode = hash_table_get_inst(already_open, ext4_node_t, link); 316 298 *rfn = enode->fs_node; 317 299 enode->references++; … … 322 304 323 305 /* Prepare new enode */ 324 enode = malloc(sizeof(ext4 fs_node_t));306 enode = malloc(sizeof(ext4_node_t)); 325 307 if (enode == NULL) { 326 308 fibril_mutex_unlock(&open_nodes_lock); … … 373 355 * 374 356 */ 375 int ext4fs_node_put_core(ext4fs_node_t *enode)357 static int ext4_node_put_core(ext4_node_t *enode) 376 358 { 377 359 hash_table_remove_item(&open_nodes, &enode->link); … … 400 382 * 401 383 */ 402 int ext4 fs_node_open(fs_node_t *fn)384 int ext4_node_open(fs_node_t *fn) 403 385 { 404 386 /* Stateless operation */ … … 414 396 * 415 397 */ 416 int ext4 fs_node_put(fs_node_t *fn)398 int ext4_node_put(fs_node_t *fn) 417 399 { 418 400 fibril_mutex_lock(&open_nodes_lock); 419 401 420 ext4 fs_node_t *enode = EXT4FS_NODE(fn);402 ext4_node_t *enode = EXT4_NODE(fn); 421 403 assert(enode->references > 0); 422 404 enode->references--; 423 405 if (enode->references == 0) { 424 int rc = ext4 fs_node_put_core(enode);406 int rc = ext4_node_put_core(enode); 425 407 if (rc != EOK) { 426 408 fibril_mutex_unlock(&open_nodes_lock); … … 443 425 * 444 426 */ 445 int ext4 fs_create_node(fs_node_t **rfn, service_id_t service_id, int flags)427 int ext4_create_node(fs_node_t **rfn, service_id_t service_id, int flags) 446 428 { 447 429 /* Allocate enode */ 448 ext4 fs_node_t *enode;449 enode = malloc(sizeof(ext4 fs_node_t));430 ext4_node_t *enode; 431 enode = malloc(sizeof(ext4_node_t)); 450 432 if (enode == NULL) 451 433 return ENOMEM; … … 460 442 461 443 /* Load instance */ 462 ext4 fs_instance_t *inst;463 int rc = ext4 fs_instance_get(service_id, &inst);444 ext4_instance_t *inst; 445 int rc = ext4_instance_get(service_id, &inst); 464 446 if (rc != EOK) { 465 447 free(enode); … … 504 486 * 505 487 */ 506 int ext4 fs_destroy_node(fs_node_t *fn)488 int ext4_destroy_node(fs_node_t *fn) 507 489 { 508 490 /* If directory, check for children */ 509 491 bool has_children; 510 int rc = ext4 fs_has_children(&has_children, fn);511 if (rc != EOK) { 512 ext4 fs_node_put(fn);492 int rc = ext4_has_children(&has_children, fn); 493 if (rc != EOK) { 494 ext4_node_put(fn); 513 495 return rc; 514 496 } 515 497 516 498 if (has_children) { 517 ext4 fs_node_put(fn);499 ext4_node_put(fn); 518 500 return EINVAL; 519 501 } 520 502 521 ext4 fs_node_t *enode = EXT4FS_NODE(fn);503 ext4_node_t *enode = EXT4_NODE(fn); 522 504 ext4_inode_ref_t *inode_ref = enode->inode_ref; 523 505 … … 525 507 rc = ext4_filesystem_truncate_inode(inode_ref, 0); 526 508 if (rc != EOK) { 527 ext4 fs_node_put(fn);509 ext4_node_put(fn); 528 510 return rc; 529 511 } … … 539 521 rc = ext4_filesystem_free_inode(inode_ref); 540 522 if (rc != EOK) { 541 ext4 fs_node_put(fn);542 return rc; 543 } 544 545 return ext4 fs_node_put(fn);523 ext4_node_put(fn); 524 return rc; 525 } 526 527 return ext4_node_put(fn); 546 528 } 547 529 … … 555 537 * 556 538 */ 557 int ext4 fs_link(fs_node_t *pfn, fs_node_t *cfn, const char *name)539 int ext4_link(fs_node_t *pfn, fs_node_t *cfn, const char *name) 558 540 { 559 541 /* Check maximum name length */ … … 561 543 return ENAMETOOLONG; 562 544 563 ext4 fs_node_t *parent = EXT4FS_NODE(pfn);564 ext4 fs_node_t *child = EXT4FS_NODE(cfn);545 ext4_node_t *parent = EXT4_NODE(pfn); 546 ext4_node_t *child = EXT4_NODE(cfn); 565 547 ext4_filesystem_t *fs = parent->instance->filesystem; 566 548 … … 628 610 * 629 611 */ 630 int ext4 fs_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *name)612 int ext4_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *name) 631 613 { 632 614 bool has_children; 633 int rc = ext4 fs_has_children(&has_children, cfn);615 int rc = ext4_has_children(&has_children, cfn); 634 616 if (rc != EOK) 635 617 return rc; … … 640 622 641 623 /* Remove entry from parent directory */ 642 ext4_inode_ref_t *parent = EXT4 FS_NODE(pfn)->inode_ref;624 ext4_inode_ref_t *parent = EXT4_NODE(pfn)->inode_ref; 643 625 rc = ext4_directory_remove_entry(parent, name); 644 626 if (rc != EOK) … … 646 628 647 629 /* Decrement links count */ 648 ext4_inode_ref_t *child_inode_ref = EXT4 FS_NODE(cfn)->inode_ref;630 ext4_inode_ref_t *child_inode_ref = EXT4_NODE(cfn)->inode_ref; 649 631 650 632 uint32_t lnk_count = … … 653 635 654 636 /* If directory - handle links from parent */ 655 if ((lnk_count <= 1) && (ext4 fs_is_directory(cfn))) {637 if ((lnk_count <= 1) && (ext4_is_directory(cfn))) { 656 638 assert(lnk_count == 1); 657 639 658 640 lnk_count--; 659 641 660 ext4_inode_ref_t *parent_inode_ref = EXT4 FS_NODE(pfn)->inode_ref;642 ext4_inode_ref_t *parent_inode_ref = EXT4_NODE(pfn)->inode_ref; 661 643 662 644 uint32_t parent_lnk_count = ext4_inode_get_links_count( … … 701 683 * 702 684 */ 703 int ext4 fs_has_children(bool *has_children, fs_node_t *fn)704 { 705 ext4 fs_node_t *enode = EXT4FS_NODE(fn);685 int ext4_has_children(bool *has_children, fs_node_t *fn) 686 { 687 ext4_node_t *enode = EXT4_NODE(fn); 706 688 ext4_filesystem_t *fs = enode->instance->filesystem; 707 689 … … 725 707 ext4_directory_entry_ll_get_name_length(fs->superblock, 726 708 it.current); 727 if (!ext4 fs_is_dots(it.current->name, name_size)) {709 if (!ext4_is_dots(it.current->name, name_size)) { 728 710 found = true; 729 711 break; … … 754 736 * 755 737 */ 756 fs_index_t ext4 fs_index_get(fs_node_t *fn)757 { 758 ext4 fs_node_t *enode = EXT4FS_NODE(fn);738 fs_index_t ext4_index_get(fs_node_t *fn) 739 { 740 ext4_node_t *enode = EXT4_NODE(fn); 759 741 return enode->inode_ref->index; 760 742 } … … 767 749 * 768 750 */ 769 aoff64_t ext4 fs_size_get(fs_node_t *fn)770 { 771 ext4 fs_node_t *enode = EXT4FS_NODE(fn);751 aoff64_t ext4_size_get(fs_node_t *fn) 752 { 753 ext4_node_t *enode = EXT4_NODE(fn); 772 754 ext4_superblock_t *sb = enode->instance->filesystem->superblock; 773 755 return ext4_inode_get_size(sb, enode->inode_ref->inode); … … 781 763 * 782 764 */ 783 unsigned ext4 fs_lnkcnt_get(fs_node_t *fn)784 { 785 ext4 fs_node_t *enode = EXT4FS_NODE(fn);765 unsigned ext4_lnkcnt_get(fs_node_t *fn) 766 { 767 ext4_node_t *enode = EXT4_NODE(fn); 786 768 uint32_t lnkcnt = ext4_inode_get_links_count(enode->inode_ref->inode); 787 769 788 if (ext4 fs_is_directory(fn)) {770 if (ext4_is_directory(fn)) { 789 771 if (lnkcnt > 1) 790 772 return 1; … … 804 786 * 805 787 */ 806 bool ext4 fs_is_directory(fs_node_t *fn)807 { 808 ext4 fs_node_t *enode = EXT4FS_NODE(fn);788 bool ext4_is_directory(fs_node_t *fn) 789 { 790 ext4_node_t *enode = EXT4_NODE(fn); 809 791 ext4_superblock_t *sb = enode->instance->filesystem->superblock; 810 792 … … 820 802 * 821 803 */ 822 bool ext4 fs_is_file(fs_node_t *fn)823 { 824 ext4 fs_node_t *enode = EXT4FS_NODE(fn);804 bool ext4_is_file(fs_node_t *fn) 805 { 806 ext4_node_t *enode = EXT4_NODE(fn); 825 807 ext4_superblock_t *sb = enode->instance->filesystem->superblock; 826 808 … … 836 818 * 837 819 */ 838 service_id_t ext4 fs_service_get(fs_node_t *fn)839 { 840 ext4 fs_node_t *enode = EXT4FS_NODE(fn);820 service_id_t ext4_service_get(fs_node_t *fn) 821 { 822 ext4_node_t *enode = EXT4_NODE(fn); 841 823 return enode->instance->service_id; 842 824 } 843 825 844 int ext4 fs_size_block(service_id_t service_id, uint32_t *size)845 { 846 ext4 fs_instance_t *inst;847 int rc = ext4 fs_instance_get(service_id, &inst);826 int ext4_size_block(service_id_t service_id, uint32_t *size) 827 { 828 ext4_instance_t *inst; 829 int rc = ext4_instance_get(service_id, &inst); 848 830 if (rc != EOK) 849 831 return rc; … … 858 840 } 859 841 860 int ext4 fs_total_block_count(service_id_t service_id, uint64_t *count)861 { 862 ext4 fs_instance_t *inst;863 int rc = ext4 fs_instance_get(service_id, &inst);842 int ext4_total_block_count(service_id_t service_id, uint64_t *count) 843 { 844 ext4_instance_t *inst; 845 int rc = ext4_instance_get(service_id, &inst); 864 846 if (rc != EOK) 865 847 return rc; … … 874 856 } 875 857 876 int ext4 fs_free_block_count(service_id_t service_id, uint64_t *count)877 { 878 ext4 fs_instance_t *inst;879 int rc = ext4 fs_instance_get(service_id, &inst);858 int ext4_free_block_count(service_id_t service_id, uint64_t *count) 859 { 860 ext4_instance_t *inst; 861 int rc = ext4_instance_get(service_id, &inst); 880 862 if (rc != EOK) 881 863 return rc; … … 890 872 * libfs operations. 891 873 */ 892 libfs_ops_t ext4 fs_libfs_ops = {893 .root_get = ext4 fs_root_get,894 .match = ext4 fs_match,895 .node_get = ext4 fs_node_get,896 .node_open = ext4 fs_node_open,897 .node_put = ext4 fs_node_put,898 .create = ext4 fs_create_node,899 .destroy = ext4 fs_destroy_node,900 .link = ext4 fs_link,901 .unlink = ext4 fs_unlink,902 .has_children = ext4 fs_has_children,903 .index_get = ext4 fs_index_get,904 .size_get = ext4 fs_size_get,905 .lnkcnt_get = ext4 fs_lnkcnt_get,906 .is_directory = ext4 fs_is_directory,907 .is_file = ext4 fs_is_file,908 .service_get = ext4 fs_service_get,909 .size_block = ext4 fs_size_block,910 .total_block_count = ext4 fs_total_block_count,911 .free_block_count = ext4 fs_free_block_count874 libfs_ops_t ext4_libfs_ops = { 875 .root_get = ext4_root_get, 876 .match = ext4_match, 877 .node_get = ext4_node_get, 878 .node_open = ext4_node_open, 879 .node_put = ext4_node_put, 880 .create = ext4_create_node, 881 .destroy = ext4_destroy_node, 882 .link = ext4_link, 883 .unlink = ext4_unlink, 884 .has_children = ext4_has_children, 885 .index_get = ext4_index_get, 886 .size_get = ext4_size_get, 887 .lnkcnt_get = ext4_lnkcnt_get, 888 .is_directory = ext4_is_directory, 889 .is_file = ext4_is_file, 890 .service_get = ext4_service_get, 891 .size_block = ext4_size_block, 892 .total_block_count = ext4_total_block_count, 893 .free_block_count = ext4_free_block_count 912 894 }; 913 895 … … 925 907 * @return Error code 926 908 */ 927 static int ext4 fs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)928 { 929 return ENOTSUP;909 static int ext4_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 910 { 911 return ext4_filesystem_probe(service_id); 930 912 } 931 913 … … 943 925 * 944 926 */ 945 static int ext4 fs_mounted(service_id_t service_id, const char *opts,927 static int ext4_mounted(service_id_t service_id, const char *opts, 946 928 fs_index_t *index, aoff64_t *size, unsigned *lnkcnt) 947 929 { 948 /* Allocate libext4 filesystem structure */ 949 ext4_filesystem_t *fs = (ext4_filesystem_t *) 950 malloc(sizeof(ext4_filesystem_t)); 951 if (fs == NULL) 930 ext4_filesystem_t *fs; 931 932 /* Allocate instance structure */ 933 ext4_instance_t *inst = (ext4_instance_t *) 934 malloc(sizeof(ext4_instance_t)); 935 if (inst == NULL) 952 936 return ENOMEM; 953 954 /* Allocate instance structure */955 ext4fs_instance_t *inst = (ext4fs_instance_t *)956 malloc(sizeof(ext4fs_instance_t));957 if (inst == NULL) {958 free(fs);959 return ENOMEM;960 }961 937 962 938 enum cache_mode cmode; … … 966 942 cmode = CACHE_MODE_WB; 967 943 968 /* Initialize the filesystem */969 int rc = ext4_filesystem_init(fs, service_id, cmode);970 if (rc != EOK) {971 free(fs);972 free(inst);973 return rc;974 }975 976 /* Check flags */977 bool read_only;978 rc = ext4_filesystem_check_features(fs, &read_only);979 if (rc != EOK) {980 ext4_filesystem_fini(fs);981 free(fs);982 free(inst);983 return rc;984 }985 986 944 /* Initialize instance */ 987 945 link_initialize(&inst->link); 988 946 inst->service_id = service_id; 989 inst->filesystem = fs;990 947 inst->open_nodes_count = 0; 991 948 992 /* Read root node */ 993 fs_node_t *root_node; 994 rc = ext4fs_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX); 995 if (rc != EOK) { 996 ext4_filesystem_fini(fs); 997 free(fs); 949 /* Initialize the filesystem */ 950 aoff64_t rnsize; 951 int rc = ext4_filesystem_open(inst, service_id, cmode, &rnsize, &fs); 952 if (rc != EOK) { 998 953 free(inst); 999 954 return rc; … … 1005 960 fibril_mutex_unlock(&instance_list_mutex); 1006 961 1007 ext4fs_node_t *enode = EXT4FS_NODE(root_node);1008 1009 962 *index = EXT4_INODE_ROOT_INDEX; 1010 *size = ext4_inode_get_size(fs->superblock, enode->inode_ref->inode);963 *size = rnsize; 1011 964 *lnkcnt = 1; 1012 965 1013 return ext4fs_node_put(root_node);966 return EOK; 1014 967 } 1015 968 … … 1023 976 * 1024 977 */ 1025 static int ext4 fs_unmounted(service_id_t service_id)1026 { 1027 ext4 fs_instance_t *inst;1028 int rc = ext4 fs_instance_get(service_id, &inst);978 static int ext4_unmounted(service_id_t service_id) 979 { 980 ext4_instance_t *inst; 981 int rc = ext4_instance_get(service_id, &inst); 1029 982 if (rc != EOK) 1030 983 return rc; … … 1044 997 fibril_mutex_unlock(&open_nodes_lock); 1045 998 1046 return ext4_filesystem_fini(inst->filesystem); 999 rc = ext4_filesystem_close(inst->filesystem); 1000 if (rc != EOK) { 1001 fibril_mutex_lock(&instance_list_mutex); 1002 list_append(&inst->link, &instance_list); 1003 fibril_mutex_unlock(&instance_list_mutex); 1004 } 1005 1006 free(inst); 1007 return EOK; 1047 1008 } 1048 1009 … … 1057 1018 * 1058 1019 */ 1059 static int ext4 fs_read(service_id_t service_id, fs_index_t index, aoff64_t pos,1020 static int ext4_read(service_id_t service_id, fs_index_t index, aoff64_t pos, 1060 1021 size_t *rbytes) 1061 1022 { … … 1070 1031 } 1071 1032 1072 ext4 fs_instance_t *inst;1073 int rc = ext4 fs_instance_get(service_id, &inst);1033 ext4_instance_t *inst; 1034 int rc = ext4_instance_get(service_id, &inst); 1074 1035 if (rc != EOK) { 1075 1036 async_answer_0(callid, rc); … … 1088 1049 if (ext4_inode_is_type(inst->filesystem->superblock, inode_ref->inode, 1089 1050 EXT4_INODE_MODE_FILE)) { 1090 rc = ext4 fs_read_file(callid, pos, size, inst, inode_ref,1051 rc = ext4_read_file(callid, pos, size, inst, inode_ref, 1091 1052 rbytes); 1092 1053 } else if (ext4_inode_is_type(inst->filesystem->superblock, 1093 1054 inode_ref->inode, EXT4_INODE_MODE_DIRECTORY)) { 1094 rc = ext4 fs_read_directory(callid, pos, size, inst, inode_ref,1055 rc = ext4_read_directory(callid, pos, size, inst, inode_ref, 1095 1056 rbytes); 1096 1057 } else { … … 1113 1074 * 1114 1075 */ 1115 bool ext4 fs_is_dots(const uint8_t *name, size_t name_size)1076 bool ext4_is_dots(const uint8_t *name, size_t name_size) 1116 1077 { 1117 1078 if ((name_size == 1) && (name[0] == '.')) … … 1136 1097 * 1137 1098 */ 1138 int ext4 fs_read_directory(ipc_callid_t callid, aoff64_t pos, size_t size,1139 ext4 fs_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)1099 int ext4_read_directory(ipc_callid_t callid, aoff64_t pos, size_t size, 1100 ext4_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes) 1140 1101 { 1141 1102 ext4_directory_iterator_t it; … … 1160 1121 1161 1122 /* Skip . and .. */ 1162 if (ext4 fs_is_dots(it.current->name, name_size))1123 if (ext4_is_dots(it.current->name, name_size)) 1163 1124 goto skip; 1164 1125 … … 1227 1188 * 1228 1189 */ 1229 int ext4 fs_read_file(ipc_callid_t callid, aoff64_t pos, size_t size,1230 ext4 fs_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)1190 int ext4_read_file(ipc_callid_t callid, aoff64_t pos, size_t size, 1191 ext4_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes) 1231 1192 { 1232 1193 ext4_superblock_t *sb = inst->filesystem->superblock; … … 1316 1277 * 1317 1278 */ 1318 static int ext4 fs_write(service_id_t service_id, fs_index_t index, aoff64_t pos,1279 static int ext4_write(service_id_t service_id, fs_index_t index, aoff64_t pos, 1319 1280 size_t *wbytes, aoff64_t *nsize) 1320 1281 { 1321 1282 fs_node_t *fn; 1322 int rc = ext4 fs_node_get(&fn, service_id, index);1283 int rc = ext4_node_get(&fn, service_id, index); 1323 1284 if (rc != EOK) 1324 1285 return rc; … … 1332 1293 } 1333 1294 1334 ext4 fs_node_t *enode = EXT4FS_NODE(fn);1295 ext4_node_t *enode = EXT4_NODE(fn); 1335 1296 ext4_filesystem_t *fs = enode->instance->filesystem; 1336 1297 … … 1438 1399 ; 1439 1400 1440 int const rc2 = ext4 fs_node_put(fn);1401 int const rc2 = ext4_node_put(fn); 1441 1402 return rc == EOK ? rc2 : rc; 1442 1403 } … … 1453 1414 * 1454 1415 */ 1455 static int ext4 fs_truncate(service_id_t service_id, fs_index_t index,1416 static int ext4_truncate(service_id_t service_id, fs_index_t index, 1456 1417 aoff64_t new_size) 1457 1418 { 1458 1419 fs_node_t *fn; 1459 int rc = ext4 fs_node_get(&fn, service_id, index);1460 if (rc != EOK) 1461 return rc; 1462 1463 ext4 fs_node_t *enode = EXT4FS_NODE(fn);1420 int rc = ext4_node_get(&fn, service_id, index); 1421 if (rc != EOK) 1422 return rc; 1423 1424 ext4_node_t *enode = EXT4_NODE(fn); 1464 1425 ext4_inode_ref_t *inode_ref = enode->inode_ref; 1465 1426 1466 1427 rc = ext4_filesystem_truncate_inode(inode_ref, new_size); 1467 int const rc2 = ext4 fs_node_put(fn);1428 int const rc2 = ext4_node_put(fn); 1468 1429 1469 1430 return rc == EOK ? rc2 : rc; … … 1478 1439 * 1479 1440 */ 1480 static int ext4 fs_close(service_id_t service_id, fs_index_t index)1441 static int ext4_close(service_id_t service_id, fs_index_t index) 1481 1442 { 1482 1443 return EOK; … … 1491 1452 * 1492 1453 */ 1493 static int ext4 fs_destroy(service_id_t service_id, fs_index_t index)1454 static int ext4_destroy(service_id_t service_id, fs_index_t index) 1494 1455 { 1495 1456 fs_node_t *fn; 1496 int rc = ext4 fs_node_get(&fn, service_id, index);1457 int rc = ext4_node_get(&fn, service_id, index); 1497 1458 if (rc != EOK) 1498 1459 return rc; 1499 1460 1500 1461 /* Destroy the inode */ 1501 return ext4 fs_destroy_node(fn);1462 return ext4_destroy_node(fn); 1502 1463 } 1503 1464 … … 1508 1469 * 1509 1470 */ 1510 static int ext4 fs_sync(service_id_t service_id, fs_index_t index)1471 static int ext4_sync(service_id_t service_id, fs_index_t index) 1511 1472 { 1512 1473 fs_node_t *fn; 1513 int rc = ext4 fs_node_get(&fn, service_id, index);1514 if (rc != EOK) 1515 return rc; 1516 1517 ext4 fs_node_t *enode = EXT4FS_NODE(fn);1474 int rc = ext4_node_get(&fn, service_id, index); 1475 if (rc != EOK) 1476 return rc; 1477 1478 ext4_node_t *enode = EXT4_NODE(fn); 1518 1479 enode->inode_ref->dirty = true; 1519 1480 1520 return ext4 fs_node_put(fn);1481 return ext4_node_put(fn); 1521 1482 } 1522 1483 … … 1524 1485 * 1525 1486 */ 1526 vfs_out_ops_t ext4 fs_ops = {1527 .fsprobe = ext4 fs_fsprobe,1528 .mounted = ext4 fs_mounted,1529 .unmounted = ext4 fs_unmounted,1530 .read = ext4 fs_read,1531 .write = ext4 fs_write,1532 .truncate = ext4 fs_truncate,1533 .close = ext4 fs_close,1534 .destroy = ext4 fs_destroy,1535 .sync = ext4 fs_sync1487 vfs_out_ops_t ext4_ops = { 1488 .fsprobe = ext4_fsprobe, 1489 .mounted = ext4_mounted, 1490 .unmounted = ext4_unmounted, 1491 .read = ext4_read, 1492 .write = ext4_write, 1493 .truncate = ext4_truncate, 1494 .close = ext4_close, 1495 .destroy = ext4_destroy, 1496 .sync = ext4_sync 1536 1497 }; 1537 1498 -
uspace/lib/ext4/src/superblock.c
r02082f3 re48947e 33 33 34 34 /** 35 * @file libext4_superblock.c35 * @file superblock.c 36 36 * @brief Ext4 superblock operations. 37 37 */ -
uspace/lib/fdisk/src/fdisk.c
r02082f3 re48947e 824 824 sfstype = "Ext4"; 825 825 break; 826 case fs_cdfs: 827 sfstype = "ISO 9660"; 828 break; 826 829 } 827 830 … … 993 996 pcnt = lpc_ext4; 994 997 break; 998 case fs_cdfs: 999 return EINVAL; /* You cannot create an ISO partition */ 995 1000 } 996 1001 -
uspace/srv/fs/cdfs/cdfs_ops.c
r02082f3 re48947e 906 906 } 907 907 908 static bool iso_readfs(cdfs_t *fs, fs_node_t *rfn, 909 cdfs_lba_t altroot) 908 /** Read the volume descriptors. */ 909 static bool iso_read_vol_desc(service_id_t sid, cdfs_lba_t altroot, 910 uint32_t *rlba, uint32_t *rsize, cdfs_enc_t *enc) 910 911 { 911 912 /* First 16 blocks of isofs are empty */ 912 913 block_t *block; 913 int rc = block_get(&block, fs->service_id, altroot + 16, BLOCK_FLAGS_NONE);914 int rc = block_get(&block, sid, altroot + 16, BLOCK_FLAGS_NONE); 914 915 if (rc != EOK) 915 916 return false; … … 956 957 // TODO: implement path table support 957 958 958 cdfs_node_t *node = CDFS_NODE(rfn);959 960 959 /* Search for Joliet SVD */ 961 960 … … 963 962 uint32_t jrsize; 964 963 965 rc = cdfs_find_joliet_svd( fs->service_id, altroot, &jrlba, &jrsize);964 rc = cdfs_find_joliet_svd(sid, altroot, &jrlba, &jrsize); 966 965 if (rc == EOK) { 967 966 /* Found */ 968 node->lba = jrlba;969 node->size = jrsize;970 fs->enc = enc_ucs2;967 *rlba = jrlba; 968 *rsize = jrsize; 969 *enc = enc_ucs2; 971 970 } else { 972 node->lba = uint32_lb(vol_desc->data.prisec.root_dir.lba); 973 node->size = uint32_lb(vol_desc->data.prisec.root_dir.size); 974 fs->enc = enc_ascii; 975 } 976 977 if (!cdfs_readdir(fs, rfn)) { 978 block_put(block); 979 return false; 971 *rlba = uint32_lb(vol_desc->data.prisec.root_dir.lba); 972 *rsize = uint32_lb(vol_desc->data.prisec.root_dir.size); 973 *enc = enc_ascii; 980 974 } 981 975 982 976 block_put(block); 983 977 return true; 978 } 979 980 static bool iso_readfs(cdfs_t *fs, fs_node_t *rfn, 981 cdfs_lba_t altroot) 982 { 983 int rc; 984 985 cdfs_node_t *node = CDFS_NODE(rfn); 986 987 rc = iso_read_vol_desc(fs->service_id, altroot, &node->lba, 988 &node->size, &fs->enc); 989 if (rc != EOK) 990 return false; 991 992 return cdfs_readdir(fs, rfn); 984 993 } 985 994 … … 1023 1032 static int cdfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 1024 1033 { 1025 return ENOTSUP; 1034 /* Initialize the block layer */ 1035 int rc = block_init(service_id, BLOCK_SIZE); 1036 if (rc != EOK) 1037 return rc; 1038 1039 cdfs_lba_t altroot = 0; 1040 1041 /* 1042 * Read TOC multisession information and get the start address 1043 * of the first track in the last session 1044 */ 1045 scsi_toc_multisess_data_t toc; 1046 1047 rc = block_read_toc(service_id, 1, &toc, sizeof(toc)); 1048 if (rc == EOK && (uint16_t_be2host(toc.toc_len) == 10)) 1049 altroot = uint32_t_be2host(toc.ftrack_lsess.start_addr); 1050 1051 /* Initialize the block cache */ 1052 rc = block_cache_init(service_id, BLOCK_SIZE, 0, CACHE_MODE_WT); 1053 if (rc != EOK) { 1054 block_fini(service_id); 1055 return rc; 1056 } 1057 1058 /* Check if this device is not already mounted */ 1059 fs_node_t *rootfn; 1060 rc = cdfs_root_get(&rootfn, service_id); 1061 if ((rc == EOK) && (rootfn)) { 1062 cdfs_node_put(rootfn); 1063 block_cache_fini(service_id); 1064 block_fini(service_id); 1065 return EOK; 1066 } 1067 1068 /* Read volume descriptors */ 1069 uint32_t rlba; 1070 uint32_t rsize; 1071 cdfs_enc_t enc; 1072 if (!iso_read_vol_desc(service_id, altroot, &rlba, &rsize, &enc)) { 1073 block_cache_fini(service_id); 1074 block_fini(service_id); 1075 return EIO; 1076 } 1077 1078 return EOK; 1026 1079 } 1027 1080 -
uspace/srv/fs/exfat/exfat_fat.c
r02082f3 re48947e 540 540 * does not contain a exfat file system. 541 541 */ 542 int exfat_sanity_check(exfat_bs_t *bs , service_id_t service_id)542 int exfat_sanity_check(exfat_bs_t *bs) 543 543 { 544 544 if (str_cmp((char const *)bs->oem_name, "EXFAT ")) -
uspace/srv/fs/exfat/exfat_fat.h
r02082f3 re48947e 72 72 extern int exfat_set_cluster(struct exfat_bs *, service_id_t, exfat_cluster_t, 73 73 exfat_cluster_t); 74 extern int exfat_sanity_check(struct exfat_bs * , service_id_t);74 extern int exfat_sanity_check(struct exfat_bs *); 75 75 76 76 extern int exfat_append_clusters(struct exfat_bs *, struct exfat_node *, -
uspace/srv/fs/exfat/exfat_ops.c
r02082f3 re48947e 1053 1053 static int exfat_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 1054 1054 { 1055 return ENOTSUP; 1055 int rc; 1056 exfat_bs_t *bs; 1057 1058 /* initialize libblock */ 1059 rc = block_init(service_id, BS_SIZE); 1060 if (rc != EOK) 1061 return rc; 1062 1063 /* prepare the boot block */ 1064 rc = block_bb_read(service_id, BS_BLOCK); 1065 if (rc != EOK) { 1066 block_fini(service_id); 1067 return rc; 1068 } 1069 1070 /* get the buffer with the boot sector */ 1071 bs = block_bb_get(service_id); 1072 1073 /* Do some simple sanity checks on the file system. */ 1074 rc = exfat_sanity_check(bs); 1075 1076 (void) block_cache_fini(service_id); 1077 block_fini(service_id); 1078 return rc; 1056 1079 } 1057 1080 … … 1086 1109 bs = block_bb_get(service_id); 1087 1110 1111 /* Do some simple sanity checks on the file system. */ 1112 rc = exfat_sanity_check(bs); 1113 if (rc != EOK) { 1114 (void) block_cache_fini(service_id); 1115 block_fini(service_id); 1116 return rc; 1117 } 1118 1088 1119 /* Initialize the block cache */ 1089 1120 rc = block_cache_init(service_id, BPS(bs), 0 /* XXX */, cmode); 1090 1121 if (rc != EOK) { 1091 block_fini(service_id);1092 return rc;1093 }1094 1095 /* Do some simple sanity checks on the file system. */1096 rc = exfat_sanity_check(bs, service_id);1097 if (rc != EOK) {1098 (void) block_cache_fini(service_id);1099 1122 block_fini(service_id); 1100 1123 return rc; -
uspace/srv/fs/ext4fs/ext4fs.c
r02082f3 re48947e 72 72 } 73 73 74 int rc = ext4 fs_global_init();74 int rc = ext4_global_init(); 75 75 if (rc != EOK) { 76 76 printf("%s: Global initialization failed\n", NAME); … … 78 78 } 79 79 80 rc = fs_register(vfs_sess, &ext4fs_vfs_info, &ext4 fs_ops,81 &ext4 fs_libfs_ops);80 rc = fs_register(vfs_sess, &ext4fs_vfs_info, &ext4_ops, 81 &ext4_libfs_ops); 82 82 if (rc != EOK) { 83 83 printf("%s: Failed to register file system\n", NAME); -
uspace/srv/fs/fat/fat_ops.c
r02082f3 re48947e 915 915 static int fat_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 916 916 { 917 return ENOTSUP; 917 fat_bs_t *bs; 918 int rc; 919 920 /* initialize libblock */ 921 rc = block_init(service_id, BS_SIZE); 922 if (rc != EOK) 923 return rc; 924 925 /* prepare the boot block */ 926 rc = block_bb_read(service_id, BS_BLOCK); 927 if (rc != EOK) { 928 block_fini(service_id); 929 return rc; 930 } 931 932 /* get the buffer with the boot sector */ 933 bs = block_bb_get(service_id); 934 935 if (BPS(bs) != BS_SIZE) { 936 block_fini(service_id); 937 return ENOTSUP; 938 } 939 940 /* Initialize the block cache */ 941 rc = block_cache_init(service_id, BPS(bs), 0 /* XXX */, CACHE_MODE_WB); 942 if (rc != EOK) { 943 block_fini(service_id); 944 return rc; 945 } 946 947 /* Do some simple sanity checks on the file system. */ 948 rc = fat_sanity_check(bs, service_id); 949 950 (void) block_cache_fini(service_id); 951 block_fini(service_id); 952 953 return rc; 918 954 } 919 955 -
uspace/srv/volsrv/mkfs.c
r02082f3 re48947e 119 119 break; 120 120 case fs_ext4: 121 case fs_cdfs: 121 122 cmd = NULL; 122 123 break; -
uspace/srv/volsrv/part.c
r02082f3 re48947e 53 53 static FIBRIL_MUTEX_INITIALIZE(vol_parts_lock); 54 54 55 struct fsname_type { 56 const char *name; 57 vol_fstype_t fstype; 58 }; 59 60 static struct fsname_type fstab[] = { 61 { "ext4fs", fs_ext4 }, 62 { "cdfs", fs_cdfs }, 63 { "exfat", fs_exfat }, 64 { "fat", fs_fat }, 65 { "mfs", fs_minix }, 66 { NULL, 0 } 67 }; 68 55 69 /** Check for new partitions */ 56 70 static int vol_part_check_new(void) … … 134 148 bool empty; 135 149 vfs_fs_probe_info_t info; 150 struct fsname_type *fst; 136 151 int rc; 137 152 … … 157 172 158 173 log_msg(LOG_DEFAULT, LVL_NOTE, "Probe partition %s", part->svc_name); 159 rc = vfs_fsprobe("mfs", sid, &info); 160 if (rc == EOK) { 174 175 fst = &fstab[0]; 176 while (fst->name != NULL) { 177 rc = vfs_fsprobe(fst->name, sid, &info); 178 if (rc == EOK) 179 break; 180 ++fst; 181 } 182 183 if (fst->name != NULL) { 184 log_msg(LOG_DEFAULT, LVL_NOTE, "Found %s", fst->name); 161 185 part->pcnt = vpc_fs; 162 part->fstype = fs _minix;186 part->fstype = fst->fstype; 163 187 } else { 164 188 log_msg(LOG_DEFAULT, LVL_NOTE, "Partition does not contain "
Note:
See TracChangeset
for help on using the changeset viewer.