Changes in uspace/srv/vfs/vfs_ops.c [e6da6d5:286286c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
re6da6d5 r286286c 52 52 #include <assert.h> 53 53 #include <vfs/canonify.h> 54 #include <vfs/vfs_mtab.h>55 56 FIBRIL_MUTEX_INITIALIZE(mtab_list_lock);57 LIST_INITIALIZE(mtab_list);58 static size_t mtab_size = 0;59 54 60 55 /* Forward declarations of static functions. */ … … 73 68 }; 74 69 75 static intvfs_mount_internal(ipc_callid_t rid, service_id_t service_id,70 static void vfs_mount_internal(ipc_callid_t rid, service_id_t service_id, 76 71 fs_handle_t fs_handle, char *mp, char *opts) 77 72 { … … 96 91 fibril_rwlock_write_unlock(&namespace_rwlock); 97 92 async_answer_0(rid, EBUSY); 98 return EBUSY;93 return; 99 94 } 100 95 … … 104 99 fibril_rwlock_write_unlock(&namespace_rwlock); 105 100 async_answer_0(rid, rc); 106 return rc;101 return; 107 102 } 108 103 … … 111 106 fibril_rwlock_write_unlock(&namespace_rwlock); 112 107 async_answer_0(rid, ENOMEM); 113 return ENOMEM;108 return; 114 109 } 115 110 … … 140 135 fibril_rwlock_write_unlock(&namespace_rwlock); 141 136 async_answer_0(rid, rc); 142 return rc;137 return; 143 138 } 144 139 async_wait_for(msg, &rc); … … 147 142 fibril_rwlock_write_unlock(&namespace_rwlock); 148 143 async_answer_0(rid, rc); 149 return rc;144 return; 150 145 } 151 146 … … 171 166 fibril_rwlock_write_unlock(&namespace_rwlock); 172 167 async_answer_0(rid, rc); 173 return rc;168 return; 174 169 } else { 175 170 /* … … 179 174 fibril_rwlock_write_unlock(&namespace_rwlock); 180 175 async_answer_0(rid, ENOENT); 181 return ENOENT;176 return; 182 177 } 183 178 } … … 212 207 async_answer_0(rid, rc); 213 208 fibril_rwlock_write_unlock(&namespace_rwlock); 214 return rc;209 return; 215 210 } 216 211 … … 227 222 fibril_rwlock_write_unlock(&namespace_rwlock); 228 223 async_answer_0(rid, rc); 229 return rc;224 return; 230 225 } 231 226 … … 263 258 async_answer_0(rid, rc); 264 259 fibril_rwlock_write_unlock(&namespace_rwlock); 265 return rc;266 260 } 267 261 … … 358 352 } 359 353 fibril_mutex_unlock(&fs_list_lock); 360 361 /* Add the filesystem info to the list of mounted filesystems */ 362 mtab_ent_t *mtab_ent = malloc(sizeof(mtab_ent_t)); 363 if (!mtab_ent) { 364 async_answer_0(callid, ENOMEM); 365 async_answer_0(rid, ENOMEM); 366 free(mp); 367 free(fs_name); 368 free(opts); 369 return; 370 } 371 354 355 /* Acknowledge that we know fs_name. */ 356 async_answer_0(callid, EOK); 357 372 358 /* Do the mount */ 373 rc = vfs_mount_internal(rid, service_id, fs_handle, mp, opts); 374 if (rc != EOK) { 375 async_answer_0(callid, ENOTSUP); 376 async_answer_0(rid, ENOTSUP); 377 free(mtab_ent); 378 free(mp); 379 free(opts); 380 free(fs_name); 381 return; 382 } 383 384 /* Add the filesystem info to the list of mounted filesystems */ 385 386 str_cpy(mtab_ent->mp, MAX_PATH_LEN, mp); 387 str_cpy(mtab_ent->fs_name, FS_NAME_MAXLEN, fs_name); 388 str_cpy(mtab_ent->opts, MAX_MNTOPTS_LEN, opts); 389 mtab_ent->instance = instance; 390 mtab_ent->service_id = service_id; 391 392 link_initialize(&mtab_ent->link); 393 394 fibril_mutex_lock(&mtab_list_lock); 395 list_append(&mtab_ent->link, &mtab_list); 396 mtab_size++; 397 fibril_mutex_unlock(&mtab_list_lock); 398 359 vfs_mount_internal(rid, service_id, fs_handle, mp, opts); 399 360 free(mp); 400 361 free(fs_name); 401 362 free(opts); 402 403 /* Acknowledge that we know fs_name. */404 async_answer_0(callid, EOK);405 363 } 406 364 … … 475 433 */ 476 434 435 free(mp); 436 477 437 exch = vfs_exchange_grab(mr_node->fs_handle); 478 438 rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED, … … 482 442 if (rc != EOK) { 483 443 fibril_rwlock_write_unlock(&namespace_rwlock); 484 free(mp);485 444 vfs_node_put(mr_node); 486 445 async_answer_0(rid, rc); … … 500 459 501 460 rc = vfs_lookup_internal(mp, L_MP, &mp_res, NULL); 461 free(mp); 502 462 if (rc != EOK) { 503 463 fibril_rwlock_write_unlock(&namespace_rwlock); 504 free(mp);505 464 vfs_node_put(mr_node); 506 465 async_answer_0(rid, rc); … … 511 470 if (!mp_node) { 512 471 fibril_rwlock_write_unlock(&namespace_rwlock); 513 free(mp);514 472 vfs_node_put(mr_node); 515 473 async_answer_0(rid, ENOMEM); … … 524 482 if (rc != EOK) { 525 483 fibril_rwlock_write_unlock(&namespace_rwlock); 526 free(mp);527 484 vfs_node_put(mp_node); 528 485 vfs_node_put(mr_node); … … 542 499 */ 543 500 vfs_node_forget(mr_node); 501 544 502 fibril_rwlock_write_unlock(&namespace_rwlock); 545 546 fibril_mutex_lock(&mtab_list_lock);547 548 int found = 0;549 550 list_foreach(mtab_list, cur) {551 mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t,552 link);553 554 if (str_cmp(mtab_ent->mp, mp) == 0) {555 list_remove(&mtab_ent->link);556 mtab_size--;557 free(mtab_ent);558 found = 1;559 break;560 }561 }562 assert(found);563 fibril_mutex_unlock(&mtab_list_lock);564 565 free(mp);566 567 503 async_answer_0(rid, EOK); 568 504 } … … 1353 1289 } 1354 1290 1355 void vfs_get_mtab(ipc_callid_t rid, ipc_call_t *request)1356 {1357 ipc_callid_t callid;1358 ipc_call_t data;1359 sysarg_t rc = EOK;1360 size_t len;1361 1362 fibril_mutex_lock(&mtab_list_lock);1363 1364 /* Send to the caller the number of mounted filesystems */1365 callid = async_get_call(&data);1366 if (IPC_GET_IMETHOD(data) != VFS_IN_PING) {1367 rc = ENOTSUP;1368 async_answer_0(callid, rc);1369 goto exit;1370 }1371 async_answer_1(callid, EOK, mtab_size);1372 1373 list_foreach(mtab_list, cur) {1374 mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t,1375 link);1376 1377 rc = ENOTSUP;1378 1379 if (!async_data_read_receive(&callid, &len)) {1380 async_answer_0(callid, rc);1381 goto exit;1382 }1383 1384 (void) async_data_read_finalize(callid, mtab_ent->mp,1385 str_size(mtab_ent->mp));1386 1387 if (!async_data_read_receive(&callid, &len)) {1388 async_answer_0(callid, rc);1389 goto exit;1390 }1391 1392 (void) async_data_read_finalize(callid, mtab_ent->opts,1393 str_size(mtab_ent->opts));1394 1395 if (!async_data_read_receive(&callid, &len)) {1396 async_answer_0(callid, rc);1397 goto exit;1398 }1399 1400 (void) async_data_read_finalize(callid, mtab_ent->fs_name,1401 str_size(mtab_ent->fs_name));1402 1403 callid = async_get_call(&data);1404 1405 if (IPC_GET_IMETHOD(data) != VFS_IN_PING) {1406 async_answer_0(callid, rc);1407 goto exit;1408 }1409 1410 rc = EOK;1411 async_answer_2(callid, rc, mtab_ent->instance,1412 mtab_ent->service_id);1413 }1414 1415 exit:1416 fibril_mutex_unlock(&mtab_list_lock);1417 async_answer_0(rid, rc);1418 }1419 1420 1291 /** 1421 1292 * @}
Note:
See TracChangeset
for help on using the changeset viewer.