1 /* $NetBSD: vgdisplay.c,v 1.1.1.1 2008/12/22 00:19:09 haad Exp $ */ 2 3 /* 4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. 5 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. 6 * 7 * This file is part of LVM2. 8 * 9 * This copyrighted material is made available to anyone wishing to use, 10 * modify, copy, or redistribute it subject to the terms and conditions 11 * of the GNU Lesser General Public License v.2.1. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this program; if not, write to the Free Software Foundation, 15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 */ 17 18 #include "tools.h" 19 20 static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name, 21 struct volume_group *vg, int consistent, 22 void *handle __attribute((unused))) 23 { 24 /* FIXME Do the active check here if activevolumegroups_ARG ? */ 25 if (!vg) { 26 log_error("Volume group \"%s\" doesn't exist", vg_name); 27 return ECMD_FAILED; 28 } 29 30 if (!consistent) 31 log_error("WARNING: Volume group \"%s\" inconsistent", vg_name); 32 33 vg_check_status(vg, EXPORTED_VG); 34 35 if (arg_count(cmd, colon_ARG)) { 36 vgdisplay_colons(vg); 37 return ECMD_PROCESSED; 38 } 39 40 if (arg_count(cmd, short_ARG)) { 41 vgdisplay_short(vg); 42 return ECMD_PROCESSED; 43 } 44 45 vgdisplay_full(vg); /* was vg_show */ 46 47 if (arg_count(cmd, verbose_ARG)) { 48 vgdisplay_extents(vg); 49 50 process_each_lv_in_vg(cmd, vg, NULL, NULL, NULL, 51 (process_single_lv_fn_t)lvdisplay_full); 52 53 log_print("--- Physical volumes ---"); 54 process_each_pv_in_vg(cmd, vg, NULL, NULL, 55 (process_single_pv_fn_t)pvdisplay_short); 56 } 57 58 check_current_backup(vg); 59 60 return ECMD_PROCESSED; 61 } 62 63 int vgdisplay(struct cmd_context *cmd, int argc, char **argv) 64 { 65 if (arg_count(cmd, columns_ARG)) { 66 if (arg_count(cmd, colon_ARG) || 67 arg_count(cmd, activevolumegroups_ARG) || 68 arg_count(cmd, short_ARG)) { 69 log_error("Incompatible options selected"); 70 return EINVALID_CMD_LINE; 71 } 72 return vgs(cmd, argc, argv); 73 } else if (arg_count(cmd, aligned_ARG) || 74 arg_count(cmd, noheadings_ARG) || 75 arg_count(cmd, options_ARG) || 76 arg_count(cmd, separator_ARG) || 77 arg_count(cmd, sort_ARG) || arg_count(cmd, unbuffered_ARG)) { 78 log_error("Incompatible options selected"); 79 return EINVALID_CMD_LINE; 80 } 81 82 if (arg_count(cmd, colon_ARG) && arg_count(cmd, short_ARG)) { 83 log_error("Option -c is not allowed with option -s"); 84 return EINVALID_CMD_LINE; 85 } 86 87 if (argc && arg_count(cmd, activevolumegroups_ARG)) { 88 log_error("Option -A is not allowed with volume group names"); 89 return EINVALID_CMD_LINE; 90 } 91 92 /* FIXME -D disk_ARG is now redundant */ 93 94 /********* FIXME: Do without this - or else 2(+) passes! 95 Figure out longest volume group name 96 for (c = opt; opt < argc; opt++) { 97 len = strlen(argv[opt]); 98 if (len > max_len) 99 max_len = len; 100 } 101 **********/ 102 103 return process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, NULL, 104 vgdisplay_single); 105 106 /******** FIXME Need to count number processed 107 Add this to process_each_vg if arg_count(cmd,activevolumegroups_ARG) ? 108 109 if (opt == argc) { 110 log_print("no "); 111 if (arg_count(cmd,activevolumegroups_ARG)) 112 printf("active "); 113 printf("volume groups found\n\n"); 114 return LVM_E_NO_VG; 115 } 116 ************/ 117 } 118