Rev 3547 | Rev 3550 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3547 | Rev 3548 | ||
---|---|---|---|
Line 687... | Line 687... | ||
687 | * This is the more difficult case. We must allocate new |
687 | * This is the more difficult case. We must allocate new |
688 | * clusters for the node and zero them out. |
688 | * clusters for the node and zero them out. |
689 | */ |
689 | */ |
690 | int status; |
690 | int status; |
691 | unsigned nclsts; |
691 | unsigned nclsts; |
692 | fat_cluster_t mcl, lcl; |
692 | fat_cluster_t mcl, lcl; |
693 | 693 | ||
694 | nclsts = (ROUND_UP(pos + bytes, bps * spc) - boundary) / |
694 | nclsts = (ROUND_UP(pos + bytes, bps * spc) - boundary) / |
695 | bps * spc; |
695 | bps * spc; |
696 | /* create an independent chain of nclsts clusters in all FATs */ |
696 | /* create an independent chain of nclsts clusters in all FATs */ |
697 | status = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, |
697 | status = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, |
698 | &lcl); |
698 | &lcl); |
Line 703... | Line 703... | ||
703 | ipc_answer_0(rid, status); |
703 | ipc_answer_0(rid, status); |
704 | return; |
704 | return; |
705 | } |
705 | } |
706 | /* zero fill any gaps */ |
706 | /* zero fill any gaps */ |
707 | fat_fill_gap(bs, nodep, mcl, pos); |
707 | fat_fill_gap(bs, nodep, mcl, pos); |
708 | b = _fat_block_get(bs, dev_handle, lcl, |
708 | b = _fat_block_get(bs, dev_handle, lcl, (pos / bps) % spc); |
709 | (pos / bps) % spc); |
- | |
710 | (void) ipc_data_write_finalize(callid, b->data + pos % bps, |
709 | (void) ipc_data_write_finalize(callid, b->data + pos % bps, |
711 | bytes); |
710 | bytes); |
712 | b->dirty = true; /* need to sync block */ |
711 | b->dirty = true; /* need to sync block */ |
713 | block_put(b); |
712 | block_put(b); |
714 | /* |
713 | /* |
Line 724... | Line 723... | ||
724 | } |
723 | } |
725 | } |
724 | } |
726 | 725 | ||
727 | void fat_truncate(ipc_callid_t rid, ipc_call_t *request) |
726 | void fat_truncate(ipc_callid_t rid, ipc_call_t *request) |
728 | { |
727 | { |
- | 728 | dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); |
|
- | 729 | fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); |
|
- | 730 | size_t size = (off_t)IPC_GET_ARG3(*request); |
|
- | 731 | fat_node_t *nodep = (fat_node_t *)fat_node_get(dev_handle, index); |
|
- | 732 | int rc; |
|
- | 733 | ||
- | 734 | if (!nodep) { |
|
729 | ipc_answer_0(rid, ENOTSUP); |
735 | ipc_answer_0(rid, ENOENT); |
- | 736 | return; |
|
- | 737 | } |
|
- | 738 | ||
- | 739 | if (nodep->size == size) { |
|
- | 740 | rc = EOK; |
|
- | 741 | } else if (nodep->size < size) { |
|
- | 742 | /* |
|
- | 743 | * TODO: the standard says we have the freedom to grow the file. |
|
- | 744 | * For now, we simply return an error. |
|
- | 745 | */ |
|
- | 746 | rc = EINVAL; |
|
- | 747 | } else { |
|
- | 748 | /* |
|
- | 749 | * The file is to be shrunk. |
|
- | 750 | */ |
|
- | 751 | rc = ENOTSUP; /* XXX */ |
|
- | 752 | } |
|
- | 753 | fat_node_put(nodep); |
|
- | 754 | ipc_answer_0(rid, rc); |
|
- | 755 | return; |
|
- | 756 | ||
730 | } |
757 | } |
731 | 758 | ||
732 | /** |
759 | /** |
733 | * @} |
760 | * @} |
734 | */ |
761 | */ |