diff options
author | sobomax <sobomax@FreeBSD.org> | 2011-06-25 07:51:39 +0800 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2011-06-25 07:51:39 +0800 |
commit | 89b6046b152f29d5f012c48cacc9aeab5307e6e4 (patch) | |
tree | b48f1ba56e5ff4070a1aefea7147124d6672674e /sysutils/ataidle | |
parent | ba08b3447442138c41730cd48ad5c7d1339d823e (diff) | |
download | freebsd-ports-gnome-89b6046b152f29d5f012c48cacc9aeab5307e6e4.tar.gz freebsd-ports-gnome-89b6046b152f29d5f012c48cacc9aeab5307e6e4.tar.zst freebsd-ports-gnome-89b6046b152f29d5f012c48cacc9aeab5307e6e4.zip |
Add option to enable/disable write cache and display its current
status. Bump PORTREVISION.
Diffstat (limited to 'sysutils/ataidle')
-rw-r--r-- | sysutils/ataidle/Makefile | 1 | ||||
-rw-r--r-- | sysutils/ataidle/files/patch-main.c | 39 | ||||
-rw-r--r-- | sysutils/ataidle/files/patch-mi_atagen.h | 32 | ||||
-rw-r--r-- | sysutils/ataidle/files/patch-mi_util.c | 102 | ||||
-rw-r--r-- | sysutils/ataidle/pkg-descr | 8 |
5 files changed, 178 insertions, 4 deletions
diff --git a/sysutils/ataidle/Makefile b/sysutils/ataidle/Makefile index 38a7eadc53b6..5168c4d323f6 100644 --- a/sysutils/ataidle/Makefile +++ b/sysutils/ataidle/Makefile @@ -7,6 +7,7 @@ PORTNAME= ataidle PORTVERSION= 2.5.1 +PORTREVISION= 1 CATEGORIES= sysutils MASTER_SITES= http://www.cran.org.uk/bruce/software/ diff --git a/sysutils/ataidle/files/patch-main.c b/sysutils/ataidle/files/patch-main.c new file mode 100644 index 000000000000..1bc9226f8912 --- /dev/null +++ b/sysutils/ataidle/files/patch-main.c @@ -0,0 +1,39 @@ + +$FreeBSD$ + +--- main.c ++++ main.c +@@ -52,7 +52,7 @@ + long opt_val; + int ch; + struct ata_ident ident; +- const char * const optstr = "hA:S:sI:iP:o"; ++ const char * const optstr = "hA:S:sI:iP:owW"; + + /* need more than just the executable name */ + if( argc == 1 ) +@@ -151,6 +151,24 @@ + } + break; + ++ /* Write Cache Disable */ ++ case 'w': ++ if (!(ident.cmd_supp1 & ATA_WC_SUPPORTED)) { ++ warnx("the device does not support write cache"); ++ break; ++ } ++ rc = ata_setwc(ata, 0); ++ break; ++ ++ /* Write Cache Enable */ ++ case 'W': ++ if (!(ident.cmd_supp1 & ATA_WC_SUPPORTED)) { ++ warnx("the device does not support write cache"); ++ break; ++ } ++ rc = ata_setwc(ata, 1); ++ break; ++ + case 'h': + default: + usage(); diff --git a/sysutils/ataidle/files/patch-mi_atagen.h b/sysutils/ataidle/files/patch-mi_atagen.h new file mode 100644 index 000000000000..a2a2bc4ec2c4 --- /dev/null +++ b/sysutils/ataidle/files/patch-mi_atagen.h @@ -0,0 +1,32 @@ + +$FreeBSD$ + +--- mi/atagen.h ++++ mi/atagen.h +@@ -62,6 +62,9 @@ + #define ATA_SMART_SUPPORTED 0x0001 + #define ATA_SMART_ENABLED 0x0001 + ++#define ATA_WC_SUPPORTED 0x0020 ++#define ATA_WC_ENABLED 0x0020 ++ + #define ATA__SETFEATURES 0xEF + #define ATA__IDENTIFY 0xEC + #define ATA__ATAPI_IDENTIFY 0xA1 +@@ -76,6 +79,8 @@ + #define ATA_AUTOACOUSTIC_DISABLE 0xC2 + #define ATA_APM_ENABLE 0x05 + #define ATA_APM_DISABLE 0x85 ++#define ATA_WC_ENABLE 0x02 ++#define ATA_WC_DISABLE 0x82 + #define ATA_AUTOACOUSTIC_MAXPERF 0xFE + #define ATA_AUTOACOUSTIC_MINPERF 0x80 + #define ATA_APM_MINPOWER_NO_STANDBY 0x80 +@@ -156,6 +161,7 @@ + ATA* ata_open(const char *device); + void ata_close(ATA *ata); + int ata_setidletimer(ATA *ata, uint32_t idle_mins); ++int ata_setwc(ATA *ata, int enable); + int ata_sleep(ATA *ata); + int ata_setstandbytimer(ATA *ata, uint32_t standby_mins); + int ata_setacoustic(ATA *ata, uint32_t acoustic_val); diff --git a/sysutils/ataidle/files/patch-mi_util.c b/sysutils/ataidle/files/patch-mi_util.c new file mode 100644 index 000000000000..39b3f5510460 --- /dev/null +++ b/sysutils/ataidle/files/patch-mi_util.c @@ -0,0 +1,102 @@ + +$FreeBSD$ + +--- mi/util.c ++++ mi/util.c +@@ -230,19 +230,19 @@ + printf("Model:\t\t\t%s\n", model); + printf("Serial:\t\t\t%s\n", serial); + printf("Firmware Rev:\t\t%s\n", firmware); +- ata_version = ata_getversionstring(buf[80]); ++ ata_version = ata_getversionstring(ident.version_major); + printf("ATA revision:\t\t%s\n", (ident.version_major > 1)? + ata_version : "unknown/pre ATA-2"); +- printf("LBA 48:\t\t\t%s\n", (buf[86] & 0x400)? "yes" : "no"); ++ printf("LBA 48:\t\t\t%s\n", (ident.cmd_enabled2 & 0x400)? "yes" : "no"); + printf("Geometry:\t\t%d cyls, %d heads, %d spt\n", +- buf[1], buf[3], buf[6]); ++ ident.word1, ident.word3, ident.word6); + + if (ata_version != NULL) + free(ata_version); + + mbsize = 0; + +- if (buf[86] & 0x400) ++ if (ident.cmd_enabled2 & 0x400) + { + mbsize = (((uint64_t)ident.max_lba48_address[0] + + ((uint64_t)ident.max_lba48_address[1] << 16) + +@@ -254,12 +254,14 @@ + mbsize = ((ident.nsect[0] + (ident.nsect[1] << 16))*512)/1048576; + } + +- bool smart_supported = buf[82] & ATA_SMART_SUPPORTED; +- bool smart_enabled = buf[85] & ATA_SMART_ENABLED; +- bool apm_supported = buf[83] & ATA_APM_SUPPORTED; +- bool apm_enabled = buf[86] & ATA_APM_ENABLED; +- bool aam_supported = buf[83] & ATA_AAM_SUPPORTED; +- bool aam_enabled = buf[86] & ATA_AAM_ENABLED; ++ bool smart_supported = ident.cmd_supp1 & ATA_SMART_SUPPORTED; ++ bool smart_enabled = ident.cmd_enabled1 & ATA_SMART_ENABLED; ++ bool wc_supported = ident.cmd_supp1 & ATA_WC_SUPPORTED; ++ bool wc_enabled = ident.cmd_enabled1 & ATA_WC_ENABLED; ++ bool apm_supported = ident.cmd_supp2 & ATA_APM_SUPPORTED; ++ bool apm_enabled = ident.cmd_enabled2 & ATA_APM_ENABLED; ++ bool aam_supported = ident.cmd_supp2 & ATA_AAM_SUPPORTED; ++ bool aam_enabled = ident.cmd_enabled2 & ATA_AAM_ENABLED; + + printf("Capacity:\t\t%u%s\n", (mbsize < 1024)? + mbsize : mbsize/1024, (mbsize < 1024)? "MB" : "GB"); +@@ -269,12 +271,17 @@ + if (smart_supported) + printf("SMART Enabled: \t\t%s\n", smart_enabled? "yes" : "no" ); + ++ printf("Write Cache Supported: \t%s\n", wc_supported? "yes" : "no" ); ++ ++ if (wc_supported) ++ printf("Write Cache Enabled: \t\t%s\n", wc_enabled? "yes" : "no" ); ++ + printf("APM Supported: \t\t%s\n", apm_supported? "yes" : "no" ); + + if (apm_supported) { + printf("APM Enabled: \t\t%s\n", apm_enabled? "yes" : "no" ); + if (apm_enabled) +- printf("APM Value: \t\t%d\n", buf[91]); ++ printf("APM Value: \t\t%d\n", ident.apm_value); + } + + printf("AAM Supported: \t\t%s\n", aam_supported? "yes" : "no" ); +@@ -282,9 +289,9 @@ + if (aam_supported) { + printf("AAM Enabled: \t\t%s\n", aam_enabled? "yes" : "no"); + if (aam_enabled) +- printf("AAM Value: \t\t%d\n", ((buf[94] & 0x00FF))-127); ++ printf("AAM Value: \t\t%d\n", ((ident.aam_value & 0x00FF))-127); + +- printf("Vendor Recommended AAM: %d\n", ((buf[94] & 0xFF00) >> 8)-127); ++ printf("Vendor Recommended AAM: %d\n", ((ident.aam_value & 0xFF00) >> 8)-127); + } + } + +@@ -345,6 +352,20 @@ + return rc; + } + ++int ++ata_setwc(ATA *ata, int enable) ++{ ++ int rc, cmd; ++ ++ /* allocate and initialize the ata_cmd structure */ ++ ata_init(ata); ++ cmd = enable ? ATA_WC_ENABLE : ATA_WC_DISABLE; ++ rc = ata_cmd(ata, ATA__SETFEATURES, cmd, 0); ++ if(rc) ++ perror("Failed to configure Write Cache"); ++ return rc; ++} ++ + /* + * Sets the acoustic level on modern hard drives. This is used to run it + * at a lower speed/performance level, which in turn reduces noise. diff --git a/sysutils/ataidle/pkg-descr b/sysutils/ataidle/pkg-descr index b6bd21a64d90..7b932f51ab86 100644 --- a/sysutils/ataidle/pkg-descr +++ b/sysutils/ataidle/pkg-descr @@ -1,7 +1,7 @@ -ATAidle is a utility to set the power management features -of ata hard drives. This includes standby timeouts, power (APM) -and acoustic (AAM) level settings, and it can show details about -the installed devices. +ATAidle is a utility to set the power management and performance +features of ATA hard drives. This includes standby timeouts, power +(APM) write cache and acoustic (AAM) level settings, and it can show +details about the installed devices. Author: Bruce Cran <bruce@cran.org.uk> WWW: http://www.cran.org.uk/bruce/software/ataidle/ |