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