summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/opensolaris
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2017-10-04 07:43:04 +0000
committeravg <avg@FreeBSD.org>2017-10-04 07:43:04 +0000
commit7dabf7165ce0478b645a42fb52c19554750ef6f2 (patch)
tree5aa3e8c8e37ea504409a2a44e6324db677861e96 /cddl/contrib/opensolaris
parent4dd3087fce1dcac3a4a31ac14113c4368173ded2 (diff)
downloadFreeBSD-src-7dabf7165ce0478b645a42fb52c19554750ef6f2.zip
FreeBSD-src-7dabf7165ce0478b645a42fb52c19554750ef6f2.tar.gz
MFC r323791: MFV r323790: 8567 Inconsistent return value in zpool_read_label
Diffstat (limited to 'cddl/contrib/opensolaris')
-rw-r--r--cddl/contrib/opensolaris/cmd/zpool/zpool_main.c2
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c9
2 files changed, 6 insertions, 5 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
index 572265f..409bd24 100644
--- a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
+++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
@@ -705,7 +705,7 @@ zpool_do_labelclear(int argc, char **argv)
return (1);
}
- if (zpool_read_label(fd, &config) != 0 || config == NULL) {
+ if (zpool_read_label(fd, &config) != 0) {
(void) fprintf(stderr,
gettext("failed to read label from %s\n"), vdev);
return (1);
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
index 3f6e643..1bbb8c5 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
@@ -865,6 +865,7 @@ label_offset(uint64_t size, int l)
/*
* Given a file descriptor, read the label information and return an nvlist
* describing the configuration, if there is one.
+ * Return 0 on success, or -1 on failure
*/
int
zpool_read_label(int fd, nvlist_t **config)
@@ -877,7 +878,7 @@ zpool_read_label(int fd, nvlist_t **config)
*config = NULL;
if (fstat64(fd, &statbuf) == -1)
- return (0);
+ return (-1);
size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t);
if ((label = malloc(sizeof (vdev_label_t))) == NULL)
@@ -911,7 +912,7 @@ zpool_read_label(int fd, nvlist_t **config)
free(label);
*config = NULL;
- return (0);
+ return (-1);
}
typedef struct rdsk_node {
@@ -1089,7 +1090,7 @@ zpool_open_func(void *arg)
}
#endif /* illumos */
- if ((zpool_read_label(fd, &config)) != 0) {
+ if ((zpool_read_label(fd, &config)) != 0 && errno == ENOMEM) {
(void) close(fd);
(void) no_memory(rn->rn_hdl);
return;
@@ -1590,7 +1591,7 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr,
*inuse = B_FALSE;
- if (zpool_read_label(fd, &config) != 0) {
+ if (zpool_read_label(fd, &config) != 0 && errno == ENOMEM) {
(void) no_memory(hdl);
return (-1);
}
OpenPOWER on IntegriCloud