Changeset b2a18234 in mainline for uspace/srv/fs/minixfs/mfs_inode.c
- Timestamp:
- 2011-07-27T10:55:19Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e8b6b6a
- Parents:
- 88be951e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs_inode.c
r88be951e rb2a18234 352 352 } 353 353 354 int355 inode_grow(struct mfs_node *mnode, size_t size_grow)356 {357 unsigned i;358 struct mfs_sb_info *sbi = mnode->instance->sbi;359 struct mfs_ino_info *ino_i = mnode->ino_i;360 const int bs = sbi->block_size;361 362 const uint32_t old_size = ino_i->i_size;363 const uint32_t new_size = old_size + size_grow;364 365 assert(size_grow > 0);366 367 /*Compute the number of zones to add to the inode*/368 unsigned zones_to_add = 0;369 if (old_size == 0)370 ++zones_to_add;371 372 zones_to_add += (new_size / bs) - (old_size / bs);373 374 /*Compute the start zone*/375 unsigned start_zone = old_size / bs;376 start_zone += (old_size % bs) != 0;377 378 int r;379 for (i = 0; i < zones_to_add; ++i) {380 uint32_t new_zone;381 uint32_t dummy;382 383 r = mfs_alloc_zone(mnode->instance, &new_zone);384 on_error(r, return r);385 386 block_t *b;387 r = block_get(&b, mnode->instance->handle, new_zone,388 BLOCK_FLAGS_NOREAD);389 on_error(r, return r);390 391 memset(b->data, 0, bs);392 b->dirty = true;393 block_put(b);394 395 r = write_map(mnode, (start_zone + i) * bs,396 new_zone, &dummy);397 398 on_error(r, return r);399 400 ino_i->i_size += bs;401 ino_i->dirty = true;402 }403 404 ino_i->i_size = new_size;405 ino_i->dirty = true;406 407 return EOK;408 }409 410 354 /** 411 355 * @}
Note:
See TracChangeset
for help on using the changeset viewer.