1 /* $NetBSD: vgdisplay.c,v 1.1.1.2 2009/12/02 00:25:57 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, 22 void *handle __attribute((unused))) 23 { 24 /* FIXME Do the active check here if activevolumegroups_ARG ? */ 25 vg_check_status(vg, EXPORTED_VG); 26 27 if (arg_count(cmd, colon_ARG)) { 28 vgdisplay_colons(vg); 29 return ECMD_PROCESSED; 30 } 31 32 if (arg_count(cmd, short_ARG)) { 33 vgdisplay_short(vg); 34 return ECMD_PROCESSED; 35 } 36 37 vgdisplay_full(vg); /* was vg_show */ 38 39 if (arg_count(cmd, verbose_ARG)) { 40 vgdisplay_extents(vg); 41 42 process_each_lv_in_vg(cmd, vg, NULL, NULL, NULL, 43 (process_single_lv_fn_t)lvdisplay_full); 44 45 log_print("--- Physical volumes ---"); 46 process_each_pv_in_vg(cmd, vg, NULL, NULL, 47 (process_single_pv_fn_t)pvdisplay_short); 48 } 49 50 check_current_backup(vg); 51 52 return ECMD_PROCESSED; 53 } 54 55 int vgdisplay(struct cmd_context *cmd, int argc, char **argv) 56 { 57 if (arg_count(cmd, columns_ARG)) { 58 if (arg_count(cmd, colon_ARG) || 59 arg_count(cmd, activevolumegroups_ARG) || 60 arg_count(cmd, short_ARG)) { 61 log_error("Incompatible options selected"); 62 return EINVALID_CMD_LINE; 63 } 64 return vgs(cmd, argc, argv); 65 } else if (arg_count(cmd, aligned_ARG) || 66 arg_count(cmd, noheadings_ARG) || 67 arg_count(cmd, options_ARG) || 68 arg_count(cmd, separator_ARG) || 69 arg_count(cmd, sort_ARG) || arg_count(cmd, unbuffered_ARG)) { 70 log_error("Incompatible options selected"); 71 return EINVALID_CMD_LINE; 72 } 73 74 if (arg_count(cmd, colon_ARG) && arg_count(cmd, short_ARG)) { 75 log_error("Option -c is not allowed with option -s"); 76 return EINVALID_CMD_LINE; 77 } 78 79 if (argc && arg_count(cmd, activevolumegroups_ARG)) { 80 log_error("Option -A is not allowed with volume group names"); 81 return EINVALID_CMD_LINE; 82 } 83 84 /********* FIXME: Do without this - or else 2(+) passes! 85 Figure out longest volume group name 86 for (c = opt; opt < argc; opt++) { 87 len = strlen(argv[opt]); 88 if (len > max_len) 89 max_len = len; 90 } 91 **********/ 92 93 return process_each_vg(cmd, argc, argv, 0, NULL, 94 vgdisplay_single); 95 96 /******** FIXME Need to count number processed 97 Add this to process_each_vg if arg_count(cmd,activevolumegroups_ARG) ? 98 99 if (opt == argc) { 100 log_print("no "); 101 if (arg_count(cmd,activevolumegroups_ARG)) 102 printf("active "); 103 printf("volume groups found\n\n"); 104 return LVM_E_NO_VG; 105 } 106 ************/ 107 } 108