+ if (array_size >= 0) {
+ /* alway impose array size first, independent of
+ * anything else
+ * Do not allow level or raid_disks changes at the
+ * same time as that can be irreversibly destructive.
+ */
+ struct mdinfo sra;
+ int err;
+ if (raiddisks || level != UnSet) {
+ fprintf(stderr, Name ": cannot change array size in same operation "
+ "as changing raiddisks or level.\n"
+ " Change size first, then check that data is still intact.\n");
+ rv = 1;
+ break;
+ }
+ sysfs_init(&sra, mdfd, 0);
+ if (array_size == 0)
+ err = sysfs_set_str(&sra, NULL, "array_size", "default");
+ else
+ err = sysfs_set_num(&sra, NULL, "array_size", array_size / 2);
+ if (err < 0) {
+ if (errno == E2BIG)
+ fprintf(stderr, Name ": --array-size setting"
+ " is too large.\n");
+ else
+ fprintf(stderr, Name ": current kernel does"
+ " not support setting --array-size\n");
+ rv = 1;
+ break;
+ }
+ }
+ if (devs_found > 1 && raiddisks == 0) {