Changes in uspace/srv/fs/mfs/mfs_ops.c [7a46bfe:5bf76c1] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/mfs/mfs_ops.c
r7a46bfe r5bf76c1 55 55 static int mfs_has_children(bool *has_children, fs_node_t *fsnode); 56 56 static int mfs_root_get(fs_node_t **rfn, service_id_t service_id); 57 static service_id_t mfs_ device_get(fs_node_t *fsnode);57 static service_id_t mfs_service_get(fs_node_t *fsnode); 58 58 static aoff64_t mfs_size_get(fs_node_t *node); 59 59 static int mfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component); … … 73 73 74 74 75 static LIST_INITIALIZE(inst_list);76 static FIBRIL_MUTEX_INITIALIZE(inst_list_mutex);77 75 static hash_table_t open_nodes; 78 76 static FIBRIL_MUTEX_INITIALIZE(open_nodes_lock); … … 81 79 .size_get = mfs_size_get, 82 80 .root_get = mfs_root_get, 83 . device_get = mfs_device_get,81 .service_get = mfs_service_get, 84 82 .is_directory = mfs_is_directory, 85 83 .is_file = mfs_is_file, … … 179 177 return ENOMEM; 180 178 } 181 182 instance->open_nodes_cnt = 0;183 179 184 180 sb = malloc(MFS_SUPERBLOCK_SIZE); … … 268 264 free(instance); 269 265 free(sbi); 270 free(sb);271 266 block_cache_fini(service_id); 272 267 block_fini(service_id); … … 275 270 } 276 271 277 /*Initialize the instance structure and add it to the list*/ 278 link_initialize(&instance->link); 272 /*Initialize the instance structure and remember it*/ 279 273 instance->service_id = service_id; 280 274 instance->sbi = sbi; 281 282 fibril_mutex_lock(&inst_list_mutex); 283 list_append(&instance->link, &inst_list); 284 fibril_mutex_unlock(&inst_list_mutex); 275 instance->open_nodes_cnt = 0; 276 rc = fs_instance_create(service_id, instance); 277 if (rc != EOK) { 278 free(instance); 279 free(sbi); 280 block_cache_fini(service_id); 281 block_fini(service_id); 282 mfsdebug("fs instance creation failed\n"); 283 return rc; 284 } 285 285 286 286 mfsdebug("mount successful\n"); … … 315 315 block_fini(service_id); 316 316 317 /* Remove the instance from the list */ 318 fibril_mutex_lock(&inst_list_mutex); 319 list_remove(&inst->link); 320 fibril_mutex_unlock(&inst_list_mutex); 321 317 /* Remove and destroy the instance */ 318 (void) fs_instance_destroy(service_id); 322 319 free(inst->sbi); 323 320 free(inst); … … 325 322 } 326 323 327 service_id_t mfs_ device_get(fs_node_t *fsnode)324 service_id_t mfs_service_get(fs_node_t *fsnode) 328 325 { 329 326 struct mfs_node *node = fsnode->data; … … 468 465 static aoff64_t mfs_size_get(fs_node_t *node) 469 466 { 470 assert(node);471 472 467 const struct mfs_node *mnode = node->data; 473 assert(mnode);474 assert(mnode->ino_i);475 476 468 return mnode->ino_i->i_size; 477 469 } … … 513 505 assert(mnode->instance->open_nodes_cnt > 0); 514 506 mnode->instance->open_nodes_cnt--; 515 rc = mfs_put_inode _core(mnode);507 rc = mfs_put_inode(mnode); 516 508 free(mnode->ino_i); 517 509 free(mnode); … … 535 527 { 536 528 struct mfs_node *mnode = fsnode->data; 537 538 assert(mnode->ino_i);539 529 return mnode->ino_i->index; 540 530 } … … 1019 1009 mfs_instance_get(service_id_t service_id, struct mfs_instance **instance) 1020 1010 { 1021 struct mfs_instance *instance_ptr; 1022 1023 fibril_mutex_lock(&inst_list_mutex); 1024 1025 if (list_empty(&inst_list)) { 1026 fibril_mutex_unlock(&inst_list_mutex); 1027 return EINVAL; 1028 } 1029 1030 list_foreach(inst_list, link) { 1031 instance_ptr = list_get_instance(link, struct mfs_instance, 1032 link); 1033 1034 if (instance_ptr->service_id == service_id) { 1035 *instance = instance_ptr; 1036 fibril_mutex_unlock(&inst_list_mutex); 1037 return EOK; 1038 } 1039 } 1040 1041 mfsdebug("Instance not found\n"); 1042 1043 fibril_mutex_unlock(&inst_list_mutex); 1044 return EINVAL; 1011 void *data; 1012 int rc; 1013 1014 rc = fs_instance_get(service_id, &data); 1015 if (rc == EOK) { 1016 *instance = (struct mfs_instance *) data; 1017 } else { 1018 mfsdebug("instance not found\n"); 1019 } 1020 1021 return rc; 1045 1022 } 1046 1023
Note:
See TracChangeset
for help on using the changeset viewer.