svn commit: r324256 - in stable/10/cddl/contrib/opensolaris: cmd/zpool lib/libzfs/common

Andriy Gapon avg at FreeBSD.org
Wed Oct 4 07:43:27 UTC 2017


Author: avg
Date: Wed Oct  4 07:43:23 2017
New Revision: 324256
URL: https://svnweb.freebsd.org/changeset/base/324256

Log:
  MFC r323791: MFV r323790: 8567 Inconsistent return value in zpool_read_label

Modified:
  stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
  stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==============================================================================
--- stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c	Wed Oct  4 07:43:04 2017	(r324255)
+++ stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c	Wed Oct  4 07:43:23 2017	(r324256)
@@ -704,7 +704,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);

Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
==============================================================================
--- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c	Wed Oct  4 07:43:04 2017	(r324255)
+++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c	Wed Oct  4 07:43:23 2017	(r324256)
@@ -864,6 +864,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)
@@ -876,7 +877,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)
@@ -910,7 +911,7 @@ zpool_read_label(int fd, nvlist_t **config)
 
 	free(label);
 	*config = NULL;
-	return (0);
+	return (-1);
 }
 
 typedef struct rdsk_node {
@@ -1088,7 +1089,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;
@@ -1589,7 +1590,7 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_
 
 	*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);
 	}


More information about the svn-src-stable mailing list