Changes in / [e48947e:02082f3] in mainline
- Location:
- uspace
- Files:
-
- 1 added
- 1 deleted
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/init.c
re48947e r02082f3 316 316 } 317 317 318 /* Make sure file systems arerunning. */318 /* Make sure tmpfs is running. */ 319 319 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) 320 320 srv_start("/srv/tmpfs"); 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"); 321 326 322 srv_start("/srv/mfs"); 327 323 -
uspace/lib/c/include/types/vol.h
re48947e r02082f3 52 52 fs_fat, 53 53 fs_minix, 54 fs_ext4, 55 fs_cdfs 54 fs_ext4 56 55 } vol_fstype_t; 57 56 -
uspace/lib/ext4/include/ext4/filesystem.h
re48947e r02082f3 36 36 37 37 #include <block.h> 38 #include "ext4/fstypes.h"39 38 #include "ext4/types.h" 40 39 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_c lose(ext4_filesystem_t*);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_check_features(ext4_filesystem_t *, bool *); 45 44 extern uint32_t ext4_filesystem_blockaddr2_index_in_group(ext4_superblock_t *, 46 45 uint32_t); -
uspace/lib/ext4/include/ext4/ops.h
re48947e r02082f3 35 35 36 36 #include <libfs.h> 37 #include "ext4/fstypes.h"38 37 39 extern vfs_out_ops_t ext4 _ops;40 extern libfs_ops_t ext4 _libfs_ops;38 extern vfs_out_ops_t ext4fs_ops; 39 extern libfs_ops_t ext4fs_libfs_ops; 41 40 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 *); 41 extern int ext4fs_global_init(void); 42 extern int ext4fs_global_fini(void); 47 43 48 44 -
uspace/lib/ext4/src/balloc.c
re48947e r02082f3 31 31 */ 32 32 /** 33 * @file balloc.c33 * @file libext4_balloc.c 34 34 * @brief Physical block allocator. 35 35 */ -
uspace/lib/ext4/src/bitmap.c
re48947e r02082f3 31 31 */ 32 32 /** 33 * @file bitmap.c33 * @file libext4_bitmap.c 34 34 * @brief Ext4 bitmap operations. 35 35 */ -
uspace/lib/ext4/src/block_group.c
re48947e r02082f3 32 32 */ 33 33 /** 34 * @file block_group.c34 * @file libext4_block_group.c 35 35 * @brief Ext4 block group structure operations. 36 36 */ -
uspace/lib/ext4/src/directory.c
re48947e r02082f3 32 32 */ 33 33 /** 34 * @file directory.c34 * @file libext4_directory.c 35 35 * @brief Ext4 directory structure operations. 36 36 */ -
uspace/lib/ext4/src/directory_index.c
re48947e r02082f3 31 31 */ 32 32 /** 33 * @file directory_index.c33 * @file libext4_directory_index.c 34 34 * @brief Ext4 directory index operations. 35 35 */ -
uspace/lib/ext4/src/extent.c
re48947e r02082f3 31 31 */ 32 32 /** 33 * @file extent.c33 * @file libext4_extent.c 34 34 * @brief Ext4 extent structures operations. 35 35 */ -
uspace/lib/ext4/src/filesystem.c
re48947e r02082f3 32 32 */ 33 33 /** 34 * @file filesystem.c34 * @file libext4_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>45 44 #include <stdlib.h> 46 45 #include "ext4/balloc.h" … … 51 50 #include "ext4/ialloc.h" 52 51 #include "ext4/inode.h" 53 #include "ext4/ops.h"54 52 #include "ext4/superblock.h" 55 53 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. 54 /** Initialize filesystem and read all needed data. 61 55 * 62 56 * @param fs Filesystem instance to be initialized 63 * @param service_id Block device to open 64 * @param cmode Cache mode 65 * 66 * @return Error code 67 * 68 */ 69 static int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id, 57 * @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, 70 63 enum cache_mode cmode) 71 64 { … … 120 113 goto err_2; 121 114 } 122 115 123 116 rc = ext4_superblock_check_sanity(fs->superblock); 124 117 if (rc != EOK) 125 118 goto err_2; 126 119 127 /* Check flags*/128 bool read_only;129 rc = ext4_ filesystem_check_features(fs, &read_only);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); 130 123 if (rc != EOK) 131 124 goto err_2; 132 125 126 uint16_t mnt_count = ext4_superblock_get_mount_count(fs->superblock); 127 ext4_superblock_set_mount_count(fs->superblock, mnt_count + 1); 128 133 129 return EOK; 130 134 131 err_2: 135 132 block_cache_fini(fs->device); … … 142 139 } 143 140 144 /** Finalize filesystem. 145 * 146 * @param fs Filesystem to be finalized 147 * 148 */ 149 static void ext4_filesystem_fini(ext4_filesystem_t *fs) 150 { 141 /** Destroy filesystem instance (used by unmount operation). 142 * 143 * @param fs Filesystem to be destroyed 144 * 145 * @return Error code 146 * 147 */ 148 int ext4_filesystem_fini(ext4_filesystem_t *fs) 149 { 150 /* Write the superblock to the device */ 151 ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_VALID_FS); 152 int rc = ext4_superblock_write_direct(fs->device, fs->superblock); 153 151 154 /* Release memory space for superblock */ 152 155 free(fs->superblock); … … 155 158 block_cache_fini(fs->device); 156 159 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 160 247 161 return rc; 248 }249 250 /** Close filesystem.251 *252 * @param fs Filesystem to be destroyed253 *254 * @return EOK or negative error code. On error the state of the file255 * system is unchanged.256 *257 */258 int ext4_filesystem_close(ext4_filesystem_t *fs)259 {260 /* Write the superblock to the device */261 ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_VALID_FS);262 int rc = ext4_superblock_write_direct(fs->device, fs->superblock);263 if (rc != EOK)264 return rc;265 266 ext4_filesystem_fini(fs);267 return EOK;268 162 } 269 163 … … 275 169 * 276 170 * @param fs Filesystem to be checked 277 * @param read_only Place to write flag saying whether filesystem 278 * should be mounted only for reading 279 * 280 * @return Error code 281 * 282 */ 283 static int ext4_filesystem_check_features(ext4_filesystem_t *fs, 284 bool *read_only) 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) 285 177 { 286 178 /* Feature flags are present only in higher revisions */ -
uspace/lib/ext4/src/hash.c
re48947e r02082f3 31 31 */ 32 32 /** 33 * @file hash.c33 * @file libext4_hash.c 34 34 * @brief Hashing algorithms for ext4 HTree. 35 35 */ -
uspace/lib/ext4/src/ialloc.c
re48947e r02082f3 31 31 */ 32 32 /** 33 * @file ialloc.c33 * @file libext4_ialloc.c 34 34 * @brief I-node (de)allocation operations. 35 35 */ -
uspace/lib/ext4/src/inode.c
re48947e r02082f3 32 32 */ 33 33 /** 34 * @file inode.c34 * @file libext4_inode.c 35 35 * @brief Ext4 i-node structure operations. 36 36 */ -
uspace/lib/ext4/src/ops.c
re48947e r02082f3 32 32 */ 33 33 /** 34 * @file ops.c34 * @file ext4fs_ops.c 35 35 * @brief Operations for ext4 filesystem. 36 36 */ 37 37 38 #include <adt/hash_table.h>39 #include <adt/hash.h>40 38 #include <errno.h> 39 #include <ext4/libext4.h> 41 40 #include <fibril_synch.h> 42 41 #include <libfs.h> 43 42 #include <macros.h> 44 43 #include <malloc.h> 45 #include < mem.h>46 #include < str.h>44 #include <adt/hash_table.h> 45 #include <adt/hash.h> 47 46 #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"53 47 #include "ext4/ops.h" 54 #include "ext4/filesystem.h" 55 #include "ext4/fstypes.h" 56 #include "ext4/superblock.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; 57 73 58 74 /* Forward declarations of auxiliary functions */ 59 75 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 *,76 static int ext4fs_read_directory(ipc_callid_t, aoff64_t, size_t, 77 ext4fs_instance_t *, ext4_inode_ref_t *, size_t *); 78 static int ext4fs_read_file(ipc_callid_t, aoff64_t, size_t, ext4fs_instance_t *, 63 79 ext4_inode_ref_t *, size_t *); 64 static bool ext4_is_dots(const uint8_t *, size_t); 65 static int ext4_instance_get(service_id_t, ext4_instance_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 *); 66 84 67 85 /* Forward declarations of ext4 libfs operations. */ 68 86 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 *);87 static int ext4fs_root_get(fs_node_t **, service_id_t); 88 static int ext4fs_match(fs_node_t **, fs_node_t *, const char *); 89 static int ext4fs_node_get(fs_node_t **, service_id_t, fs_index_t); 90 static int ext4fs_node_open(fs_node_t *); 91 static int ext4fs_node_put(fs_node_t *); 92 static int ext4fs_create_node(fs_node_t **, service_id_t, int); 93 static int ext4fs_destroy_node(fs_node_t *); 94 static int ext4fs_link(fs_node_t *, fs_node_t *, const char *); 95 static int ext4fs_unlink(fs_node_t *, fs_node_t *, const char *); 96 static int ext4fs_has_children(bool *, fs_node_t *); 97 static fs_index_t ext4fs_index_get(fs_node_t *); 98 static aoff64_t ext4fs_size_get(fs_node_t *); 99 static unsigned ext4fs_lnkcnt_get(fs_node_t *); 100 static bool ext4fs_is_directory(fs_node_t *); 101 static bool ext4fs_is_file(fs_node_t *node); 102 static service_id_t ext4fs_service_get(fs_node_t *node); 103 static int ext4fs_size_block(service_id_t, uint32_t *); 104 static int ext4fs_total_block_count(service_id_t, uint64_t *); 105 static int ext4fs_free_block_count(service_id_t, uint64_t *); 88 106 89 107 /* Static variables */ … … 109 127 static size_t open_nodes_hash(const ht_link_t *item) 110 128 { 111 ext4 _node_t *enode = hash_table_get_inst(item, ext4_node_t, link);129 ext4fs_node_t *enode = hash_table_get_inst(item, ext4fs_node_t, link); 112 130 return hash_combine(enode->instance->service_id, enode->inode_ref->index); 113 131 } … … 116 134 { 117 135 node_key_t *key = (node_key_t *)key_arg; 118 ext4 _node_t *enode = hash_table_get_inst(item, ext4_node_t, link);136 ext4fs_node_t *enode = hash_table_get_inst(item, ext4fs_node_t, link); 119 137 120 138 return key->service_id == enode->instance->service_id … … 138 156 * 139 157 */ 140 int ext4 _global_init(void)158 int ext4fs_global_init(void) 141 159 { 142 160 if (!hash_table_create(&open_nodes, 0, 0, &open_nodes_ops)) … … 152 170 * @return Error code 153 171 */ 154 int ext4 _global_fini(void)172 int ext4fs_global_fini(void) 155 173 { 156 174 hash_table_destroy(&open_nodes); … … 170 188 * 171 189 */ 172 int ext4 _instance_get(service_id_t service_id, ext4_instance_t **inst)190 int ext4fs_instance_get(service_id_t service_id, ext4fs_instance_t **inst) 173 191 { 174 192 fibril_mutex_lock(&instance_list_mutex); … … 179 197 } 180 198 181 list_foreach(instance_list, link, ext4 _instance_t, tmp) {199 list_foreach(instance_list, link, ext4fs_instance_t, tmp) { 182 200 if (tmp->service_id == service_id) { 183 201 *inst = tmp; … … 199 217 * 200 218 */ 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);219 int ext4fs_root_get(fs_node_t **rfn, service_id_t service_id) 220 { 221 return ext4fs_node_get(rfn, service_id, EXT4_INODE_ROOT_INDEX); 204 222 } 205 223 … … 215 233 * 216 234 */ 217 int ext4 _match(fs_node_t **rfn, fs_node_t *pfn, const char *component)218 { 219 ext4 _node_t *eparent = EXT4_NODE(pfn);235 int ext4fs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component) 236 { 237 ext4fs_node_t *eparent = EXT4FS_NODE(pfn); 220 238 ext4_filesystem_t *fs = eparent->instance->filesystem; 221 239 … … 239 257 /* Load node from search result */ 240 258 uint32_t inode = ext4_directory_entry_ll_get_inode(result.dentry); 241 rc = ext4 _node_get_core(rfn, eparent->instance, inode);259 rc = ext4fs_node_get_core(rfn, eparent->instance, inode); 242 260 if (rc != EOK) 243 261 goto exit; … … 262 280 * 263 281 */ 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);282 int ext4fs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index) 283 { 284 ext4fs_instance_t *inst; 285 int rc = ext4fs_instance_get(service_id, &inst); 286 if (rc != EOK) 287 return rc; 288 289 return ext4fs_node_get_core(rfn, inst, index); 272 290 } 273 291 … … 281 299 * 282 300 */ 283 int ext4 _node_get_core(fs_node_t **rfn, ext4_instance_t *inst,301 int ext4fs_node_get_core(fs_node_t **rfn, ext4fs_instance_t *inst, 284 302 fs_index_t index) 285 303 { … … 293 311 294 312 ht_link_t *already_open = hash_table_find(&open_nodes, &key); 295 ext4 _node_t *enode = NULL;313 ext4fs_node_t *enode = NULL; 296 314 if (already_open) { 297 enode = hash_table_get_inst(already_open, ext4 _node_t, link);315 enode = hash_table_get_inst(already_open, ext4fs_node_t, link); 298 316 *rfn = enode->fs_node; 299 317 enode->references++; … … 304 322 305 323 /* Prepare new enode */ 306 enode = malloc(sizeof(ext4 _node_t));324 enode = malloc(sizeof(ext4fs_node_t)); 307 325 if (enode == NULL) { 308 326 fibril_mutex_unlock(&open_nodes_lock); … … 355 373 * 356 374 */ 357 static int ext4_node_put_core(ext4_node_t *enode)375 int ext4fs_node_put_core(ext4fs_node_t *enode) 358 376 { 359 377 hash_table_remove_item(&open_nodes, &enode->link); … … 382 400 * 383 401 */ 384 int ext4 _node_open(fs_node_t *fn)402 int ext4fs_node_open(fs_node_t *fn) 385 403 { 386 404 /* Stateless operation */ … … 396 414 * 397 415 */ 398 int ext4 _node_put(fs_node_t *fn)416 int ext4fs_node_put(fs_node_t *fn) 399 417 { 400 418 fibril_mutex_lock(&open_nodes_lock); 401 419 402 ext4 _node_t *enode = EXT4_NODE(fn);420 ext4fs_node_t *enode = EXT4FS_NODE(fn); 403 421 assert(enode->references > 0); 404 422 enode->references--; 405 423 if (enode->references == 0) { 406 int rc = ext4 _node_put_core(enode);424 int rc = ext4fs_node_put_core(enode); 407 425 if (rc != EOK) { 408 426 fibril_mutex_unlock(&open_nodes_lock); … … 425 443 * 426 444 */ 427 int ext4 _create_node(fs_node_t **rfn, service_id_t service_id, int flags)445 int ext4fs_create_node(fs_node_t **rfn, service_id_t service_id, int flags) 428 446 { 429 447 /* Allocate enode */ 430 ext4 _node_t *enode;431 enode = malloc(sizeof(ext4 _node_t));448 ext4fs_node_t *enode; 449 enode = malloc(sizeof(ext4fs_node_t)); 432 450 if (enode == NULL) 433 451 return ENOMEM; … … 442 460 443 461 /* Load instance */ 444 ext4 _instance_t *inst;445 int rc = ext4 _instance_get(service_id, &inst);462 ext4fs_instance_t *inst; 463 int rc = ext4fs_instance_get(service_id, &inst); 446 464 if (rc != EOK) { 447 465 free(enode); … … 486 504 * 487 505 */ 488 int ext4 _destroy_node(fs_node_t *fn)506 int ext4fs_destroy_node(fs_node_t *fn) 489 507 { 490 508 /* If directory, check for children */ 491 509 bool has_children; 492 int rc = ext4 _has_children(&has_children, fn);493 if (rc != EOK) { 494 ext4 _node_put(fn);510 int rc = ext4fs_has_children(&has_children, fn); 511 if (rc != EOK) { 512 ext4fs_node_put(fn); 495 513 return rc; 496 514 } 497 515 498 516 if (has_children) { 499 ext4 _node_put(fn);517 ext4fs_node_put(fn); 500 518 return EINVAL; 501 519 } 502 520 503 ext4 _node_t *enode = EXT4_NODE(fn);521 ext4fs_node_t *enode = EXT4FS_NODE(fn); 504 522 ext4_inode_ref_t *inode_ref = enode->inode_ref; 505 523 … … 507 525 rc = ext4_filesystem_truncate_inode(inode_ref, 0); 508 526 if (rc != EOK) { 509 ext4 _node_put(fn);527 ext4fs_node_put(fn); 510 528 return rc; 511 529 } … … 521 539 rc = ext4_filesystem_free_inode(inode_ref); 522 540 if (rc != EOK) { 523 ext4 _node_put(fn);524 return rc; 525 } 526 527 return ext4 _node_put(fn);541 ext4fs_node_put(fn); 542 return rc; 543 } 544 545 return ext4fs_node_put(fn); 528 546 } 529 547 … … 537 555 * 538 556 */ 539 int ext4 _link(fs_node_t *pfn, fs_node_t *cfn, const char *name)557 int ext4fs_link(fs_node_t *pfn, fs_node_t *cfn, const char *name) 540 558 { 541 559 /* Check maximum name length */ … … 543 561 return ENAMETOOLONG; 544 562 545 ext4 _node_t *parent = EXT4_NODE(pfn);546 ext4 _node_t *child = EXT4_NODE(cfn);563 ext4fs_node_t *parent = EXT4FS_NODE(pfn); 564 ext4fs_node_t *child = EXT4FS_NODE(cfn); 547 565 ext4_filesystem_t *fs = parent->instance->filesystem; 548 566 … … 610 628 * 611 629 */ 612 int ext4 _unlink(fs_node_t *pfn, fs_node_t *cfn, const char *name)630 int ext4fs_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *name) 613 631 { 614 632 bool has_children; 615 int rc = ext4 _has_children(&has_children, cfn);633 int rc = ext4fs_has_children(&has_children, cfn); 616 634 if (rc != EOK) 617 635 return rc; … … 622 640 623 641 /* Remove entry from parent directory */ 624 ext4_inode_ref_t *parent = EXT4 _NODE(pfn)->inode_ref;642 ext4_inode_ref_t *parent = EXT4FS_NODE(pfn)->inode_ref; 625 643 rc = ext4_directory_remove_entry(parent, name); 626 644 if (rc != EOK) … … 628 646 629 647 /* Decrement links count */ 630 ext4_inode_ref_t *child_inode_ref = EXT4 _NODE(cfn)->inode_ref;648 ext4_inode_ref_t *child_inode_ref = EXT4FS_NODE(cfn)->inode_ref; 631 649 632 650 uint32_t lnk_count = … … 635 653 636 654 /* If directory - handle links from parent */ 637 if ((lnk_count <= 1) && (ext4 _is_directory(cfn))) {655 if ((lnk_count <= 1) && (ext4fs_is_directory(cfn))) { 638 656 assert(lnk_count == 1); 639 657 640 658 lnk_count--; 641 659 642 ext4_inode_ref_t *parent_inode_ref = EXT4 _NODE(pfn)->inode_ref;660 ext4_inode_ref_t *parent_inode_ref = EXT4FS_NODE(pfn)->inode_ref; 643 661 644 662 uint32_t parent_lnk_count = ext4_inode_get_links_count( … … 683 701 * 684 702 */ 685 int ext4 _has_children(bool *has_children, fs_node_t *fn)686 { 687 ext4 _node_t *enode = EXT4_NODE(fn);703 int ext4fs_has_children(bool *has_children, fs_node_t *fn) 704 { 705 ext4fs_node_t *enode = EXT4FS_NODE(fn); 688 706 ext4_filesystem_t *fs = enode->instance->filesystem; 689 707 … … 707 725 ext4_directory_entry_ll_get_name_length(fs->superblock, 708 726 it.current); 709 if (!ext4 _is_dots(it.current->name, name_size)) {727 if (!ext4fs_is_dots(it.current->name, name_size)) { 710 728 found = true; 711 729 break; … … 736 754 * 737 755 */ 738 fs_index_t ext4 _index_get(fs_node_t *fn)739 { 740 ext4 _node_t *enode = EXT4_NODE(fn);756 fs_index_t ext4fs_index_get(fs_node_t *fn) 757 { 758 ext4fs_node_t *enode = EXT4FS_NODE(fn); 741 759 return enode->inode_ref->index; 742 760 } … … 749 767 * 750 768 */ 751 aoff64_t ext4 _size_get(fs_node_t *fn)752 { 753 ext4 _node_t *enode = EXT4_NODE(fn);769 aoff64_t ext4fs_size_get(fs_node_t *fn) 770 { 771 ext4fs_node_t *enode = EXT4FS_NODE(fn); 754 772 ext4_superblock_t *sb = enode->instance->filesystem->superblock; 755 773 return ext4_inode_get_size(sb, enode->inode_ref->inode); … … 763 781 * 764 782 */ 765 unsigned ext4 _lnkcnt_get(fs_node_t *fn)766 { 767 ext4 _node_t *enode = EXT4_NODE(fn);783 unsigned ext4fs_lnkcnt_get(fs_node_t *fn) 784 { 785 ext4fs_node_t *enode = EXT4FS_NODE(fn); 768 786 uint32_t lnkcnt = ext4_inode_get_links_count(enode->inode_ref->inode); 769 787 770 if (ext4 _is_directory(fn)) {788 if (ext4fs_is_directory(fn)) { 771 789 if (lnkcnt > 1) 772 790 return 1; … … 786 804 * 787 805 */ 788 bool ext4 _is_directory(fs_node_t *fn)789 { 790 ext4 _node_t *enode = EXT4_NODE(fn);806 bool ext4fs_is_directory(fs_node_t *fn) 807 { 808 ext4fs_node_t *enode = EXT4FS_NODE(fn); 791 809 ext4_superblock_t *sb = enode->instance->filesystem->superblock; 792 810 … … 802 820 * 803 821 */ 804 bool ext4 _is_file(fs_node_t *fn)805 { 806 ext4 _node_t *enode = EXT4_NODE(fn);822 bool ext4fs_is_file(fs_node_t *fn) 823 { 824 ext4fs_node_t *enode = EXT4FS_NODE(fn); 807 825 ext4_superblock_t *sb = enode->instance->filesystem->superblock; 808 826 … … 818 836 * 819 837 */ 820 service_id_t ext4 _service_get(fs_node_t *fn)821 { 822 ext4 _node_t *enode = EXT4_NODE(fn);838 service_id_t ext4fs_service_get(fs_node_t *fn) 839 { 840 ext4fs_node_t *enode = EXT4FS_NODE(fn); 823 841 return enode->instance->service_id; 824 842 } 825 843 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);844 int ext4fs_size_block(service_id_t service_id, uint32_t *size) 845 { 846 ext4fs_instance_t *inst; 847 int rc = ext4fs_instance_get(service_id, &inst); 830 848 if (rc != EOK) 831 849 return rc; … … 840 858 } 841 859 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);860 int ext4fs_total_block_count(service_id_t service_id, uint64_t *count) 861 { 862 ext4fs_instance_t *inst; 863 int rc = ext4fs_instance_get(service_id, &inst); 846 864 if (rc != EOK) 847 865 return rc; … … 856 874 } 857 875 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);876 int ext4fs_free_block_count(service_id_t service_id, uint64_t *count) 877 { 878 ext4fs_instance_t *inst; 879 int rc = ext4fs_instance_get(service_id, &inst); 862 880 if (rc != EOK) 863 881 return rc; … … 872 890 * libfs operations. 873 891 */ 874 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_count892 libfs_ops_t ext4fs_libfs_ops = { 893 .root_get = ext4fs_root_get, 894 .match = ext4fs_match, 895 .node_get = ext4fs_node_get, 896 .node_open = ext4fs_node_open, 897 .node_put = ext4fs_node_put, 898 .create = ext4fs_create_node, 899 .destroy = ext4fs_destroy_node, 900 .link = ext4fs_link, 901 .unlink = ext4fs_unlink, 902 .has_children = ext4fs_has_children, 903 .index_get = ext4fs_index_get, 904 .size_get = ext4fs_size_get, 905 .lnkcnt_get = ext4fs_lnkcnt_get, 906 .is_directory = ext4fs_is_directory, 907 .is_file = ext4fs_is_file, 908 .service_get = ext4fs_service_get, 909 .size_block = ext4fs_size_block, 910 .total_block_count = ext4fs_total_block_count, 911 .free_block_count = ext4fs_free_block_count 894 912 }; 895 913 … … 907 925 * @return Error code 908 926 */ 909 static int ext4 _fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)910 { 911 return ext4_filesystem_probe(service_id);927 static int ext4fs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 928 { 929 return ENOTSUP; 912 930 } 913 931 … … 925 943 * 926 944 */ 927 static int ext4 _mounted(service_id_t service_id, const char *opts,945 static int ext4fs_mounted(service_id_t service_id, const char *opts, 928 946 fs_index_t *index, aoff64_t *size, unsigned *lnkcnt) 929 947 { 930 ext4_filesystem_t *fs; 948 /* Allocate libext4 filesystem structure */ 949 ext4_filesystem_t *fs = (ext4_filesystem_t *) 950 malloc(sizeof(ext4_filesystem_t)); 951 if (fs == NULL) 952 return ENOMEM; 931 953 932 954 /* Allocate instance structure */ 933 ext4_instance_t *inst = (ext4_instance_t *) 934 malloc(sizeof(ext4_instance_t)); 935 if (inst == NULL) 955 ext4fs_instance_t *inst = (ext4fs_instance_t *) 956 malloc(sizeof(ext4fs_instance_t)); 957 if (inst == NULL) { 958 free(fs); 936 959 return ENOMEM; 960 } 937 961 938 962 enum cache_mode cmode; … … 942 966 cmode = CACHE_MODE_WB; 943 967 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 944 986 /* Initialize instance */ 945 987 link_initialize(&inst->link); 946 988 inst->service_id = service_id; 989 inst->filesystem = fs; 947 990 inst->open_nodes_count = 0; 948 991 949 /* Initialize the filesystem */ 950 aoff64_t rnsize; 951 int rc = ext4_filesystem_open(inst, service_id, cmode, &rnsize, &fs); 952 if (rc != EOK) { 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); 953 998 free(inst); 954 999 return rc; … … 960 1005 fibril_mutex_unlock(&instance_list_mutex); 961 1006 1007 ext4fs_node_t *enode = EXT4FS_NODE(root_node); 1008 962 1009 *index = EXT4_INODE_ROOT_INDEX; 963 *size = rnsize;1010 *size = ext4_inode_get_size(fs->superblock, enode->inode_ref->inode); 964 1011 *lnkcnt = 1; 965 1012 966 return EOK;1013 return ext4fs_node_put(root_node); 967 1014 } 968 1015 … … 976 1023 * 977 1024 */ 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);1025 static int ext4fs_unmounted(service_id_t service_id) 1026 { 1027 ext4fs_instance_t *inst; 1028 int rc = ext4fs_instance_get(service_id, &inst); 982 1029 if (rc != EOK) 983 1030 return rc; … … 997 1044 fibril_mutex_unlock(&open_nodes_lock); 998 1045 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; 1046 return ext4_filesystem_fini(inst->filesystem); 1008 1047 } 1009 1048 … … 1018 1057 * 1019 1058 */ 1020 static int ext4 _read(service_id_t service_id, fs_index_t index, aoff64_t pos,1059 static int ext4fs_read(service_id_t service_id, fs_index_t index, aoff64_t pos, 1021 1060 size_t *rbytes) 1022 1061 { … … 1031 1070 } 1032 1071 1033 ext4 _instance_t *inst;1034 int rc = ext4 _instance_get(service_id, &inst);1072 ext4fs_instance_t *inst; 1073 int rc = ext4fs_instance_get(service_id, &inst); 1035 1074 if (rc != EOK) { 1036 1075 async_answer_0(callid, rc); … … 1049 1088 if (ext4_inode_is_type(inst->filesystem->superblock, inode_ref->inode, 1050 1089 EXT4_INODE_MODE_FILE)) { 1051 rc = ext4 _read_file(callid, pos, size, inst, inode_ref,1090 rc = ext4fs_read_file(callid, pos, size, inst, inode_ref, 1052 1091 rbytes); 1053 1092 } else if (ext4_inode_is_type(inst->filesystem->superblock, 1054 1093 inode_ref->inode, EXT4_INODE_MODE_DIRECTORY)) { 1055 rc = ext4 _read_directory(callid, pos, size, inst, inode_ref,1094 rc = ext4fs_read_directory(callid, pos, size, inst, inode_ref, 1056 1095 rbytes); 1057 1096 } else { … … 1074 1113 * 1075 1114 */ 1076 bool ext4 _is_dots(const uint8_t *name, size_t name_size)1115 bool ext4fs_is_dots(const uint8_t *name, size_t name_size) 1077 1116 { 1078 1117 if ((name_size == 1) && (name[0] == '.')) … … 1097 1136 * 1098 1137 */ 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)1138 int ext4fs_read_directory(ipc_callid_t callid, aoff64_t pos, size_t size, 1139 ext4fs_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes) 1101 1140 { 1102 1141 ext4_directory_iterator_t it; … … 1121 1160 1122 1161 /* Skip . and .. */ 1123 if (ext4 _is_dots(it.current->name, name_size))1162 if (ext4fs_is_dots(it.current->name, name_size)) 1124 1163 goto skip; 1125 1164 … … 1188 1227 * 1189 1228 */ 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)1229 int ext4fs_read_file(ipc_callid_t callid, aoff64_t pos, size_t size, 1230 ext4fs_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes) 1192 1231 { 1193 1232 ext4_superblock_t *sb = inst->filesystem->superblock; … … 1277 1316 * 1278 1317 */ 1279 static int ext4 _write(service_id_t service_id, fs_index_t index, aoff64_t pos,1318 static int ext4fs_write(service_id_t service_id, fs_index_t index, aoff64_t pos, 1280 1319 size_t *wbytes, aoff64_t *nsize) 1281 1320 { 1282 1321 fs_node_t *fn; 1283 int rc = ext4 _node_get(&fn, service_id, index);1322 int rc = ext4fs_node_get(&fn, service_id, index); 1284 1323 if (rc != EOK) 1285 1324 return rc; … … 1293 1332 } 1294 1333 1295 ext4 _node_t *enode = EXT4_NODE(fn);1334 ext4fs_node_t *enode = EXT4FS_NODE(fn); 1296 1335 ext4_filesystem_t *fs = enode->instance->filesystem; 1297 1336 … … 1399 1438 ; 1400 1439 1401 int const rc2 = ext4 _node_put(fn);1440 int const rc2 = ext4fs_node_put(fn); 1402 1441 return rc == EOK ? rc2 : rc; 1403 1442 } … … 1414 1453 * 1415 1454 */ 1416 static int ext4 _truncate(service_id_t service_id, fs_index_t index,1455 static int ext4fs_truncate(service_id_t service_id, fs_index_t index, 1417 1456 aoff64_t new_size) 1418 1457 { 1419 1458 fs_node_t *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);1459 int rc = ext4fs_node_get(&fn, service_id, index); 1460 if (rc != EOK) 1461 return rc; 1462 1463 ext4fs_node_t *enode = EXT4FS_NODE(fn); 1425 1464 ext4_inode_ref_t *inode_ref = enode->inode_ref; 1426 1465 1427 1466 rc = ext4_filesystem_truncate_inode(inode_ref, new_size); 1428 int const rc2 = ext4 _node_put(fn);1467 int const rc2 = ext4fs_node_put(fn); 1429 1468 1430 1469 return rc == EOK ? rc2 : rc; … … 1439 1478 * 1440 1479 */ 1441 static int ext4 _close(service_id_t service_id, fs_index_t index)1480 static int ext4fs_close(service_id_t service_id, fs_index_t index) 1442 1481 { 1443 1482 return EOK; … … 1452 1491 * 1453 1492 */ 1454 static int ext4 _destroy(service_id_t service_id, fs_index_t index)1493 static int ext4fs_destroy(service_id_t service_id, fs_index_t index) 1455 1494 { 1456 1495 fs_node_t *fn; 1457 int rc = ext4 _node_get(&fn, service_id, index);1496 int rc = ext4fs_node_get(&fn, service_id, index); 1458 1497 if (rc != EOK) 1459 1498 return rc; 1460 1499 1461 1500 /* Destroy the inode */ 1462 return ext4 _destroy_node(fn);1501 return ext4fs_destroy_node(fn); 1463 1502 } 1464 1503 … … 1469 1508 * 1470 1509 */ 1471 static int ext4 _sync(service_id_t service_id, fs_index_t index)1510 static int ext4fs_sync(service_id_t service_id, fs_index_t index) 1472 1511 { 1473 1512 fs_node_t *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);1513 int rc = ext4fs_node_get(&fn, service_id, index); 1514 if (rc != EOK) 1515 return rc; 1516 1517 ext4fs_node_t *enode = EXT4FS_NODE(fn); 1479 1518 enode->inode_ref->dirty = true; 1480 1519 1481 return ext4 _node_put(fn);1520 return ext4fs_node_put(fn); 1482 1521 } 1483 1522 … … 1485 1524 * 1486 1525 */ 1487 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 _sync1526 vfs_out_ops_t ext4fs_ops = { 1527 .fsprobe = ext4fs_fsprobe, 1528 .mounted = ext4fs_mounted, 1529 .unmounted = ext4fs_unmounted, 1530 .read = ext4fs_read, 1531 .write = ext4fs_write, 1532 .truncate = ext4fs_truncate, 1533 .close = ext4fs_close, 1534 .destroy = ext4fs_destroy, 1535 .sync = ext4fs_sync 1497 1536 }; 1498 1537 -
uspace/lib/ext4/src/superblock.c
re48947e r02082f3 33 33 34 34 /** 35 * @file superblock.c35 * @file libext4_superblock.c 36 36 * @brief Ext4 superblock operations. 37 37 */ -
uspace/lib/fdisk/src/fdisk.c
re48947e r02082f3 824 824 sfstype = "Ext4"; 825 825 break; 826 case fs_cdfs:827 sfstype = "ISO 9660";828 break;829 826 } 830 827 … … 996 993 pcnt = lpc_ext4; 997 994 break; 998 case fs_cdfs:999 return EINVAL; /* You cannot create an ISO partition */1000 995 } 1001 996 -
uspace/srv/fs/cdfs/cdfs_ops.c
re48947e r02082f3 906 906 } 907 907 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) 908 static bool iso_readfs(cdfs_t *fs, fs_node_t *rfn, 909 cdfs_lba_t altroot) 911 910 { 912 911 /* First 16 blocks of isofs are empty */ 913 912 block_t *block; 914 int rc = block_get(&block, sid, altroot + 16, BLOCK_FLAGS_NONE);913 int rc = block_get(&block, fs->service_id, altroot + 16, BLOCK_FLAGS_NONE); 915 914 if (rc != EOK) 916 915 return false; … … 957 956 // TODO: implement path table support 958 957 958 cdfs_node_t *node = CDFS_NODE(rfn); 959 959 960 /* Search for Joliet SVD */ 960 961 … … 962 963 uint32_t jrsize; 963 964 964 rc = cdfs_find_joliet_svd( sid, altroot, &jrlba, &jrsize);965 rc = cdfs_find_joliet_svd(fs->service_id, altroot, &jrlba, &jrsize); 965 966 if (rc == EOK) { 966 967 /* Found */ 967 *rlba = jrlba;968 *rsize = jrsize;969 *enc = enc_ucs2;968 node->lba = jrlba; 969 node->size = jrsize; 970 fs->enc = enc_ucs2; 970 971 } else { 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; 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; 974 980 } 975 981 976 982 block_put(block); 977 983 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);993 984 } 994 985 … … 1032 1023 static int cdfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 1033 1024 { 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; 1025 return ENOTSUP; 1079 1026 } 1080 1027 -
uspace/srv/fs/exfat/exfat_fat.c
re48947e r02082f3 540 540 * does not contain a exfat file system. 541 541 */ 542 int exfat_sanity_check(exfat_bs_t *bs )542 int exfat_sanity_check(exfat_bs_t *bs, service_id_t service_id) 543 543 { 544 544 if (str_cmp((char const *)bs->oem_name, "EXFAT ")) -
uspace/srv/fs/exfat/exfat_fat.h
re48947e r02082f3 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 * );74 extern int exfat_sanity_check(struct exfat_bs *, service_id_t); 75 75 76 76 extern int exfat_append_clusters(struct exfat_bs *, struct exfat_node *, -
uspace/srv/fs/exfat/exfat_ops.c
re48947e r02082f3 1053 1053 static int exfat_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 1054 1054 { 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; 1055 return ENOTSUP; 1079 1056 } 1080 1057 … … 1109 1086 bs = block_bb_get(service_id); 1110 1087 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 1119 1088 /* Initialize the block cache */ 1120 1089 rc = block_cache_init(service_id, BPS(bs), 0 /* XXX */, cmode); 1121 1090 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); 1122 1099 block_fini(service_id); 1123 1100 return rc; -
uspace/srv/fs/ext4fs/ext4fs.c
re48947e r02082f3 72 72 } 73 73 74 int rc = ext4 _global_init();74 int rc = ext4fs_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 _ops,81 &ext4 _libfs_ops);80 rc = fs_register(vfs_sess, &ext4fs_vfs_info, &ext4fs_ops, 81 &ext4fs_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
re48947e r02082f3 915 915 static int fat_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 916 916 { 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; 917 return ENOTSUP; 954 918 } 955 919 -
uspace/srv/volsrv/mkfs.c
re48947e r02082f3 119 119 break; 120 120 case fs_ext4: 121 case fs_cdfs:122 121 cmd = NULL; 123 122 break; -
uspace/srv/volsrv/part.c
re48947e r02082f3 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 69 55 /** Check for new partitions */ 70 56 static int vol_part_check_new(void) … … 148 134 bool empty; 149 135 vfs_fs_probe_info_t info; 150 struct fsname_type *fst;151 136 int rc; 152 137 … … 172 157 173 158 log_msg(LOG_DEFAULT, LVL_NOTE, "Probe partition %s", part->svc_name); 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); 159 rc = vfs_fsprobe("mfs", sid, &info); 160 if (rc == EOK) { 185 161 part->pcnt = vpc_fs; 186 part->fstype = fs t->fstype;162 part->fstype = fs_minix; 187 163 } else { 188 164 log_msg(LOG_DEFAULT, LVL_NOTE, "Partition does not contain "
Note:
See TracChangeset
for help on using the changeset viewer.