forked from pool/hdparm
This commit is contained in:
parent
0594fc5df2
commit
60ffb71f7c
@ -1,17 +1,16 @@
|
||||
--- hdparm.c
|
||||
+++ hdparm.c
|
||||
@@ -292,11 +292,10 @@
|
||||
@@ -269,10 +269,9 @@
|
||||
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); /* do it again, big time */
|
||||
#ifdef HDIO_DRIVE_CMD
|
||||
- if (ioctl(fd, HDIO_DRIVE_CMD, NULL) && errno != EINVAL) /* await completion */
|
||||
- if (do_drive_cmd(fd, NULL) && errno != EINVAL) /* await completion */
|
||||
- perror("HDIO_DRIVE_CMD(null) (wait for flush complete) failed");
|
||||
+ ioctl(fd, BLKFLSBUF, NULL); /* do it again, big time */
|
||||
+ if (errno != EINVAL && errno != EOPNOTSUPP)
|
||||
+ ioctl(fd, HDIO_DRIVE_CMD, NULL);/* await completion */
|
||||
#endif
|
||||
+ do_drive_cmd(fd, NULL); /* await completion */
|
||||
}
|
||||
|
||||
int seek_to_zero (int fd)
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- hdparm.c
|
||||
+++ hdparm.c
|
||||
@@ -446,18 +446,20 @@
|
||||
@@ -401,18 +401,20 @@
|
||||
return 0;
|
||||
}
|
||||
rc = ioctl(fd, BLKGETSIZE, &blksize32); // returns sectors
|
||||
@ -23,11 +23,11 @@
|
||||
+ int shmid, err = 0;
|
||||
unsigned int max_iterations = 1024, total_MB, iterations;
|
||||
|
||||
//
|
||||
@@ -465,23 +467,26 @@
|
||||
//
|
||||
/*
|
||||
@@ -421,23 +423,26 @@
|
||||
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;
|
||||
@ -55,7 +55,7 @@
|
||||
}
|
||||
if (shmctl(shmid, IPC_RMID, NULL) == -1)
|
||||
perror ("shmctl(,IPC_RMID,) failed");
|
||||
@@ -521,6 +526,7 @@
|
||||
@@ -477,6 +482,7 @@
|
||||
quit:
|
||||
if (-1 == shmdt(buf))
|
||||
perror ("could not detach sharedmem buf");
|
||||
@ -63,37 +63,37 @@
|
||||
}
|
||||
|
||||
static void on_off (unsigned int value)
|
||||
@@ -707,7 +713,7 @@
|
||||
@@ -780,7 +786,7 @@
|
||||
|
||||
void process_dev (char *devname)
|
||||
{
|
||||
- int fd;
|
||||
+ int fd, err = 0;
|
||||
static long parm, multcount;
|
||||
#ifndef HDIO_DRIVE_CMD
|
||||
int force_operation = 0;
|
||||
@@ -724,14 +730,18 @@
|
||||
__u16 *id = (void *)-1;
|
||||
|
||||
@@ -796,14 +802,18 @@
|
||||
if (set_fsreadahead) {
|
||||
if (get_fsreadahead)
|
||||
printf(" setting fs readahead to %ld\n", fsreadahead);
|
||||
printf(" setting fs readahead to %d\n", fsreadahead);
|
||||
- if (ioctl(fd, BLKRASET, fsreadahead))
|
||||
+ if (ioctl(fd, BLKRASET, fsreadahead)) {
|
||||
+ err = errno;
|
||||
perror(" BLKRASET failed");
|
||||
+ }
|
||||
}
|
||||
#ifdef HDIO_UNREGISTER_HWIF
|
||||
if (unregister_hwif) {
|
||||
printf(" attempting to unregister hwif#%u\n", hwif);
|
||||
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");
|
||||
+ }
|
||||
}
|
||||
#endif
|
||||
#ifdef HDIO_SCAN_HWIF
|
||||
@@ -741,8 +751,10 @@
|
||||
if (scan_hwif) {
|
||||
int args[3];
|
||||
@@ -811,8 +821,10 @@
|
||||
args[0] = hwif_data;
|
||||
args[1] = hwif_ctrl;
|
||||
args[2] = hwif_irq;
|
||||
@ -103,9 +103,9 @@
|
||||
perror(" HDIO_SCAN_HWIF failed");
|
||||
+ }
|
||||
}
|
||||
#endif
|
||||
#ifdef HDIO_SET_PIO_MODE
|
||||
@@ -757,21 +769,27 @@
|
||||
if (set_piomode) {
|
||||
if (get_piomode) {
|
||||
@@ -825,68 +837,86 @@
|
||||
else
|
||||
printf(" attempting to set UDMA mode to %d\n", (piomode-200));
|
||||
}
|
||||
@ -115,10 +115,9 @@
|
||||
perror(" HDIO_SET_PIO_MODE failed");
|
||||
+ }
|
||||
}
|
||||
#endif
|
||||
if (set_io32bit) {
|
||||
if (get_io32bit)
|
||||
printf(" setting 32-bit IO_support flag to %ld\n", 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;
|
||||
@ -127,17 +126,16 @@
|
||||
}
|
||||
if (set_mult) {
|
||||
if (get_mult)
|
||||
printf(" setting multcount to %ld\n", 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");
|
||||
+ }
|
||||
#ifndef HDIO_DRIVE_CMD
|
||||
else force_operation = 1;
|
||||
#endif
|
||||
@@ -781,16 +799,20 @@
|
||||
printf(" setting readonly to %ld", readonly);
|
||||
}
|
||||
if (set_readonly) {
|
||||
if (get_readonly) {
|
||||
printf(" setting readonly to %d", readonly);
|
||||
on_off(readonly);
|
||||
}
|
||||
- if (ioctl(fd, BLKROSET, &readonly))
|
||||
@ -148,7 +146,7 @@
|
||||
}
|
||||
if (set_unmask) {
|
||||
if (get_unmask) {
|
||||
printf(" setting unmaskirq to %ld", unmask);
|
||||
printf(" setting unmaskirq to %d", unmask);
|
||||
on_off(unmask);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_SET_UNMASKINTR, unmask))
|
||||
@ -157,10 +155,9 @@
|
||||
perror(" HDIO_SET_UNMASKINTR failed");
|
||||
+ }
|
||||
}
|
||||
#ifdef HDIO_SET_DMA
|
||||
if (set_dma) {
|
||||
@@ -798,8 +820,10 @@
|
||||
printf(" setting using_dma to %ld", dma);
|
||||
if (get_dma) {
|
||||
printf(" setting using_dma to %d", dma);
|
||||
on_off(dma);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_SET_DMA, dma))
|
||||
@ -169,10 +166,9 @@
|
||||
perror(" HDIO_SET_DMA failed");
|
||||
+ }
|
||||
}
|
||||
#endif
|
||||
#ifdef HDIO_SET_QDMA
|
||||
@@ -808,8 +832,10 @@
|
||||
printf(" setting DMA queue_depth to %ld", dma_q);
|
||||
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))
|
||||
@ -181,10 +177,9 @@
|
||||
perror(" HDIO_SET_QDMA failed");
|
||||
+ }
|
||||
}
|
||||
#endif
|
||||
#ifdef HDIO_SET_NOWERR
|
||||
@@ -818,8 +844,10 @@
|
||||
printf(" setting nowerr to %ld", nowerr);
|
||||
if (set_nowerr) {
|
||||
if (get_nowerr) {
|
||||
printf(" setting nowerr to %d", nowerr);
|
||||
on_off(nowerr);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_SET_NOWERR, nowerr))
|
||||
@ -193,10 +188,9 @@
|
||||
perror(" HDIO_SET_NOWERR failed");
|
||||
+ }
|
||||
}
|
||||
#endif
|
||||
#ifdef HDIO_GET_KEEPSETTINGS
|
||||
@@ -828,8 +856,10 @@
|
||||
printf(" setting keep_settings to %ld", keep);
|
||||
if (set_keep) {
|
||||
if (get_keep) {
|
||||
printf(" setting keep_settings to %d", keep);
|
||||
on_off(keep);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_SET_KEEPSETTINGS, keep))
|
||||
@ -205,175 +199,199 @@
|
||||
perror(" HDIO_SET_KEEPSETTINGS failed");
|
||||
+ }
|
||||
}
|
||||
#endif /* HDIO_GET_KEEPSETTINGS */
|
||||
if (set_doorlock) {
|
||||
@@ -839,8 +869,10 @@
|
||||
printf(" setting drive doorlock to %ld", doorlock);
|
||||
__u8 args[4] = {0,0,0,0};
|
||||
@@ -895,8 +925,10 @@
|
||||
printf(" setting drive doorlock to %d", doorlock);
|
||||
on_off(doorlock);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_DRIVE_CMD, &args))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
- 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 */
|
||||
@@ -850,24 +882,30 @@
|
||||
@@ -906,24 +938,30 @@
|
||||
on_off(dkeep);
|
||||
}
|
||||
args[2] = dkeep ? 0x66 : 0xcc;
|
||||
- if (ioctl(fd, HDIO_DRIVE_CMD, &args))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(keepsettings) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_defects) {
|
||||
unsigned char args[4] = {WIN_SETFEATURES,0,0x04,0};
|
||||
__u8 args[4] = {ATA_OP_SETFEATURES,0,0x04,0};
|
||||
args[2] = defects ? 0x04 : 0x84;
|
||||
if (get_defects)
|
||||
printf(" setting drive defect management to %ld\n", defects);
|
||||
- if (ioctl(fd, HDIO_DRIVE_CMD, &args))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
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) {
|
||||
unsigned char args[4] = {WIN_SETFEATURES,0,0xab,0};
|
||||
__u8 args[4] = {ATA_OP_SETFEATURES,0,0xab,0};
|
||||
args[1] = prefetch;
|
||||
if (get_prefetch)
|
||||
printf(" setting drive prefetch to %ld\n", prefetch);
|
||||
- if (ioctl(fd, HDIO_DRIVE_CMD, &args))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
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) {
|
||||
unsigned char args[4] = {WIN_SETFEATURES,0,3,0};
|
||||
@@ -876,8 +914,10 @@
|
||||
__u8 args[4] = {ATA_OP_SETFEATURES,0,3,0};
|
||||
@@ -932,8 +970,10 @@
|
||||
printf(" setting xfermode to %d", xfermode_requested);
|
||||
interpret_xfermode(xfermode_requested);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_DRIVE_CMD, &args))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(setxfermode) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_lookahead) {
|
||||
unsigned char args[4] = {WIN_SETFEATURES,0,0,0};
|
||||
@@ -886,8 +926,10 @@
|
||||
printf(" setting drive read-lookahead to %ld", lookahead);
|
||||
__u8 args[4] = {ATA_OP_SETFEATURES,0,0,0};
|
||||
@@ -942,8 +982,10 @@
|
||||
printf(" setting drive read-lookahead to %d", lookahead);
|
||||
on_off(lookahead);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_DRIVE_CMD, &args))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(setreadahead) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_apmmode) {
|
||||
unsigned char args[4] = {WIN_SETFEATURES,0,0,0};
|
||||
@@ -905,14 +947,18 @@
|
||||
args[1] = apmmode; /* sector count register */
|
||||
if (get_apmmode) printf(" 0x%02lX (%ld)\n",apmmode,apmmode);
|
||||
if (set_powerup_in_standby) {
|
||||
__u8 args[4] = {ATA_OP_SETFEATURES,0,0,0};
|
||||
@@ -978,14 +1020,18 @@
|
||||
if (get_apmmode)
|
||||
printf(" 0x%02x (%d)\n",apmmode,apmmode);
|
||||
}
|
||||
- if (ioctl(fd, HDIO_DRIVE_CMD, &args))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD failed");
|
||||
+ }
|
||||
}
|
||||
#ifdef CDROM_SELECT_SPEED
|
||||
if (set_cdromspeed) {
|
||||
printf ("setting cdrom speed to %ld\n", 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");
|
||||
+ }
|
||||
}
|
||||
#endif
|
||||
if (set_acoustic) {
|
||||
__u8 args[4];
|
||||
@@ -995,8 +1041,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) {
|
||||
@@ -929,13 +975,23 @@
|
||||
on_off(wcache);
|
||||
__u8 flushcache1[4] = {ATA_OP_FLUSHCACHE,0,0,0};
|
||||
@@ -1009,11 +1057,16 @@
|
||||
}
|
||||
#ifdef HDIO_SET_WCACHE
|
||||
if (!wcache && do_drive_cmd(fd, flushcache1))
|
||||
perror (" HDIO_DRIVE_CMD(flushcache1) failed");
|
||||
- if (ioctl(fd, HDIO_SET_WCACHE, wcache))
|
||||
- if (do_drive_cmd(fd, setcache))
|
||||
+ if (ioctl(fd, HDIO_SET_WCACHE, wcache)) {
|
||||
#endif
|
||||
- if (ioctl(fd, HDIO_DRIVE_CMD, &args))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(setcache) failed");
|
||||
+ if (do_drive_cmd(fd, setcache)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(setcache) failed");
|
||||
- if (!wcache && do_drive_cmd(fd, flushcache2))
|
||||
+ }
|
||||
+ }
|
||||
+#ifdef HDIO_SET_WCACHE
|
||||
+ } else {
|
||||
+ if (!wcache && do_drive_cmd(fd, flushcache2)) {
|
||||
+ err = errno;
|
||||
+ perror(" HDIO_SET_WCACHE(wcache) failed");
|
||||
perror (" HDIO_DRIVE_CMD(flushcache2) failed");
|
||||
+ }
|
||||
+#endif
|
||||
#ifdef DO_FLUSHCACHE
|
||||
- if (!wcache && ioctl(fd, HDIO_DRIVE_CMD, &flushcache))
|
||||
+ if (!wcache && ioctl(fd, HDIO_DRIVE_CMD, &flushcache)) {
|
||||
+ err = errno;
|
||||
perror (" HDIO_DRIVE_CMD(flushcache) failed");
|
||||
+ }
|
||||
#endif /* DO_FLUSHCACHE */
|
||||
}
|
||||
if (set_standbynow) {
|
||||
@@ -950,8 +1006,10 @@
|
||||
__u8 args1[4] = {ATA_OP_STANDBYNOW1,0,0,0};
|
||||
@@ -1021,8 +1074,10 @@
|
||||
if (get_standbynow)
|
||||
printf(" issuing standby command\n");
|
||||
if (ioctl(fd, HDIO_DRIVE_CMD, &args1)
|
||||
- && ioctl(fd, HDIO_DRIVE_CMD, &args2))
|
||||
+ && ioctl(fd, HDIO_DRIVE_CMD, &args2)) {
|
||||
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) {
|
||||
#ifndef WIN_SLEEPNOW1
|
||||
@@ -965,8 +1023,10 @@
|
||||
__u8 args1[4] = {ATA_OP_SLEEPNOW1,0,0,0};
|
||||
@@ -1030,8 +1085,10 @@
|
||||
if (get_sleepnow)
|
||||
printf(" issuing sleep command\n");
|
||||
if (ioctl(fd, HDIO_DRIVE_CMD, &args1)
|
||||
- && ioctl(fd, HDIO_DRIVE_CMD, &args2))
|
||||
+ && ioctl(fd, HDIO_DRIVE_CMD, &args2)) {
|
||||
if (do_drive_cmd(fd, args1)
|
||||
- && do_drive_cmd(fd, args2))
|
||||
+ && do_drive_cmd(fd, args2)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(sleep) failed");
|
||||
+ }
|
||||
}
|
||||
#ifdef WIN_SECURITY_FREEZE_LOCK
|
||||
if (set_security) {
|
||||
@@ -1093,8 +1153,10 @@
|
||||
unsigned char args[4] = {0xfb,0,0,0};
|
||||
do_set_security(fd);
|
||||
@@ -1039,15 +1096,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 (ioctl(fd, HDIO_DRIVE_CMD, &args))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(seagatepwrsave) failed");
|
||||
+ }
|
||||
}
|
||||
if (set_standby) {
|
||||
unsigned char args[4] = {WIN_SETIDLE1,standby_requested,0,0};
|
||||
@@ -1102,8 +1164,10 @@
|
||||
printf(" setting standby to %lu", standby_requested);
|
||||
interpret_standby(standby_requested);
|
||||
__u8 args[4] = {ATA_OP_SETIDLE1,standby,0,0};
|
||||
@@ -1055,14 +1116,18 @@
|
||||
printf(" setting standby to %u", standby);
|
||||
interpret_standby();
|
||||
}
|
||||
- if (ioctl(fd, HDIO_DRIVE_CMD, &args))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
- if (do_drive_cmd(fd, args))
|
||||
+ if (do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(setidle1) failed");
|
||||
+ }
|
||||
}
|
||||
|
||||
if (!flagcount)
|
||||
@@ -1134,12 +1198,18 @@
|
||||
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 (get_hitachi_temp) {
|
||||
__u8 args[4] = {0xf0,0,0x01,0}; /* "Sense Condition", vendor-specific */
|
||||
@@ -1104,12 +1169,18 @@
|
||||
break;
|
||||
default:printf("\?\?\?)\n");
|
||||
}
|
||||
@ -382,9 +400,9 @@
|
||||
+ perror(" HDIO_GET_32BIT failed");
|
||||
}
|
||||
}
|
||||
if (verbose || get_unmask) {
|
||||
if (do_defaults || get_unmask) {
|
||||
if (0 == ioctl(fd, HDIO_GET_UNMASKINTR, &parm)) {
|
||||
printf(" unmaskirq = %2ld", parm);
|
||||
printf(" unmaskirq = %2ld", parm);
|
||||
on_off(parm);
|
||||
+ } else {
|
||||
+ err = errno;
|
||||
@ -392,7 +410,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1151,12 +1221,16 @@
|
||||
@@ -1120,6 +1191,9 @@
|
||||
printf(" (DMA-Assisted-PIO)\n");
|
||||
else
|
||||
on_off(parm);
|
||||
@ -401,26 +419,16 @@
|
||||
+ perror(" HDIO_GET_DMA failed");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef HDIO_GET_QDMA
|
||||
if (get_dma_q) {
|
||||
if(ioctl(fd, HDIO_GET_QDMA, &parm)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_GET_QDMA failed");
|
||||
} else {
|
||||
printf(" queue_depth = %2ld", parm);
|
||||
@@ -1169,32 +1243,38 @@
|
||||
@@ -1134,28 +1208,34 @@
|
||||
if (0 == ioctl(fd, HDIO_GET_KEEPSETTINGS, &parm)) {
|
||||
printf(" keepsettings = %2ld", parm);
|
||||
printf(" keepsettings = %2ld", parm);
|
||||
on_off(parm);
|
||||
+ } else {
|
||||
+ err = errno;
|
||||
+ perror(" HDIO_GET_KEEPSETTINGS failed");
|
||||
}
|
||||
}
|
||||
#endif /* HDIO_GET_KEEPSETTINGS */
|
||||
|
||||
#ifdef HDIO_SET_NOWERR
|
||||
if (get_nowerr) {
|
||||
- if (ioctl(fd, HDIO_GET_NOWERR, &parm))
|
||||
+ if (ioctl(fd, HDIO_GET_NOWERR, &parm)) {
|
||||
@ -428,45 +436,41 @@
|
||||
perror(" HDIO_GET_NOWERR failed");
|
||||
- else {
|
||||
+ } else {
|
||||
printf(" nowerr = %2ld", parm);
|
||||
printf(" nowerr = %2ld", parm);
|
||||
on_off(parm);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (verbose || get_readonly) {
|
||||
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);
|
||||
printf(" readonly = %2ld", parm);
|
||||
on_off(parm);
|
||||
}
|
||||
}
|
||||
if (verbose || get_fsreadahead) {
|
||||
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);
|
||||
printf(" readahead = %2ld", parm);
|
||||
on_off(parm);
|
||||
}
|
||||
@@ -1209,15 +1289,16 @@
|
||||
static struct hd_big_geometry bg;
|
||||
#endif
|
||||
@@ -1170,12 +1250,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))) {
|
||||
#ifdef HDIO_GETGEO_BIG
|
||||
if (!ioctl(fd, HDIO_GETGEO_BIG, &bg))
|
||||
printf(msg, bg.cylinders, bg.heads, bg.sectors, blksize, bg.start);
|
||||
else
|
||||
#endif
|
||||
- if (ioctl(fd, HDIO_GETGEO, &g))
|
||||
+ if (ioctl(fd, HDIO_GETGEO, &g)) {
|
||||
- else if (ioctl(fd, HDIO_GETGEO, &g))
|
||||
+ else if (ioctl(fd, HDIO_GETGEO, &g)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_GETGEO failed");
|
||||
- else
|
||||
@ -474,38 +478,16 @@
|
||||
printf(msg, g.cylinders, g.heads, g.sectors, blksize, g.start);
|
||||
}
|
||||
}
|
||||
@@ -1234,6 +1315,7 @@
|
||||
if (ioctl(fd, HDIO_DRIVE_CMD, &args)
|
||||
&& (args[0] = WIN_CHECKPOWERMODE2) /* try again with 0x98 */
|
||||
&& ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
@@ -1185,6 +1266,7 @@
|
||||
if (do_drive_cmd(fd, args)
|
||||
&& (args[0] = ATA_OP_CHECKPOWERMODE2) /* (single =) try again with 0x98 */
|
||||
&& do_drive_cmd(fd, args)) {
|
||||
+ err = errno;
|
||||
if (errno != EIO || args[0] != 0 || args[1] != 0)
|
||||
state = "unknown";
|
||||
else
|
||||
@@ -1246,15 +1328,19 @@
|
||||
#endif
|
||||
#ifdef HDIO_DRIVE_RESET
|
||||
if (perform_reset) {
|
||||
- if (ioctl(fd, HDIO_DRIVE_RESET, NULL))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_RESET, NULL)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_RESET failed");
|
||||
+ }
|
||||
}
|
||||
#endif /* HDIO_DRIVE_RESET */
|
||||
#ifdef HDIO_TRISTATE_HWIF
|
||||
if (perform_tristate) {
|
||||
unsigned char args[4] = {0,tristate,0,0};
|
||||
- if (ioctl(fd, HDIO_TRISTATE_HWIF, &args))
|
||||
+ if (ioctl(fd, HDIO_TRISTATE_HWIF, &args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_TRISTATE_HWIF failed");
|
||||
+ }
|
||||
}
|
||||
#endif /* HDIO_TRISTATE_HWIF */
|
||||
if (get_identity) {
|
||||
@@ -1269,8 +1355,10 @@
|
||||
dump_identity(&id);
|
||||
@@ -1205,8 +1287,10 @@
|
||||
dump_identity(id2);
|
||||
} else if (errno == -ENOMSG)
|
||||
printf(" no identification info available\n");
|
||||
- else
|
||||
@ -514,67 +496,21 @@
|
||||
perror(" HDIO_GET_IDENTITY failed");
|
||||
+ }
|
||||
}
|
||||
if (get_IDentity) {
|
||||
__u16 *id;
|
||||
@@ -1279,6 +1367,7 @@
|
||||
if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
args[0] = WIN_PIDENTIFY;
|
||||
if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD(identify) failed");
|
||||
goto identify_abort;
|
||||
}
|
||||
@@ -1303,15 +1392,18 @@
|
||||
printf(" setting bus state to %d", busstate);
|
||||
bus_state_value(busstate);
|
||||
if (do_IDentity) {
|
||||
id = get_identify_data(fd, id);
|
||||
@@ -1259,39 +1343,46 @@
|
||||
}
|
||||
- if (ioctl(fd, HDIO_SET_BUSSTATE, busstate))
|
||||
+ if (ioctl(fd, HDIO_SET_BUSSTATE, busstate)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_SET_BUSSTATE failed");
|
||||
+ }
|
||||
}
|
||||
#endif
|
||||
#ifdef HDIO_GET_BUSSTATE
|
||||
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", parm);
|
||||
bus_state_value(parm);
|
||||
}
|
||||
@@ -1319,6 +1411,7 @@
|
||||
#endif
|
||||
if (reread_partn) {
|
||||
if (ioctl(fd, BLKRRPART, NULL)) {
|
||||
+ err = errno;
|
||||
perror(" BLKRRPART failed");
|
||||
}
|
||||
- else
|
||||
+ } else
|
||||
printf(" busstate = %2ld (%s)\n", parm, busstate_str(parm));
|
||||
}
|
||||
@@ -1335,8 +1428,10 @@
|
||||
unsigned char args[4] = {WIN_SETFEATURES,0,0,0};
|
||||
args[1] = acoustic;
|
||||
args[2] = acoustic ? 0x42 : 0xc2;
|
||||
- if (ioctl(fd, HDIO_DRIVE_CMD, &args))
|
||||
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_DRIVE_CMD:ACOUSTIC failed");
|
||||
+ }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1344,6 +1439,7 @@
|
||||
#ifdef HDIO_GET_ACOUSTIC
|
||||
if (get_acoustic) {
|
||||
if (ioctl(fd, HDIO_GET_ACOUSTIC, &parm)) {
|
||||
+ err = errno;
|
||||
perror(" HDIO_GET_ACOUSTIC failed");
|
||||
} else {
|
||||
printf(" acoustic = %2ld (128=quiet ... 254=fast)\n", parm);
|
||||
@@ -1354,10 +1450,11 @@
|
||||
|
||||
if (do_ctimings)
|
||||
time_cache (fd);
|
||||
if (do_timings)
|
||||
@ -582,11 +518,38 @@
|
||||
+ 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);
|
||||
+ exit (err);
|
||||
}
|
||||
|
||||
void usage_error (int out)
|
||||
static void usage_help (int rc)
|
||||
--- hdparm.h
|
||||
+++ hdparm.h
|
||||
@@ -19,7 +19,7 @@
|
||||
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:cc7de2aebec2b9eefe9b32fb488e27690a614398f72e261b8ab124b596dd46db
|
||||
size 43009
|
3
hdparm-7.1.tar.bz2
Normal file
3
hdparm-7.1.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:03ba38f464ad1be1f3574ea2d0893d1aaef9251fc35e383756a20d4d835ff8a9
|
||||
size 55061
|
@ -1,3 +1,29 @@
|
||||
-------------------------------------------------------------------
|
||||
Sun Apr 29 11:50:34 CEST 2007 - ro@suse.de
|
||||
|
||||
- update to 7.1
|
||||
- big-endian fixes for -I, --Istdin, --Istdout
|
||||
- cody tidying in sgio.c
|
||||
- updated help/manpage for -v
|
||||
- marked -s1 as (DANGEROUS)
|
||||
- hdparm-7.0
|
||||
- new command-line parser
|
||||
- allow any chars (except 0x00) in security passwords
|
||||
- fixed -s manpage format error
|
||||
- updated -W manpage description
|
||||
- major internal rework in hdparm.c
|
||||
- added SET_FEATURES subcommand 0x07 to the -s0 sequence
|
||||
(the kernel will eventually have to do this automatically)
|
||||
- fixed duplicate display of udma modes 3,4,5 with -i
|
||||
- added Timed-Command-Completion (TLC) data for -I
|
||||
- added support for SG_IO (SAT) ATA_16 command transport
|
||||
- ignore case for longargs (eg. --istdout or --Istdout)
|
||||
- remove dependencies on <linux/hdreg.h>
|
||||
- added query wcache (-W)
|
||||
- enhanced query acoustic (-M)
|
||||
- added kernel_patches directory with patches for ATAPI support
|
||||
- disable acoustic patch (surrounding code changed)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Oct 28 15:53:07 CEST 2006 - aj@suse.de
|
||||
|
||||
|
35
hdparm.spec
35
hdparm.spec
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package hdparm (Version 6.9)
|
||||
# spec file for package hdparm (Version 7.1)
|
||||
#
|
||||
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2007 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.
|
||||
#
|
||||
@ -11,12 +11,12 @@
|
||||
# norootforbuild
|
||||
|
||||
Name: hdparm
|
||||
License: Freely Redistributable Software (FSR)
|
||||
License: Any permissive
|
||||
Group: Hardware/Other
|
||||
PreReq: %insserv_prereq %fillup_prereq coreutils
|
||||
Provides: base:/sbin/hdparm
|
||||
Autoreqprov: on
|
||||
Version: 6.9
|
||||
Version: 7.1
|
||||
Release: 1
|
||||
Summary: A Program to Get and Set Hard Disk Parameters
|
||||
Source: hdparm-%{version}.tar.bz2
|
||||
@ -43,7 +43,7 @@ Authors:
|
||||
%setup -q
|
||||
%patch
|
||||
%patch1
|
||||
%patch2
|
||||
#patch2
|
||||
|
||||
%build
|
||||
make CFLAGS="$RPM_OPT_FLAGS -Wall -Wstrict-prototypes" LDFLAGS=
|
||||
@ -101,7 +101,30 @@ fi
|
||||
/etc/udev/rules.d/56-idedma.rules
|
||||
/var/adm/fillup-templates/sysconfig.ide
|
||||
|
||||
%changelog -n hdparm
|
||||
%changelog
|
||||
* Sun Apr 29 2007 - ro@suse.de
|
||||
- update to 7.1
|
||||
- big-endian fixes for -I, --Istdin, --Istdout
|
||||
- cody tidying in sgio.c
|
||||
- updated help/manpage for -v
|
||||
- marked -s1 as (DANGEROUS)
|
||||
- hdparm-7.0
|
||||
- new command-line parser
|
||||
- allow any chars (except 0x00) in security passwords
|
||||
- fixed -s manpage format error
|
||||
- updated -W manpage description
|
||||
- major internal rework in hdparm.c
|
||||
- added SET_FEATURES subcommand 0x07 to the -s0 sequence
|
||||
(the kernel will eventually have to do this automatically)
|
||||
- fixed duplicate display of udma modes 3,4,5 with -i
|
||||
- added Timed-Command-Completion (TLC) data for -I
|
||||
- added support for SG_IO (SAT) ATA_16 command transport
|
||||
- ignore case for longargs (eg. --istdout or --Istdout)
|
||||
- remove dependencies on <linux/hdreg.h>
|
||||
- added query wcache (-W)
|
||||
- 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
|
||||
- Update to version 6.9, changes since 6.6 are:
|
||||
* added -s flag to control power-up in standby
|
||||
|
Loading…
x
Reference in New Issue
Block a user