Changeset 852664b9 in mainline
- Timestamp:
- 2015-10-21T09:55:49Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 21f1543
- Parents:
- b598460a
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fdisk/fdisk.c
rb598460a r852664b9 513 513 fdisk_part_info_t pinfo; 514 514 fdisk_cap_t cap; 515 fdisk_cap_t mcap; 515 516 fdisk_dev_flags_t dflags; 516 517 char *sltype = NULL; 517 518 char *sdcap = NULL; 518 519 char *scap = NULL; 520 char *smcap = NULL; 519 521 char *sfstype = NULL; 520 522 char *svcname = NULL; … … 646 648 647 649 part = fdisk_part_next(part); 650 } 651 652 /* Display available space */ 653 if ((linfo.flags & lf_can_create_pri) != 0) { 654 rc = fdisk_part_get_max_avail(dev, spc_pri, &mcap); 655 if (rc != EOK) { 656 rc = EIO; 657 goto error; 658 } 659 660 rc = fdisk_cap_format(&mcap, &smcap); 661 if (rc != EOK) { 662 rc = ENOMEM; 663 goto error; 664 } 665 666 if ((linfo.flags & lf_ext_supp) != 0) 667 printf("Maximum free primary block: %s\n", smcap); 668 else 669 printf("Maximum free block: %s\n", smcap); 670 671 free(smcap); 672 smcap = NULL; 673 674 rc = fdisk_part_get_tot_avail(dev, spc_pri, &mcap); 675 if (rc != EOK) { 676 rc = EIO; 677 goto error; 678 } 679 680 rc = fdisk_cap_format(&mcap, &smcap); 681 if (rc != EOK) { 682 rc = ENOMEM; 683 goto error; 684 } 685 686 if ((linfo.flags & lf_ext_supp) != 0) 687 printf("Total free primary space: %s\n", smcap); 688 else 689 printf("Total free space: %s\n", smcap); 690 691 free(smcap); 692 smcap = NULL; 693 } 694 695 /* Display available space */ 696 if ((linfo.flags & lf_can_create_log) != 0) { 697 rc = fdisk_part_get_max_avail(dev, spc_log, &mcap); 698 if (rc != EOK) { 699 rc = EIO; 700 goto error; 701 } 702 703 rc = fdisk_cap_format(&mcap, &smcap); 704 if (rc != EOK) { 705 rc = ENOMEM; 706 goto error; 707 } 708 709 printf("Maximum free logical block: %s\n", smcap); 710 free(smcap); 711 smcap = NULL; 712 713 rc = fdisk_part_get_tot_avail(dev, spc_log, &mcap); 714 if (rc != EOK) { 715 rc = EIO; 716 goto error; 717 } 718 719 rc = fdisk_cap_format(&mcap, &smcap); 720 if (rc != EOK) { 721 rc = ENOMEM; 722 goto error; 723 } 724 725 printf("Total free logical space: %s\n", smcap); 726 free(smcap); 727 smcap = NULL; 648 728 } 649 729 … … 785 865 free(sdcap); 786 866 free(scap); 867 free(smcap); 787 868 free(sfstype); 788 869 free(svcname); -
uspace/lib/fdisk/include/fdisk.h
rb598460a r852664b9 65 65 extern int fdisk_part_get_info(fdisk_part_t *, fdisk_part_info_t *); 66 66 extern int fdisk_part_get_max_avail(fdisk_dev_t *, fdisk_spc_t, fdisk_cap_t *); 67 extern int fdisk_part_get_tot_avail(fdisk_dev_t *, fdisk_spc_t, fdisk_cap_t *); 67 68 extern int fdisk_part_create(fdisk_dev_t *, fdisk_part_spec_t *, 68 69 fdisk_part_t **); -
uspace/lib/fdisk/src/fdisk.c
rb598460a r852664b9 763 763 } 764 764 765 /** Get size of largest free block. */ 765 766 int fdisk_part_get_max_avail(fdisk_dev_t *dev, fdisk_spc_t spc, fdisk_cap_t *cap) 766 767 { … … 783 784 784 785 cap->value = nb * dev->dinfo.block_size; 786 cap->cunit = cu_byte; 787 return EOK; 788 } 789 790 /** Get total free space capacity. */ 791 int fdisk_part_get_tot_avail(fdisk_dev_t *dev, fdisk_spc_t spc, 792 fdisk_cap_t *cap) 793 { 794 fdisk_free_range_t fr; 795 uint64_t hdrb; 796 uint64_t b0; 797 uint64_t nb; 798 uint64_t totb; 799 800 if (spc == spc_log) 801 hdrb = max(1, dev->align); 802 else 803 hdrb = 0; 804 805 totb = 0; 806 fdisk_free_range_first(dev, spc, &fr); 807 do { 808 if (fdisk_free_range_get(&fr, &b0, &nb)) { 809 if (nb > hdrb) 810 totb += nb - hdrb; 811 } 812 } while (fdisk_free_range_next(&fr)); 813 814 cap->value = totb * dev->dinfo.block_size; 785 815 cap->cunit = cu_byte; 786 816 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.