Changeset 87337dc5 in mainline for uspace/app/mkfat/mkfat.c
- Timestamp:
- 2018-07-09T15:00:24Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d054ad3
- Parents:
- 914c693
- git-author:
- Jiri Svoboda <jiri@…> (2018-07-08 19:58:56)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-07-09 15:00:24)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkfat/mkfat.c
r914c693 r87337dc5 48 48 #include <inttypes.h> 49 49 #include <errno.h> 50 #include <rndgen.h> 50 51 #include <str.h> 51 52 #include "fat.h" … … 89 90 static errno_t fat_params_compute(struct fat_cfg *cfg); 90 91 static errno_t fat_blocks_write(struct fat_cfg const *cfg, service_id_t service_id); 91 static voidfat_bootsec_create(struct fat_cfg const *cfg, struct fat_bs *bs);92 static errno_t fat_bootsec_create(struct fat_cfg const *cfg, struct fat_bs *bs); 92 93 93 94 int main(int argc, char **argv) … … 376 377 fat_dentry_t *de; 377 378 378 fat_bootsec_create(cfg, &bs); 379 rc = fat_bootsec_create(cfg, &bs); 380 if (rc != EOK) 381 return rc; 379 382 380 383 rc = block_write_direct(service_id, BS_BLOCK, 1, &bs); … … 442 445 (void) fat_label_encode(&de->name, cfg->label); 443 446 de->attr = FAT_ATTR_VOLLABEL; 444 de->mtime = 0x1234; 445 de->mdate = 0x1234; 447 de->mtime = 0x1234; // XXX Proper time 448 de->mdate = 0x1234; // XXX Proper date 446 449 } else if (idx == 1) { 447 450 /* Clear volume label entry */ … … 462 465 463 466 /** Construct boot sector with the given parameters. */ 464 static voidfat_bootsec_create(struct fat_cfg const *cfg, struct fat_bs *bs)467 static errno_t fat_bootsec_create(struct fat_cfg const *cfg, struct fat_bs *bs) 465 468 { 466 469 const char *bs_label; 470 rndgen_t *rndgen; 471 uint32_t vsn; 472 errno_t rc; 473 474 /* Generate a volume serial number */ 475 rc = rndgen_create(&rndgen); 476 if (rc != EOK) 477 return rc; 478 479 rc = rndgen_uint32(rndgen, &vsn); 480 if (rc != EOK) { 481 rndgen_destroy(rndgen); 482 return rc; 483 } 484 485 rndgen_destroy(rndgen); 467 486 468 487 /* … … 503 522 bs->hidden_sec = host2uint32_t_le(0); 504 523 524 505 525 if (cfg->fat_type == FAT32) { 506 526 bs->sec_per_fat = 0; … … 509 529 bs->fat32.pdn = 0x80; 510 530 bs->fat32.ebs = 0x29; 511 bs->fat32.id = host2uint32_t_be( 0x12345678);531 bs->fat32.id = host2uint32_t_be(vsn); 512 532 bs->fat32.root_cluster = 2; 513 533 … … 518 538 bs->pdn = 0x80; 519 539 bs->ebs = 0x29; 520 bs->id = host2uint32_t_be( 0x12345678);540 bs->id = host2uint32_t_be(vsn); 521 541 522 542 (void) fat_label_encode(&bs->label, bs_label); … … 526 546 memcpy(bs->type, "FAT16 ", 8); 527 547 } 548 549 return EOK; 528 550 } 529 551
Note:
See TracChangeset
for help on using the changeset viewer.