Hello community,

here is the log from the commit of package hdparm for openSUSE:Factory checked 
in at 2018-11-06 13:57:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/hdparm (Old)
 and      /work/SRC/openSUSE:Factory/.hdparm.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "hdparm"

Tue Nov  6 13:57:53 2018 rev:71 rq:643891 version:9.57

Changes:
--------
--- /work/SRC/openSUSE:Factory/hdparm/hdparm.changes    2018-04-26 
13:34:48.159179587 +0200
+++ /work/SRC/openSUSE:Factory/.hdparm.new/hdparm.changes       2018-11-06 
13:58:26.707919946 +0100
@@ -1,0 +2,11 @@
+Thu Oct 18 08:16:40 UTC 2018 - mvet...@suse.com
+
+- Update to 9.57:
+  * Added --set-sector-size flag, used to change logical sector
+    size for drives which support multiple sector sizes.
+  * Also updated various bits of hdparm to better cope with
+    non-512 byte sectors.
+  * Various other minor fixes/enhancements.
+- Update hdparm-leak-fix.patch
+
+-------------------------------------------------------------------

Old:
----
  hdparm-9.56.tar.gz

New:
----
  hdparm-9.57.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ hdparm.spec ++++++
--- /var/tmp/diff_new_pack.sg99de/_old  2018-11-06 13:58:27.663918637 +0100
+++ /var/tmp/diff_new_pack.sg99de/_new  2018-11-06 13:58:27.667918631 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           hdparm
-Version:        9.56
+Version:        9.57
 Release:        0
 Summary:        A Program to get and set hard disk parameters
 License:        SUSE-Permissive
@@ -41,7 +41,7 @@
 %setup -q
 %patch1
 %patch2 -p1
-%patch3
+%patch3 -p1
 %patch4 -p1
 
 %build

++++++ hdparm-9.56.tar.gz -> hdparm-9.57.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hdparm-9.56/Changelog new/hdparm-9.57/Changelog
--- old/hdparm-9.56/Changelog   2018-03-25 19:07:14.000000000 +0200
+++ new/hdparm-9.57/Changelog   2018-10-16 19:39:11.000000000 +0200
@@ -1,3 +1,11 @@
+hdparm-9.57:
+       - added --set-sector-size flag to change logical sector size.
+       - fixed handling of non-512 byte logical sectors in several places.
+       - fixed possibility of infinite loop in sysfs_find_attr_file_path().
+       - respect the "quiet" flag in a few more places.
+       - skip "full device" checks for character devices (eg. /dev/sg*).
+       - don't issue READ_LOG_EXT commands unless the drive claims to support 
them.
+       - work around kernel/sysfs bug for "start" lba.
 hdparm-9.56:
        - fixed byte order for --Istdout so that --Istdin can grok it
        - added --Iraw for raw binary output of IDENTIFY data to a file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hdparm-9.56/fibmap.c new/hdparm-9.57/fibmap.c
--- old/hdparm-9.56/fibmap.c    2016-10-13 01:50:52.000000000 +0200
+++ new/hdparm-9.57/fibmap.c    2018-10-16 19:22:02.000000000 +0200
@@ -22,8 +22,6 @@
 
 #include "hdparm.h"
 
-static const unsigned int sector_bytes = 512; // FIXME someday
-
 struct file_extent {
        __u64 byte_offset;
        __u64 first_block;
@@ -152,7 +150,7 @@
 
 #define FIEMAP _IOWR('f', 11, struct fm_s)
 
-static int walk_fiemap (int fd, unsigned int sectors_per_block, __u64 
start_lba)
+static int walk_fiemap (int fd, unsigned int sectors_per_block, __u64 
start_lba, unsigned int sector_bytes)
 {
        unsigned int i, done = 0;
        unsigned int blksize = sectors_per_block * sector_bytes;
@@ -222,7 +220,7 @@
        int fd, err;
        struct stat st;
        __u64 start_lba = 0;
-       unsigned int sectors_per_block, blksize;
+       unsigned int sectors_per_block, blksize, sector_bytes;
 
        if ((fd = open(file_name, O_RDONLY)) == -1) {
                err = errno;
@@ -243,7 +241,7 @@
        /*
         * Get the filesystem starting LBA:
         */
-       err = get_dev_t_geometry(st.st_dev, NULL, NULL, NULL, &start_lba, NULL);
+       err = get_dev_t_geometry(st.st_dev, NULL, NULL, NULL, &start_lba, NULL, 
&sector_bytes);
        if (err) {
                close(fd);
                return err;
@@ -272,7 +270,7 @@
                return 0;
        }
 
-       err = walk_fiemap(fd, sectors_per_block, start_lba);
+       err = walk_fiemap(fd, sectors_per_block, start_lba, sector_bytes);
        if (err)
                err = walk_fibmap(fd, &st, blksize, sectors_per_block, 
start_lba);
        close (fd);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hdparm-9.56/geom.c new/hdparm-9.57/geom.c
--- old/hdparm-9.56/geom.c      2018-03-15 20:27:21.000000000 +0100
+++ new/hdparm-9.57/geom.c      2018-10-16 19:37:12.000000000 +0200
@@ -146,6 +146,7 @@
        static struct local_hd_geometry      g;
        static struct local_hd_big_geometry bg;
        int err = 0, try_getgeo_big_first = 1;
+       int sector_bytes = get_current_sector_size(fd);
 
        if (nsectors) {
                err = get_sector_count(fd, nsectors);
@@ -159,9 +160,12 @@
                 * so it cannot be relied upon for start_lba with very large 
drives >= 2TB.
                 */
                __u64 result;
-               if (0 == sysfs_get_attr(fd, "start", "%llu", &result, NULL, 0)
-                || 0 == get_raid1_start_lba(fd, &result))
-               {
+               if (0 == sysfs_get_attr(fd, "start", "%llu", &result, NULL, 0)) 
{
+                       result /= (sector_bytes / 512);   /* sysfs entry is 
broken for non-512byte sectors */
+                       *start_lba = result;
+                       start_lba = NULL;
+                       try_getgeo_big_first = 0;       /* if kernel has sysfs, 
it probably lacks GETGEO_BIG */
+               } else if (0 == get_raid1_start_lba(fd, &result)) {
                        *start_lba = result;
                         start_lba = NULL;
                        try_getgeo_big_first = 0;       /* if kernel has sysfs, 
it probably lacks GETGEO_BIG */
@@ -247,7 +251,7 @@
 }
 
 int get_dev_t_geometry (dev_t dev, __u32 *cyls, __u32 *heads, __u32 *sects,
-                               __u64 *start_lba, __u64 *nsectors)
+                               __u64 *start_lba, __u64 *nsectors, unsigned int 
*sector_bytes)
 {
        char path[PATH_MAX];
        int fd, err;
@@ -262,6 +266,7 @@
                perror(path);
                return err;
        }
+       *sector_bytes = get_current_sector_size(fd);
 
        err = get_dev_geometry(fd, cyls, heads, sects, start_lba, nsectors);
        close(fd);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hdparm-9.56/hdparm.8 new/hdparm-9.57/hdparm.8
--- old/hdparm-9.56/hdparm.8    2018-03-25 19:08:09.000000000 +0200
+++ new/hdparm-9.57/hdparm.8    2018-10-16 20:15:23.000000000 +0200
@@ -1,4 +1,4 @@
-.TH HDPARM 8 "March 2018" "Version 9.55"
+.TH HDPARM 8 "October 2018" "Version 9.57"
 
 .SH NAME
 hdparm \- get/set SATA/IDE device parameters
@@ -606,6 +606,13 @@
 minutes plus 15 seconds.  Note that some older drives may have very
 different interpretations of these values.
 .TP
+.I --set-sector-size
+For drives which support reconfiguring of the Logical Sector Size,
+this flag can be used to specify the new desired sector size in bytes.
+.B VERY DANGEROUS.  This most likely will scramble all data on the drive.
+The specified size must be one of 512, 520, 528, 4096, 4160, or 4224.
+Very few drives support values other than 512 and 4096.
+.TP
 .I -t
 Perform timings of device reads for benchmark and comparison purposes.
 For meaningful results, this operation should be repeated 2-3 times on
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hdparm-9.56/hdparm.c new/hdparm-9.57/hdparm.c
--- old/hdparm-9.56/hdparm.c    2018-03-25 19:06:24.000000000 +0200
+++ new/hdparm-9.57/hdparm.c    2018-10-16 20:12:53.000000000 +0200
@@ -1,8 +1,8 @@
 /*
  * hdparm.c - Command line interface to get/set hard disk parameters.
- *          - by Mark Lord (C) 1994-2017 -- freely distributable.
+ *          - by Mark Lord (C) 1994-2018 -- freely distributable.
  */
-#define HDPARM_VERSION "v9.56"
+#define HDPARM_VERSION "v9.57"
 
 #define _LARGEFILE64_SOURCE /*for lseek64*/
 #define _BSD_SOURCE    /* for strtoll() */
@@ -139,6 +139,9 @@
 static struct sector_range_s *trim_sector_ranges = NULL;
 static int   trim_sector_ranges_count = 0;
 static int   trim_from_stdin = 0;
+static int   do_set_sector_size = 0;
+static __u64 new_sector_size = 0;
+#define SET_SECTOR_SIZE "set-sector-size"
 
 static int   write_sector = 0;
 static __u64 write_sector_addr = ~0ULL;
@@ -985,11 +988,13 @@
                        fprintf(stderr, "BUG in do_set_security(), 
command1=0x%x\n", security_command);
                        exit(EINVAL);
        }
-       printf(" Issuing %s command, password=\"%s\", user=%s",
-               description, security_password, (data[0] & 1) ? "master" : 
"user");
-       if (security_command == ATA_OP_SECURITY_SET_PASS)
-               printf(", mode=%s", data[1] ? "max" : "high");
-       printf("\n");
+       if (!quiet) {
+               printf(" Issuing %s command, password=\"%s\", user=%s",
+                       description, security_password, (data[0] & 1) ? 
"master" : "user");
+               if (security_command == ATA_OP_SECURITY_SET_PASS)
+                       printf(", mode=%s", data[1] ? "max" : "high");
+               printf("\n");
+       }
 
        /*
         * The Linux kernel IDE driver (until at least 2.6.12) segfaults on the 
first
@@ -1081,7 +1086,7 @@
        }
 }
 
-int get_id_log_page_data (int fd, __u8 pagenr, __u8 *buf)
+static int do_read_log (int fd, __u8 log_address, __u8 pagenr, void *buf)
 {
        struct hdio_taskfile *r;
        int err = 0;
@@ -1093,7 +1098,7 @@
                return err;
        }
 
-       init_hdio_taskfile(r, ATA_OP_READ_LOG_EXT, RW_READ, LBA48_FORCE, 0x30 + 
(pagenr << 8), 1, 512);
+       init_hdio_taskfile(r, ATA_OP_READ_LOG_EXT, RW_READ, LBA48_FORCE, 
log_address + (pagenr << 8), 1, 512);
        if (do_taskfile_cmd(fd, r, timeout_15secs)) {
                err = errno;
        } else {
@@ -1103,6 +1108,35 @@
        return err;
 }
 
+
+int get_log_page_data (int fd, __u8 log_address, __u8 pagenr, __u8 *buf)
+{
+       static __u16 *page0 = NULL, page0_buf[512] = {0,};
+       int err;
+
+       get_identify_data(fd);
+       if (!id)
+               exit(EIO);
+       if ((id[84] && (1<<5)) == 0)
+               return -ENOENT;  /* READ_LOG_EXT not supported */
+       if (!page0) {
+               err = do_read_log(fd, 0, 0, page0_buf);
+               if (err) {
+                       fprintf(stderr, "READ_LOG_EXT(0,0) failed: %s\n", 
strerror(err));
+                       return -ENOENT;
+               }
+               page0 = page0_buf;
+       }
+       if (page0[log_address] <= pagenr)
+               return -ENOENT;
+       err = do_read_log(fd, log_address, pagenr, buf);
+       if (err) {
+               fprintf(stderr, "READ_LOG_EXT(0x%02x, %u) failed: %s\n", 
log_address, pagenr, strerror(err));
+               return -ENOENT;
+       }
+       return 0;
+}
+
 static void confirm_i_know_what_i_am_doing (const char *opt, const char 
*explanation)
 {
        if (!i_know_what_i_am_doing) {
@@ -1138,11 +1172,11 @@
        return err;
 }
 
-static void dump_sectors (__u16 *w, unsigned int count, int raw)
+static void dump_sectors (__u16 *w, unsigned int count, int raw, unsigned int 
sector_bytes)
 {
        unsigned int i;
 
-       for (i = 0; i < (count*256/8); ++i) {
+       for (i = 0; i < (count*(sector_bytes/2)/8); ++i) {
                if (raw) {
                        printf("%04x %04x %04x %04x %04x %04x %04x %04x\n",
                                w[0], w[1], w[2], w[3], w[4], w[5], w[6], w[7]);
@@ -1160,10 +1194,13 @@
 
 static int abort_if_not_full_device (int fd, __u64 lba, const char *devname, 
const char *msg)
 {
+       struct stat stat;
        __u64 start_lba;
        int i, err, shortened = 0;
        char *fdevname = strdup(devname);
 
+       if (0 == fstat(fd, &stat) && S_ISCHR(stat.st_mode))
+               return 0; /* skip geometry test for character (non-block) 
devices; eg. /dev/sg* */
        err = get_dev_geometry(fd, NULL, NULL, NULL, &start_lba, NULL);
        if (err)
                exit(err);
@@ -1211,7 +1248,7 @@
                        unsigned char *b = (unsigned char *)&dco[i];
                        dco[i] = b[0] | (b[1] << 8);    /* le16_to_cpu */
                }
-               //dump_sectors(dco, 1, 0);
+               //dump_sectors(dco, 1, 0, 512);
                return dco;
        }
 }
@@ -1243,7 +1280,7 @@
                }
                if (verbose) {
                        printf("Original DCO:\n");
-                       dump_sectors(dco, 1, 0);
+                       dump_sectors(dco, 1, 0, 512);
                }
                // set the new MAXLBA to the requested sectors - 1
                *maxlba = set_max_addr - 1;
@@ -1251,7 +1288,7 @@
                dco[255] = (dco[255] & 0xFF) | ((__u16) 
dco_verify_checksum(dco) << 8);
                if (verbose) {
                        printf("New DCO:\n");
-                       dump_sectors(dco, 1, 0);
+                       dump_sectors(dco, 1, 0, 512);
                }
 
        } else {
@@ -1557,6 +1594,82 @@
        return 1;  /* all other drives, including Intel SSDs */
 }
 
+int get_current_sector_size (int fd)
+{
+       unsigned int words = 256;
+
+       get_identify_data(fd);
+       if((id[106] & 0xc000) == 0x4000) {
+               if (id[106] & (1<<12))
+                       words = (id[118] << 16) | id[117];
+       }
+       return 2 * words;
+}
+
+static int
+get_set_sector_index (int fd, unsigned int wanted_sector_size, int *checkword)
+{
+       __u8 d[512] = {0,};
+       const int SECTOR_CONFIG = 0x2f;
+       int i, rc;
+
+       rc = get_log_page_data(fd, SECTOR_CONFIG, 0, d);
+       if (rc) {
+               fprintf(stderr, "READ_LOG_EXT(SECTOR_CONFIGURATION) failed: 
%s\n", strerror(rc));
+               exit(1);
+       }
+       for (i = 0; i < 128; i += 16) {
+               unsigned int lss;
+               if ((d[i] & 0x80) == 0)  /* Is this descriptor valid? */
+                       continue;  /* not valid */
+               lss = d[i + 4] | (d[i + 5] << 8) | (d[i + 6] << 16) | (d[i + 7] 
<< 24);  /* logical sector size */
+               if (lss == wanted_sector_size) {
+                       *checkword = d[i + 2] | (d[i + 3] << 8);
+                       return i / 16;  /* descriptor index */
+               }
+       }
+       fprintf(stderr, "ERROR: unsupported sector size: %d\n", 
wanted_sector_size);
+       exit (-1);
+}
+
+static int do_set_sector_size_cmd (int fd, const char *devname)
+{
+       int index, err = 0;
+       __u8 ata_op;
+       struct hdio_taskfile *r;
+       int checkword = 0;
+
+       abort_if_not_full_device(fd, 0, devname, NULL);
+       r = malloc(sizeof(struct hdio_taskfile) + 512);
+       if (!r) {
+               err = errno;
+               perror("malloc()");
+               return err;
+       }
+       ata_op = ATA_OP_SET_SECTOR_CONFIGURATION;
+       init_hdio_taskfile(r, ata_op, RW_WRITE, LBA48_FORCE, 0, 0, 0);
+
+       index = get_set_sector_index(fd, new_sector_size, &checkword);
+       r->hob.feat  = checkword >> 8;
+       r->lob.feat  = checkword;
+       r->hob.nsect = 0;
+       r->lob.nsect = index;
+       r->oflags.bits.hob.feat = 1;
+
+       printf("changing sector size configuration to %llu: ", new_sector_size);
+       fflush(stdout);
+
+       if (do_taskfile_cmd(fd, r, timeout_60secs)) {
+               err = errno;
+               perror("FAILED");
+       } else {
+               printf("succeeded\n");
+       }
+
+       free(r);
+       return err;
+}
+
 static int
 do_trim_from_stdin (int fd, const char *devname)
 {
@@ -1628,16 +1741,17 @@
        int err = 0;
        __u8 ata_op;
        struct hdio_taskfile *r;
+       int sector_bytes = get_current_sector_size(fd);
 
        abort_if_not_full_device(fd, lba, devname, NULL);
-       r = malloc(sizeof(struct hdio_taskfile) + 512);
+       r = malloc(sizeof(struct hdio_taskfile) + sector_bytes);
        if (!r) {
                err = errno;
                perror("malloc()");
                return err;
        }
        ata_op = (lba >= lba28_limit) ? ATA_OP_WRITE_PIO_EXT : ATA_OP_WRITE_PIO;
-       init_hdio_taskfile(r, ata_op, RW_WRITE, LBA28_OK, lba, 1, 512);
+       init_hdio_taskfile(r, ata_op, RW_WRITE, LBA28_OK, lba, 1, sector_bytes);
 
        printf("re-writing sector %llu: ", lba);
        fflush(stdout);
@@ -1661,16 +1775,17 @@
        int err = 0;
        __u8 ata_op;
        struct hdio_taskfile *r;
+       int sector_bytes = get_current_sector_size(fd);
 
        abort_if_not_full_device(fd, lba, devname, NULL);
-       r = malloc(sizeof(struct hdio_taskfile) + 512);
+       r = malloc(sizeof(struct hdio_taskfile) + sector_bytes);
        if (!r) {
                err = errno;
                perror("malloc()");
                return err;
        }
        ata_op = (lba >= lba28_limit) ? ATA_OP_READ_PIO_EXT : ATA_OP_READ_PIO;
-       init_hdio_taskfile(r, ata_op, RW_READ, LBA28_OK, lba, 1, 512);
+       init_hdio_taskfile(r, ata_op, RW_READ, LBA28_OK, lba, 1, sector_bytes);
 
        printf("reading sector %llu: ", lba);
        fflush(stdout);
@@ -1680,7 +1795,7 @@
                perror("FAILED");
        } else {
                printf("succeeded\n");
-               dump_sectors(r->data, 1, 0);
+               dump_sectors(r->data, 1, 0, sector_bytes);
        }
        free(r);
        return err;
@@ -1834,6 +1949,7 @@
        " --sanitize-overwrite  PATTERN  Overwrite the internal media with 
constant PATTERN\n"
        " --sanitize-status           Show sanitize status information\n"
        " --security-help             Display help for ATA security commands\n"
+       " --set-sector-size           Change logical sector size of drive\n"
        " --trim-sector-ranges        Tell SSD firmware to discard unneeded 
data sectors: lba:count ..\n"
        " --trim-sector-ranges-stdin  Same as above, but reads lba:count pairs 
from stdin\n"
        " --verbose                   Display extra diagnostics from some 
commands\n"
@@ -1898,6 +2014,13 @@
                exit(err);
        }
 
+       if (do_set_sector_size) {
+               if (num_flags_processed > 1 || argc)
+                       usage_help(16,EINVAL);
+               confirm_please_destroy_my_drive("--" SET_SECTOR_SIZE, "This 
will likely destroy all data on the drive.");
+               exit(do_set_sector_size_cmd(fd, devname));
+       }
+
        if (trim_from_stdin) {
                if (num_flags_processed > 1 || argc)
                        usage_help(12,EINVAL);
@@ -2228,7 +2351,8 @@
        if (do_dco_restore) {
                __u8 args[4] = {ATA_OP_DCO,0,0xc0,0};
                confirm_i_know_what_i_am_doing("--dco-restore", "You are trying 
to deliberately reset your drive configuration back to the factory 
defaults.\nThis may change the apparent capacity and feature set of the drive, 
making all data on it inaccessible.\nYou could lose *everything*.");
-               printf(" issuing DCO restore command\n");
+               if (!quiet)
+                       printf(" issuing DCO restore command\n");
                if (do_drive_cmd(fd, args, 0)) {
                        err = errno;
                        perror(" HDIO_DRIVE_CMD(dco_restore) failed");
@@ -2236,7 +2360,8 @@
        }
        if (do_dco_freeze) {
                __u8 args[4] = {ATA_OP_DCO,0,0xc1,0};
-               printf(" issuing DCO freeze command\n");
+               if (!quiet)
+                       printf(" issuing DCO freeze command\n");
                if (do_drive_cmd(fd, args, 0)) {
                        err = errno;
                        perror(" HDIO_DRIVE_CMD(dco_freeze) failed");
@@ -2249,7 +2374,8 @@
                                confirm_i_know_what_i_am_doing("--dco-setmax", 
"You have requested reducing the apparent size of the drive.\nThis is a BAD 
idea, and can easily destroy all of the drive's contents.");
 
                        // set max sectors with DCO set command
-                       printf("issuing DCO set command (sectors = %llu)\n", 
set_max_addr);
+                       if (!quiet)
+                               printf("issuing DCO set command (sectors = 
%llu)\n", set_max_addr);
                        do_dco_setmax_cmd(fd);
 
                        // invalidate current IDENTIFY data
@@ -2258,7 +2384,8 @@
        }
        if (security_freeze) {
                __u8 args[4] = {ATA_OP_SECURITY_FREEZE_LOCK,0,0,0};
-               printf(" issuing security freeze command\n");
+               if (!quiet)
+                       printf(" issuing security freeze command\n");
                if (do_drive_cmd(fd, args, 0)) {
                        err = errno;
                        perror(" HDIO_DRIVE_CMD(security_freeze) failed");
@@ -2266,7 +2393,7 @@
        }
        if (set_seagate) {
                __u8 args[4] = {0xfb,0,0,0};
-               if (get_seagate)
+               if (!quiet && get_seagate)
                        printf(" disabling Seagate auto powersaving mode\n");
                if (do_drive_cmd(fd, args, 0)) {
                        err = errno;
@@ -2274,7 +2401,7 @@
                }
        }
        if (set_busstate) {
-               if (get_busstate)
+               if (!quiet && get_busstate)
                        printf(" setting bus state to %d (%s)\n", busstate, 
busstate_str(busstate));
                if (ioctl(fd, HDIO_SET_BUSSTATE, busstate)) {
                        err = errno;
@@ -2282,7 +2409,7 @@
                }
        }
        if (set_max_sectors) {
-               if (get_native_max_sectors)
+               if (!quiet && get_native_max_sectors)
                        printf(" setting max visible sectors to %llu (%s)\n", 
set_max_addr, set_max_permanent ? "permanent" : "temporary");
                get_identify_data(fd);
                if (id) {
@@ -2536,7 +2663,7 @@
                get_identify_data(fd);
                if (id) {
                        if (do_IDentity == 2) {
-                               dump_sectors(id, 1, 1);
+                               dump_sectors(id, 1, 1, 512);
                        } else if (do_IDentity == 3) {
                                /* Write raw binary IDENTIFY DEVICE data to the 
specified file */
                                int rfd = open(raw_identify_path, 
O_WRONLY|O_TRUNC|O_CREAT, 0644);
@@ -2920,6 +3047,7 @@
        }
 }
 
+static const char *sector_size_emsg = "sector size out of range";
 static const char *lba_emsg = "bad/missing sector value";
 static const char *count_emsg = "bad/missing sector count";
 static const __u64 lba_limit = (1ULL << 48) - 1;
@@ -3164,6 +3292,9 @@
                erase_sectors = 1;
                get_u64_parm(0, 0, NULL, &erase_sectors_addr, 0, lba_limit, 
name, lba_emsg);
 #endif
+       } else if (0 == strcasecmp(name, SET_SECTOR_SIZE)) {
+               if (get_u64_parm(0, 0, NULL, &new_sector_size, 0x200, 0x1080, 
"--" SET_SECTOR_SIZE, sector_size_emsg))
+                       do_set_sector_size = 1;
        } else if (0 == strcasecmp(name, "trim-sector-ranges-stdin")) {
                trim_from_stdin = 1;
        } else if (0 == strcasecmp(name, "trim-sector-ranges")) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hdparm-9.56/hdparm.h new/hdparm-9.57/hdparm.h
--- old/hdparm-9.56/hdparm.h    2017-05-01 21:09:54.000000000 +0200
+++ new/hdparm-9.57/hdparm.h    2018-10-16 19:01:00.000000000 +0200
@@ -19,7 +19,8 @@
 int sysfs_get_attr_recursive (int fd, const char *attr, const char *fmt, void 
*val1, void *val2, int verbose);
 
 int get_dev_geometry (int fd, __u32 *cyls, __u32 *heads, __u32 *sects, __u64 
*start_lba, __u64 *nsectors);
-int get_dev_t_geometry (dev_t dev, __u32 *cyls, __u32 *heads, __u32 *sects, 
__u64 *start_lba, __u64 *nsectors);
+int get_dev_t_geometry (dev_t dev, __u32 *cyls, __u32 *heads, __u32 *sects,
+                               __u64 *start_lba, __u64 *nsectors, unsigned int 
*sector_bytes);
 int do_filemap(const char *file_name);
 int do_fallocate_syscall (const char *name, __u64 bytecount);
 int fwdownload (int fd, __u16 *id, const char *fwpath, int xfer_mode);
@@ -32,7 +33,8 @@
 void wdidle3_print_timeout (unsigned char timeout);
 unsigned char wdidle3_msecs_to_timeout (unsigned int msecs);
 
-int get_id_log_page_data (int fd, __u8 pagenr, __u8 *buf);
+int get_log_page_data (int fd, __u8 log_address, __u8 pagenr, __u8 *buf);
+int get_current_sector_size (int fd);
 
 /* APT Functions */
 int apt_detect (int fd, int verbose);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hdparm-9.56/hdparm.lsm new/hdparm-9.57/hdparm.lsm
--- old/hdparm-9.56/hdparm.lsm  2018-03-25 19:08:50.000000000 +0200
+++ new/hdparm-9.57/hdparm.lsm  2018-10-16 20:13:38.000000000 +0200
@@ -1,8 +1,9 @@
 Begin4
 Title:         hdparm
-Version:       9.56
-Entered-date:  2018-03-25
+Version:       9.57
+Entered-date:  2018-10-16
 Description:   hdparm - get/set hard disk parameters for Linux SATA/IDE drives.
+               v9.57 added --set-sector-size, general support for non-512 byte 
partitions
                v9.56 fixed --Istdout, added --Iraw
                v9.55 #include <sys/sysmacros.h>
                v9.54 partial revert of JMicron changes.
@@ -130,7 +131,7 @@
 Maintained-by: ml...@pobox.com (Mark Lord)
 Primary-site:  http://sourceforge.net/projects/hdparm/
 Alternate-site:        http://www.ibiblio.org/pub/Linux/system/hardware
-               137K hdparm-9.56.tar.gz
+               138K hdparm-9.57.tar.gz
                7K hdparm.lsm
 Platforms:     Linux
 Copying-policy:        BSD License
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hdparm-9.56/identify.c new/hdparm-9.57/identify.c
--- old/hdparm-9.56/identify.c  2016-10-17 20:06:28.000000000 +0200
+++ new/hdparm-9.57/identify.c  2018-09-19 17:17:28.000000000 +0200
@@ -678,7 +678,7 @@
                int mdat = 0;
 
                memset(buf, 0, 512);
-               if (fd != -1 && !get_id_log_page_data(fd, 8, buf) && (buf[0x37] 
& 0x80)) {
+               if (fd != -1 && !get_log_page_data(fd, 0x30, 8, buf) && 
(buf[0x37] & 0x80)) {
                        mdat = buf[0x30] & 0x1f;
                        deto = buf[0x31];
                        printf("Device Sleep:\n");
@@ -688,6 +688,28 @@
        }
 }
 
+static void
+print_logical_sector_sizes (int fd)
+{
+       __u8 d[512] = {0,};
+       int i, found = 0, rc;
+
+       rc = get_log_page_data(fd, 0x2f, 0, d);
+       if (rc)
+               return;
+       for (i = 0; i < 128; i += 16) {
+               unsigned int lss;
+               if ((d[i] & 0x80) == 0)  /* Is this descriptor valid? */
+                       continue;  /* not valid */
+               if (!found++)
+                       printf(" [ Supported:");
+               lss = d[i + 4] | (d[i + 5] << 8) | (d[i + 6] << 16) | (d[i + 7] 
<< 24);  /* logical sector size */
+               printf(" %u", lss);
+       }
+       if (found)
+               printf(" ]");
+}
+
 /* our main() routine: */
 void identify (int fd, __u16 *id_supplied)
 {
@@ -974,20 +996,23 @@
                        if (val[106] & (1<<12))
                                lsize = (val[118] << 16) | val[117];
                        sector_bytes = 2 * lsize;
-                       printf("\t%-31s %11u bytes\n","Logical  Sector size:", 
sector_bytes);
+                       printf("\t%-31s %11u bytes","Logical  Sector size:", 
sector_bytes);
+                       print_logical_sector_sizes(fd);
+                       printf("\n");
                        printf("\t%-31s %11u bytes\n","Physical Sector size:", 
sector_bytes * pfactor);
                        if ((val[209] & 0xc000) == 0x4000) {
                                unsigned int offset = val[209] & 0x1fff;
                                printf("\t%-31s %11u bytes\n", "Logical 
Sector-0 offset:", offset * sector_bytes);
                        }
                }
-               if (!bbbig) bbbig = (__u64)(ll>mm ? ll : mm); /* # 512 byte 
blocks */
+               if (!bbbig) bbbig = (__u64)((ll > mm) ? ll : mm); /* # 512 byte 
blocks */
                if (!bbbig) bbbig = bb;
-               bbbig *= (sector_bytes / 512);
-               printf("\tdevice size with M = 1024*1024: %11llu MBytes\n", 
(unsigned long long)(bbbig>>11));
-               bbbig = (bbbig<<9)/1000000;
-               printf("\tdevice size with M = 1000*1000: %11llu MBytes ", 
(unsigned long long)bbbig);
-               if(bbbig > 1000) printf("(%llu GB)\n", (unsigned long 
long)(bbbig/1000));
+               bbbig *= sector_bytes;
+
+               printf("\tdevice size with M = 1024*1024: %11llu MBytes\n", 
bbbig / (1024ull * 1024ull));
+               bbbig /= 1000ull;
+               printf("\tdevice size with M = 1000*1000: %11llu MBytes ",  
bbbig / 1000ull);
+               if (bbbig > 1000ull) printf("(%llu GB)\n", bbbig/1000000ull);
                else printf("\n");
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hdparm-9.56/sgio.h new/hdparm-9.57/sgio.h
--- old/hdparm-9.56/sgio.h      2017-05-01 21:07:50.000000000 +0200
+++ new/hdparm-9.57/sgio.h      2018-10-12 19:22:49.000000000 +0200
@@ -33,6 +33,7 @@
        ATA_OP_GET_NATIVE_MAX_EXT       = 0x78,
        ATA_OP_SMART                    = 0xb0,
        ATA_OP_DCO                      = 0xb1,
+       ATA_OP_SET_SECTOR_CONFIGURATION = 0xb2,
        ATA_OP_SANITIZE                 = 0xb4,
        ATA_OP_ERASE_SECTORS            = 0xc0,
        ATA_OP_READ_DMA                 = 0xc8,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hdparm-9.56/sysfs.c new/hdparm-9.57/sysfs.c
--- old/hdparm-9.56/sysfs.c     2018-03-15 20:27:21.000000000 +0100
+++ new/hdparm-9.57/sysfs.c     2018-09-03 20:20:25.000000000 +0200
@@ -217,7 +217,7 @@
 
        strcpy(path, start_path);
 
-       while (depth < 20) {
+       while (depth++ < 20) {
                strcat(path, "/..");
 
                if (stat(path, &st) != 0)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hdparm-9.56/wdidle3.c new/hdparm-9.57/wdidle3.c
--- old/hdparm-9.56/wdidle3.c   2016-10-13 01:50:52.000000000 +0200
+++ new/hdparm-9.57/wdidle3.c   2018-10-16 18:55:35.000000000 +0200
@@ -195,7 +195,7 @@
 void wdidle3_print_timeout (unsigned char timeout)
 {
        if (verbose)
-               printf("[raw=0x%02x] ", timeout);       //FIXME
+               printf("[raw=0x%02x] ", timeout);
        if (timeout == 0)
                printf("disabled");
        else if (timeout < 0x50 || timeout == WDC_TIMEOUT_THRESHOLD)

++++++ hdparm-leak-fix.patch ++++++
--- /var/tmp/diff_new_pack.sg99de/_old  2018-11-06 13:58:27.819918423 +0100
+++ /var/tmp/diff_new_pack.sg99de/_new  2018-11-06 13:58:27.823918418 +0100
@@ -1,15 +1,16 @@
---- hdparm.c.old       2009-08-02 22:08:56.000000000 +0200
-+++ hdparm.c   2009-09-17 09:57:44.000000000 +0200
-@@ -880,7 +880,7 @@
- {
+diff -urEbwB hdparm-9.57/hdparm.c hdparm-9.57.new/hdparm.c
+--- hdparm-9.57/hdparm.c       2018-10-16 20:12:53.000000000 +0200
++++ hdparm-9.57.new/hdparm.c   2018-10-18 10:15:54.448809739 +0200
+@@ -1197,7 +1197,7 @@
+       struct stat stat;
        __u64 start_lba;
        int i, err, shortened = 0;
 -      char *fdevname = strdup(devname);
 +      char *fdevname = strdupa(devname);
  
-       err = get_dev_geometry(fd, NULL, NULL, NULL, &start_lba, NULL);
-       if (err)
-@@ -891,7 +891,7 @@
+       if (0 == fstat(fd, &stat) && S_ISCHR(stat.st_mode))
+               return 0; /* skip geometry test for character (non-block) 
devices; eg. /dev/sg* */
+@@ -1210,7 +1210,7 @@
        }
  
        if (!shortened)


Reply via email to