Changeset 197b671 in mainline
- Timestamp:
- 2011-03-10T19:11:23Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d3ce9515
- Parents:
- 7a34efde
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkminix/mkminix.c
r7a34efde r197b671 69 69 /*Generic MFS superblock*/ 70 70 struct mfs_sb_info { 71 devmap_handle_t handle;72 71 uint64_t n_inodes; 73 72 uint64_t n_zones; 74 73 aoff64_t dev_nblocks; 75 aoff64_t devblock_size;76 74 unsigned long ibmap_blocks; 77 75 unsigned long zbmap_blocks; … … 91 89 static int num_of_set_bits(uint32_t n); 92 90 static int init_superblock(struct mfs_sb_info *sb); 93 static int write_superblock( struct mfs_sb_info *sbi);94 static int write_superblock3( struct mfs_sb_info *sbi);95 static int init_bitmaps( struct mfs_sb_info *sb);96 static int init_inode_table( struct mfs_sb_info *sb);97 static int make_root_ino( struct mfs_sb_info *sb);98 static int make_root_ino3( struct mfs_sb_info *sb);91 static int write_superblock(const struct mfs_sb_info *sbi); 92 static int write_superblock3(const struct mfs_sb_info *sbi); 93 static int init_bitmaps(const struct mfs_sb_info *sb); 94 static int init_inode_table(const struct mfs_sb_info *sb); 95 static int make_root_ino(const struct mfs_sb_info *sb); 96 static int make_root_ino3(const struct mfs_sb_info *sb); 99 97 static void mark_bmap(uint32_t *bmap, int idx, int v); 100 static int insert_dentries(struct mfs_sb_info *sb); 98 static int insert_dentries(const struct mfs_sb_info *sb); 99 100 static devmap_handle_t handle; 101 101 102 102 static struct option const long_options[] = { … … 115 115 int rc, c, opt_ind; 116 116 char *device_name; 117 aoff64_t devblock_size; 117 118 118 119 struct mfs_sb_info sb; … … 200 201 } 201 202 202 rc = devmap_device_get_handle(device_name, & sb.handle, 0);203 rc = devmap_device_get_handle(device_name, &handle, 0); 203 204 if (rc != EOK) { 204 205 printf(NAME ": Error resolving device `%s'.\n", device_name); … … 206 207 } 207 208 208 rc = block_init( sb.handle, MFS_MIN_BLOCKSIZE);209 rc = block_init(handle, MFS_MIN_BLOCKSIZE); 209 210 if (rc != EOK) { 210 211 printf(NAME ": Error initializing libblock.\n"); … … 212 213 } 213 214 214 rc = block_get_bsize( sb.handle, &sb.devblock_size);215 rc = block_get_bsize(handle, &devblock_size); 215 216 if (rc != EOK) { 216 217 printf(NAME ": Error determining device block size.\n"); … … 218 219 } 219 220 220 rc = block_get_nblocks( sb.handle, &sb.dev_nblocks);221 rc = block_get_nblocks(handle, &sb.dev_nblocks); 221 222 if (rc != EOK) { 222 223 printf(NAME ": Warning, failed to obtain block device size.\n"); … … 226 227 } 227 228 228 if ( sb.devblock_size != 512) {229 if (devblock_size != 512) { 229 230 printf(NAME ": Error. Device block size is not 512 bytes.\n"); 230 231 return 2; … … 274 275 } 275 276 276 static int insert_dentries( struct mfs_sb_info *sb)277 static int insert_dentries(const struct mfs_sb_info *sb) 277 278 { 278 279 void *root_block; … … 309 310 } 310 311 311 rc = block_write_direct( sb->handle, root_dblock, 1, root_block);312 rc = block_write_direct(handle, root_dblock, 1, root_block); 312 313 313 314 free(root_block); … … 315 316 } 316 317 317 static int init_inode_table( struct mfs_sb_info *sb)318 static int init_inode_table(const struct mfs_sb_info *sb) 318 319 { 319 320 unsigned int i; … … 338 339 339 340 for (i = 0; i < itable_size; ++i, ++itable_off) { 340 rc = block_write_direct( sb->handle, itable_off, 1, itable_buf);341 rc = block_write_direct(handle, itable_off, 1, itable_buf); 341 342 342 343 if (rc != EOK) … … 348 349 } 349 350 350 static int make_root_ino( struct mfs_sb_info *sb)351 static int make_root_ino(const struct mfs_sb_info *sb) 351 352 { 352 353 struct mfs_inode *ino_buf; … … 374 375 ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone; 375 376 376 rc = block_write_direct( sb->handle, itable_off, 1, ino_buf);377 rc = block_write_direct(handle, itable_off, 1, ino_buf); 377 378 378 379 free(ino_buf); … … 380 381 } 381 382 382 static int make_root_ino3( struct mfs_sb_info *sb)383 static int make_root_ino3(const struct mfs_sb_info *sb) 383 384 { 384 385 struct mfs2_inode *ino_buf; … … 412 413 ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone; 413 414 414 rc = block_write_direct( sb->handle, itable_off, 1, ino_buf);415 rc = block_write_direct(handle, itable_off, 1, ino_buf); 415 416 416 417 free(ino_buf); … … 496 497 } 497 498 498 static int write_superblock( struct mfs_sb_info *sbi)499 static int write_superblock(const struct mfs_sb_info *sbi) 499 500 { 500 501 struct mfs_superblock *sb; … … 517 518 sb->s_state = MFS_VALID_FS; 518 519 519 rc = block_write_direct( sbi->handle, MFS_SUPERBLOCK, 1, sb);520 rc = block_write_direct(handle, MFS_SUPERBLOCK, 1, sb); 520 521 free(sb); 521 522 … … 523 524 } 524 525 525 static int write_superblock3( struct mfs_sb_info *sbi)526 static int write_superblock3(const struct mfs_sb_info *sbi) 526 527 { 527 528 struct mfs3_superblock *sb; … … 544 545 sb->s_disk_version = 3; 545 546 546 rc = block_write_direct( sbi->handle, MFS_SUPERBLOCK, 1, sb);547 rc = block_write_direct(handle, MFS_SUPERBLOCK, 1, sb); 547 548 free(sb); 548 549 … … 550 551 } 551 552 552 static int init_bitmaps( struct mfs_sb_info *sb)553 static int init_bitmaps(const struct mfs_sb_info *sb) 553 554 { 554 555 uint32_t *ibmap_buf, *zbmap_buf; … … 584 585 585 586 for (i = 0; i < ibmap_nblocks; ++i) { 586 if ((rc = block_write_direct( sb->handle, start_block + i,587 if ((rc = block_write_direct(handle, start_block + i, 587 588 1, (ibmap_buf8 + i * MFS_BLOCKSIZE))) != EOK) 588 589 return rc; … … 592 593 593 594 for (i = 0; i < zbmap_nblocks; ++i) { 594 if ((rc = block_write_direct( sb->handle, start_block + i,595 if ((rc = block_write_direct(handle, start_block + i, 595 596 1, (zbmap_buf8 + i * MFS_BLOCKSIZE))) != EOK) 596 597 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.