aboutsummaryrefslogtreecommitdiff
path: root/lib/libzfs/os/linux/libzfs_pool_os.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libzfs/os/linux/libzfs_pool_os.c')
-rw-r--r--lib/libzfs/os/linux/libzfs_pool_os.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/libzfs/os/linux/libzfs_pool_os.c b/lib/libzfs/os/linux/libzfs_pool_os.c
index b135e0146962..7b18e31c8674 100644
--- a/lib/libzfs/os/linux/libzfs_pool_os.c
+++ b/lib/libzfs/os/linux/libzfs_pool_os.c
@@ -6,7 +6,7 @@
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
+ * or https://opensource.org/licenses/CDDL-1.0.
* See the License for the specific language governing permissions
* and limitations under the License.
*
@@ -96,7 +96,7 @@ zpool_relabel_disk(libzfs_handle_t *hdl, const char *path, const char *msg)
static int
read_efi_label(nvlist_t *config, diskaddr_t *sb)
{
- char *path;
+ const char *path;
int fd;
char diskname[MAXPATHLEN];
int err = -1;
@@ -268,11 +268,22 @@ zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name)
if (start_block == MAXOFFSET_T)
start_block = NEW_START_BLOCK;
slice_size -= start_block;
- slice_size = P2ALIGN(slice_size, PARTITION_END_ALIGNMENT);
+ slice_size = P2ALIGN_TYPED(slice_size, PARTITION_END_ALIGNMENT,
+ uint64_t);
vtoc->efi_parts[0].p_start = start_block;
vtoc->efi_parts[0].p_size = slice_size;
+ if (vtoc->efi_parts[0].p_size * vtoc->efi_lbasize < SPA_MINDEVSIZE) {
+ (void) close(fd);
+ efi_free(vtoc);
+
+ zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "cannot "
+ "label '%s': partition would be less than the minimum "
+ "device size (64M)"), path);
+ return (zfs_error(hdl, EZFS_LABELFAILED, errbuf));
+ }
+
/*
* Why we use V_USR: V_BACKUP confuses users, and is considered
* disposable by some EFI utilities (since EFI doesn't have a backup