diff options
author | Rob Landley <rob@landley.net> | 2006-04-29 15:23:33 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-04-29 15:23:33 +0000 |
commit | 2e2d752d490fe8b71bfa398439851a954a1b308e (patch) | |
tree | 4a4be4ee356b6e75f435f8b4787238356b8c57ab | |
parent | 2514042661c1eca7dc2aef2c94a00b223a341665 (diff) | |
download | busybox-w32-2e2d752d490fe8b71bfa398439851a954a1b308e.tar.gz busybox-w32-2e2d752d490fe8b71bfa398439851a954a1b308e.tar.bz2 busybox-w32-2e2d752d490fe8b71bfa398439851a954a1b308e.zip |
Cleanup to hdparm by tito.
-rw-r--r-- | miscutils/hdparm.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 30babc165..80af44511 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -630,7 +630,7 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
630 | uint8_t have_mode = 0, err_dma = 0; | 630 | uint8_t have_mode = 0, err_dma = 0; |
631 | uint8_t chksum = 0; | 631 | uint8_t chksum = 0; |
632 | uint32_t ll, mm, nn, oo; | 632 | uint32_t ll, mm, nn, oo; |
633 | __u64 bbbig; /* (:) */ | 633 | uint64_t bbbig; /* (:) */ |
634 | 634 | ||
635 | if (id_supplied) | 635 | if (id_supplied) |
636 | { | 636 | { |
@@ -642,14 +642,13 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
642 | } | 642 | } |
643 | else | 643 | else |
644 | { | 644 | { |
645 | id_file = xcalloc(1, strlen(devname)+22); | ||
646 | sprintf(id_file, "/proc/ide/%s/identify", devname); | ||
647 | /* open the file, read in all the info and close it */ | 645 | /* open the file, read in all the info and close it */ |
648 | if (id_file == NULL) | 646 | if (devname == NULL) |
649 | fl = stdin; | 647 | fl = stdin; |
650 | else | 648 | else { |
649 | id_file = bb_xasprintf("/proc/ide/%s/identify", devname); | ||
651 | fl = bb_xfopen(id_file, "r"); | 650 | fl = bb_xfopen(id_file, "r"); |
652 | 651 | } | |
653 | /* calculate checksum over all bytes */ | 652 | /* calculate checksum over all bytes */ |
654 | for(ii = GEN_CONFIG; ii<=INTEGRITY; ii++) | 653 | for(ii = GEN_CONFIG; ii<=INTEGRITY; ii++) |
655 | { | 654 | { |
@@ -659,8 +658,8 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
659 | val[ii] = (uint16_t)scratch; | 658 | val[ii] = (uint16_t)scratch; |
660 | chksum += val[ii] + (val[ii] >> 8); | 659 | chksum += val[ii] + (val[ii] >> 8); |
661 | } | 660 | } |
662 | fclose(fl); | 661 | bb_fclose_nonstdin(fl); |
663 | /*bb_fclose_nonstdin(fl);*/ | 662 | if (ENABLE_FEATURE_CLEAN_UP) free(id_file); |
664 | if(ii < (INTEGRITY+1)) | 663 | if(ii < (INTEGRITY+1)) |
665 | bb_error_msg_and_die("Input file wrong format or length"); | 664 | bb_error_msg_and_die("Input file wrong format or length"); |
666 | } | 665 | } |
@@ -909,15 +908,15 @@ static void identify (uint16_t *id_supplied, const char *devname) | |||
909 | if( ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) && | 908 | if( ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) && |
910 | (val[CMDS_SUPP_1] & SUPPORT_48_BIT) ) | 909 | (val[CMDS_SUPP_1] & SUPPORT_48_BIT) ) |
911 | { | 910 | { |
912 | bbbig = (__u64)val[LBA_64_MSB] << 48 | | 911 | bbbig = (uint64_t)val[LBA_64_MSB] << 48 | |
913 | (__u64)val[LBA_48_MSB] << 32 | | 912 | (uint64_t)val[LBA_48_MSB] << 32 | |
914 | (__u64)val[LBA_MID] << 16 | | 913 | (uint64_t)val[LBA_MID] << 16 | |
915 | val[LBA_LSB] ; | 914 | val[LBA_LSB] ; |
916 | printf("\tLBA48 user addressable sectors:%11llu\n",bbbig); | 915 | printf("\tLBA48 user addressable sectors:%11llu\n",bbbig); |
917 | } | 916 | } |
918 | 917 | ||
919 | if (!bbbig) | 918 | if (!bbbig) |
920 | bbbig = (__u64)(ll>mm ? ll : mm); /* # 512 byte blocks */ | 919 | bbbig = (uint64_t)(ll>mm ? ll : mm); /* # 512 byte blocks */ |
921 | printf("\tdevice size with M = 1024*1024: %11llu MBytes\n",bbbig>>11); | 920 | printf("\tdevice size with M = 1024*1024: %11llu MBytes\n",bbbig>>11); |
922 | bbbig = (bbbig<<9)/1000000; | 921 | bbbig = (bbbig<<9)/1000000; |
923 | printf("\tdevice size with M = 1000*1000: %11llu MBytes ",bbbig); | 922 | printf("\tdevice size with M = 1000*1000: %11llu MBytes ",bbbig); |