The current offset of cxt->dev_fd may not be still 0, notably when blkdev_get_size has to resort to using blkdev_find_size Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx --- libfdisk/src/utils.c.original 2014-11-09 02:06:55.000000000 +0000 +++ libfdisk/src/utils.c 2014-11-09 02:07:58.000000000 +0000 @@ -49,6 +49,13 @@ int fdisk_read_firstsector(struct fdisk_ DBG(CXT, ul_debugobj(cxt, "reading first sector " "buffer [sector_size=%lu]", cxt->sector_size)); + r = lseek(cxt->dev_fd, 0, SEEK_SET); + if (r == -1) + { + DBG(CXT, ul_debugobj(cxt, "failed to seek to first sector %m")); + return -errno; + } + r = read(cxt->dev_fd, cxt->firstsector, cxt->sector_size); if (r != cxt->sector_size) { -- 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