]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - libdisk/lvm.c
590b03086105ceffd21fca6255804ec4d9e116fa
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 #include <sys/types.h>
40 #include <linux/major.h>
44 mnt_is_lvm_subvol(dev_t dev
)
46 if (dev
>> 8 == LVM_BLK_MAJOR
)
52 lvm_get_subvol_stripe(
59 int lvpipe
[2], stripes
= 0, stripesize
= 0;
60 char *largv
[3], buf
[1024];
63 if (!mnt_is_lvm_subvol(sb
->st_rdev
))
66 /* Quest for lvdisplay */
67 if (!access("/usr/local/sbin/lvdisplay", R_OK
|X_OK
))
68 largv
[0] = "/usr/local/sbin/lvdisplay";
69 else if (!access("/usr/sbin/lvdisplay", R_OK
|X_OK
))
70 largv
[0] = "/usr/sbin/lvdisplay";
71 else if (!access("/sbin/lvdisplay", R_OK
|X_OK
))
72 largv
[0] = "/sbin/lvdisplay";
75 "Warning - LVM device, but no lvdisplay(8) found\n");
83 if (pipe(lvpipe
) < 0) {
84 fprintf(stderr
, "Could not open pipe\n");
94 if (lvpipe
[1] != STDOUT_FILENO
)
95 dup2(lvpipe
[1], STDOUT_FILENO
);
97 execv(largv
[0], largv
);
99 fprintf(stderr
, "\nFailed to execute %s\n", largv
[0]);
103 fprintf(stderr
, "Failed forking lvdisplay process\n");
111 stream
= fdopen(lvpipe
[0], "r");
113 /* Scan stream for keywords */
114 while (fgets(buf
, 1023, stream
) != NULL
) {
116 if (!strncmp(buf
, "Stripes", 7))
117 sscanf(buf
, "Stripes %d", &stripes
);
119 if (!strncmp(buf
, "Stripe size", 11))
120 sscanf(buf
, "Stripe size (KByte) %d", &stripesize
);
124 *sunit
= stripesize
<< 1;
125 *swidth
= (stripes
* stripesize
) << 1;