Changeset 7bd68e6 in mainline
- Timestamp:
- 2011-04-05T21:07:59Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 82c198f
- Parents:
- 2bbbfd3
- Location:
- uspace/srv/fs/minixfs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs.h
r2bbbfd3 r7bd68e6 163 163 put_inode(struct mfs_node *mnode); 164 164 165 int 166 mfs_inode_grow(struct mfs_node *mnode, unsigned size_grow); 167 165 168 /*mfs_rw.c*/ 166 169 extern int -
uspace/srv/fs/minixfs/mfs_inode.c
r2bbbfd3 r7bd68e6 271 271 } 272 272 273 int 274 mfs_inode_grow(struct mfs_node *mnode, unsigned size_grow) 275 { 276 unsigned i; 277 278 if (size_grow == 0) 279 return EOK; 280 281 struct mfs_sb_info *sbi = mnode->instance->sbi; 282 struct mfs_ino_info *ino_i = mnode->ino_i; 283 const int bs = sbi->block_size; 284 285 const uint32_t old_size = ino_i->i_size; 286 const uint32_t new_size = old_size + size_grow; 287 288 /*Compute the number of zones to add to the inode*/ 289 unsigned zones_to_add = 0; 290 if ((old_size % (bs - 1)) == 0) 291 zones_to_add++; 292 293 zones_to_add += (new_size - old_size) / bs; 294 295 /*Compute the start zone*/ 296 unsigned start_zone = old_size / bs; 297 start_zone += (old_size % bs) != 0; 298 299 int r; 300 for (i = 0; i < zones_to_add; ++i) { 301 uint32_t new_zone; 302 uint32_t dummy; 303 304 r = mfs_alloc_bit(mnode->instance, &new_zone, BMAP_ZONE); 305 if (r != EOK) 306 return r; 307 308 r = write_map(mnode, (start_zone + i) * sbi->block_size, 309 new_zone, &dummy); 310 if (r != EOK) 311 return r; 312 } 313 return EOK; 314 } 315 273 316 /** 274 317 * @}
Note:
See TracChangeset
for help on using the changeset viewer.