X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fmdadm.git;a=blobdiff_plain;f=util.c;h=c0c3f0c97c4147c541ffbce3c0398cb7cba69262;hp=080decc222a970bf36a9e2329c6eb7b27f307678;hb=4a06e2c270948bdcfaa447c8a0e80abb0978b5c4;hpb=84e11361aa37c92c3c016095e5db7f4fc434ac18 diff --git a/util.c b/util.c index 080decc2..c0c3f0c9 100644 --- a/util.c +++ b/util.c @@ -185,6 +185,40 @@ long long parse_size(char *size) return s; } +int parse_layout_10(char *layout) +{ + int copies, rv; + char *cp; + /* Parse the layout string for raid10 */ + /* 'f', 'o' or 'n' followed by a number <= raid_disks */ + if ((layout[0] != 'n' && layout[0] != 'f' && layout[0] != 'o') || + (copies = strtoul(layout+1, &cp, 10)) < 1 || + copies > 200 || + *cp) + return -1; + if (layout[0] == 'n') + rv = 256 + copies; + else if (layout[0] == 'o') + rv = 0x10000 + (copies<<8) + 1; + else + rv = 1 + (copies<<8); + return rv; +} + +int parse_layout_faulty(char *layout) +{ + /* Parse the layout string for 'faulty' */ + int ln = strcspn(layout, "0123456789"); + char *m = strdup(layout); + int mode; + m[ln] = 0; + mode = map_name(faultylayout, m); + if (mode == UnSet) + return -1; + + return mode | (atoi(layout+ln)<< ModeShift); +} + void remove_partitions(int fd) { /* remove partitions from this block devices.