Changeset b4b7187 in mainline
- Timestamp:
- 2008-10-25T19:38:38Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8b0bc1f
- Parents:
- 6f2dfd1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
r6f2dfd1 rb4b7187 850 850 } 851 851 852 /** Fill the gap between EOF and a new file position. 853 * 854 * @param nodep FAT node with the gap. 855 * @param mcl First cluster in an independent cluster chain that will 856 * be later appended to the end of the node's own cluster 857 * chain. If pos is still in the last allocated cluster, 858 * this argument is ignored. 859 * @param pos Position in the last node block. 860 */ 852 861 static void 853 fat_fill_gap(fat_node_t *nodep, fat_cluster_t mclst, off_t pos) 854 { 855 /* TODO */ 862 fat_fill_gap(fat_node_t *nodep, fat_cluster_t mcl, off_t pos) 863 { 864 uint16_t bps; 865 unsigned spc; 866 block_t *bb, *b; 867 off_t o, boundary; 868 869 bb = block_get(nodep->idx->dev_handle, BS_BLOCK, BS_SIZE); 870 bps = uint16_t_le2host(FAT_BS(bb)->bps); 871 spc = FAT_BS(bb)->spc; 872 block_put(bb); 873 874 boundary = ROUND_UP(nodep->size, bps * spc); 875 876 /* zero out already allocated space */ 877 for (o = nodep->size - 1; o < pos && o < boundary; 878 o = ALIGN_DOWN(o + bps, bps)) { 879 b = fat_block_get(nodep, o / bps); 880 memset(b->data + o % bps, 0, bps - o % bps); 881 b->dirty = true; /* need to sync node */ 882 block_put(b); 883 } 884 885 if (o >= pos) 886 return; 887 888 /* zero out the initial part of the new cluster chain */ 889 for (o = boundary; o < pos; o += bps) { 890 b = _fat_block_get(nodep->idx->dev_handle, mcl, 891 (o - boundary) / bps); 892 memset(b->data, 0, min(bps, pos - o)); 893 b->dirty = true; 894 block_put(b); 895 } 856 896 } 857 897 … … 877 917 uint16_t bps; 878 918 unsigned spc; 879 off_t clst_boundary;919 off_t boundary; 880 920 881 921 if (!nodep) { … … 914 954 block_put(bb); 915 955 916 clst_boundary = ROUND_UP(nodep->size, bps * spc);917 if (pos < clst_boundary) {956 boundary = ROUND_UP(nodep->size, bps * spc); 957 if (pos < boundary) { 918 958 /* 919 959 * This is the easier case - we are either overwriting already … … 944 984 fat_cluster_t mcl, lcl; 945 985 946 nclsts = (ROUND_UP(pos + bytes, bps * spc) - clst_boundary) /986 nclsts = (ROUND_UP(pos + bytes, bps * spc) - boundary) / 947 987 bps * spc; 948 988 /* create an independent chain of nclsts clusters in all FATs */ … … 960 1000 (void) ipc_data_write_finalize(callid, b->data + pos % bps, 961 1001 bytes); 962 b->dirty = true; 1002 b->dirty = true; /* need to sync block */ 963 1003 block_put(b); 964 1004 /* … … 968 1008 fat_append_clusters(nodep, mcl); 969 1009 nodep->size = pos + bytes; 970 nodep->dirty = true; 1010 nodep->dirty = true; /* need to sync node */ 971 1011 fat_node_put(nodep); 972 1012 ipc_answer_1(rid, EOK, bytes);
Note:
See TracChangeset
for help on using the changeset viewer.