Changes in uspace/srv/fs/mfs/mfs_rw.c [36cb22f:6d4d883] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/mfs/mfs_rw.c
r36cb22f r6d4d883 36 36 static int 37 37 rw_map_ondisk(uint32_t *b, const struct mfs_node *mnode, int rblock, 38 38 bool write_mode, uint32_t w_block); 39 39 40 40 static int … … 68 68 const int block_size = sbi->block_size; 69 69 70 /* Compute relative block number in file*/70 /* Compute relative block number in file */ 71 71 int rblock = pos / block_size; 72 72 73 73 if (ROUND_UP(mnode->ino_i->i_size, sbi->block_size) < pos) { 74 /* Trying to read beyond the end of file*/74 /* Trying to read beyond the end of file */ 75 75 r = EOK; 76 76 *b = 0; … … 85 85 int 86 86 mfs_write_map(struct mfs_node *mnode, const uint32_t pos, uint32_t new_zone, 87 87 uint32_t *old_zone) 88 88 { 89 89 const struct mfs_sb_info *sbi = mnode->instance->sbi; 90 90 91 91 if (pos >= sbi->max_file_size) { 92 /* Can't write beyond the maximum file size*/92 /* Can't write beyond the maximum file size */ 93 93 return EINVAL; 94 94 } 95 95 96 /* Compute the relative block number in file*/96 /* Compute the relative block number in file */ 97 97 int rblock = pos / sbi->block_size; 98 98 … … 102 102 static int 103 103 rw_map_ondisk(uint32_t *b, const struct mfs_node *mnode, int rblock, 104 104 bool write_mode, uint32_t w_block) 105 105 { 106 106 int r, nr_direct; … … 123 123 } 124 124 125 /* Check if the wanted block is in the direct zones*/125 /* Check if the wanted block is in the direct zones */ 126 126 if (rblock < nr_direct) { 127 127 *b = ino_i->i_dzone[rblock]; … … 136 136 137 137 if (rblock < ptrs_per_block) { 138 /* The wanted block is in the single indirect zone chain*/138 /* The wanted block is in the single indirect zone chain */ 139 139 if (ino_i->i_izone[0] == 0) { 140 140 if (write_mode && !deleting) { … … 168 168 rblock -= ptrs_per_block; 169 169 170 /* The wanted block is in the double indirect zone chain*/171 172 /* read the first indirect zone of the chain*/170 /* The wanted block is in the double indirect zone chain */ 171 172 /* Read the first indirect zone of the chain */ 173 173 if (ino_i->i_izone[1] == 0) { 174 174 if (write_mode && !deleting) { … … 181 181 ino_i->dirty = true; 182 182 } else { 183 /* Sparse block*/183 /* Sparse block */ 184 184 *b = 0; 185 185 return EOK; … … 192 192 193 193 /* 194 * Compute the position of the second indirect195 * zone pointer in the chain.194 * Compute the position of the second indirect 195 * zone pointer in the chain. 196 196 */ 197 197 uint32_t ind2_off = rblock / ptrs_per_block; 198 198 199 /* read the second indirect zone of the chain*/199 /* read the second indirect zone of the chain */ 200 200 if (ind_zone[ind2_off] == 0) { 201 201 if (write_mode && !deleting) { … … 208 208 write_ind_zone(inst, ino_i->i_izone[1], ind_zone); 209 209 } else { 210 /* Sparse block*/210 /* Sparse block */ 211 211 r = EOK; 212 212 *b = 0; … … 264 264 265 265 if (rblock < nr_direct) { 266 /* free the single indirect zone*/266 /* Free the single indirect zone */ 267 267 if (ino_i->i_izone[0]) { 268 268 r = mfs_free_zone(inst, ino_i->i_izone[0]); … … 282 282 ++fzone_to_free; 283 283 284 /* free the entire double indirect zone*/284 /* Free the entire double indirect zone */ 285 285 uint32_t *dbl_zone; 286 286 287 287 if (ino_i->i_izone[1] == 0) { 288 /* Nothing to be done*/288 /* Nothing to be done */ 289 289 return EOK; 290 290 } … … 350 350 block_t *b; 351 351 const int max_ind_zone_ptrs = (MFS_MAX_BLOCKSIZE / sizeof(uint16_t)) * 352 352 sizeof(uint32_t); 353 353 354 354 *ind_zone = malloc(max_ind_zone_ptrs);
Note:
See TracChangeset
for help on using the changeset viewer.