Changeset 45e7868 in mainline for uspace/srv/vfs/vfs_ops.c
- Timestamp:
- 2011-11-07T23:02:28Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8c62a71
- Parents:
- a0c05e7 (diff), 7b5f4c9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
ra0c05e7 r45e7868 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; 54 59 55 60 /* Forward declarations of static functions. */ … … 68 73 }; 69 74 70 static voidvfs_mount_internal(ipc_callid_t rid, service_id_t service_id,75 static int vfs_mount_internal(ipc_callid_t rid, service_id_t service_id, 71 76 fs_handle_t fs_handle, char *mp, char *opts) 72 77 { … … 91 96 fibril_rwlock_write_unlock(&namespace_rwlock); 92 97 async_answer_0(rid, EBUSY); 93 return ;98 return EBUSY; 94 99 } 95 100 … … 99 104 fibril_rwlock_write_unlock(&namespace_rwlock); 100 105 async_answer_0(rid, rc); 101 return ;106 return rc; 102 107 } 103 108 … … 106 111 fibril_rwlock_write_unlock(&namespace_rwlock); 107 112 async_answer_0(rid, ENOMEM); 108 return ;113 return ENOMEM; 109 114 } 110 115 … … 135 140 fibril_rwlock_write_unlock(&namespace_rwlock); 136 141 async_answer_0(rid, rc); 137 return ;142 return rc; 138 143 } 139 144 async_wait_for(msg, &rc); … … 142 147 fibril_rwlock_write_unlock(&namespace_rwlock); 143 148 async_answer_0(rid, rc); 144 return ;149 return rc; 145 150 } 146 151 … … 166 171 fibril_rwlock_write_unlock(&namespace_rwlock); 167 172 async_answer_0(rid, rc); 168 return ;173 return rc; 169 174 } else { 170 175 /* … … 174 179 fibril_rwlock_write_unlock(&namespace_rwlock); 175 180 async_answer_0(rid, ENOENT); 176 return ;181 return ENOENT; 177 182 } 178 183 } … … 207 212 async_answer_0(rid, rc); 208 213 fibril_rwlock_write_unlock(&namespace_rwlock); 209 return ;214 return rc; 210 215 } 211 216 … … 222 227 fibril_rwlock_write_unlock(&namespace_rwlock); 223 228 async_answer_0(rid, rc); 224 return ;229 return rc; 225 230 } 226 231 … … 258 263 async_answer_0(rid, rc); 259 264 fibril_rwlock_write_unlock(&namespace_rwlock); 265 return rc; 260 266 } 261 267 … … 352 358 } 353 359 fibril_mutex_unlock(&fs_list_lock); 354 355 /* Acknowledge that we know fs_name. */ 356 async_answer_0(callid, EOK); 357 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 358 372 /* Do the mount */ 359 vfs_mount_internal(rid, service_id, fs_handle, mp, opts); 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 360 399 free(mp); 361 400 free(fs_name); 362 401 free(opts); 402 403 /* Acknowledge that we know fs_name. */ 404 async_answer_0(callid, EOK); 363 405 } 364 406 … … 433 475 */ 434 476 435 free(mp);436 437 477 exch = vfs_exchange_grab(mr_node->fs_handle); 438 478 rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED, … … 442 482 if (rc != EOK) { 443 483 fibril_rwlock_write_unlock(&namespace_rwlock); 484 free(mp); 444 485 vfs_node_put(mr_node); 445 486 async_answer_0(rid, rc); … … 459 500 460 501 rc = vfs_lookup_internal(mp, L_MP, &mp_res, NULL); 461 free(mp);462 502 if (rc != EOK) { 463 503 fibril_rwlock_write_unlock(&namespace_rwlock); 504 free(mp); 464 505 vfs_node_put(mr_node); 465 506 async_answer_0(rid, rc); … … 470 511 if (!mp_node) { 471 512 fibril_rwlock_write_unlock(&namespace_rwlock); 513 free(mp); 472 514 vfs_node_put(mr_node); 473 515 async_answer_0(rid, ENOMEM); … … 482 524 if (rc != EOK) { 483 525 fibril_rwlock_write_unlock(&namespace_rwlock); 526 free(mp); 484 527 vfs_node_put(mp_node); 485 528 vfs_node_put(mr_node); … … 499 542 */ 500 543 vfs_node_forget(mr_node); 501 502 544 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 503 567 async_answer_0(rid, EOK); 504 568 } … … 1289 1353 } 1290 1354 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 1291 1420 /** 1292 1421 * @}
Note:
See TracChangeset
for help on using the changeset viewer.