Rev 4437 | Rev 4445 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4437 | Rev 4443 | ||
---|---|---|---|
Line 484... | Line 484... | ||
484 | free(opts); |
484 | free(opts); |
485 | } |
485 | } |
486 | 486 | ||
487 | void vfs_open(ipc_callid_t rid, ipc_call_t *request) |
487 | void vfs_open(ipc_callid_t rid, ipc_call_t *request) |
488 | { |
488 | { |
- | 489 | async_serialize_start(); |
|
- | 490 | ||
489 | if (!vfs_files_init()) { |
491 | if (!vfs_files_init()) { |
490 | ipc_answer_0(rid, ENOMEM); |
492 | ipc_answer_0(rid, ENOMEM); |
- | 493 | async_serialize_end(); |
|
491 | return; |
494 | return; |
492 | } |
495 | } |
493 | 496 | ||
494 | /* |
497 | /* |
495 | * The POSIX interface is open(path, oflag, mode). |
498 | * The POSIX interface is open(path, oflag, mode). |
Line 509... | Line 512... | ||
509 | * L_DIRECTORY. |
512 | * L_DIRECTORY. |
510 | */ |
513 | */ |
511 | if ((lflag & (L_FILE | L_DIRECTORY)) == 0 || |
514 | if ((lflag & (L_FILE | L_DIRECTORY)) == 0 || |
512 | (lflag & (L_FILE | L_DIRECTORY)) == (L_FILE | L_DIRECTORY)) { |
515 | (lflag & (L_FILE | L_DIRECTORY)) == (L_FILE | L_DIRECTORY)) { |
513 | ipc_answer_0(rid, EINVAL); |
516 | ipc_answer_0(rid, EINVAL); |
- | 517 | async_serialize_end(); |
|
514 | return; |
518 | return; |
515 | } |
519 | } |
516 | 520 | ||
517 | if (oflag & O_CREAT) |
521 | if (oflag & O_CREAT) |
518 | lflag |= L_CREATE; |
522 | lflag |= L_CREATE; |
Line 522... | Line 526... | ||
522 | ipc_callid_t callid; |
526 | ipc_callid_t callid; |
523 | 527 | ||
524 | if (!ipc_data_write_receive(&callid, &len)) { |
528 | if (!ipc_data_write_receive(&callid, &len)) { |
525 | ipc_answer_0(callid, EINVAL); |
529 | ipc_answer_0(callid, EINVAL); |
526 | ipc_answer_0(rid, EINVAL); |
530 | ipc_answer_0(rid, EINVAL); |
- | 531 | async_serialize_end(); |
|
527 | return; |
532 | return; |
528 | } |
533 | } |
529 | char *path = malloc(len + 1); |
534 | char *path = malloc(len + 1); |
530 | if (!path) { |
535 | if (!path) { |
531 | ipc_answer_0(callid, ENOMEM); |
536 | ipc_answer_0(callid, ENOMEM); |
532 | ipc_answer_0(rid, ENOMEM); |
537 | ipc_answer_0(rid, ENOMEM); |
- | 538 | async_serialize_end(); |
|
533 | return; |
539 | return; |
534 | } |
540 | } |
535 | int rc; |
541 | int rc; |
536 | if ((rc = ipc_data_write_finalize(callid, path, len))) { |
542 | if ((rc = ipc_data_write_finalize(callid, path, len))) { |
537 | ipc_answer_0(rid, rc); |
543 | ipc_answer_0(rid, rc); |
538 | free(path); |
544 | free(path); |
- | 545 | async_serialize_end(); |
|
539 | return; |
546 | return; |
540 | } |
547 | } |
541 | path[len] = '\0'; |
548 | path[len] = '\0'; |
542 | 549 | ||
543 | /* |
550 | /* |
Line 558... | Line 565... | ||
558 | rwlock_write_unlock(&namespace_rwlock); |
565 | rwlock_write_unlock(&namespace_rwlock); |
559 | else |
566 | else |
560 | rwlock_read_unlock(&namespace_rwlock); |
567 | rwlock_read_unlock(&namespace_rwlock); |
561 | ipc_answer_0(rid, rc); |
568 | ipc_answer_0(rid, rc); |
562 | free(path); |
569 | free(path); |
- | 570 | async_serialize_end(); |
|
563 | return; |
571 | return; |
564 | } |
572 | } |
565 | 573 | ||
566 | /* Path is no longer needed. */ |
574 | /* Path is no longer needed. */ |
567 | free(path); |
575 | free(path); |
Line 580... | Line 588... | ||
580 | node->dev_handle, node->index, 0); |
588 | node->dev_handle, node->index, 0); |
581 | if (rc) { |
589 | if (rc) { |
582 | rwlock_write_unlock(&node->contents_rwlock); |
590 | rwlock_write_unlock(&node->contents_rwlock); |
583 | vfs_node_put(node); |
591 | vfs_node_put(node); |
584 | ipc_answer_0(rid, rc); |
592 | ipc_answer_0(rid, rc); |
- | 593 | async_serialize_end(); |
|
585 | return; |
594 | return; |
586 | } |
595 | } |
587 | node->size = 0; |
596 | node->size = 0; |
588 | } |
597 | } |
589 | rwlock_write_unlock(&node->contents_rwlock); |
598 | rwlock_write_unlock(&node->contents_rwlock); |
Line 595... | Line 604... | ||
595 | */ |
604 | */ |
596 | int fd = vfs_fd_alloc(); |
605 | int fd = vfs_fd_alloc(); |
597 | if (fd < 0) { |
606 | if (fd < 0) { |
598 | vfs_node_put(node); |
607 | vfs_node_put(node); |
599 | ipc_answer_0(rid, fd); |
608 | ipc_answer_0(rid, fd); |
- | 609 | async_serialize_end(); |
|
600 | return; |
610 | return; |
601 | } |
611 | } |
602 | vfs_file_t *file = vfs_file_get(fd); |
612 | vfs_file_t *file = vfs_file_get(fd); |
603 | file->node = node; |
613 | file->node = node; |
604 | if (oflag & O_APPEND) |
614 | if (oflag & O_APPEND) |
Line 614... | Line 624... | ||
614 | vfs_node_addref(node); |
624 | vfs_node_addref(node); |
615 | vfs_node_put(node); |
625 | vfs_node_put(node); |
616 | 626 | ||
617 | /* Success! Return the new file descriptor to the client. */ |
627 | /* Success! Return the new file descriptor to the client. */ |
618 | ipc_answer_1(rid, EOK, fd); |
628 | ipc_answer_1(rid, EOK, fd); |
- | 629 | async_serialize_end(); |
|
619 | } |
630 | } |
620 | 631 | ||
621 | void vfs_close(ipc_callid_t rid, ipc_call_t *request) |
632 | void vfs_close(ipc_callid_t rid, ipc_call_t *request) |
622 | { |
633 | { |
623 | int fd = IPC_GET_ARG1(*request); |
634 | int fd = IPC_GET_ARG1(*request); |