2
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
2
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
4
4
* This program is free software; you can redistribute it and/or modify it
5
5
* under the terms of version 2 of the GNU General Public License as
6
6
* published by the Free Software Foundation.
8
8
* This program is distributed in the hope that it would be useful, but
9
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
12
* Further, this software is distributed without any warranty that it is
13
13
* free of the rightful claim of any third person regarding infringement
14
14
* or the like. Any license provided herein, whether implied or
15
15
* otherwise, applies only to this software file. Patent licenses, if
16
16
* any, provided herein do not apply to combinations of this program with
17
17
* other software, or any other product whatsoever.
19
19
* You should have received a copy of the GNU General Public License along
20
20
* with this program; if not, write the Free Software Foundation, Inc., 59
21
21
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
23
23
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24
24
* Mountain View, CA 94043, or:
28
* For further information regarding this notice, see:
28
* For further information regarding this notice, see:
30
30
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
40
extern int md_get_subvol_stripe(char*, sv_type_t, int*, int*, struct stat64*);
41
extern int lvm_get_subvol_stripe(char*, sv_type_t, int*, int*, struct stat64*);
42
extern int xvm_get_subvol_stripe(char*, sv_type_t, int*, int*, struct stat64*);
45
36
get_subvol_stripe_wrapper(char *dev, sv_type_t type, int *sunit, int *swidth)
52
43
if (stat64(dev, &sb)) {
53
fprintf(stderr, "Cannot stat %s: %s\n", dev, strerror(errno));
44
fprintf(stderr, _("Cannot stat %s: %s\n"),
45
dev, strerror(errno));
57
if ( md_get_subvol_stripe(dev, type, sunit, swidth, &sb))
59
if (lvm_get_subvol_stripe(dev, type, sunit, swidth, &sb))
61
if (xvm_get_subvol_stripe(dev, type, sunit, swidth, &sb))
49
if ( dm_get_subvol_stripe(dev, type, sunit, swidth, &sb))
51
if ( md_get_subvol_stripe(dev, type, sunit, swidth, &sb))
53
if ( lvm_get_subvol_stripe(dev, type, sunit, swidth, &sb))
55
if ( xvm_get_subvol_stripe(dev, type, sunit, swidth, &sb))
57
if (evms_get_subvol_stripe(dev, type, sunit, swidth, &sb))
63
60
/* ... add new device drivers here */
63
#define DEVICES "/proc/devices"
67
66
* General purpose routine which dredges through procfs trying to
68
67
* match up device driver names with the associated major numbers
69
68
* being used in the running kernel.
72
get_driver_block_major(const char *driver)
71
get_driver_block_major(const char *driver, int major)
75
74
char buf[64], puf[64];
75
int dmajor, match = 0;
78
#define PROC_DEVICES "/proc/devices"
79
if ((f = fopen(PROC_DEVICES, "r")) == NULL)
77
if ((f = fopen(DEVICES, "r")) == NULL)
81
79
while (fgets(buf, sizeof(buf), f)) /* skip to block dev section */
82
if (strcmp("Block devices:\n", buf) == 0)
80
if (strncmp("Block devices:\n", buf, sizeof(buf)) == 0)
84
82
while (fgets(buf, sizeof(buf), f))
85
if ((sscanf(buf, "%u %s\n", &major, puf) == 2) &&
86
(strcmp(puf, driver) == 0))
83
if ((sscanf(buf, "%u %s\n", &dmajor, puf) == 2) &&
84
(strncmp(puf, driver, sizeof(puf)) == 0) &&