diff options
author | Brian Behlendorf <[email protected]> | 2013-07-09 15:13:40 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-07-09 16:02:04 -0700 |
commit | ff3510c1a562914902d78f3d56552e126103f5a4 (patch) | |
tree | f841ead1a0c30d85a0868231cd6baddc644ad96a /lib/libzfs/libzfs_import.c | |
parent | 131cc95ca78b8552c13555d2cded791808008ff3 (diff) |
Fix zpool_read_label()
The zpool_read_label() function was subtly broken due to a
difference of behavior in fstat64(2) on Solaris vs Linux.
Under Solaris when a block device is stat'ed the st_size
field will contain the size of the device in bytes. Under
Linux this is only true for regular file and symlinks. A
compatibility function called fstat64_blk(2) was added
which can be used when the Solaris behavior is required.
This flaw was never noticed because the only time we would
need to use the device size is when the first two labels
are damaged. I noticed this issue while adding the
zpool_clear_label() function which is similar in design
and does require us to write all the labels.
Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'lib/libzfs/libzfs_import.c')
-rw-r--r-- | lib/libzfs/libzfs_import.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index de9851e60..9e79bd934 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -862,7 +862,7 @@ zpool_read_label(int fd, nvlist_t **config) *config = NULL; - if (fstat64(fd, &statbuf) == -1) + if (fstat64_blk(fd, &statbuf) == -1) return (0); size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t); |