From 0ac8993002ee179cc3289243a0fc956ee0db04da Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 30 Jul 2020 01:12:12 -0500 Subject: 13013 Port OpenZFS zpool label clear improvements 13012 zpool_read_label semantics should match OpenZFS Portions contributed by: Jason King Reviewed by: Matt Ahrens Reviewed by: Tim Chase Reviewed by: Tony Hutter Reviewed by: Andy Fiddaman Reviewed by: Toomas Soome Approved by: Dan McDonald --- usr/src/lib/libzutil/common/zutil_import.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'usr/src/lib/libzutil/common/zutil_import.c') diff --git a/usr/src/lib/libzutil/common/zutil_import.c b/usr/src/lib/libzutil/common/zutil_import.c index 961247c5c0..b4e6ccc0ca 100644 --- a/usr/src/lib/libzutil/common/zutil_import.c +++ b/usr/src/lib/libzutil/common/zutil_import.c @@ -25,6 +25,7 @@ * Copyright (c) 2012, 2018 by Delphix. All rights reserved. * Copyright 2015 RackTop Systems. * Copyright (c) 2016, Intel Corporation. + * Copyright 2020 Joyent, Inc. */ /* @@ -913,8 +914,11 @@ zpool_read_label(int fd, nvlist_t **config, int *num_labels) *config = NULL; + if (num_labels != NULL) + *num_labels = 0; + if (fstat64(fd, &statbuf) == -1) - return (-1); + return (0); size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t); if ((label = malloc(sizeof (vdev_label_t))) == NULL) @@ -968,11 +972,6 @@ zpool_read_label(int fd, nvlist_t **config, int *num_labels) free(label); *config = expected_config; - if (count == 0) { - errno = ENOENT; - return (-1); - } - return (0); } -- cgit v1.2.3