Factor out test for subarray version string.

We are about to change the syntax of the version string
for 'subarray's.  So factor out the test into a single function.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2008-08-19 17:55:15 +10:00
parent 6c386dd368
commit 3c558363a1
5 changed files with 11 additions and 5 deletions

View File

@ -523,7 +523,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
st->ss->getinfo_super(st, &info);
if (did_default && verbose >= 0) {
if (info.text_version[0] == '/') {
if (is_subarray(info.text_version)) {
int dnum = devname2devnum(info.text_version+1);
char *path;
int mdp = get_mdp_major();

View File

@ -123,7 +123,7 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
mdi = sysfs_read(fd, -1, GET_LEVEL|GET_VERSION);
if (mdi &&
mdi->array.level > 0 &&
mdi->text_version[0] == '/') {
is_subarray(mdi->text_version)) {
char *cp;
/* This is mdmon managed. */
@ -147,7 +147,7 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
} else if (mdi &&
mdi->array.major_version == -1 &&
mdi->array.minor_version == -2 &&
mdi->text_version[0] != '/') {
!is_subarray(mdi->text_version)) {
/* container, possibly mdmon-managed.
* Make sure mdmon isn't opening it, which
* would interfere with the 'stop'

View File

@ -492,7 +492,8 @@ void manage(struct mdstat_ent *mdstat, struct supertype *container)
continue;
}
if (mdstat->metadata_version == NULL ||
strncmp(mdstat->metadata_version, "external:/", 10) != 0 ||
strncmp(mdstat->metadata_version, "external:", 9) != 0 ||
!is_subarray(mdstat->metadata_version+9) ||
strncmp(mdstat->metadata_version+10, container->devname,
strlen(container->devname)) != 0 ||
mdstat->metadata_version[10+strlen(container->devname)]

View File

@ -805,6 +805,11 @@ static inline int ROUND_UP(int a, int base)
return ((a+base-1)/base)*base;
}
static inline int is_subarray(char *vers)
{
return (*vers == '/');
}
#define LEVEL_MULTIPATH (-4)
#define LEVEL_LINEAR (-1)
#define LEVEL_FAULTY (-5)

2
util.c
View File

@ -821,7 +821,7 @@ struct supertype *super_by_fd(int fd)
sprintf(version, "%d.%d", vers, minor);
verstr = version;
}
if (minor == -2 && verstr[0] == '/') {
if (minor == -2 && is_subarray(verstr)) {
char *dev = verstr+1;
subarray = strchr(dev, '/');
int devnum;