OBS User unknown 2007-04-29 09:57:15 +00:00 committed by Git OBS Bridge
parent 0594fc5df2
commit 60ffb71f7c
6 changed files with 258 additions and 247 deletions

View File

@ -1,17 +1,16 @@
--- hdparm.c --- hdparm.c
+++ hdparm.c +++ hdparm.c
@@ -292,11 +292,10 @@ @@ -269,10 +269,9 @@
void flush_buffer_cache (int fd) void flush_buffer_cache (int fd)
{ {
fsync (fd); /* flush buffers */ fsync (fd); /* flush buffers */
- if (ioctl(fd, BLKFLSBUF, NULL)) /* do it again, big time */ - if (ioctl(fd, BLKFLSBUF, NULL)) /* do it again, big time */
- perror("BLKFLSBUF failed"); - perror("BLKFLSBUF failed");
+ ioctl(fd, BLKFLSBUF, NULL); /* do it again, big time */ - if (do_drive_cmd(fd, NULL) && errno != EINVAL) /* await completion */
#ifdef HDIO_DRIVE_CMD
- if (ioctl(fd, HDIO_DRIVE_CMD, NULL) && errno != EINVAL) /* await completion */
- perror("HDIO_DRIVE_CMD(null) (wait for flush complete) failed"); - perror("HDIO_DRIVE_CMD(null) (wait for flush complete) failed");
+ ioctl(fd, BLKFLSBUF, NULL); /* do it again, big time */
+ if (errno != EINVAL && errno != EOPNOTSUPP) + if (errno != EINVAL && errno != EOPNOTSUPP)
+ ioctl(fd, HDIO_DRIVE_CMD, NULL);/* await completion */ + do_drive_cmd(fd, NULL); /* await completion */
#endif
} }
int seek_to_zero (int fd)

View File

@ -1,6 +1,6 @@
--- hdparm.c --- hdparm.c
+++ hdparm.c +++ hdparm.c
@@ -446,18 +446,20 @@ @@ -401,18 +401,20 @@
return 0; return 0;
} }
rc = ioctl(fd, BLKGETSIZE, &blksize32); // returns sectors rc = ioctl(fd, BLKGETSIZE, &blksize32); // returns sectors
@ -23,11 +23,11 @@
+ int shmid, err = 0; + int shmid, err = 0;
unsigned int max_iterations = 1024, total_MB, iterations; unsigned int max_iterations = 1024, total_MB, iterations;
// /*
@@ -465,23 +467,26 @@ @@ -421,23 +423,26 @@
//
if (do_ctimings || do_timings) { if (do_ctimings || do_timings) {
unsigned long long blksize; unsigned long long blksize;
do_flush = 1;
- if (0 == do_blkgetsize(fd, &blksize)) - if (0 == do_blkgetsize(fd, &blksize))
+ if (0 == (err = do_blkgetsize(fd, &blksize))) + if (0 == (err = do_blkgetsize(fd, &blksize)))
max_iterations = blksize / (2 * 1024) / TIMING_BUF_MB; max_iterations = blksize / (2 * 1024) / TIMING_BUF_MB;
@ -55,7 +55,7 @@
} }
if (shmctl(shmid, IPC_RMID, NULL) == -1) if (shmctl(shmid, IPC_RMID, NULL) == -1)
perror ("shmctl(,IPC_RMID,) failed"); perror ("shmctl(,IPC_RMID,) failed");
@@ -521,6 +526,7 @@ @@ -477,6 +482,7 @@
quit: quit:
if (-1 == shmdt(buf)) if (-1 == shmdt(buf))
perror ("could not detach sharedmem buf"); perror ("could not detach sharedmem buf");
@ -63,37 +63,37 @@
} }
static void on_off (unsigned int value) static void on_off (unsigned int value)
@@ -707,7 +713,7 @@ @@ -780,7 +786,7 @@
void process_dev (char *devname) void process_dev (char *devname)
{ {
- int fd; - int fd;
+ int fd, err = 0; + int fd, err = 0;
static long parm, multcount; static long parm, multcount;
#ifndef HDIO_DRIVE_CMD __u16 *id = (void *)-1;
int force_operation = 0;
@@ -724,14 +730,18 @@ @@ -796,14 +802,18 @@
if (set_fsreadahead) { if (set_fsreadahead) {
if (get_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))
+ if (ioctl(fd, BLKRASET, fsreadahead)) { + if (ioctl(fd, BLKRASET, fsreadahead)) {
+ err = errno; + err = errno;
perror(" BLKRASET failed"); perror(" BLKRASET failed");
+ } + }
} }
#ifdef HDIO_UNREGISTER_HWIF if (set_unregister) {
if (unregister_hwif) { if (get_unregister)
printf(" attempting to unregister hwif#%u\n", hwif); printf(" attempting to unregister hwif#%u\n", hwif);
- if (ioctl(fd, HDIO_UNREGISTER_HWIF, hwif)) - if (ioctl(fd, HDIO_UNREGISTER_HWIF, hwif))
+ if (ioctl(fd, HDIO_UNREGISTER_HWIF, hwif)) { + if (ioctl(fd, HDIO_UNREGISTER_HWIF, hwif)) {
+ err = errno; + err = errno;
perror(" HDIO_UNREGISTER_HWIF failed"); perror(" HDIO_UNREGISTER_HWIF failed");
+ } + }
} }
#endif if (scan_hwif) {
#ifdef HDIO_SCAN_HWIF int args[3];
@@ -741,8 +751,10 @@ @@ -811,8 +821,10 @@
args[0] = hwif_data; args[0] = hwif_data;
args[1] = hwif_ctrl; args[1] = hwif_ctrl;
args[2] = hwif_irq; args[2] = hwif_irq;
@ -103,9 +103,9 @@
perror(" HDIO_SCAN_HWIF failed"); perror(" HDIO_SCAN_HWIF failed");
+ } + }
} }
#endif if (set_piomode) {
#ifdef HDIO_SET_PIO_MODE if (get_piomode) {
@@ -757,21 +769,27 @@ @@ -825,68 +837,86 @@
else else
printf(" attempting to set UDMA mode to %d\n", (piomode-200)); printf(" attempting to set UDMA mode to %d\n", (piomode-200));
} }
@ -115,10 +115,9 @@
perror(" HDIO_SET_PIO_MODE failed"); perror(" HDIO_SET_PIO_MODE failed");
+ } + }
} }
#endif
if (set_io32bit) { if (set_io32bit) {
if (get_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))
+ if (ioctl(fd, HDIO_SET_32BIT, io32bit)) { + if (ioctl(fd, HDIO_SET_32BIT, io32bit)) {
+ err = errno; + err = errno;
@ -127,17 +126,16 @@
} }
if (set_mult) { if (set_mult) {
if (get_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))
+ if (ioctl(fd, HDIO_SET_MULTCOUNT, mult)) { + if (ioctl(fd, HDIO_SET_MULTCOUNT, mult)) {
+ err = errno; + err = errno;
perror(" HDIO_SET_MULTCOUNT failed"); perror(" HDIO_SET_MULTCOUNT failed");
+ } + }
#ifndef HDIO_DRIVE_CMD }
else force_operation = 1; if (set_readonly) {
#endif if (get_readonly) {
@@ -781,16 +799,20 @@ printf(" setting readonly to %d", readonly);
printf(" setting readonly to %ld", readonly);
on_off(readonly); on_off(readonly);
} }
- if (ioctl(fd, BLKROSET, &readonly)) - if (ioctl(fd, BLKROSET, &readonly))
@ -148,7 +146,7 @@
} }
if (set_unmask) { if (set_unmask) {
if (get_unmask) { if (get_unmask) {
printf(" setting unmaskirq to %ld", unmask); printf(" setting unmaskirq to %d", unmask);
on_off(unmask); on_off(unmask);
} }
- if (ioctl(fd, HDIO_SET_UNMASKINTR, unmask)) - if (ioctl(fd, HDIO_SET_UNMASKINTR, unmask))
@ -157,10 +155,9 @@
perror(" HDIO_SET_UNMASKINTR failed"); perror(" HDIO_SET_UNMASKINTR failed");
+ } + }
} }
#ifdef HDIO_SET_DMA
if (set_dma) { if (set_dma) {
@@ -798,8 +820,10 @@ if (get_dma) {
printf(" setting using_dma to %ld", dma); printf(" setting using_dma to %d", dma);
on_off(dma); on_off(dma);
} }
- if (ioctl(fd, HDIO_SET_DMA, dma)) - if (ioctl(fd, HDIO_SET_DMA, dma))
@ -169,10 +166,9 @@
perror(" HDIO_SET_DMA failed"); perror(" HDIO_SET_DMA failed");
+ } + }
} }
#endif if (set_dma_q) {
#ifdef HDIO_SET_QDMA if (get_dma_q) {
@@ -808,8 +832,10 @@ printf(" setting DMA queue_depth to %d", dma_q);
printf(" setting DMA queue_depth to %ld", dma_q);
on_off(dma_q); on_off(dma_q);
} }
- if (ioctl(fd, HDIO_SET_QDMA, dma_q)) - if (ioctl(fd, HDIO_SET_QDMA, dma_q))
@ -181,10 +177,9 @@
perror(" HDIO_SET_QDMA failed"); perror(" HDIO_SET_QDMA failed");
+ } + }
} }
#endif if (set_nowerr) {
#ifdef HDIO_SET_NOWERR if (get_nowerr) {
@@ -818,8 +844,10 @@ printf(" setting nowerr to %d", nowerr);
printf(" setting nowerr to %ld", nowerr);
on_off(nowerr); on_off(nowerr);
} }
- if (ioctl(fd, HDIO_SET_NOWERR, nowerr)) - if (ioctl(fd, HDIO_SET_NOWERR, nowerr))
@ -193,10 +188,9 @@
perror(" HDIO_SET_NOWERR failed"); perror(" HDIO_SET_NOWERR failed");
+ } + }
} }
#endif if (set_keep) {
#ifdef HDIO_GET_KEEPSETTINGS if (get_keep) {
@@ -828,8 +856,10 @@ printf(" setting keep_settings to %d", keep);
printf(" setting keep_settings to %ld", keep);
on_off(keep); on_off(keep);
} }
- if (ioctl(fd, HDIO_SET_KEEPSETTINGS, keep)) - if (ioctl(fd, HDIO_SET_KEEPSETTINGS, keep))
@ -205,175 +199,199 @@
perror(" HDIO_SET_KEEPSETTINGS failed"); perror(" HDIO_SET_KEEPSETTINGS failed");
+ } + }
} }
#endif /* HDIO_GET_KEEPSETTINGS */
if (set_doorlock) { if (set_doorlock) {
@@ -839,8 +869,10 @@ __u8 args[4] = {0,0,0,0};
printf(" setting drive doorlock to %ld", doorlock); @@ -895,8 +925,10 @@
printf(" setting drive doorlock to %d", doorlock);
on_off(doorlock); on_off(doorlock);
} }
- if (ioctl(fd, HDIO_DRIVE_CMD, &args)) - if (do_drive_cmd(fd, args))
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { + if (do_drive_cmd(fd, args)) {
+ err = errno; + err = errno;
perror(" HDIO_DRIVE_CMD(doorlock) failed"); perror(" HDIO_DRIVE_CMD(doorlock) failed");
+ } + }
} }
if (set_dkeep) { if (set_dkeep) {
/* lock/unlock the drive's "feature" settings */ /* lock/unlock the drive's "feature" settings */
@@ -850,24 +882,30 @@ @@ -906,24 +938,30 @@
on_off(dkeep); on_off(dkeep);
} }
args[2] = dkeep ? 0x66 : 0xcc; args[2] = dkeep ? 0x66 : 0xcc;
- if (ioctl(fd, HDIO_DRIVE_CMD, &args)) - if (do_drive_cmd(fd, args))
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { + if (do_drive_cmd(fd, args)) {
+ err = errno; + err = errno;
perror(" HDIO_DRIVE_CMD(keepsettings) failed"); perror(" HDIO_DRIVE_CMD(keepsettings) failed");
+ } + }
} }
if (set_defects) { 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; args[2] = defects ? 0x04 : 0x84;
if (get_defects) if (get_defects)
printf(" setting drive defect management to %ld\n", defects); printf(" setting drive defect management to %d\n", defects);
- if (ioctl(fd, HDIO_DRIVE_CMD, &args)) - if (do_drive_cmd(fd, args))
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { + if (do_drive_cmd(fd, args)) {
+ err = errno; + err = errno;
perror(" HDIO_DRIVE_CMD(defectmgmt) failed"); perror(" HDIO_DRIVE_CMD(defectmgmt) failed");
+ } + }
} }
if (set_prefetch) { if (set_prefetch) {
unsigned char args[4] = {WIN_SETFEATURES,0,0xab,0}; __u8 args[4] = {ATA_OP_SETFEATURES,0,0xab,0};
args[1] = prefetch; args[1] = prefetch;
if (get_prefetch) if (get_prefetch)
printf(" setting drive prefetch to %ld\n", prefetch); printf(" setting drive prefetch to %d\n", prefetch);
- if (ioctl(fd, HDIO_DRIVE_CMD, &args)) - if (do_drive_cmd(fd, args))
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { + if (do_drive_cmd(fd, args)) {
+ err = errno; + err = errno;
perror(" HDIO_DRIVE_CMD(setprefetch) failed"); perror(" HDIO_DRIVE_CMD(setprefetch) failed");
+ } + }
} }
if (set_xfermode) { if (set_xfermode) {
unsigned char args[4] = {WIN_SETFEATURES,0,3,0}; __u8 args[4] = {ATA_OP_SETFEATURES,0,3,0};
@@ -876,8 +914,10 @@ @@ -932,8 +970,10 @@
printf(" setting xfermode to %d", xfermode_requested); printf(" setting xfermode to %d", xfermode_requested);
interpret_xfermode(xfermode_requested); interpret_xfermode(xfermode_requested);
} }
- if (ioctl(fd, HDIO_DRIVE_CMD, &args)) - if (do_drive_cmd(fd, args))
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { + if (do_drive_cmd(fd, args)) {
+ err = errno; + err = errno;
perror(" HDIO_DRIVE_CMD(setxfermode) failed"); perror(" HDIO_DRIVE_CMD(setxfermode) failed");
+ } + }
} }
if (set_lookahead) { if (set_lookahead) {
unsigned char args[4] = {WIN_SETFEATURES,0,0,0}; __u8 args[4] = {ATA_OP_SETFEATURES,0,0,0};
@@ -886,8 +926,10 @@ @@ -942,8 +982,10 @@
printf(" setting drive read-lookahead to %ld", lookahead); printf(" setting drive read-lookahead to %d", lookahead);
on_off(lookahead); on_off(lookahead);
} }
- if (ioctl(fd, HDIO_DRIVE_CMD, &args)) - if (do_drive_cmd(fd, args))
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { + if (do_drive_cmd(fd, args)) {
+ err = errno; + err = errno;
perror(" HDIO_DRIVE_CMD(setreadahead) failed"); perror(" HDIO_DRIVE_CMD(setreadahead) failed");
+ } + }
} }
if (set_apmmode) { if (set_powerup_in_standby) {
unsigned char args[4] = {WIN_SETFEATURES,0,0,0}; __u8 args[4] = {ATA_OP_SETFEATURES,0,0,0};
@@ -905,14 +947,18 @@ @@ -978,14 +1020,18 @@
args[1] = apmmode; /* sector count register */ if (get_apmmode)
if (get_apmmode) printf(" 0x%02lX (%ld)\n",apmmode,apmmode); printf(" 0x%02x (%d)\n",apmmode,apmmode);
} }
- if (ioctl(fd, HDIO_DRIVE_CMD, &args)) - if (do_drive_cmd(fd, args))
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { + if (do_drive_cmd(fd, args)) {
+ err = errno; + err = errno;
perror(" HDIO_DRIVE_CMD failed"); perror(" HDIO_DRIVE_CMD failed");
+ } + }
} }
#ifdef CDROM_SELECT_SPEED
if (set_cdromspeed) { 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))
+ if (ioctl (fd, CDROM_SELECT_SPEED, cdromspeed)) { + if (ioctl (fd, CDROM_SELECT_SPEED, cdromspeed)) {
+ err = errno; + err = errno;
perror(" CDROM_SELECT_SPEED failed"); 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) { if (set_wcache) {
@@ -929,13 +975,23 @@ __u8 flushcache1[4] = {ATA_OP_FLUSHCACHE,0,0,0};
on_off(wcache); @@ -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 (ioctl(fd, HDIO_SET_WCACHE, wcache))
- if (do_drive_cmd(fd, setcache))
+ if (ioctl(fd, HDIO_SET_WCACHE, wcache)) { + if (ioctl(fd, HDIO_SET_WCACHE, wcache)) {
#endif + if (do_drive_cmd(fd, setcache)) {
- if (ioctl(fd, HDIO_DRIVE_CMD, &args)) + err = errno;
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { perror(" HDIO_DRIVE_CMD(setcache) failed");
+ err = errno; - if (!wcache && do_drive_cmd(fd, flushcache2))
perror(" HDIO_DRIVE_CMD(setcache) failed"); + }
+ } + }
+#ifdef HDIO_SET_WCACHE + if (!wcache && do_drive_cmd(fd, flushcache2)) {
+ } else {
+ err = errno; + 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) { if (set_standbynow) {
@@ -950,8 +1006,10 @@ __u8 args1[4] = {ATA_OP_STANDBYNOW1,0,0,0};
@@ -1021,8 +1074,10 @@
if (get_standbynow) if (get_standbynow)
printf(" issuing standby command\n"); printf(" issuing standby command\n");
if (ioctl(fd, HDIO_DRIVE_CMD, &args1) if (do_drive_cmd(fd, args1)
- && ioctl(fd, HDIO_DRIVE_CMD, &args2)) - && do_drive_cmd(fd, args2))
+ && ioctl(fd, HDIO_DRIVE_CMD, &args2)) { + && do_drive_cmd(fd, args2)) {
+ err = errno; + err = errno;
perror(" HDIO_DRIVE_CMD(standby) failed"); perror(" HDIO_DRIVE_CMD(standby) failed");
+ } + }
} }
if (set_sleepnow) { if (set_sleepnow) {
#ifndef WIN_SLEEPNOW1 __u8 args1[4] = {ATA_OP_SLEEPNOW1,0,0,0};
@@ -965,8 +1023,10 @@ @@ -1030,8 +1085,10 @@
if (get_sleepnow) if (get_sleepnow)
printf(" issuing sleep command\n"); printf(" issuing sleep command\n");
if (ioctl(fd, HDIO_DRIVE_CMD, &args1) if (do_drive_cmd(fd, args1)
- && ioctl(fd, HDIO_DRIVE_CMD, &args2)) - && do_drive_cmd(fd, args2))
+ && ioctl(fd, HDIO_DRIVE_CMD, &args2)) { + && do_drive_cmd(fd, args2)) {
+ err = errno; + err = errno;
perror(" HDIO_DRIVE_CMD(sleep) failed"); perror(" HDIO_DRIVE_CMD(sleep) failed");
+ } + }
} }
#ifdef WIN_SECURITY_FREEZE_LOCK
if (set_security) { if (set_security) {
@@ -1093,8 +1153,10 @@ do_set_security(fd);
unsigned char args[4] = {0xfb,0,0,0}; @@ -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) if (get_seagate)
printf(" disabling Seagate auto powersaving mode\n"); printf(" disabling Seagate auto powersaving mode\n");
- if (ioctl(fd, HDIO_DRIVE_CMD, &args)) - if (do_drive_cmd(fd, args))
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { + if (do_drive_cmd(fd, args)) {
+ err = errno; + err = errno;
perror(" HDIO_DRIVE_CMD(seagatepwrsave) failed"); perror(" HDIO_DRIVE_CMD(seagatepwrsave) failed");
+ } + }
} }
if (set_standby) { if (set_standby) {
unsigned char args[4] = {WIN_SETIDLE1,standby_requested,0,0}; __u8 args[4] = {ATA_OP_SETIDLE1,standby,0,0};
@@ -1102,8 +1164,10 @@ @@ -1055,14 +1116,18 @@
printf(" setting standby to %lu", standby_requested); printf(" setting standby to %u", standby);
interpret_standby(standby_requested); interpret_standby();
} }
- if (ioctl(fd, HDIO_DRIVE_CMD, &args)) - if (do_drive_cmd(fd, args))
+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) { + if (do_drive_cmd(fd, args)) {
+ err = errno; + err = errno;
perror(" HDIO_DRIVE_CMD(setidle1) failed"); perror(" HDIO_DRIVE_CMD(setidle1) failed");
+ } + }
} }
if (set_busstate) {
if (!flagcount) if (get_busstate)
@@ -1134,12 +1198,18 @@ 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; break;
default:printf("\?\?\?)\n"); default:printf("\?\?\?)\n");
} }
@ -382,9 +400,9 @@
+ perror(" HDIO_GET_32BIT failed"); + perror(" HDIO_GET_32BIT failed");
} }
} }
if (verbose || get_unmask) { if (do_defaults || get_unmask) {
if (0 == ioctl(fd, HDIO_GET_UNMASKINTR, &parm)) { if (0 == ioctl(fd, HDIO_GET_UNMASKINTR, &parm)) {
printf(" unmaskirq = %2ld", parm); printf(" unmaskirq = %2ld", parm);
on_off(parm); on_off(parm);
+ } else { + } else {
+ err = errno; + err = errno;
@ -392,7 +410,7 @@
} }
} }
@@ -1151,12 +1221,16 @@ @@ -1120,6 +1191,9 @@
printf(" (DMA-Assisted-PIO)\n"); printf(" (DMA-Assisted-PIO)\n");
else else
on_off(parm); on_off(parm);
@ -401,26 +419,16 @@
+ perror(" HDIO_GET_DMA failed"); + perror(" HDIO_GET_DMA failed");
} }
} }
#endif
#ifdef HDIO_GET_QDMA
if (get_dma_q) { if (get_dma_q) {
if(ioctl(fd, HDIO_GET_QDMA, &parm)) { @@ -1134,28 +1208,34 @@
+ err = errno;
perror(" HDIO_GET_QDMA failed");
} else {
printf(" queue_depth = %2ld", parm);
@@ -1169,32 +1243,38 @@
if (0 == ioctl(fd, HDIO_GET_KEEPSETTINGS, &parm)) { if (0 == ioctl(fd, HDIO_GET_KEEPSETTINGS, &parm)) {
printf(" keepsettings = %2ld", parm); printf(" keepsettings = %2ld", parm);
on_off(parm); on_off(parm);
+ } else { + } else {
+ err = errno; + err = errno;
+ perror(" HDIO_GET_KEEPSETTINGS failed"); + perror(" HDIO_GET_KEEPSETTINGS failed");
} }
} }
#endif /* HDIO_GET_KEEPSETTINGS */
#ifdef HDIO_SET_NOWERR
if (get_nowerr) { if (get_nowerr) {
- if (ioctl(fd, HDIO_GET_NOWERR, &parm)) - if (ioctl(fd, HDIO_GET_NOWERR, &parm))
+ if (ioctl(fd, HDIO_GET_NOWERR, &parm)) { + if (ioctl(fd, HDIO_GET_NOWERR, &parm)) {
@ -428,45 +436,41 @@
perror(" HDIO_GET_NOWERR failed"); perror(" HDIO_GET_NOWERR failed");
- else { - else {
+ } else { + } else {
printf(" nowerr = %2ld", parm); printf(" nowerr = %2ld", parm);
on_off(parm); on_off(parm);
} }
} }
#endif if (do_defaults || get_readonly) {
if (verbose || get_readonly) {
- if (ioctl(fd, BLKROGET, &parm)) - if (ioctl(fd, BLKROGET, &parm))
+ if (ioctl(fd, BLKROGET, &parm)) { + if (ioctl(fd, BLKROGET, &parm)) {
+ err = errno; + err = errno;
perror(" BLKROGET failed"); perror(" BLKROGET failed");
- else { - else {
+ } else { + } else {
printf(" readonly = %2ld", parm); printf(" readonly = %2ld", parm);
on_off(parm); on_off(parm);
} }
} }
if (verbose || get_fsreadahead) { if (do_defaults || get_fsreadahead) {
- if (ioctl(fd, BLKRAGET, &parm)) - if (ioctl(fd, BLKRAGET, &parm))
+ if (ioctl(fd, BLKRAGET, &parm)) { + if (ioctl(fd, BLKRAGET, &parm)) {
+ err = errno; + err = errno;
perror(" BLKRAGET failed"); perror(" BLKRAGET failed");
- else { - else {
+ } else { + } else {
printf(" readahead = %2ld", parm); printf(" readahead = %2ld", parm);
on_off(parm); on_off(parm);
} }
@@ -1209,15 +1289,16 @@ @@ -1170,12 +1250,13 @@
static struct hd_big_geometry bg; static struct hd_geometry g;
#endif static struct local_hd_big_geometry bg;
- if (0 == do_blkgetsize(fd, &blksize)) { - if (0 == do_blkgetsize(fd, &blksize)) {
+ if (0 == (err = do_blkgetsize(fd, &blksize))) { + if (0 == (err = do_blkgetsize(fd, &blksize))) {
#ifdef HDIO_GETGEO_BIG
if (!ioctl(fd, HDIO_GETGEO_BIG, &bg)) if (!ioctl(fd, HDIO_GETGEO_BIG, &bg))
printf(msg, bg.cylinders, bg.heads, bg.sectors, blksize, bg.start); printf(msg, bg.cylinders, bg.heads, bg.sectors, blksize, bg.start);
else - else if (ioctl(fd, HDIO_GETGEO, &g))
#endif + else if (ioctl(fd, HDIO_GETGEO, &g)) {
- if (ioctl(fd, HDIO_GETGEO, &g))
+ if (ioctl(fd, HDIO_GETGEO, &g)) {
+ err = errno; + err = errno;
perror(" HDIO_GETGEO failed"); perror(" HDIO_GETGEO failed");
- else - else
@ -474,38 +478,16 @@
printf(msg, g.cylinders, g.heads, g.sectors, blksize, g.start); printf(msg, g.cylinders, g.heads, g.sectors, blksize, g.start);
} }
} }
@@ -1234,6 +1315,7 @@ @@ -1185,6 +1266,7 @@
if (ioctl(fd, HDIO_DRIVE_CMD, &args) if (do_drive_cmd(fd, args)
&& (args[0] = WIN_CHECKPOWERMODE2) /* try again with 0x98 */ && (args[0] = ATA_OP_CHECKPOWERMODE2) /* (single =) try again with 0x98 */
&& ioctl(fd, HDIO_DRIVE_CMD, &args)) { && do_drive_cmd(fd, args)) {
+ err = errno; + err = errno;
if (errno != EIO || args[0] != 0 || args[1] != 0) if (errno != EIO || args[0] != 0 || args[1] != 0)
state = "unknown"; state = "unknown";
else else
@@ -1246,15 +1328,19 @@ @@ -1205,8 +1287,10 @@
#endif dump_identity(id2);
#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);
} else if (errno == -ENOMSG) } else if (errno == -ENOMSG)
printf(" no identification info available\n"); printf(" no identification info available\n");
- else - else
@ -514,67 +496,21 @@
perror(" HDIO_GET_IDENTITY failed"); perror(" HDIO_GET_IDENTITY failed");
+ } + }
} }
if (get_IDentity) { if (do_IDentity) {
__u16 *id; id = get_identify_data(fd, id);
@@ -1279,6 +1367,7 @@ @@ -1259,39 +1343,46 @@
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 (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 (get_busstate) {
- if (ioctl(fd, HDIO_GET_BUSSTATE, &parm)) - if (ioctl(fd, HDIO_GET_BUSSTATE, &parm))
+ if (ioctl(fd, HDIO_GET_BUSSTATE, &parm)) { + if (ioctl(fd, HDIO_GET_BUSSTATE, &parm)) {
+ err = errno; + err = errno;
perror(" HDIO_GET_BUSSTATE failed"); perror(" HDIO_GET_BUSSTATE failed");
- else { - else
+ } else { + } else
printf(" busstate = %2ld", parm); printf(" busstate = %2ld (%s)\n", parm, busstate_str(parm));
bus_state_value(parm);
}
@@ -1319,6 +1411,7 @@
#endif
if (reread_partn) {
if (ioctl(fd, BLKRRPART, NULL)) {
+ err = errno;
perror(" BLKRRPART failed");
}
} }
@@ -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) if (do_ctimings)
time_cache (fd); time_cache (fd);
if (do_timings) if (do_timings)
@ -582,11 +518,38 @@
+ err = time_device (fd); + err = time_device (fd);
if (do_flush) if (do_flush)
flush_buffer_cache (fd); 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); close (fd);
+ exit(err); + exit (err);
} }
void usage_error (int out) static void usage_help (int rc)
--- hdparm.h --- hdparm.h
+++ hdparm.h +++ hdparm.h
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@

View File

@ -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
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:03ba38f464ad1be1f3574ea2d0893d1aaef9251fc35e383756a20d4d835ff8a9
size 55061

View File

@ -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 Sat Oct 28 15:53:07 CEST 2006 - aj@suse.de

View File

@ -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 # This file and all modifications and additions to the pristine
# package are under the same license as the package itself. # package are under the same license as the package itself.
# #
@ -11,12 +11,12 @@
# norootforbuild # norootforbuild
Name: hdparm Name: hdparm
License: Freely Redistributable Software (FSR) License: Any permissive
Group: Hardware/Other Group: Hardware/Other
PreReq: %insserv_prereq %fillup_prereq coreutils PreReq: %insserv_prereq %fillup_prereq coreutils
Provides: base:/sbin/hdparm Provides: base:/sbin/hdparm
Autoreqprov: on Autoreqprov: on
Version: 6.9 Version: 7.1
Release: 1 Release: 1
Summary: A Program to Get and Set Hard Disk Parameters Summary: A Program to Get and Set Hard Disk Parameters
Source: hdparm-%{version}.tar.bz2 Source: hdparm-%{version}.tar.bz2
@ -43,7 +43,7 @@ Authors:
%setup -q %setup -q
%patch %patch
%patch1 %patch1
%patch2 #patch2
%build %build
make CFLAGS="$RPM_OPT_FLAGS -Wall -Wstrict-prototypes" LDFLAGS= make CFLAGS="$RPM_OPT_FLAGS -Wall -Wstrict-prototypes" LDFLAGS=
@ -101,7 +101,30 @@ fi
/etc/udev/rules.d/56-idedma.rules /etc/udev/rules.d/56-idedma.rules
/var/adm/fillup-templates/sysconfig.ide /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 * Sat Oct 28 2006 - aj@suse.de
- Update to version 6.9, changes since 6.6 are: - Update to version 6.9, changes since 6.6 are:
* added -s flag to control power-up in standby * added -s flag to control power-up in standby