]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - libdisk/lvm.c
remove rules to tidy up tmp libtool files - we use the installed version now.
[thirdparty/xfsprogs-dev.git] / libdisk / lvm.c
1 /*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33 #include <stdio.h>
34 #include <errno.h>
35 #include <sys/stat.h>
36 #include <volume.h>
37
38 #include "lvm_user.h"
39
40 #if HAVE_LIBLVM
41 char *cmd; /* Not used. liblvm is broken */
42 int opt_d; /* Same thing */
43 #endif
44
45 int
46 mnt_is_lvm_subvol(dev_t dev)
47 {
48 if (dev >> 8 == LVM_BLK_MAJOR)
49 return 1;
50 return 0;
51 }
52
53 int
54 lvm_get_subvol_stripe(
55 char *dfile,
56 sv_type_t type,
57 int *sunit,
58 int *swidth,
59 struct stat64 *sb)
60 {
61 #if HAVE_LIBLVM
62 if (mnt_is_lvm_subvol(sb->st_rdev)) {
63 lv_t *lv;
64 char *vgname;
65
66 /* Find volume group */
67 if (! (vgname = vg_name_of_lv(dfile))) {
68 fprintf(stderr, "Can't find volume group for %s\n",
69 dfile);
70 exit(1);
71 }
72
73 /* Logical volume */
74 if (! lvm_tab_lv_check_exist(dfile)) {
75 fprintf(stderr, "Logical volume %s doesn't exist!\n",
76 dfile);
77 exit(1);
78 }
79
80 /* Get status */
81 if (lv_status_byname(vgname, dfile, &lv) < 0 || lv == NULL) {
82 fprintf(stderr, "Could not get status info from %s\n",
83 dfile);
84 exit(1);
85 }
86
87 /* Check that data is consistent */
88 if (lv_check_consistency(lv) < 0) {
89 fprintf(stderr, "Logical volume %s is inconsistent\n",
90 dfile);
91 exit(1);
92 }
93
94 /* Update sizes */
95 *sunit = lv->lv_stripesize;
96 *swidth = lv->lv_stripes * lv->lv_stripesize;
97
98 return 1;
99 }
100 #endif /* HAVE_LIBLVM */
101 return 0;
102 }