return (a*1000000)+(b*1000)+c;
}
+#ifndef MDASSEMBLE
int mdadm_version(char *version)
{
int a, b, c;
return (a*1000000)+(b*1000)+c;
}
-#ifndef MDASSEMBLE
long long parse_size(char *size)
{
/* parse 'size' which should be a number optionally
return 1;
}
+int test_partition_from_id(dev_t id)
+{
+ char buf[20];
+ int fd, rv;
+
+ sprintf(buf, "%d:%d", major(id), minor(id));
+ fd = dev_open(buf, O_RDONLY);
+ if (fd < 0)
+ return -1;
+ rv = test_partition(fd);
+ close(fd);
+ return rv;
+}
int enough(int level, int raid_disks, int layout, int clean,
char *avail, int avail_disks)
}
#endif /* MDASSEMBLE */
-char *map_num(mapping_t *map, int num)
-{
- while (map->name) {
- if (map->num == num)
- return map->name;
- map++;
- }
- return NULL;
-}
-
-int map_name(mapping_t *map, char *name)
-{
- while (map->name) {
- if (strcmp(map->name, name)==0)
- return map->num;
- map++;
- }
- return UnSet;
-}
-
-
int is_standard(char *dev, int *nump)
{
/* tests if dev is a "standard" md dev name.
return fd;
}
-int open_dev(int devnum)
+int open_dev_flags(int devnum, int flags)
{
char buf[20];
sprintf(buf, "%d:%d", dev2major(devnum), dev2minor(devnum));
- return dev_open(buf, O_RDWR);
+ return dev_open(buf, flags);
+}
+
+int open_dev(int devnum)
+{
+ return open_dev_flags(devnum, O_RDONLY);
}
int open_dev_excl(int devnum)
{
char buf[20];
int i;
+ int flags = O_RDWR;
sprintf(buf, "%d:%d", dev2major(devnum), dev2minor(devnum));
for (i=0 ; i<25 ; i++) {
- int fd = dev_open(buf, O_RDWR|O_EXCL);
+ int fd = dev_open(buf, flags|O_EXCL);
if (fd >= 0)
return fd;
+ if (errno == EACCES && flags == O_RDWR) {
+ flags = O_RDONLY;
+ continue;
+ }
if (errno != EBUSY)
return fd;
usleep(200000);
if (guess_type == guess_partitions && ss->add_to_super != NULL)
continue;
memset(st, 0, sizeof(*st));
+ st->ignore_hw_compat = 1;
rv = ss->load_super(st, fd, NULL);
if (rv == 0) {
struct mdinfo info;
if (bestsuper != -1) {
int rv;
memset(st, 0, sizeof(*st));
+ st->ignore_hw_compat = 1;
rv = superlist[bestsuper]->load_super(st, fd, NULL);
if (rv == 0) {
superlist[bestsuper]->free_super(st);
+ st->ignore_hw_compat = 0;
return st;
}
}
return retval;
}
-int check_partitions(int fd, char *dname, unsigned long long freesize)
+int check_partitions(int fd, char *dname, unsigned long long freesize,
+ unsigned long long size)
{
/*
* Check where the last partition ends
Name ": metadata will over-write last partition on %s.\n",
dname);
return 1;
+ } else if (size && endofpart > size) {
+ /* partitions will be truncated in new device */
+ fprintf(stderr,
+ Name ": array size is too small to cover all partitions on %s.\n",
+ dname);
+ return 1;
}
}
return 0;
for (ent = mdstat; ent; ent = ent->next)
if (is_container_member(ent, container))
- if (!subarray ||
- strcmp(to_subarray(ent, container), subarray) == 0)
+ if (strcmp(to_subarray(ent, container), subarray) == 0)
break;
free_mdstat(mdstat);
return ent != NULL;
}
-int is_container_active(char *container)
-{
- return is_subarray_active(NULL, container);
-}
-
/* open_subarray - opens a subarray in a container
* @dev: container device name
* @st: empty supertype
link[n] = 0;
cp = strrchr(link, '/');
if (cp) *cp = 0;
- cp = strchr(link, '/');
+ cp = strrchr(link, '/');
if (cp && strncmp(cp, "/md", 3) == 0)
return devname2devnum(cp+1);
}
if (spare_group)
pol_add(&pol, pol_domain,
spare_group, NULL);
- if (!domain_test(domlist, pol, metadata))
+ if (domain_test(domlist, pol, metadata) != 1)
found = 0;
dev_policy_free(pol);
}