Changeset e6aaa59 in mainline
- Timestamp:
- 2011-03-06T17:01:25Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9cfe0d5
- Parents:
- 4cee3944
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkminix/mkminix.c
r4cee3944 re6aaa59 52 52 #define NAME "mkminix" 53 53 54 #define FREE 0 55 #define USED 1 56 54 57 typedef enum { 55 58 HELP_SHORT, … … 70 73 static void setup_superblock(struct mfs_superblock *sb, mfs_params_t *opt); 71 74 static void setup_superblock_v3(struct mfs3_superblock *sb, mfs_params_t *opt); 75 static void setup_bitmaps(devmap_handle_t handle, uint32_t ninodes, uint32_t nzones); 76 static void mark_bmap(uint8_t *bmap, int idx, int v); 72 77 73 78 static struct option const long_options[] = { … … 108 113 109 114 for (c = 0, optind = 0, opt_ind = 0; c != -1;) { 110 c = getopt_long(argc, argv, " eh123b:i:", long_options, &opt_ind);115 c = getopt_long(argc, argv, "lh123b:i:", long_options, &opt_ind); 111 116 switch (c) { 112 117 case 'h': … … 207 212 } 208 213 setup_superblock_v3(sb3, &opt); 214 setup_bitmaps(handle, sb3->s_ninodes, sb3->s_total_zones); 209 215 } else { 210 216 sb = (struct mfs_superblock *) malloc(sizeof(struct mfs_superblock)); … … 215 221 setup_superblock(sb, &opt); 216 222 block_write_direct(handle, MFS_SUPERBLOCK, 1, sb); 223 setup_bitmaps(handle, sb->s_ninodes, sb->s_nzones); 217 224 } 218 225 … … 284 291 } 285 292 293 static void setup_bitmaps(devmap_handle_t handle, uint32_t ninodes, uint32_t nzones) 294 { 295 uint8_t *ibmap_buf, *zbmap_buf; 296 int ibmap_nblocks = 1 + (ninodes / 8) / MFS_BLOCKSIZE; 297 int zbmap_nblocks = 1 + (nzones / 8) / MFS_BLOCKSIZE; 298 unsigned int i; 299 300 ibmap_buf = (uint8_t *) malloc(ibmap_nblocks * MFS_BLOCKSIZE); 301 zbmap_buf = (uint8_t *) malloc(zbmap_nblocks * MFS_BLOCKSIZE); 302 303 memset(ibmap_buf, 0xFF, ibmap_nblocks * MFS_BLOCKSIZE); 304 memset(zbmap_buf, 0xFF, zbmap_nblocks * MFS_BLOCKSIZE); 305 306 for (i = 2; i < ninodes; ++i) { 307 mark_bmap(ibmap_buf, i, FREE); 308 mark_bmap(zbmap_buf, i, FREE); 309 } 310 311 block_write_direct(handle, 2, ibmap_nblocks, ibmap_buf); 312 block_write_direct(handle, 2 + ibmap_nblocks, zbmap_nblocks, zbmap_buf); 313 } 314 315 static void mark_bmap(uint8_t *bmap, int idx, int v) 316 { 317 if (v == FREE) 318 bmap[idx / 8] &= ~(1 << (idx % 8)); 319 else 320 bmap[idx / 8] |= 1 << (idx % 8); 321 } 322 286 323 static void help_cmd_mkminix(help_level_t level) 287 324 {
Note:
See TracChangeset
for help on using the changeset viewer.