diff options
author | mishra <none@none> | 2007-11-06 11:18:21 -0800 |
---|---|---|
committer | mishra <none@none> | 2007-11-06 11:18:21 -0800 |
commit | c92a08386ee67cad7e8f58bb28e68f0d30c18b4e (patch) | |
tree | 1717278c03dd7d94305acf991f18f56770e268b0 /usr | |
parent | 1f156c6a7686102f9a1057cb9294c57041f3da68 (diff) | |
download | illumos-joyent-c92a08386ee67cad7e8f58bb28e68f0d30c18b4e.tar.gz |
6607176 Format allows disk belonging to a ZFS pool to be resized and labeled.
Diffstat (limited to 'usr')
-rw-r--r-- | usr/src/cmd/format/analyze.c | 21 | ||||
-rw-r--r-- | usr/src/cmd/format/label.c | 13 | ||||
-rw-r--r-- | usr/src/cmd/format/menu_command.c | 18 | ||||
-rw-r--r-- | usr/src/cmd/format/modify_partition.c | 20 |
4 files changed, 62 insertions, 10 deletions
diff --git a/usr/src/cmd/format/analyze.c b/usr/src/cmd/format/analyze.c index 3a8499a077..e82f3afec6 100644 --- a/usr/src/cmd/format/analyze.c +++ b/usr/src/cmd/format/analyze.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * 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. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -176,7 +175,19 @@ do_scan(flags, mode) if ((flags & (SCAN_PATTERN | SCAN_WRITE)) && (checkswap(start, end))) { err_print("Cannot do analysis on a partition \ -which is currently being used for swapping.\n"); + which is currently being used for swapping.\n"); + return (-1); + } + + /* + * Check to see if any partitions used for svm, vxvm, ZFS zpool + * or live upgrade are on the disk. + */ + if ((flags & (SCAN_PATTERN | SCAN_WRITE)) && + (checkdevinuse(cur_disk->disk_name, (diskaddr_t)-1, + (diskaddr_t)-1, 0, 0))) { + err_print("Cannot do analysis on a partition " + "while it in use as described above.\n"); return (-1); } diff --git a/usr/src/cmd/format/label.c b/usr/src/cmd/format/label.c index 749c6ff918..023aa3870a 100644 --- a/usr/src/cmd/format/label.c +++ b/usr/src/cmd/format/label.c @@ -35,6 +35,7 @@ #include "main.h" #include "partition.h" #include "ctlr_scsi.h" +#include "checkdev.h" #include <string.h> #include <stdlib.h> #include <memory.h> @@ -278,6 +279,18 @@ write_label() #endif /* defined(_SUNOS_VTOC_8) */ /* + * Check to see if any partitions used for svm, vxvm or live upgrade + * are on the disk. If so, refuse to label the disk, but only + * if we are trying to shrink a partition in use. + */ + if (checkdevinuse(cur_disk->disk_name, (diskaddr_t)-1, + (diskaddr_t)-1, 0, 1)) { + err_print("Cannot label disk when " + "partitions are in use as described.\n"); + return (-1); + } + + /* * If EFI label, then write it out to disk */ if (cur_label == L_TYPE_EFI) { diff --git a/usr/src/cmd/format/menu_command.c b/usr/src/cmd/format/menu_command.c index 53f7092e9b..cdc088a741 100644 --- a/usr/src/cmd/format/menu_command.c +++ b/usr/src/cmd/format/menu_command.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -2218,6 +2218,7 @@ c_volname() "Please select a partition map for the disk first.\n"); return (-1); } + /* * Check to see if there are any mounted file systems anywhere * on the current disk. If so, refuse to label the disk, but @@ -2232,6 +2233,7 @@ c_volname() return (-1); } } + /* * Check to see if there are partitions being used for swapping * on the current disk. If so, refuse to label the disk, but @@ -2247,6 +2249,20 @@ being used for swapping.\n\n"); return (-1); } } + + /* + * Check to see if any partitions used for svm, vxvm, ZFS zpool + * or live upgrade are on the disk. If so, refuse to label the + * disk, but only if we are trying to shrink a partition in + * use. + */ + if (checkdevinuse(cur_disk->disk_name, (diskaddr_t)-1, + (diskaddr_t)-1, 0, 1)) { + err_print("Cannot label disk while its partitions " + "are in use as described.\n"); + return (-1); + } + /* * Prompt for the disk volume name. */ diff --git a/usr/src/cmd/format/modify_partition.c b/usr/src/cmd/format/modify_partition.c index 497d05a1f6..94b56b47fe 100644 --- a/usr/src/cmd/format/modify_partition.c +++ b/usr/src/cmd/format/modify_partition.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * 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. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -110,6 +109,7 @@ p_modify() "Cannot modify disk partitions while it has mounted partitions.\n\n"); return (-1); } + /* * If the disk has partitions currently being used for * swapping, cannot modify @@ -120,6 +120,18 @@ p_modify() currently being used for swapping.\n"); return (-1); } + + /* + * Check to see if any partitions used for svm, vxvm, ZFS zpool + * or live upgrade are on the disk. + */ + if (checkdevinuse(cur_disk->disk_name, (diskaddr_t)-1, + (diskaddr_t)-1, 0, 0)) { + err_print("Cannot modify disk partition when " + "partitions are in use as described.\n"); + return (-1); + } + /* * prompt user for a partition table base */ |