Changeset 36cb22f in mainline for uspace/srv/fs/mfs/mfs_ops.c
- Timestamp:
- 2011-09-27T13:01:54Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5726a1a3, 747a1e71
- Parents:
- 1db44ea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/mfs/mfs_ops.c
r1db44ea r36cb22f 889 889 struct mfs_ino_info *ino_i = mnode->ino_i; 890 890 const size_t bs = sbi->block_size; 891 size_t bytes = min(len, bs - pos % bs); 892 size_t boundary = ROUND_UP(ino_i->i_size, bs); 891 size_t bytes = min(len, bs - (pos % bs)); 893 892 uint32_t block; 894 893 … … 896 895 flags = BLOCK_FLAGS_NOREAD; 897 896 898 if (pos < boundary) { 899 r = mfs_read_map(&block, mnode, pos); 900 if (r != EOK) 901 goto out_err; 902 903 if (block == 0) { 904 /*Writing in a sparse block*/ 905 r = mfs_alloc_zone(mnode->instance, &block); 906 if (r != EOK) 907 goto out_err; 908 flags = BLOCK_FLAGS_NOREAD; 909 } 910 } else { 897 r = mfs_read_map(&block, mnode, pos); 898 if (r != EOK) 899 goto out_err; 900 901 if (block == 0) { 902 /*Writing in a sparse block*/ 911 903 uint32_t dummy; 912 904 … … 914 906 if (r != EOK) 915 907 goto out_err; 916 908 917 909 r = mfs_write_map(mnode, pos, block, &dummy); 918 910 if (r != EOK) 919 911 goto out_err; 912 913 flags = BLOCK_FLAGS_NOREAD; 920 914 } 921 915 … … 925 919 goto out_err; 926 920 927 async_data_write_finalize(callid, b->data + pos % bs, bytes); 921 if (flags == BLOCK_FLAGS_NOREAD) 922 memset(b->data, 0, sbi->block_size); 923 924 async_data_write_finalize(callid, b->data + (pos % bs), bytes); 928 925 b->dirty = true; 929 926 … … 934 931 } 935 932 936 ino_i->i_size = pos + bytes; 937 ino_i->dirty = true; 933 if (pos + bytes > ino_i->i_size) { 934 ino_i->i_size = pos + bytes; 935 ino_i->dirty = true; 936 } 938 937 r = mfs_node_put(fn); 939 *nsize = pos + bytes;938 *nsize = ino_i->i_size; 940 939 *wbytes = bytes; 941 940 return r;
Note:
See TracChangeset
for help on using the changeset viewer.