Changeset eb522e8 in mainline for uspace/lib/fs/libfs.c
- Timestamp:
- 2011-06-01T08:43:42Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8d6c1f1
- Parents:
- 9e2e715 (diff), e51a514 (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/lib/fs/libfs.c
r9e2e715 reb522e8 40 40 #include <errno.h> 41 41 #include <async.h> 42 #include <ipc/ipc.h>43 42 #include <as.h> 44 43 #include <assert.h> … … 58 57 #define answer_and_return(rid, rc) \ 59 58 do { \ 60 ipc_answer_0((rid), (rc)); \59 async_answer_0((rid), (rc)); \ 61 60 return; \ 62 61 } while (0) … … 102 101 * Ask VFS for callback connection. 103 102 */ 104 ipc_connect_to_me(vfs_phone, 0, 0, 0, ®->vfs_phonehash);103 async_connect_to_me(vfs_phone, 0, 0, 0, conn); 105 104 106 105 /* … … 129 128 130 129 /* 131 * Create a connection fibril to handle the callback connection.132 */133 async_new_connection(reg->vfs_phonehash, 0, NULL, conn);134 135 /*136 130 * Tell the async framework that other connections are to be handled by 137 131 * the same connection fibril as well. … … 150 144 ipc_call_t *request) 151 145 { 152 dev _handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);146 devmap_handle_t mp_devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 153 147 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request); 154 148 fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request); 155 dev _handle_t mr_dev_handle = (dev_handle_t) IPC_GET_ARG4(*request);149 devmap_handle_t mr_devmap_handle = (devmap_handle_t) IPC_GET_ARG4(*request); 156 150 int res; 157 ipcarg_t rc;151 sysarg_t rc; 158 152 159 153 ipc_call_t call; … … 163 157 callid = async_get_call(&call); 164 158 int mountee_phone = (int) IPC_GET_ARG1(call); 165 if ((IPC_GET_ METHOD(call) != IPC_M_CONNECTION_CLONE) ||159 if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECTION_CLONE) || 166 160 (mountee_phone < 0)) { 167 ipc_answer_0(callid, EINVAL);168 ipc_answer_0(rid, EINVAL);161 async_answer_0(callid, EINVAL); 162 async_answer_0(rid, EINVAL); 169 163 return; 170 164 } 171 165 172 166 /* Acknowledge the mountee_phone */ 173 ipc_answer_0(callid, EOK);167 async_answer_0(callid, EOK); 174 168 175 169 fs_node_t *fn; 176 res = ops->node_get(&fn, mp_dev _handle, mp_fs_index);170 res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index); 177 171 if ((res != EOK) || (!fn)) { 178 ipc_hangup(mountee_phone);172 async_hangup(mountee_phone); 179 173 async_data_write_void(combine_rc(res, ENOENT)); 180 ipc_answer_0(rid, combine_rc(res, ENOENT));174 async_answer_0(rid, combine_rc(res, ENOENT)); 181 175 return; 182 176 } 183 177 184 178 if (fn->mp_data.mp_active) { 185 ipc_hangup(mountee_phone);179 async_hangup(mountee_phone); 186 180 (void) ops->node_put(fn); 187 181 async_data_write_void(EBUSY); 188 ipc_answer_0(rid, EBUSY);182 async_answer_0(rid, EBUSY); 189 183 return; 190 184 } … … 192 186 rc = async_req_0_0(mountee_phone, IPC_M_CONNECT_ME); 193 187 if (rc != EOK) { 194 ipc_hangup(mountee_phone);188 async_hangup(mountee_phone); 195 189 (void) ops->node_put(fn); 196 190 async_data_write_void(rc); 197 ipc_answer_0(rid, rc);191 async_answer_0(rid, rc); 198 192 return; 199 193 } … … 201 195 ipc_call_t answer; 202 196 rc = async_data_write_forward_1_1(mountee_phone, VFS_OUT_MOUNTED, 203 mr_dev _handle, &answer);197 mr_devmap_handle, &answer); 204 198 205 199 if (rc == EOK) { 206 200 fn->mp_data.mp_active = true; 207 201 fn->mp_data.fs_handle = mr_fs_handle; 208 fn->mp_data.dev _handle = mr_dev_handle;202 fn->mp_data.devmap_handle = mr_devmap_handle; 209 203 fn->mp_data.phone = mountee_phone; 210 204 } … … 213 207 * Do not release the FS node so that it stays in memory. 214 208 */ 215 ipc_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer),209 async_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer), 216 210 IPC_GET_ARG3(answer)); 217 211 } … … 219 213 void libfs_unmount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *request) 220 214 { 221 dev _handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);215 devmap_handle_t mp_devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 222 216 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request); 223 217 fs_node_t *fn; 224 218 int res; 225 219 226 res = ops->node_get(&fn, mp_dev _handle, mp_fs_index);220 res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index); 227 221 if ((res != EOK) || (!fn)) { 228 ipc_answer_0(rid, combine_rc(res, ENOENT));222 async_answer_0(rid, combine_rc(res, ENOENT)); 229 223 return; 230 224 } … … 235 229 if (!fn->mp_data.mp_active) { 236 230 (void) ops->node_put(fn); 237 ipc_answer_0(rid, EINVAL);231 async_answer_0(rid, EINVAL); 238 232 return; 239 233 } … … 243 237 */ 244 238 res = async_req_1_0(fn->mp_data.phone, VFS_OUT_UNMOUNTED, 245 fn->mp_data.dev _handle);239 fn->mp_data.devmap_handle); 246 240 247 241 /* … … 249 243 */ 250 244 if (res == EOK) { 251 ipc_hangup(fn->mp_data.phone);245 async_hangup(fn->mp_data.phone); 252 246 fn->mp_data.mp_active = false; 253 247 fn->mp_data.fs_handle = 0; 254 fn->mp_data.dev _handle = 0;248 fn->mp_data.devmap_handle = 0; 255 249 fn->mp_data.phone = 0; 256 250 /* Drop the reference created in libfs_mount(). */ … … 259 253 260 254 (void) ops->node_put(fn); 261 ipc_answer_0(rid, res);255 async_answer_0(rid, res); 262 256 } 263 257 … … 281 275 unsigned int last = IPC_GET_ARG2(*request); 282 276 unsigned int next = first; 283 dev _handle_t dev_handle = IPC_GET_ARG3(*request);277 devmap_handle_t devmap_handle = IPC_GET_ARG3(*request); 284 278 int lflag = IPC_GET_ARG4(*request); 285 279 fs_index_t index = IPC_GET_ARG5(*request); … … 295 289 fs_node_t *tmp = NULL; 296 290 297 rc = ops->root_get(&cur, dev _handle);291 rc = ops->root_get(&cur, devmap_handle); 298 292 on_error(rc, goto out_with_answer); 299 293 300 294 if (cur->mp_data.mp_active) { 301 ipc_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP,302 next, last, cur->mp_data.dev _handle, lflag, index,295 async_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP, 296 next, last, cur->mp_data.devmap_handle, lflag, index, 303 297 IPC_FF_ROUTE_FROM_ME); 304 298 (void) ops->node_put(cur); … … 323 317 if (len + 1 == NAME_MAX) { 324 318 /* Component length overflow */ 325 ipc_answer_0(rid, ENAMETOOLONG);319 async_answer_0(rid, ENAMETOOLONG); 326 320 goto out; 327 321 } … … 357 351 next--; 358 352 359 ipc_forward_slow(rid, tmp->mp_data.phone,360 VFS_OUT_LOOKUP, next, last, tmp->mp_data.dev _handle,353 async_forward_slow(rid, tmp->mp_data.phone, 354 VFS_OUT_LOOKUP, next, last, tmp->mp_data.devmap_handle, 361 355 lflag, index, IPC_FF_ROUTE_FROM_ME); 362 356 (void) ops->node_put(cur); … … 371 365 if (next <= last) { 372 366 /* There are unprocessed components */ 373 ipc_answer_0(rid, ENOENT);367 async_answer_0(rid, ENOENT); 374 368 goto out; 375 369 } … … 379 373 /* Request to create a new link */ 380 374 if (!ops->is_directory(cur)) { 381 ipc_answer_0(rid, ENOTDIR);375 async_answer_0(rid, ENOTDIR); 382 376 goto out; 383 377 } … … 385 379 fs_node_t *fn; 386 380 if (lflag & L_CREATE) 387 rc = ops->create(&fn, dev _handle,381 rc = ops->create(&fn, devmap_handle, 388 382 lflag); 389 383 else 390 rc = ops->node_get(&fn, dev _handle,384 rc = ops->node_get(&fn, devmap_handle, 391 385 index); 392 386 on_error(rc, goto out_with_answer); … … 397 391 if (lflag & L_CREATE) 398 392 (void) ops->destroy(fn); 399 ipc_answer_0(rid, rc); 393 else 394 (void) ops->node_put(fn); 395 async_answer_0(rid, rc); 400 396 } else { 401 397 aoff64_t size = ops->size_get(fn); 402 ipc_answer_5(rid, fs_handle,403 dev _handle,398 async_answer_5(rid, fs_handle, 399 devmap_handle, 404 400 ops->index_get(fn), 405 401 LOWER32(size), … … 409 405 } 410 406 } else 411 ipc_answer_0(rid, ENOSPC);407 async_answer_0(rid, ENOSPC); 412 408 413 409 goto out; 414 410 } 415 411 416 ipc_answer_0(rid, ENOENT);412 async_answer_0(rid, ENOENT); 417 413 goto out; 418 414 } … … 440 436 if (lflag & (L_CREATE | L_LINK)) { 441 437 if (!ops->is_directory(cur)) { 442 ipc_answer_0(rid, ENOTDIR);438 async_answer_0(rid, ENOTDIR); 443 439 goto out; 444 440 } … … 449 445 if (ops->plb_get_char(next) == '/') { 450 446 /* More than one component */ 451 ipc_answer_0(rid, ENOENT);447 async_answer_0(rid, ENOENT); 452 448 goto out; 453 449 } … … 455 451 if (len + 1 == NAME_MAX) { 456 452 /* Component length overflow */ 457 ipc_answer_0(rid, ENAMETOOLONG);453 async_answer_0(rid, ENAMETOOLONG); 458 454 goto out; 459 455 } … … 469 465 fs_node_t *fn; 470 466 if (lflag & L_CREATE) 471 rc = ops->create(&fn, dev _handle, lflag);467 rc = ops->create(&fn, devmap_handle, lflag); 472 468 else 473 rc = ops->node_get(&fn, dev _handle, index);469 rc = ops->node_get(&fn, devmap_handle, index); 474 470 on_error(rc, goto out_with_answer); 475 471 … … 479 475 if (lflag & L_CREATE) 480 476 (void) ops->destroy(fn); 481 ipc_answer_0(rid, rc); 477 else 478 (void) ops->node_put(fn); 479 async_answer_0(rid, rc); 482 480 } else { 483 481 aoff64_t size = ops->size_get(fn); 484 ipc_answer_5(rid, fs_handle,485 dev _handle,482 async_answer_5(rid, fs_handle, 483 devmap_handle, 486 484 ops->index_get(fn), 487 485 LOWER32(size), … … 491 489 } 492 490 } else 493 ipc_answer_0(rid, ENOSPC);491 async_answer_0(rid, ENOSPC); 494 492 495 493 goto out; 496 494 } 497 495 498 ipc_answer_0(rid, ENOENT);496 async_answer_0(rid, ENOENT); 499 497 goto out; 500 498 } … … 509 507 if (rc == EOK) { 510 508 aoff64_t size = ops->size_get(cur); 511 ipc_answer_5(rid, fs_handle, dev_handle,509 async_answer_5(rid, fs_handle, devmap_handle, 512 510 ops->index_get(cur), LOWER32(size), UPPER32(size), 513 511 old_lnkcnt); 514 512 } else 515 ipc_answer_0(rid, rc);513 async_answer_0(rid, rc); 516 514 517 515 goto out; … … 520 518 if (((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) || 521 519 (lflag & L_LINK)) { 522 ipc_answer_0(rid, EEXIST);520 async_answer_0(rid, EEXIST); 523 521 goto out; 524 522 } 525 523 526 524 if ((lflag & L_FILE) && (ops->is_directory(cur))) { 527 ipc_answer_0(rid, EISDIR);525 async_answer_0(rid, EISDIR); 528 526 goto out; 529 527 } 530 528 531 529 if ((lflag & L_DIRECTORY) && (ops->is_file(cur))) { 532 ipc_answer_0(rid, ENOTDIR);530 async_answer_0(rid, ENOTDIR); 533 531 goto out; 534 532 } 535 533 536 534 if ((lflag & L_ROOT) && par) { 537 ipc_answer_0(rid, EINVAL);535 async_answer_0(rid, EINVAL); 538 536 goto out; 539 537 } … … 547 545 if (rc == EOK) { 548 546 aoff64_t size = ops->size_get(cur); 549 ipc_answer_5(rid, fs_handle, dev_handle,547 async_answer_5(rid, fs_handle, devmap_handle, 550 548 ops->index_get(cur), LOWER32(size), UPPER32(size), 551 549 ops->lnkcnt_get(cur)); 552 550 } else 553 ipc_answer_0(rid, rc);551 async_answer_0(rid, rc); 554 552 555 553 } else 556 ipc_answer_0(rid, rc);554 async_answer_0(rid, rc); 557 555 558 556 out: … … 571 569 ipc_call_t *request) 572 570 { 573 dev _handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);571 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 574 572 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 575 573 576 574 fs_node_t *fn; 577 int rc = ops->node_get(&fn, dev _handle, index);575 int rc = ops->node_get(&fn, devmap_handle, index); 578 576 on_error(rc, answer_and_return(rid, rc)); 579 577 … … 583 581 (size != sizeof(struct stat))) { 584 582 ops->node_put(fn); 585 ipc_answer_0(callid, EINVAL);586 ipc_answer_0(rid, EINVAL);583 async_answer_0(callid, EINVAL); 584 async_answer_0(rid, EINVAL); 587 585 return; 588 586 } … … 592 590 593 591 stat.fs_handle = fs_handle; 594 stat.dev _handle = dev_handle;592 stat.devmap_handle = devmap_handle; 595 593 stat.index = index; 596 594 stat.lnkcnt = ops->lnkcnt_get(fn); … … 603 601 604 602 async_data_read_finalize(callid, &stat, sizeof(struct stat)); 605 ipc_answer_0(rid, EOK);603 async_answer_0(rid, EOK); 606 604 } 607 605 … … 617 615 ipc_call_t *request) 618 616 { 619 dev _handle_t dev_handle = IPC_GET_ARG1(*request);617 devmap_handle_t devmap_handle = IPC_GET_ARG1(*request); 620 618 fs_index_t index = IPC_GET_ARG2(*request); 621 619 622 620 fs_node_t *fn; 623 int rc = ops->node_get(&fn, dev _handle, index);621 int rc = ops->node_get(&fn, devmap_handle, index); 624 622 on_error(rc, answer_and_return(rid, rc)); 625 623 626 624 if (fn == NULL) { 627 ipc_answer_0(rid, ENOENT);625 async_answer_0(rid, ENOENT); 628 626 return; 629 627 } … … 631 629 rc = ops->node_open(fn); 632 630 aoff64_t size = ops->size_get(fn); 633 ipc_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),631 async_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn), 634 632 (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0)); 635 633
Note:
See TracChangeset
for help on using the changeset viewer.