diff options
| author | Andriy Gapon <avg@FreeBSD.org> | 2017-09-20 07:18:09 +0000 |
|---|---|---|
| committer | Andriy Gapon <avg@FreeBSD.org> | 2017-09-20 07:18:09 +0000 |
| commit | 035e679e27b17d10a69ec1dbc5538e70e66beaf5 (patch) | |
| tree | d9ecc50e3ee21362d69b2cd8d56163695568873b /lib | |
| parent | c014f2f95b331d1af4672afc8739eb071ae6551c (diff) | |
Notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libzfs/common/libzfs_import.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libzfs/common/libzfs_import.c b/lib/libzfs/common/libzfs_import.c index 496ba2c321ef..7fbd9faf0b29 100644 --- a/lib/libzfs/common/libzfs_import.c +++ b/lib/libzfs/common/libzfs_import.c @@ -841,6 +841,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) @@ -853,7 +854,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) @@ -887,7 +888,7 @@ zpool_read_label(int fd, nvlist_t **config) free(label); *config = NULL; - return (0); + return (-1); } typedef struct rdsk_node { @@ -1052,7 +1053,7 @@ zpool_open_func(void *arg) check_slices(rn->rn_avl, fd, rn->rn_name); } - 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; @@ -1517,7 +1518,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); } |
