Changes in uspace/srv/fs/mfs/mfs_ops.c [5bf76c1:7a46bfe] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/mfs/mfs_ops.c
r5bf76c1 r7a46bfe 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_ service_get(fs_node_t *fsnode);57 static service_id_t mfs_device_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); 75 77 static hash_table_t open_nodes; 76 78 static FIBRIL_MUTEX_INITIALIZE(open_nodes_lock); … … 79 81 .size_get = mfs_size_get, 80 82 .root_get = mfs_root_get, 81 . service_get = mfs_service_get,83 .device_get = mfs_device_get, 82 84 .is_directory = mfs_is_directory, 83 85 .is_file = mfs_is_file, … … 177 179 return ENOMEM; 178 180 } 181 182 instance->open_nodes_cnt = 0; 179 183 180 184 sb = malloc(MFS_SUPERBLOCK_SIZE); … … 264 268 free(instance); 265 269 free(sbi); 270 free(sb); 266 271 block_cache_fini(service_id); 267 272 block_fini(service_id); … … 270 275 } 271 276 272 /*Initialize the instance structure and remember it*/ 277 /*Initialize the instance structure and add it to the list*/ 278 link_initialize(&instance->link); 273 279 instance->service_id = service_id; 274 280 instance->sbi = sbi; 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 } 281 282 fibril_mutex_lock(&inst_list_mutex); 283 list_append(&instance->link, &inst_list); 284 fibril_mutex_unlock(&inst_list_mutex); 285 285 286 286 mfsdebug("mount successful\n"); … … 315 315 block_fini(service_id); 316 316 317 /* Remove and destroy the instance */ 318 (void) fs_instance_destroy(service_id); 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 319 322 free(inst->sbi); 320 323 free(inst); … … 322 325 } 323 326 324 service_id_t mfs_ service_get(fs_node_t *fsnode)327 service_id_t mfs_device_get(fs_node_t *fsnode) 325 328 { 326 329 struct mfs_node *node = fsnode->data; … … 465 468 static aoff64_t mfs_size_get(fs_node_t *node) 466 469 { 470 assert(node); 471 467 472 const struct mfs_node *mnode = node->data; 473 assert(mnode); 474 assert(mnode->ino_i); 475 468 476 return mnode->ino_i->i_size; 469 477 } … … 505 513 assert(mnode->instance->open_nodes_cnt > 0); 506 514 mnode->instance->open_nodes_cnt--; 507 rc = mfs_put_inode (mnode);515 rc = mfs_put_inode_core(mnode); 508 516 free(mnode->ino_i); 509 517 free(mnode); … … 527 535 { 528 536 struct mfs_node *mnode = fsnode->data; 537 538 assert(mnode->ino_i); 529 539 return mnode->ino_i->index; 530 540 } … … 1009 1019 mfs_instance_get(service_id_t service_id, struct mfs_instance **instance) 1010 1020 { 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; 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; 1022 1045 } 1023 1046
Note:
See TracChangeset
for help on using the changeset viewer.