Changeset 340b5690 in mainline
- Timestamp:
- 2011-03-09T20:26:46Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bb0db564
- Parents:
- 7df022e5
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkminix/mkminix.c
r7df022e5 r340b5690 59 59 #define UPPER(n, size) (((n) / (size)) + (((n) % (size)) != 0)) 60 60 #define NEXT_DENTRY(p, dirsize) (p += dirsize) 61 #define FIRST_ZONE(bs) ((MFS_BOOTBLOCK_SIZE + MFS_SUPERBLOCK_SIZE) / (bs)) 61 62 62 63 typedef enum { … … 317 318 uint8_t *itable_buf; 318 319 int rc; 319 long itable_pos = 2 + sb->zbmap_blocks + sb->ibmap_blocks; 320 long itable_off; 321 322 itable_off = FIRST_ZONE(sb->block_size); 323 itable_off += sb->zbmap_blocks + sb->ibmap_blocks; 324 325 /*Convert to 1K offset*/ 326 itable_off *= sb->block_size / MFS_MIN_BLOCKSIZE; 320 327 321 328 itable_buf = malloc(sb->block_size); … … 326 333 memset(itable_buf, 0x00, sb->block_size); 327 334 328 const int chunks = sb->block_size / MFS_BLOCKSIZE; 329 330 for (i = 0; i < sb->itable_size; ++i, itable_pos += chunks) { 331 rc = block_write_direct(sb->handle, itable_pos, chunks, itable_buf); 335 for (i = 0; i < sb->itable_size * (sb->block_size / MFS_MIN_BLOCKSIZE); ++i, ++itable_off) { 336 rc = block_write_direct(sb->handle, itable_off, 1, itable_buf); 332 337 333 338 if (rc != EOK) … … 342 347 { 343 348 struct mfs_inode *ino_buf; 344 const long itable_pos = 2 + sb->zbmap_blocks + sb->ibmap_blocks; 345 int rc; 349 long itable_off; 350 int rc; 351 352 itable_off = FIRST_ZONE(MFS_BLOCKSIZE); 353 itable_off += sb->zbmap_blocks + sb->ibmap_blocks; 346 354 347 355 const time_t sec = time(NULL); … … 362 370 ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone; 363 371 364 rc = block_write_direct(sb->handle, itable_ pos, 1, ino_buf);372 rc = block_write_direct(sb->handle, itable_off, 1, ino_buf); 365 373 366 374 free(ino_buf); … … 371 379 { 372 380 struct mfs2_inode *ino_buf; 373 const size_t bufsize = MFS_MIN_BLOCKSIZE; 374 const long itable_pos = 2 + sb->zbmap_blocks + sb->ibmap_blocks; 375 int rc; 381 long itable_off; 382 int rc; 383 384 itable_off = FIRST_ZONE(sb->block_size); 385 itable_off += sb->zbmap_blocks + sb->ibmap_blocks; 386 387 /*Convert to 1K block offset*/ 388 itable_off *= sb->block_size / MFS_MIN_BLOCKSIZE; 376 389 377 390 const time_t sec = time(NULL); 378 391 379 ino_buf = (struct mfs2_inode *) malloc( bufsize);392 ino_buf = (struct mfs2_inode *) malloc(MFS_MIN_BLOCKSIZE); 380 393 381 394 if (!ino_buf) 382 395 return ENOMEM; 383 396 384 memset(ino_buf, 0x00, bufsize);397 memset(ino_buf, 0x00, MFS_MIN_BLOCKSIZE); 385 398 386 399 ino_buf[MFS_ROOT_INO].i_mode = S_IFDIR; … … 394 407 ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone; 395 408 396 rc = block_write_direct(sb->handle, itable_ pos * (sb->block_size / MFS_MIN_BLOCKSIZE), 1, ino_buf);409 rc = block_write_direct(sb->handle, itable_off, 1, ino_buf); 397 410 398 411 free(ino_buf); … … 442 455 sb->ibmap_blocks = UPPER(sb->n_inodes, sb->block_size * 8); 443 456 457 /*Compute inode table size*/ 458 sb->itable_size = sb->n_inodes / sb->ino_per_block; 459 444 460 /*Compute zone bitmap size in blocks*/ 445 461 sb->zbmap_blocks = UPPER(sb->n_zones, sb->block_size * 8); 446 462 447 /*Compute inode table size*/448 sb->itable_size = sb->n_inodes / sb->ino_per_block;449 450 463 /*Compute first data zone position*/ 451 sb->first_data_zone = 2+ sb->itable_size +464 sb->first_data_zone = FIRST_ZONE(sb->block_size) + sb->itable_size + 452 465 sb->zbmap_blocks + sb->ibmap_blocks; 453 466 -
uspace/lib/minix/minix.h
r7df022e5 r340b5690 48 48 #define MFS_SUPERBLOCK 1 49 49 #define MFS_SUPERBLOCK_SIZE 1024 50 #define MFS_BOOTBLOCK_SIZE 1024 50 51 51 52 #define V2_NR_DIRECT_ZONES 7
Note:
See TracChangeset
for help on using the changeset viewer.