Changes in uspace/lib/fs/libfs.c [991f645:ffa2c8ef] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/fs/libfs.c
r991f645 rffa2c8ef 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 /* … … 127 126 async_wait_for(req, NULL); 128 127 reg->fs_handle = (int) IPC_GET_ARG1(answer); 129 130 /*131 * Create a connection fibril to handle the callback connection.132 */133 async_new_connection(reg->vfs_phonehash, 0, NULL, conn);134 128 135 129 /* … … 155 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 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 } … … 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 } … … 226 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 } … … 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; … … 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 … … 299 293 300 294 if (cur->mp_data.mp_active) { 301 ipc_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP,295 async_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP, 302 296 next, last, cur->mp_data.devmap_handle, lflag, index, 303 297 IPC_FF_ROUTE_FROM_ME); … … 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,353 async_forward_slow(rid, tmp->mp_data.phone, 360 354 VFS_OUT_LOOKUP, next, last, tmp->mp_data.devmap_handle, 361 355 lflag, index, IPC_FF_ROUTE_FROM_ME); … … 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 } … … 397 391 if (lflag & L_CREATE) 398 392 (void) ops->destroy(fn); 399 ipc_answer_0(rid, rc);393 async_answer_0(rid, rc); 400 394 } else { 401 395 aoff64_t size = ops->size_get(fn); 402 ipc_answer_5(rid, fs_handle,396 async_answer_5(rid, fs_handle, 403 397 devmap_handle, 404 398 ops->index_get(fn), … … 409 403 } 410 404 } else 411 ipc_answer_0(rid, ENOSPC);405 async_answer_0(rid, ENOSPC); 412 406 413 407 goto out; 414 408 } 415 409 416 ipc_answer_0(rid, ENOENT);410 async_answer_0(rid, ENOENT); 417 411 goto out; 418 412 } … … 440 434 if (lflag & (L_CREATE | L_LINK)) { 441 435 if (!ops->is_directory(cur)) { 442 ipc_answer_0(rid, ENOTDIR);436 async_answer_0(rid, ENOTDIR); 443 437 goto out; 444 438 } … … 449 443 if (ops->plb_get_char(next) == '/') { 450 444 /* More than one component */ 451 ipc_answer_0(rid, ENOENT);445 async_answer_0(rid, ENOENT); 452 446 goto out; 453 447 } … … 455 449 if (len + 1 == NAME_MAX) { 456 450 /* Component length overflow */ 457 ipc_answer_0(rid, ENAMETOOLONG);451 async_answer_0(rid, ENAMETOOLONG); 458 452 goto out; 459 453 } … … 479 473 if (lflag & L_CREATE) 480 474 (void) ops->destroy(fn); 481 ipc_answer_0(rid, rc);475 async_answer_0(rid, rc); 482 476 } else { 483 477 aoff64_t size = ops->size_get(fn); 484 ipc_answer_5(rid, fs_handle,478 async_answer_5(rid, fs_handle, 485 479 devmap_handle, 486 480 ops->index_get(fn), … … 491 485 } 492 486 } else 493 ipc_answer_0(rid, ENOSPC);487 async_answer_0(rid, ENOSPC); 494 488 495 489 goto out; 496 490 } 497 491 498 ipc_answer_0(rid, ENOENT);492 async_answer_0(rid, ENOENT); 499 493 goto out; 500 494 } … … 509 503 if (rc == EOK) { 510 504 aoff64_t size = ops->size_get(cur); 511 ipc_answer_5(rid, fs_handle, devmap_handle,505 async_answer_5(rid, fs_handle, devmap_handle, 512 506 ops->index_get(cur), LOWER32(size), UPPER32(size), 513 507 old_lnkcnt); 514 508 } else 515 ipc_answer_0(rid, rc);509 async_answer_0(rid, rc); 516 510 517 511 goto out; … … 520 514 if (((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) || 521 515 (lflag & L_LINK)) { 522 ipc_answer_0(rid, EEXIST);516 async_answer_0(rid, EEXIST); 523 517 goto out; 524 518 } 525 519 526 520 if ((lflag & L_FILE) && (ops->is_directory(cur))) { 527 ipc_answer_0(rid, EISDIR);521 async_answer_0(rid, EISDIR); 528 522 goto out; 529 523 } 530 524 531 525 if ((lflag & L_DIRECTORY) && (ops->is_file(cur))) { 532 ipc_answer_0(rid, ENOTDIR);526 async_answer_0(rid, ENOTDIR); 533 527 goto out; 534 528 } 535 529 536 530 if ((lflag & L_ROOT) && par) { 537 ipc_answer_0(rid, EINVAL);531 async_answer_0(rid, EINVAL); 538 532 goto out; 539 533 } … … 547 541 if (rc == EOK) { 548 542 aoff64_t size = ops->size_get(cur); 549 ipc_answer_5(rid, fs_handle, devmap_handle,543 async_answer_5(rid, fs_handle, devmap_handle, 550 544 ops->index_get(cur), LOWER32(size), UPPER32(size), 551 545 ops->lnkcnt_get(cur)); 552 546 } else 553 ipc_answer_0(rid, rc);547 async_answer_0(rid, rc); 554 548 555 549 } else 556 ipc_answer_0(rid, rc);550 async_answer_0(rid, rc); 557 551 558 552 out: … … 583 577 (size != sizeof(struct stat))) { 584 578 ops->node_put(fn); 585 ipc_answer_0(callid, EINVAL);586 ipc_answer_0(rid, EINVAL);579 async_answer_0(callid, EINVAL); 580 async_answer_0(rid, EINVAL); 587 581 return; 588 582 } … … 603 597 604 598 async_data_read_finalize(callid, &stat, sizeof(struct stat)); 605 ipc_answer_0(rid, EOK);599 async_answer_0(rid, EOK); 606 600 } 607 601 … … 625 619 626 620 if (fn == NULL) { 627 ipc_answer_0(rid, ENOENT);621 async_answer_0(rid, ENOENT); 628 622 return; 629 623 } … … 631 625 rc = ops->node_open(fn); 632 626 aoff64_t size = ops->size_get(fn); 633 ipc_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),627 async_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn), 634 628 (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0)); 635 629
Note:
See TracChangeset
for help on using the changeset viewer.