On Mon, Jan 23, 2017 at 2:38 PM, Damien Le Moal <damien.lemoal@xxxxxxx> wrote: > Shaun, > > On 1/19/17 18:02, Shaun Tancheff wrote: >> +++ b/sys-utils/blkreset.c >> @@ -0,0 +1,192 @@ >> +/* > [...] >> + >> + if (ioctl(fd, BLKGETSIZE64, &blksize)) >> + err(EXIT_FAILURE, _("%s: BLKGETSIZE64 ioctl failed"), path); >> + >> + blksectors = blksize << 9; > > blksize being in bytes here, it looks like the shift is in the wrong > direction here... i.e. > > blksectors = blksize >> 9; Good catch! Reposting with Karel's suggestion to use blkdev_get_sectors(). Thanks! >> + >> + /* check offset alignment to the chunk size */ >> + if (zsector & (zsize - 1)) >> + errx(EXIT_FAILURE, _("%s: zone %" PRIu64 " is not aligned " >> + "to zone size %" PRIu64), path, zsector, zsize); >> + if (zsector > blksectors) >> + errx(EXIT_FAILURE, _("%s: zone %" PRIu64 " is too large " >> + "for device %" PRIu64), path, zsector, blksectors); >> + >> + zlen = zcount * zsize; >> + if (zsector + zlen > blksectors) >> + zlen = blksectors - zsector; >> + >> + za.sector = zsector; >> + za.nr_sectors = zlen; >> + rc = ioctl(fd, BLKRESETZONE, &za); >> + if (rc == -1) >> + err(EXIT_FAILURE, _("%s: BLKRESETZONE ioctl failed"), path); >> + >> + close(fd); >> + return EXIT_SUCCESS; >> +} >> > > Best regards. > > -- > Damien Le Moal, Ph.D. > Sr Manager, System Software Research Group, > Western Digital > Damien.LeMoal@xxxxxxxx > Tel: (+81) 0466-98-3593 (Ext. 51-3593) > 1 kirihara-cho, Fujisawa, Kanagawa, 252-0888 Japan > www.wdc.com, www.hgst.com > Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer: > > This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system. > -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html