Changeset bc99ed6 in mainline
- Timestamp:
- 2011-03-07T20:20:08Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f5cbd4f
- Parents:
- e80b1de
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified uspace/app/mkminix/mkminix.c ¶
re80b1de rbc99ed6 63 63 64 64 typedef struct mfs_params { 65 uint16_t fs_magic; 66 uint32_t block_size; 67 size_t devblock_size; 68 unsigned long n_inodes; 69 aoff64_t dev_nblocks; 70 bool fs_longnames; 65 devmap_handle_t handle; 66 uint16_t fs_magic; 67 uint32_t block_size; 68 size_t devblock_size; 69 unsigned long n_inodes; 70 aoff64_t dev_nblocks; 71 bool fs_longnames; 71 72 } mfs_params_t; 72 73 73 74 static void help_cmd_mkminix(help_level_t level); 74 75 static int num_of_set_bits(uint32_t n); 75 static void setup_superblock(struct mfs_superblock *sb, mfs_params_t *opt); 76 static void setup_superblock_v3(struct mfs3_superblock *sb, mfs_params_t *opt); 77 static void setup_bitmaps(devmap_handle_t handle, uint32_t ninodes, 78 uint32_t nzones, int bsize); 76 static void init_superblock(struct mfs_superblock *sb, mfs_params_t *opt); 77 static void init_superblock_v3(struct mfs3_superblock *sb, mfs_params_t *opt); 78 static void init_bitmaps(uint32_t ninodes, uint32_t nzones, int bsize, mfs_params_t *opt); 79 79 static void mark_bmap(uint8_t *bmap, int idx, int v); 80 80 … … 94 94 int rc, c, opt_ind; 95 95 char *device_name; 96 devmap_handle_t handle;97 96 98 97 struct mfs_superblock *sb; … … 170 169 } 171 170 172 rc = devmap_device_get_handle(device_name, & handle, 0);171 rc = devmap_device_get_handle(device_name, &opt.handle, 0); 173 172 if (rc != EOK) { 174 173 printf(NAME ": Error resolving device `%s'.\n", device_name); … … 176 175 } 177 176 178 rc = block_init( handle, MFS_MIN_BLOCKSIZE);177 rc = block_init(opt.handle, MFS_MIN_BLOCKSIZE); 179 178 if (rc != EOK) { 180 179 printf(NAME ": Error initializing libblock.\n"); … … 182 181 } 183 182 184 rc = block_get_bsize( handle, &opt.devblock_size);183 rc = block_get_bsize(opt.handle, &opt.devblock_size); 185 184 if (rc != EOK) { 186 185 printf(NAME ": Error determining device block size.\n"); … … 188 187 } 189 188 190 rc = block_get_nblocks( handle, &opt.dev_nblocks);189 rc = block_get_nblocks(opt.handle, &opt.dev_nblocks); 191 190 if (rc != EOK) { 192 191 printf(NAME ": Warning, failed to obtain block device size.\n"); … … 214 213 return 2; 215 214 } 216 setup_superblock_v3(sb3, &opt); 217 block_write_direct(handle, MFS_SUPERBLOCK, 1, sb3); 218 setup_bitmaps(handle, sb3->s_ninodes, 219 sb3->s_nzones, sb3->s_block_size); 215 init_superblock_v3(sb3, &opt); 216 init_bitmaps(sb3->s_ninodes, sb3->s_nzones, sb3->s_block_size, &opt); 220 217 } else { 221 218 sb = (struct mfs_superblock *) malloc(sizeof(struct mfs_superblock)); … … 224 221 return 2; 225 222 } 226 setup_superblock(sb, &opt); 227 block_write_direct(handle, MFS_SUPERBLOCK, 1, sb); 228 setup_bitmaps(handle, sb->s_ninodes, sb->s_nzones, MFS_BLOCKSIZE); 223 init_superblock(sb, &opt); 224 init_bitmaps(sb->s_ninodes, sb->s_nzones, MFS_BLOCKSIZE, &opt); 229 225 } 230 226 … … 232 228 } 233 229 234 static void setup_superblock(struct mfs_superblock *sb, mfs_params_t *opt)230 static void init_superblock(struct mfs_superblock *sb, mfs_params_t *opt) 235 231 { 236 232 int ino_per_block = 0; … … 297 293 printf(NAME ": first data zone = %d\n", sb->s_first_data_zone); 298 294 printf(NAME ": long fnames = %s\n", opt->fs_longnames ? "Yes" : "No"); 299 } 300 301 static void setup_superblock_v3(struct mfs3_superblock *sb, mfs_params_t *opt) 295 296 block_write_direct(opt->handle, MFS_SUPERBLOCK, 1, sb); 297 } 298 299 static void init_superblock_v3(struct mfs3_superblock *sb, mfs_params_t *opt) 302 300 { 303 301 int ino_per_block; … … 348 346 printf(NAME ": inode table blocks = %ld\n", ninodes_blocks); 349 347 printf(NAME ": first data zone = %d\n", sb->s_first_data_zone); 350 } 351 352 static void setup_bitmaps(devmap_handle_t handle, uint32_t ninodes, 353 uint32_t nzones, int bsize) 348 349 block_write_direct(opt->handle, MFS_SUPERBLOCK, 1, sb); 350 } 351 352 static void init_bitmaps(uint32_t ninodes, uint32_t nzones, 353 int bsize, mfs_params_t *opt) 354 354 { 355 355 uint8_t *ibmap_buf, *zbmap_buf; … … 372 372 zbmap_nblocks *= bsize / MFS_BLOCKSIZE; 373 373 374 block_write_direct( handle, 2, ibmap_nblocks, ibmap_buf);375 block_write_direct( handle, 2 + ibmap_nblocks, zbmap_nblocks, zbmap_buf);374 block_write_direct(opt->handle, 2, ibmap_nblocks, ibmap_buf); 375 block_write_direct(opt->handle, 2 + ibmap_nblocks, zbmap_nblocks, zbmap_buf); 376 376 } 377 377
Note:
See TracChangeset
for help on using the changeset viewer.