Changeset 2cf95e8 in mainline
- Timestamp:
- 2011-03-29T19:26:24Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3317724
- Parents:
- 77a2d77
- Location:
- uspace/srv/fs/minixfs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs.h
r77a2d77 r2cf95e8 161 161 /*mfs_balloc.c*/ 162 162 extern int 163 mfs_alloc_bit(struct mfs_instance *inst, uint32_t *idx, bmap_id_t id); 163 mfs_alloc_bit(struct mfs_instance *inst, uint32_t *idx, bmap_id_t bid); 164 165 extern int 166 mfs_free_bit(struct mfs_instance *inst, uint32_t idx, bmap_id_t bid); 164 167 165 168 #endif -
uspace/srv/fs/minixfs/mfs_balloc.c
r77a2d77 r2cf95e8 7 7 static int 8 8 find_free_bit_and_set(bitchunk_t *b, const int bsize, const bool native); 9 10 int 11 mfs_free_bit(struct mfs_instance *inst, uint32_t idx, bmap_id_t bid) 12 { 13 struct mfs_sb_info *sbi; 14 int r; 15 unsigned start_block; 16 block_t *b; 17 18 assert(inst != NULL); 19 sbi = inst->sbi; 20 assert(sbi != NULL); 21 22 if (bid == BMAP_ZONE) { 23 start_block = 2 + sbi->ibmap_blocks; 24 if (idx > sbi->nzones) { 25 printf(NAME ": Error! Trying to free beyond the" \ 26 "bitmap max size\n"); 27 return -1; 28 } 29 } else { 30 /*bid == BMAP_INODE*/ 31 start_block = 2; 32 if (idx > sbi->ninodes) { 33 printf(NAME ": Error! Trying to free beyond the" \ 34 "bitmap max size\n"); 35 return -1; 36 } 37 } 38 39 /*Compute the bitmap block*/ 40 uint32_t block = idx / (sbi->block_size * 8) + start_block; 41 42 r = block_get(&b, inst->handle, block, BLOCK_FLAGS_NONE); 43 if (r != EOK) 44 goto out_err; 45 46 /*Compute the bit index in the block*/ 47 idx %= (sbi->block_size * 8); 48 bitchunk_t *ptr = b->data; 49 bitchunk_t chunk; 50 51 chunk = conv32(sbi->native, ptr[idx / 32]); 52 chunk &= ~(1 << (idx % 32)); 53 ptr[idx / 32] = conv32(sbi->native, chunk); 54 b->dirty = true; 55 r = EOK; 56 block_put(b); 57 58 out_err: 59 return r; 60 } 9 61 10 62 int
Note:
See TracChangeset
for help on using the changeset viewer.