forked from pool/hdparm
This commit is contained in:
parent
e73cb2b43b
commit
007924a4c6
@ -1,17 +0,0 @@
|
||||
--- hdparm.c
|
||||
+++ hdparm.c
|
||||
@@ -273,11 +273,10 @@
|
||||
void flush_buffer_cache (int fd)
|
||||
{
|
||||
fsync (fd); /* flush buffers */
|
||||
- if (ioctl(fd, BLKFLSBUF, NULL)) /* do it again, big time */
|
||||
- perror("BLKFLSBUF failed");
|
||||
+ ioctl(fd, BLKFLSBUF, NULL);
|
||||
/* await completion */
|
||||
- if (do_drive_cmd(fd, NULL) && errno != EINVAL && errno != ENOTTY && errno != ENOIOCTLCMD)
|
||||
- perror("HDIO_DRIVE_CMD(null) (wait for flush complete) failed");
|
||||
+ if (errno != EINVAL && errno != EOPNOTSUPP)
|
||||
+ do_drive_cmd(fd, NULL);
|
||||
}
|
||||
|
||||
int seek_to_zero (int fd)
|
@ -1,564 +0,0 @@
|
||||
--- hdparm.c
|
||||
+++ hdparm.c
|
||||
@@ -281,17 +281,20 @@
|
||||
}
|
||||
#endif
|
||||
rc = ioctl(fd, BLKGETSIZE, &blksize32); // returns sectors
|
||||
- if (rc)
|
||||
+ if (rc) {
|
||||
+ rc = errno;
|
||||
perror(" BLKGETSIZE failed");
|
||||
+ }
|
||||
*blksize64 = blksize32;
|
||||
return rc;
|
||||
}
|
||||
|
||||
-static void time_device (int fd)
|
||||
+static int time_device (int fd)
|
||||
{
|
||||
char *buf;
|
||||
double elapsed;
|
||||
struct itimerval e1, e2;
|
||||
+ int err = 0;
|
||||
unsigned int max_iterations = 1024, total_MB, iterations;
|
||||
|
||||
/*
|
||||
@@ -300,12 +303,12 @@
|
||||
if (do_ctimings || do_timings) {
|
||||
unsigned long long blksize;
|
||||
do_flush = 1;
|
||||
- if (0 == do_blkgetsize(fd, &blksize))
|
||||
+ if (0 == (err = do_blkgetsize(fd, &blksize)))
|
||||
max_iterations = blksize / (2 * 1024) / TIMING_BUF_MB;
|
||||
}
|
||||
buf = prepare_timing_buf(TIMING_BUF_BYTES);
|
||||
if (!buf)
|
||||
- return;
|
||||
+ return 1;
|
||||
|
||||
printf(" Timing %s disk reads: ", (open_flags & O_DIRECT) ? "O_DIRECT" : "buffered");
|
||||
fflush(stdout);
|
||||
@@ -338,6 +341,7 @@
|
||||
quit:
|
||||
munlockall();
|
||||
munmap(buf, TIMING_BUF_BYTES);
|
||||
+ return err;
|
||||
}
|
||||
|
||||
static void dmpstr (const char *prefix, unsigned int i, const char *s[], unsigned int maxi)
|
||||
@@ -789,21 +793,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
-static void flush_wcache (int fd, __u16 **id_p)
|
||||
+static int flush_wcache (int fd, __u16 **id_p)
|
||||
{
|
||||
__u8 args[4] = {ATA_OP_FLUSHCACHE,0,0,0};
|
||||
__u16 *id;
|
||||
+ int err = 0;
|
||||
|
||||
*id_p = id = get_identify_data(fd, *id_p);
|
||||
if (id && (id[83] & 0xe000) == 0x6000)
|
||||
args[0] = ATA_OP_FLUSHCACHE_EXT;
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror (" HDIO_DRIVE_CMD(flushcache) failed");
|
||||
+ }
|
||||
+ return err;
|
||||
}
|
||||
|
||||
void process_dev (char *devname)
|
||||
{
|
||||
- int fd;
|
||||
+ int fd, err = 0;
|
||||
static long parm, multcount;
|
||||
__u16 *id = (void *)-1;
|
||||
|
||||
@@ -819,14 +827,18 @@
|
||||
if (set_fsreadahead) {
|
||||
if (get_fsreadahead)
|
||||
printf(" setting fs readahead to %d\n", fsreadahead);
|
||||
- if (ioctl(fd, BLKRASET, fsreadahead))
|
||||
+ if (ioctl(fd, BLKRASET, fsreadahead)) {
|
||||
+ err = errno;
|
||||
perror(" BLKRASET failed");
|
||||
+ }
|
||||
}
|
||||
if (set_unregister) {
|
||||
if (get_unregister)
|
||||
printf(" attempting to unregister hwif#%u\n", hwif);
|
||||
- if (ioctl(fd, HDIO_UNREGISTER_HWIF, hwif))
|
||||
+ if (ioctl(fd, HDIO_UNREGISTER_HWIF, hwif)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_UNREGISTER_HWIF failed");
|
||||
+ }
|
||||
}
|
||||
if (scan_hwif) {
|
||||
int args[3];
|
||||
@@ -834,8 +846,10 @@
|
||||
args[0] = hwif_data;
|
||||
args[1] = hwif_ctrl;
|
||||
args[2] = hwif_irq;
|
||||
- if (ioctl(fd, HDIO_SCAN_HWIF, args))
|
||||
+ if (ioctl(fd, HDIO_SCAN_HWIF, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_SCAN_HWIF failed");
|
||||
+ }
|
||||
}
|
||||
if (set_piomode) {
|
||||
if (get_piomode) {
|
||||
@@ -848,68 +862,86 @@
|
||||
else
|
||||
printf(" attempting to set UDMA mode to %d\n", (piomode-200));
|
||||
}
|
||||
- if (ioctl(fd, HDIO_SET_PIO_MODE, piomode))
|
||||
+ if (ioctl(fd, HDIO_SET_PIO_MODE, piomode)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_SET_PIO_MODE failed");
|
||||
+ }
|
||||
}
|
||||
if (set_io32bit) {
|
||||
if (get_io32bit)
|
||||
printf(" setting 32-bit IO_support flag to %d\n", io32bit);
|
||||
- if (ioctl(fd, HDIO_SET_32BIT, io32bit))
|
||||
+ if (ioctl(fd, HDIO_SET_32BIT, io32bit)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_SET_32BIT failed");
|
||||
+ }
|
||||
}
|
||||
if (set_mult) {
|
||||
if (get_mult)
|
||||
printf(" setting multcount to %d\n", mult);
|
||||
- if (ioctl(fd, HDIO_SET_MULTCOUNT, mult))
|
||||
+ if (ioctl(fd, HDIO_SET_MULTCOUNT, mult)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_SET_MULTCOUNT failed");
|
||||
+ }
|
||||
}
|
||||
if (set_readonly) {
|
||||
if (get_readonly) {
|
||||
printf(" setting readonly to %d", readonly);
|
||||
on_off(readonly);
|
||||
}
|
||||
- if (ioctl(fd, BLKROSET, &readonly))
|
||||
+ if (ioctl(fd, BLKROSET, &readonly)) {
|
||||
+ err = errno;
|
||||
perror(" BLKROSET failed");
|
||||
+ }
|
||||
}
|
||||
if (set_unmask) {
|
||||
if (get_unmask) {
|
||||
printf(" setting unmaskirq to %d", unmask);
|
||||
on_off(unmask);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_SET_UNMASKINTR, unmask))
|
||||
+ if (ioctl(fd, HDIO_SET_UNMASKINTR, unmask)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_SET_UNMASKINTR failed");
|
||||
+ }
|
||||
}
|
||||
if (set_dma) {
|
||||
if (get_dma) {
|
||||
printf(" setting using_dma to %d", dma);
|
||||
on_off(dma);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_SET_DMA, dma))
|
||||
+ if (ioctl(fd, HDIO_SET_DMA, dma)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_SET_DMA failed");
|
||||
+ }
|
||||
}
|
||||
if (set_dma_q) {
|
||||
if (get_dma_q) {
|
||||
printf(" setting DMA queue_depth to %d", dma_q);
|
||||
on_off(dma_q);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_SET_QDMA, dma_q))
|
||||
+ if (ioctl(fd, HDIO_SET_QDMA, dma_q)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_SET_QDMA failed");
|
||||
+ }
|
||||
}
|
||||
if (set_nowerr) {
|
||||
if (get_nowerr) {
|
||||
printf(" setting nowerr to %d", nowerr);
|
||||
on_off(nowerr);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_SET_NOWERR, nowerr))
|
||||
+ if (ioctl(fd, HDIO_SET_NOWERR, nowerr)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_SET_NOWERR failed");
|
||||
+ }
|
||||
}
|
||||
if (set_keep) {
|
||||
if (get_keep) {
|
||||
printf(" setting keep_settings to %d", keep);
|
||||
on_off(keep);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_SET_KEEPSETTINGS, keep))
|
||||
+ if (ioctl(fd, HDIO_SET_KEEPSETTINGS, keep)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_SET_KEEPSETTINGS failed");
|
||||
+ }
|
||||
}
|
||||
if (set_doorlock) {
|
||||
__u8 args[4] = {0,0,0,0};
|
||||
@@ -918,8 +950,10 @@
|
||||
printf(" setting drive doorlock to %d", doorlock);
|
||||
on_off(doorlock);
|
||||
}
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(doorlock) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_dkeep) {
|
||||
/* lock/unlock the drive's "feature" settings */
|
||||
@@ -929,24 +963,30 @@
|
||||
on_off(dkeep);
|
||||
}
|
||||
args[2] = dkeep ? 0x66 : 0xcc;
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(keepsettings) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_defects) {
|
||||
__u8 args[4] = {ATA_OP_SETFEATURES,0,0x04,0};
|
||||
args[2] = defects ? 0x04 : 0x84;
|
||||
if (get_defects)
|
||||
printf(" setting drive defect management to %d\n", defects);
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(defectmgmt) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_prefetch) {
|
||||
__u8 args[4] = {ATA_OP_SETFEATURES,0,0xab,0};
|
||||
args[1] = prefetch;
|
||||
if (get_prefetch)
|
||||
printf(" setting drive prefetch to %d\n", prefetch);
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(setprefetch) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_xfermode) {
|
||||
__u8 args[4] = {ATA_OP_SETFEATURES,0,3,0};
|
||||
@@ -955,8 +995,10 @@
|
||||
printf(" setting xfermode to %d", xfermode_requested);
|
||||
interpret_xfermode(xfermode_requested);
|
||||
}
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(setxfermode) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_lookahead) {
|
||||
__u8 args[4] = {ATA_OP_SETFEATURES,0,0,0};
|
||||
@@ -965,8 +1007,10 @@
|
||||
printf(" setting drive read-lookahead to %d", lookahead);
|
||||
on_off(lookahead);
|
||||
}
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(setreadahead) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_powerup_in_standby) {
|
||||
__u8 args[4] = {ATA_OP_SETFEATURES,0,0,0};
|
||||
@@ -1004,14 +1048,18 @@
|
||||
if (get_apmmode)
|
||||
printf(" 0x%02x (%d)\n",apmmode,apmmode);
|
||||
}
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD failed");
|
||||
+ }
|
||||
}
|
||||
if (set_cdromspeed) {
|
||||
if (get_cdromspeed)
|
||||
printf ("setting cdrom speed to %d\n", cdromspeed);
|
||||
- if (ioctl (fd, CDROM_SELECT_SPEED, cdromspeed))
|
||||
+ if (ioctl (fd, CDROM_SELECT_SPEED, cdromspeed)) {
|
||||
+ err = errno;
|
||||
perror(" CDROM_SELECT_SPEED failed");
|
||||
+ }
|
||||
}
|
||||
if (set_acoustic) {
|
||||
__u8 args[4];
|
||||
@@ -1021,8 +1069,10 @@
|
||||
args[1] = acoustic;
|
||||
args[2] = acoustic ? 0x42 : 0xc2;
|
||||
args[3] = 0;
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD:ACOUSTIC failed");
|
||||
+ }
|
||||
}
|
||||
if (set_wcache) {
|
||||
if (get_wcache) {
|
||||
@@ -1030,15 +1080,17 @@
|
||||
on_off(wcache);
|
||||
}
|
||||
if (!wcache)
|
||||
- flush_wcache(fd, &id);
|
||||
+ err = flush_wcache(fd, &id);
|
||||
if (ioctl(fd, HDIO_SET_WCACHE, wcache)) {
|
||||
__u8 setcache[4] = {ATA_OP_SETFEATURES,0,0,0};
|
||||
setcache[2] = wcache ? 0x02 : 0x82;
|
||||
- if (do_drive_cmd(fd, setcache))
|
||||
+ if (do_drive_cmd(fd, setcache)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(setcache) failed");
|
||||
+ }
|
||||
}
|
||||
if (!wcache)
|
||||
- flush_wcache(fd, &id);
|
||||
+ err = flush_wcache(fd, &id);
|
||||
}
|
||||
if (set_standbynow) {
|
||||
__u8 args1[4] = {ATA_OP_STANDBYNOW1,0,0,0};
|
||||
@@ -1046,8 +1098,10 @@
|
||||
if (get_standbynow)
|
||||
printf(" issuing standby command\n");
|
||||
if (do_drive_cmd(fd, args1)
|
||||
- && do_drive_cmd(fd, args2))
|
||||
+ && do_drive_cmd(fd, args2)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(standby) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_sleepnow) {
|
||||
__u8 args1[4] = {ATA_OP_SLEEPNOW1,0,0,0};
|
||||
@@ -1055,8 +1109,10 @@
|
||||
if (get_sleepnow)
|
||||
printf(" issuing sleep command\n");
|
||||
if (do_drive_cmd(fd, args1)
|
||||
- && do_drive_cmd(fd, args2))
|
||||
+ && do_drive_cmd(fd, args2)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(sleep) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_security) {
|
||||
do_set_security(fd);
|
||||
@@ -1064,15 +1120,19 @@
|
||||
if (set_freeze) {
|
||||
__u8 args[4] = {ATA_OP_SECURITY_FREEZE_LOCK,0,0,0};
|
||||
printf(" issuing Security Freeze command\n");
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(freeze) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_seagate) {
|
||||
__u8 args[4] = {0xfb,0,0,0};
|
||||
if (get_seagate)
|
||||
printf(" disabling Seagate auto powersaving mode\n");
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(seagatepwrsave) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_standby) {
|
||||
__u8 args[4] = {ATA_OP_SETIDLE1,standby,0,0};
|
||||
@@ -1080,14 +1140,18 @@
|
||||
printf(" setting standby to %u", standby);
|
||||
interpret_standby();
|
||||
}
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(setidle1) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_busstate) {
|
||||
if (get_busstate)
|
||||
printf(" setting bus state to %d (%s)\n", busstate, busstate_str(busstate));
|
||||
- if (ioctl(fd, HDIO_SET_BUSSTATE, busstate))
|
||||
+ if (ioctl(fd, HDIO_SET_BUSSTATE, busstate)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_SET_BUSSTATE failed");
|
||||
+ }
|
||||
}
|
||||
if (do_drq_hsm_error) {
|
||||
id = get_identify_data(fd, id);
|
||||
@@ -1143,12 +1207,18 @@
|
||||
break;
|
||||
default:printf("\?\?\?)\n");
|
||||
}
|
||||
+ } else {
|
||||
+ err = errno;
|
||||
+ perror(" HDIO_GET_32BIT failed");
|
||||
}
|
||||
}
|
||||
if (do_defaults || get_unmask) {
|
||||
if (0 == ioctl(fd, HDIO_GET_UNMASKINTR, &parm)) {
|
||||
printf(" unmaskirq = %2ld", parm);
|
||||
on_off(parm);
|
||||
+ } else {
|
||||
+ err = errno;
|
||||
+ perror(" HDIO_GET_UNMASKINTR failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1159,6 +1229,9 @@
|
||||
printf(" (DMA-Assisted-PIO)\n");
|
||||
else
|
||||
on_off(parm);
|
||||
+ } else {
|
||||
+ err = errno;
|
||||
+ perror(" HDIO_GET_DMA failed");
|
||||
}
|
||||
}
|
||||
if (get_dma_q) {
|
||||
@@ -1173,28 +1246,34 @@
|
||||
if (0 == ioctl(fd, HDIO_GET_KEEPSETTINGS, &parm)) {
|
||||
printf(" keepsettings = %2ld", parm);
|
||||
on_off(parm);
|
||||
+ } else {
|
||||
+ err = errno;
|
||||
+ perror(" HDIO_GET_KEEPSETTINGS failed");
|
||||
}
|
||||
}
|
||||
if (get_nowerr) {
|
||||
- if (ioctl(fd, HDIO_GET_NOWERR, &parm))
|
||||
+ if (ioctl(fd, HDIO_GET_NOWERR, &parm)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_GET_NOWERR failed");
|
||||
- else {
|
||||
+ } else {
|
||||
printf(" nowerr = %2ld", parm);
|
||||
on_off(parm);
|
||||
}
|
||||
}
|
||||
if (do_defaults || get_readonly) {
|
||||
- if (ioctl(fd, BLKROGET, &parm))
|
||||
+ if (ioctl(fd, BLKROGET, &parm)) {
|
||||
+ err = errno;
|
||||
perror(" BLKROGET failed");
|
||||
- else {
|
||||
+ } else {
|
||||
printf(" readonly = %2ld", parm);
|
||||
on_off(parm);
|
||||
}
|
||||
}
|
||||
if (do_defaults || get_fsreadahead) {
|
||||
- if (ioctl(fd, BLKRAGET, &parm))
|
||||
+ if (ioctl(fd, BLKRAGET, &parm)) {
|
||||
+ err = errno;
|
||||
perror(" BLKRAGET failed");
|
||||
- else {
|
||||
+ } else {
|
||||
printf(" readahead = %2ld", parm);
|
||||
on_off(parm);
|
||||
}
|
||||
@@ -1209,12 +1288,13 @@
|
||||
static struct hd_geometry g;
|
||||
static struct local_hd_big_geometry bg;
|
||||
|
||||
- if (0 == do_blkgetsize(fd, &blksize)) {
|
||||
+ if (0 == (err = do_blkgetsize(fd, &blksize))) {
|
||||
if (!ioctl(fd, HDIO_GETGEO_BIG, &bg))
|
||||
printf(msg, bg.cylinders, bg.heads, bg.sectors, blksize, bg.start);
|
||||
- else if (ioctl(fd, HDIO_GETGEO, &g))
|
||||
+ else if (ioctl(fd, HDIO_GETGEO, &g)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_GETGEO failed");
|
||||
- else
|
||||
+ } else
|
||||
printf(msg, g.cylinders, g.heads, g.sectors, blksize, g.start);
|
||||
}
|
||||
}
|
||||
@@ -1223,9 +1303,10 @@
|
||||
const char *state;
|
||||
if (do_drive_cmd(fd, args)
|
||||
&& (args[0] = ATA_OP_CHECKPOWERMODE2) /* (single =) try again with 0x98 */
|
||||
- && do_drive_cmd(fd, args))
|
||||
+ && do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
state = "unknown";
|
||||
- else
|
||||
+ } else
|
||||
state = (args[2] == 255) ? "active/idle" : "standby";
|
||||
printf(" drive state is: %s\n", state);
|
||||
}
|
||||
@@ -1240,8 +1321,10 @@
|
||||
dump_identity(id2);
|
||||
} else if (errno == -ENOMSG)
|
||||
printf(" no identification info available\n");
|
||||
- else
|
||||
+ else {
|
||||
+ err = errno;
|
||||
perror(" HDIO_GET_IDENTITY failed");
|
||||
+ }
|
||||
}
|
||||
if (do_IDentity) {
|
||||
id = get_identify_data(fd, id);
|
||||
@@ -1294,41 +1377,48 @@
|
||||
}
|
||||
}
|
||||
if (get_busstate) {
|
||||
- if (ioctl(fd, HDIO_GET_BUSSTATE, &parm))
|
||||
+ if (ioctl(fd, HDIO_GET_BUSSTATE, &parm)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_GET_BUSSTATE failed");
|
||||
- else
|
||||
+ } else
|
||||
printf(" busstate = %2ld (%s)\n", parm, busstate_str(parm));
|
||||
}
|
||||
|
||||
if (do_ctimings)
|
||||
time_cache(fd);
|
||||
if (do_flush_wcache)
|
||||
- flush_wcache(fd, &id);
|
||||
+ err = flush_wcache(fd, &id);
|
||||
if (do_timings)
|
||||
- time_device(fd);
|
||||
+ err = time_device(fd);
|
||||
if (do_flush)
|
||||
flush_buffer_cache(fd);
|
||||
if (set_reread_partn) {
|
||||
if (get_reread_partn)
|
||||
printf(" re-reading partition table\n");
|
||||
if (ioctl(fd, BLKRRPART, NULL)) {
|
||||
+ err = errno;
|
||||
perror(" BLKRRPART failed");
|
||||
}
|
||||
}
|
||||
if (set_doreset) {
|
||||
if (get_doreset)
|
||||
printf(" resetting drive\n");
|
||||
- if (ioctl(fd, HDIO_DRIVE_RESET, NULL))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_RESET, NULL)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_RESET failed");
|
||||
+ }
|
||||
}
|
||||
if (set_tristate) {
|
||||
__u8 args[4] = {0,tristate,0,0};
|
||||
if (get_tristate)
|
||||
printf(" setting tri-state to %d\n", tristate);
|
||||
- if (ioctl(fd, HDIO_TRISTATE_HWIF, &args))
|
||||
+ if (ioctl(fd, HDIO_TRISTATE_HWIF, &args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_TRISTATE_HWIF failed");
|
||||
+ }
|
||||
}
|
||||
close (fd);
|
||||
+ exit (err);
|
||||
}
|
||||
|
||||
static void usage_help (int rc)
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b675010e4b25481e85c94f5523c5070cc330e040ae349618f33a8f0bf4c4cba2
|
||||
size 56947
|
10
hdparm-8.4-nostrip.patch
Normal file
10
hdparm-8.4-nostrip.patch
Normal file
@ -0,0 +1,10 @@
|
||||
--- Makefile
|
||||
+++ Makefile
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
hdparm: hdparm.h sgio.h $(OBJS)
|
||||
$(CC) $(LDFLAGS) -o hdparm $(OBJS)
|
||||
- strip hdparm
|
||||
|
||||
sgio.o: sgio.h
|
||||
|
24
hdparm-8.4-silence.patch
Normal file
24
hdparm-8.4-silence.patch
Normal file
@ -0,0 +1,24 @@
|
||||
--- hdparm.c 2008-02-19 19:55:28.000000000 -0500
|
||||
+++ hdparm.c 2008-02-20 10:35:43.000000000 -0500
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
extern const char *minor_str[];
|
||||
|
||||
-#define VERSION "v8.4"
|
||||
+#define VERSION "v8.4+"
|
||||
|
||||
#ifndef O_DIRECT
|
||||
#define O_DIRECT 040000 /* direct disk access, not easily obtained from headers */
|
||||
@@ -159,10 +159,8 @@
|
||||
sync();
|
||||
if (ioctl(fd, BLKFLSBUF, NULL)) /* do it again, big time */
|
||||
perror("BLKFLSBUF failed");
|
||||
- sync();
|
||||
- /* await completion */
|
||||
- if (do_drive_cmd(fd, NULL) && errno != EINVAL && errno != ENOTTY && errno != ENOIOCTLCMD)
|
||||
- perror("HDIO_DRIVE_CMD(null) (wait for flush complete) failed");
|
||||
+ else
|
||||
+ do_drive_cmd(fd, NULL); /* IDE: await completion */
|
||||
sync();
|
||||
}
|
||||
|
3
hdparm-8.4.tar.bz2
Normal file
3
hdparm-8.4.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:cf5d3b77ba8b4304c0f077e563ebbe8944d105ef917823297f00e648eebb6cde
|
||||
size 62883
|
@ -1,3 +1,58 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Feb 20 17:03:41 CET 2008 - lmichnovic@suse.cz
|
||||
|
||||
- *silence.patch changed after discussion with author
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Feb 20 11:50:59 CET 2008 - lmichnovic@suse.cz
|
||||
|
||||
- update to 8.4
|
||||
* Changes since 8.3
|
||||
- Fix --write-sector breakage from v8.3
|
||||
* Changes since 8.2
|
||||
- fixed -i display for udma6
|
||||
- try and exit with errno on fail paths, from Ladislav Michnovic
|
||||
obsoletes *err_return.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Feb 19 17:52:13 CET 2008 - lmichnovic@suse.cz
|
||||
|
||||
- rewritten *silence.patch, *err_return.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Feb 19 11:13:20 CET 2008 - lmichnovic@suse.cz
|
||||
|
||||
- update to version 8.2
|
||||
- Fixed sector ops (and other stuff) to work with non-libata IDE
|
||||
driver again.
|
||||
* Changes since 8.1
|
||||
- clear feat register for safety with SET_MAX_ADDRESS command
|
||||
- add note to manpage regarding possible -N transient failures
|
||||
- IDE_TASKFILE bug fixes and cleanups: works with old IDE driver
|
||||
- fix misreporting of dma modes on some SATA-ATAPI bridged drives
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Feb 18 13:17:15 CET 2008 - lmichnovic@suse.cz
|
||||
|
||||
- update to version 8.1
|
||||
* Changes since 8.0
|
||||
- fixed -U parameter bug
|
||||
- added ATA8 minor revision info to -I, courtesy of chrfranke
|
||||
- added WorldWideNumber to -I, courtesy of Raksac
|
||||
* Changes since 7.7
|
||||
- added --make-bad-sector to deliberately create a media error
|
||||
- added --write-sector (aka. --repair-sector) to repair a media
|
||||
error
|
||||
- added --read-sector to test for a media error
|
||||
- Makefile dependency tweaks
|
||||
- added -N (get/set max address/HPA) flag
|
||||
- fixed LBAsects output from -i to use LBA48 values when
|
||||
available
|
||||
- fixed alternate opcode for SLEEPNOW
|
||||
- lots of changes/fixes to sgio.c to support more commands
|
||||
- add detection of buggy Sandisk 16MB CF card
|
||||
- fixed tf_to_lba() bug, courtesy of Jakub Bogusz
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Nov 30 15:48:58 CET 2007 - ro@suse.de
|
||||
|
||||
|
143
hdparm.spec
143
hdparm.spec
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package hdparm (Version 7.7)
|
||||
# spec file for package hdparm (Version 8.4)
|
||||
#
|
||||
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# This file and all modifications and additions to the pristine
|
||||
# package are under the same license as the package itself.
|
||||
#
|
||||
@ -10,22 +10,22 @@
|
||||
|
||||
# norootforbuild
|
||||
|
||||
|
||||
Name: hdparm
|
||||
License: Any permissive
|
||||
Group: Hardware/Other
|
||||
PreReq: %insserv_prereq %fillup_prereq coreutils
|
||||
Provides: base:/sbin/hdparm
|
||||
AutoReqProv: on
|
||||
Version: 7.7
|
||||
Release: 18
|
||||
Version: 8.4
|
||||
Release: 1
|
||||
Summary: A Program to Get and Set Hard Disk Parameters
|
||||
Source: hdparm-%{version}.tar.bz2
|
||||
Source1: 56-idedma.rules
|
||||
Source2: sysconfig.ide
|
||||
Source3: udev.idedma.sh
|
||||
Patch: hdparm-7.6-err_return.patch
|
||||
Patch1: hdparm-5.8-silence.patch
|
||||
Patch2: nostrip.patch
|
||||
Patch1: hdparm-8.4-silence.patch
|
||||
Patch2: hdparm-8.4-nostrip.patch
|
||||
Url: http://sourceforge.net/projects/hdparm/
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
|
||||
@ -41,7 +41,6 @@ Authors:
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch
|
||||
%patch1
|
||||
%patch2
|
||||
|
||||
@ -112,49 +111,89 @@ fi
|
||||
/var/adm/fillup-templates/sysconfig.ide
|
||||
|
||||
%changelog
|
||||
* Fri Nov 30 2007 - ro@suse.de
|
||||
* Wed Feb 20 2008 lmichnovic@suse.cz
|
||||
- *silence.patch changed after discussion with author
|
||||
* Wed Feb 20 2008 lmichnovic@suse.cz
|
||||
- update to 8.4
|
||||
* Changes since 8.3
|
||||
- Fix --write-sector breakage from v8.3
|
||||
* Changes since 8.2
|
||||
- fixed -i display for udma6
|
||||
- try and exit with errno on fail paths, from Ladislav Michnovic
|
||||
obsoletes *err_return.patch
|
||||
* Tue Feb 19 2008 lmichnovic@suse.cz
|
||||
- rewritten *silence.patch, *err_return.patch
|
||||
* Tue Feb 19 2008 lmichnovic@suse.cz
|
||||
- update to version 8.2
|
||||
- Fixed sector ops (and other stuff) to work with non-libata IDE
|
||||
driver again.
|
||||
* Changes since 8.1
|
||||
- clear feat register for safety with SET_MAX_ADDRESS command
|
||||
- add note to manpage regarding possible -N transient failures
|
||||
- IDE_TASKFILE bug fixes and cleanups: works with old IDE driver
|
||||
- fix misreporting of dma modes on some SATA-ATAPI bridged drives
|
||||
* Mon Feb 18 2008 lmichnovic@suse.cz
|
||||
- update to version 8.1
|
||||
* Changes since 8.0
|
||||
- fixed -U parameter bug
|
||||
- added ATA8 minor revision info to -I, courtesy of chrfranke
|
||||
- added WorldWideNumber to -I, courtesy of Raksac
|
||||
* Changes since 7.7
|
||||
- added --make-bad-sector to deliberately create a media error
|
||||
- added --write-sector (aka. --repair-sector) to repair a media
|
||||
error
|
||||
- added --read-sector to test for a media error
|
||||
- Makefile dependency tweaks
|
||||
- added -N (get/set max address/HPA) flag
|
||||
- fixed LBAsects output from -i to use LBA48 values when
|
||||
available
|
||||
- fixed alternate opcode for SLEEPNOW
|
||||
- lots of changes/fixes to sgio.c to support more commands
|
||||
- add detection of buggy Sandisk 16MB CF card
|
||||
- fixed tf_to_lba() bug, courtesy of Jakub Bogusz
|
||||
* Fri Nov 30 2007 ro@suse.de
|
||||
- added sd* to udev rule (#340039)
|
||||
* Fri Aug 10 2007 - ro@suse.de
|
||||
* Fri Aug 10 2007 ro@suse.de
|
||||
- update to 7.7
|
||||
- fixed bug whereby old data was shown after settings changed (eg. with -W0)
|
||||
- removed old notes about a "correction factor" from man page -tT descriptions
|
||||
- retry open with O_RDONLY if O_RDWR fails with errno==EROFS
|
||||
* Wed Jun 20 2007 - ro@suse.de
|
||||
* Wed Jun 20 2007 ro@suse.de
|
||||
- update to 7.6
|
||||
- added -F flag to flush on-drive write cache buffer
|
||||
- replaced use of shm* functions with of mmap()/mlock()
|
||||
- removed gcc -Wextra flag --> unsupported on Debian Sarge
|
||||
- re-allow use of --security-freeze in combination with other flags
|
||||
* Fri Jun 08 2007 - ro@suse.de
|
||||
* Fri Jun 08 2007 ro@suse.de
|
||||
- update to 7.5
|
||||
- beef up warnings for -s1 flag, as people seem to be ignoring them
|
||||
* Fri Jun 01 2007 - ro@suse.de
|
||||
* Fri Jun 01 2007 ro@suse.de
|
||||
- update to 7.4
|
||||
- ignore ENOTTY response from DRIVE_CMD(NULL)
|
||||
- decode CFA advanced timing information
|
||||
* Thu May 24 2007 - schwab@suse.de
|
||||
* Thu May 24 2007 schwab@suse.de
|
||||
- fix_standby is x86-only.
|
||||
* Wed May 16 2007 - ro@suse.de
|
||||
* Wed May 16 2007 ro@suse.de
|
||||
- fix lint problems
|
||||
- install contrib scripts to /usr/lib/hdparm
|
||||
- mark udev file as config
|
||||
- fix permissions for fillup-template
|
||||
* Tue May 01 2007 - schwab@suse.de
|
||||
* Tue May 01 2007 schwab@suse.de
|
||||
- Don't strip binaries.
|
||||
* Mon Apr 30 2007 - ro@suse.de
|
||||
* Mon Apr 30 2007 ro@suse.de
|
||||
- update to 7.3
|
||||
- fixed spelling of --drq-hsm-error in -h output
|
||||
- fixed SG_IO CDB[2] bits for better SAT compliance
|
||||
- fixed version number (v7.2 has "7.1" as version, doh!)
|
||||
- added #ifdef around use of BLKGETSIZE64
|
||||
- manpage updated
|
||||
* Sun Apr 29 2007 - ro@suse.de
|
||||
* Sun Apr 29 2007 ro@suse.de
|
||||
- update to 7.2
|
||||
- tweak -C
|
||||
- added more debug info from --verbose
|
||||
- added --drq-hsm-error to test libata EH (VERY DANGEROUS, do not use)
|
||||
- fixed breakage when used with old IDE driver
|
||||
* Sun Apr 29 2007 - ro@suse.de
|
||||
* Sun Apr 29 2007 ro@suse.de
|
||||
- update to 7.1
|
||||
- big-endian fixes for -I, --Istdin, --Istdout
|
||||
- cody tidying in sgio.c
|
||||
@ -177,7 +216,7 @@ fi
|
||||
- enhanced query acoustic (-M)
|
||||
- added kernel_patches directory with patches for ATAPI support
|
||||
- disable acoustic patch (surrounding code changed)
|
||||
* Sat Oct 28 2006 - aj@suse.de
|
||||
* Sat Oct 28 2006 aj@suse.de
|
||||
- Update to version 6.9, changes since 6.6 are:
|
||||
* added -s flag to control power-up in standby
|
||||
* make --Istdin more robust
|
||||
@ -192,87 +231,87 @@ fi
|
||||
* tidied up usage of prefix vars in Makefile
|
||||
* fix bug in -C implementation
|
||||
* new -H flag for (Hitachi) drive temperature
|
||||
* Mon Jun 12 2006 - ro@suse.de
|
||||
* Mon Jun 12 2006 ro@suse.de
|
||||
- update to version 6.6
|
||||
- manpage updates / corrections.
|
||||
- fixed bug in -C code.
|
||||
- major updates to bring -I information up to current specs.
|
||||
* Mon May 22 2006 - schwab@suse.de
|
||||
* Mon May 22 2006 schwab@suse.de
|
||||
- Don't strip binaries.
|
||||
* Wed Jan 25 2006 - mls@suse.de
|
||||
* Wed Jan 25 2006 mls@suse.de
|
||||
- converted neededforbuild to BuildRequires
|
||||
* Wed Nov 30 2005 - ro@suse.de
|
||||
* Wed Nov 30 2005 ro@suse.de
|
||||
- moved udev helper script to /lib/udev
|
||||
* Tue Oct 25 2005 - ro@suse.de
|
||||
* Tue Oct 25 2005 ro@suse.de
|
||||
- update to version 6.3
|
||||
* Fri Oct 07 2005 - ro@suse.de
|
||||
* Fri Oct 07 2005 ro@suse.de
|
||||
- added udev rule 56-idedma.rules
|
||||
- moved sysconfig/ide from aaa_base to this package
|
||||
(and all the legacy postinstall code with it)
|
||||
* Mon Apr 18 2005 - ro@suse.de
|
||||
* Mon Apr 18 2005 ro@suse.de
|
||||
- update to 6.1
|
||||
* Tue Mar 08 2005 - ro@suse.de
|
||||
* Tue Mar 08 2005 ro@suse.de
|
||||
- use HDIO_SET_ACOUSTIC
|
||||
* Fri Feb 11 2005 - ro@suse.de
|
||||
* Fri Feb 11 2005 ro@suse.de
|
||||
- update to 5.9
|
||||
* Wed Feb 02 2005 - ro@suse.de
|
||||
* Wed Feb 02 2005 ro@suse.de
|
||||
- fix set acoustic (#48595)
|
||||
* Fri Nov 05 2004 - ro@suse.de
|
||||
* Fri Nov 05 2004 ro@suse.de
|
||||
- update to 5.8
|
||||
- remove-dup-swap.patch has been merged upstream
|
||||
* Thu Oct 21 2004 - ro@suse.de
|
||||
* Thu Oct 21 2004 ro@suse.de
|
||||
- silence errors for BLKFLSBUF (#45057)
|
||||
* Tue Oct 12 2004 - ro@suse.de
|
||||
* Tue Oct 12 2004 ro@suse.de
|
||||
- added contrib files to doc (#47105)
|
||||
* Sun Sep 05 2004 - ro@suse.de
|
||||
* Sun Sep 05 2004 ro@suse.de
|
||||
- update to 5.7
|
||||
- removed obsolete lvm patch
|
||||
- recreated err_return patch again
|
||||
* Tue Aug 17 2004 - ro@suse.de
|
||||
* Tue Aug 17 2004 ro@suse.de
|
||||
- update to 5.6
|
||||
- recreated err_return patch
|
||||
- readahead.patch is obsolete
|
||||
* Wed May 12 2004 - meissner@suse.de
|
||||
* Wed May 12 2004 meissner@suse.de
|
||||
- Removed duplicated byte swapping on big endian, it
|
||||
is no longer needed. (SUSE#39628/LTC#7961)
|
||||
* Tue Feb 03 2004 - ro@suse.de
|
||||
* Tue Feb 03 2004 ro@suse.de
|
||||
- update to hdparm-5.5
|
||||
- added limited support for SCSI(-controlled) CDROM/optical drives
|
||||
* Tue Jan 27 2004 - ro@suse.de
|
||||
* Tue Jan 27 2004 ro@suse.de
|
||||
- rename variable readahead (glibc using this as a function)
|
||||
* Thu Nov 06 2003 - ro@suse.de
|
||||
* Thu Nov 06 2003 ro@suse.de
|
||||
- added README.acoustic (#32917)
|
||||
* Mon Oct 20 2003 - ro@suse.de
|
||||
* Mon Oct 20 2003 ro@suse.de
|
||||
- use defattr
|
||||
- don't build as root
|
||||
* Sun Jul 06 2003 - ro@suse.de
|
||||
* Sun Jul 06 2003 ro@suse.de
|
||||
- update to 5.4 with new timing code
|
||||
* Tue Jun 03 2003 - olh@suse.de
|
||||
* Wed Jun 04 2003 olh@suse.de
|
||||
- add hdparm-5.3-dump_identity-endian.dif
|
||||
do not swap the id->cur_capacity0/1 values in userland
|
||||
* Mon May 12 2003 - ro@suse.de
|
||||
* Mon May 12 2003 ro@suse.de
|
||||
- define LVM_BLK_MAJOR if not defined
|
||||
* Wed Mar 26 2003 - ro@suse.de
|
||||
* Wed Mar 26 2003 ro@suse.de
|
||||
- fix timing test for large disks (#25861)
|
||||
* Wed Mar 12 2003 - ro@suse.de
|
||||
* Wed Mar 12 2003 ro@suse.de
|
||||
- added patch to return an error for most failed ioctls
|
||||
(not all, because cdroms always fail for e.g. HDIO_GETGEO)
|
||||
* Wed Nov 27 2002 - ro@suse.de
|
||||
* Wed Nov 27 2002 ro@suse.de
|
||||
- update (v5.3 endian fixes, other stuff)
|
||||
* Thu Aug 01 2002 - ro@suse.de
|
||||
* Thu Aug 01 2002 ro@suse.de
|
||||
- update to 5.2
|
||||
. updated -Q to take queue depth as parameter value
|
||||
. formatting fixes for -I from various people
|
||||
. updated -I to most recent ATA6 draft standard
|
||||
. various compile fixes
|
||||
* Thu Apr 25 2002 - ro@suse.de
|
||||
* Thu Apr 25 2002 ro@suse.de
|
||||
- added patch from axboe to make TCQ work
|
||||
* Thu Apr 25 2002 - ro@suse.de
|
||||
* Thu Apr 25 2002 ro@suse.de
|
||||
- up to vanilla hdparm-4.7
|
||||
- use buildroot
|
||||
* Tue Sep 04 2001 - ro@suse.de
|
||||
* Tue Sep 04 2001 ro@suse.de
|
||||
- update to 4.1 (mostly merged changes from andre's patch)
|
||||
* Thu Mar 22 2001 - ro@suse.de
|
||||
* Thu Mar 22 2001 ro@suse.de
|
||||
- added split-aliases as provides
|
||||
* Thu Mar 15 2001 - ro@suse.de
|
||||
* Thu Mar 15 2001 ro@suse.de
|
||||
- split from base
|
||||
|
@ -1,10 +0,0 @@
|
||||
--- Makefile
|
||||
+++ Makefile
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
hdparm: hdparm.h $(OBJS)
|
||||
$(CC) $(LDFLAGS) -o hdparm $(OBJS)
|
||||
- strip hdparm
|
||||
|
||||
install: all hdparm.8
|
||||
if [ ! -z $(DESTDIR) ]; then $(INSTALL_DIR) $(DESTDIR) ; fi
|
Loading…
x
Reference in New Issue
Block a user