Introduce pr_err for printing error messages.

'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": '
cont_err() is also available.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2012-07-09 17:14:16 +10:00
parent 5187a38587
commit e7b84f9d50
29 changed files with 1128 additions and 1306 deletions

View File

@ -81,36 +81,34 @@ static int ident_matches(struct mddev_ident *ident,
same_uuid(content->uuid, ident->uuid, tst->ss->swapuuid)==0 &&
memcmp(content->uuid, uuid_zero, sizeof(int[4])) != 0) {
if (devname)
fprintf(stderr, Name ": %s has wrong uuid.\n",
devname);
pr_err("%s has wrong uuid.\n", devname);
return 0;
}
if (ident->name[0] && (!update || strcmp(update, "name")!= 0) &&
name_matches(content->name, ident->name, homehost)==0) {
if (devname)
fprintf(stderr, Name ": %s has wrong name.\n",
devname);
pr_err("%s has wrong name.\n", devname);
return 0;
}
if (ident->super_minor != UnSet &&
ident->super_minor != content->array.md_minor) {
if (devname)
fprintf(stderr, Name ": %s has wrong super-minor.\n",
devname);
pr_err("%s has wrong super-minor.\n",
devname);
return 0;
}
if (ident->level != UnSet &&
ident->level != content->array.level) {
if (devname)
fprintf(stderr, Name ": %s has wrong raid level.\n",
devname);
pr_err("%s has wrong raid level.\n",
devname);
return 0;
}
if (ident->raid_disks != UnSet &&
ident->raid_disks!= content->array.raid_disks) {
if (devname)
fprintf(stderr, Name ": %s requires wrong number of drives.\n",
devname);
pr_err("%s requires wrong number of drives.\n",
devname);
return 0;
}
if (ident->member && ident->member[0]) {
@ -118,13 +116,13 @@ static int ident_matches(struct mddev_ident *ident,
char *s = strchr(content->text_version+1, '/');
if (s == NULL) {
if (devname)
fprintf(stderr, Name ": %s is not a container and one is required.\n",
devname);
pr_err("%s is not a container and one is required.\n",
devname);
return 0;
} else if (strcmp(ident->member, s+1) != 0) {
if (devname)
fprintf(stderr, Name ": skipping wrong member %s is %s\n",
content->text_version, devname);
pr_err("skipping wrong member %s is %s\n",
content->text_version, devname);
return 0;
}
}
@ -253,8 +251,8 @@ int Assemble(struct supertype *st, char *mddev,
ident->name[0] == 0 &&
(ident->container == NULL || ident->member == NULL) &&
ident->devices == NULL) {
fprintf(stderr, Name ": No identity information available for %s - cannot assemble.\n",
mddev ? mddev : "further assembly");
pr_err("No identity information available for %s - cannot assemble.\n",
mddev ? mddev : "further assembly");
return 1;
}
@ -282,8 +280,8 @@ int Assemble(struct supertype *st, char *mddev,
if (!st && ident->st) st = ident->st;
if (verbose>0)
fprintf(stderr, Name ": looking for devices for %s\n",
mddev ? mddev : "further assembly");
pr_err("looking for devices for %s\n",
mddev ? mddev : "further assembly");
/* first walk the list of devices to find a consistent set
* that match the criterea, if that is possible.
@ -304,7 +302,7 @@ int Assemble(struct supertype *st, char *mddev,
if (ident->devices &&
!match_oneof(ident->devices, devname)) {
if (report_missmatch)
fprintf(stderr, Name ": %s is not one of %s\n", devname, ident->devices);
pr_err("%s is not one of %s\n", devname, ident->devices);
continue;
}
@ -313,17 +311,17 @@ int Assemble(struct supertype *st, char *mddev,
dfd = dev_open(devname, O_RDONLY);
if (dfd < 0) {
if (report_missmatch)
fprintf(stderr, Name ": cannot open device %s: %s\n",
devname, strerror(errno));
pr_err("cannot open device %s: %s\n",
devname, strerror(errno));
tmpdev->used = 2;
} else if (fstat(dfd, &stb)< 0) {
/* Impossible! */
fprintf(stderr, Name ": fstat failed for %s: %s\n",
devname, strerror(errno));
pr_err("fstat failed for %s: %s\n",
devname, strerror(errno));
tmpdev->used = 2;
} else if ((stb.st_mode & S_IFMT) != S_IFBLK) {
fprintf(stderr, Name ": %s is not a block device.\n",
devname);
pr_err("%s is not a block device.\n",
devname);
tmpdev->used = 2;
} else if (must_be_container(dfd)) {
if (st) {
@ -331,55 +329,55 @@ int Assemble(struct supertype *st, char *mddev,
* be another one.
*/
if (report_missmatch)
fprintf(stderr, Name ": %s is a container, but we are looking for components\n",
devname);
pr_err("%s is a container, but we are looking for components\n",
devname);
tmpdev->used = 2;
#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
} if (!tst && (tst = super_by_fd(dfd, NULL)) == NULL) {
if (report_missmatch)
fprintf(stderr, Name ": not a recognisable container: %s\n",
devname);
pr_err("not a recognisable container: %s\n",
devname);
tmpdev->used = 2;
#endif
} else if (!tst->ss->load_container
|| tst->ss->load_container(tst, dfd, NULL)) {
if (report_missmatch)
fprintf(stderr, Name ": no correct container type: %s\n",
devname);
pr_err("no correct container type: %s\n",
devname);
tmpdev->used = 2;
} else if (auto_assem &&
!conf_test_metadata(tst->ss->name, (pol = devnum_policy(stb.st_rdev)),
tst->ss->match_home(tst, homehost) == 1)) {
if (report_missmatch)
fprintf(stderr, Name ": %s has metadata type %s for which "
"auto-assembly is disabled\n",
devname, tst->ss->name);
pr_err("%s has metadata type %s for which "
"auto-assembly is disabled\n",
devname, tst->ss->name);
tmpdev->used = 2;
} else
found_container = 1;
} else {
if (!tst && (tst = guess_super(dfd)) == NULL) {
if (report_missmatch)
fprintf(stderr, Name ": no recogniseable superblock on %s\n",
devname);
pr_err("no recogniseable superblock on %s\n",
devname);
tmpdev->used = 2;
} else if (tst->ss->load_super(tst,dfd, NULL)) {
if (report_missmatch)
fprintf(stderr, Name ": no RAID superblock on %s\n",
devname);
pr_err("no RAID superblock on %s\n",
devname);
tmpdev->used = 2;
} else if (tst->ss->compare_super == NULL) {
if (report_missmatch)
fprintf(stderr, Name ": Cannot assemble %s metadata on %s\n",
tst->ss->name, devname);
pr_err("Cannot assemble %s metadata on %s\n",
tst->ss->name, devname);
tmpdev->used = 2;
} else if (auto_assem && st == NULL &&
!conf_test_metadata(tst->ss->name, (pol = devnum_policy(stb.st_rdev)),
tst->ss->match_home(tst, homehost) == 1)) {
if (report_missmatch)
fprintf(stderr, Name ": %s has metadata type %s for which "
"auto-assembly is disabled\n",
devname, tst->ss->name);
pr_err("%s has metadata type %s for which "
"auto-assembly is disabled\n",
devname, tst->ss->name);
tmpdev->used = 2;
}
}
@ -395,7 +393,7 @@ int Assemble(struct supertype *st, char *mddev,
goto loop;
fprintf(stderr, Name ": %s has no superblock - assembly aborted\n",
pr_err("%s has no superblock - assembly aborted\n",
devname);
if (st)
st->ss->free_super(st);
@ -415,7 +413,7 @@ int Assemble(struct supertype *st, char *mddev,
dfd = dev_open(devname, O_RDONLY | O_EXCL);
if (dfd < 0) {
if (report_missmatch)
fprintf(stderr, Name ": %s is busy - skipping\n", devname);
pr_err("%s is busy - skipping\n", devname);
goto loop;
}
close(dfd);
@ -424,7 +422,7 @@ int Assemble(struct supertype *st, char *mddev,
if (ident->container[0] == '/' &&
!same_dev(ident->container, devname)) {
if (report_missmatch)
fprintf(stderr, Name ": %s is not the container required (%s)\n",
pr_err("%s is not the container required (%s)\n",
devname, ident->container);
goto loop;
}
@ -438,7 +436,7 @@ int Assemble(struct supertype *st, char *mddev,
if (!parse_uuid(ident->container, uuid) ||
!same_uuid(content->uuid, uuid, tst->ss->swapuuid)) {
if (report_missmatch)
fprintf(stderr, Name ": %s has wrong UUID to be required container\n",
pr_err("%s has wrong UUID to be required container\n",
devname);
goto loop;
}
@ -447,7 +445,7 @@ int Assemble(struct supertype *st, char *mddev,
/* It is worth looking inside this container.
*/
if (verbose > 0)
fprintf(stderr, Name ": looking in container %s\n",
pr_err("looking in container %s\n",
devname);
for (content = tst->ss->container_content(tst, NULL);
@ -460,12 +458,12 @@ int Assemble(struct supertype *st, char *mddev,
/* message already printed */;
else if (is_member_busy(content->text_version)) {
if (report_missmatch)
fprintf(stderr, Name ": member %s in %s is already assembled\n",
pr_err("member %s in %s is already assembled\n",
content->text_version,
devname);
} else if (content->array.state & (1<<MD_SB_BLOCK_VOLUME)) {
/* do not assemble arrays with unsupported configurations */
fprintf(stderr, Name ": Cannot activate member %s in %s.\n",
pr_err("Cannot activate member %s in %s.\n",
content->text_version,
devname);
} else
@ -478,7 +476,7 @@ int Assemble(struct supertype *st, char *mddev,
st = tst; tst = NULL;
if (!auto_assem && inargv && tmpdev->next != NULL) {
fprintf(stderr, Name ": %s is a container, but is not "
pr_err("%s is a container, but is not "
"only device given: confused and aborting\n",
devname);
st->ss->free_super(st);
@ -487,7 +485,7 @@ int Assemble(struct supertype *st, char *mddev,
return 1;
}
if (verbose > 0)
fprintf(stderr, Name ": found match on member %s in %s\n",
pr_err("found match on member %s in %s\n",
content->text_version, devname);
/* make sure we finished the loop */
@ -510,7 +508,7 @@ int Assemble(struct supertype *st, char *mddev,
dfd = dev_open(devname, O_RDONLY | O_EXCL);
if (dfd < 0) {
if (report_missmatch)
fprintf(stderr, Name ": %s is busy - skipping\n", devname);
pr_err("%s is busy - skipping\n", devname);
goto loop;
}
close(dfd);
@ -549,13 +547,13 @@ int Assemble(struct supertype *st, char *mddev,
/* We can do something */
if (first) {/* just ignore this one */
if (report_missmatch)
fprintf(stderr, Name ": %s misses out due to wrong homehost\n",
pr_err("%s misses out due to wrong homehost\n",
devname);
goto loop;
} else { /* reject all those sofar */
struct mddev_dev *td;
if (report_missmatch)
fprintf(stderr, Name ": %s overrides previous devices due to good homehost\n",
pr_err("%s overrides previous devices due to good homehost\n",
devname);
for (td=devlist; td != tmpdev; td=td->next)
if (td->used == 1)
@ -565,7 +563,7 @@ int Assemble(struct supertype *st, char *mddev,
}
}
}
fprintf(stderr, Name ": superblock on %s doesn't match others - assembly aborted\n",
pr_err("superblock on %s doesn't match others - assembly aborted\n",
devname);
tst->ss->free_super(tst);
st->ss->free_super(st);
@ -616,7 +614,7 @@ int Assemble(struct supertype *st, char *mddev,
if (tmpdev->used != 3)
continue;
if (stat(tmpdev->devname, &stb)< 0) {
fprintf(stderr, Name ": fstat failed for %s: %s\n",
pr_err("fstat failed for %s: %s\n",
tmpdev->devname, strerror(errno));
tmpdev->used = 2;
} else {
@ -692,20 +690,20 @@ int Assemble(struct supertype *st, char *mddev,
mddev = chosen_name;
vers = md_get_version(mdfd);
if (vers < 9000) {
fprintf(stderr, Name ": Assemble requires driver version 0.90.0 or later.\n"
pr_err("Assemble requires driver version 0.90.0 or later.\n"
" Upgrade your kernel or try --build\n");
close(mdfd);
return 1;
}
if (mddev_busy(fd2devnum(mdfd))) {
fprintf(stderr, Name ": %s already active, cannot restart it!\n",
pr_err("%s already active, cannot restart it!\n",
mddev);
for (tmpdev = devlist ;
tmpdev && tmpdev->used != 1;
tmpdev = tmpdev->next)
;
if (tmpdev && auto_assem)
fprintf(stderr, Name ": %s needed for %s...\n",
pr_err("%s needed for %s...\n",
mddev, tmpdev->devname);
close(mdfd);
mdfd = -3;
@ -760,7 +758,7 @@ int Assemble(struct supertype *st, char *mddev,
tst = dup_super(st);
if (dfd < 0 || tst->ss->load_super(tst, dfd, NULL) != 0) {
fprintf(stderr, Name ": cannot re-read metadata from %s - aborting\n",
pr_err("cannot re-read metadata from %s - aborting\n",
devname);
if (dfd >= 0)
close(dfd);
@ -783,10 +781,9 @@ int Assemble(struct supertype *st, char *mddev,
ident->uuid_set,
homehost);
if (err < 0) {
fprintf(stderr,
Name ": --update=%s not understood"
" for %s metadata\n",
update, tst->ss->name);
pr_err("--update=%s not understood"
" for %s metadata\n",
update, tst->ss->name);
tst->ss->free_super(tst);
free(tst);
close(mdfd);
@ -801,7 +798,7 @@ int Assemble(struct supertype *st, char *mddev,
memcpy(ident->uuid, content->uuid, 16);
}
if (tst->ss->store_super(tst, dfd))
fprintf(stderr, Name ": Could not re-write superblock on %s.\n",
pr_err("Could not re-write superblock on %s.\n",
devname);
close(dfd);
@ -810,7 +807,7 @@ int Assemble(struct supertype *st, char *mddev,
if (bitmap_update_uuid(ident->bitmap_fd,
content->uuid,
tst->ss->swapuuid) != 0)
fprintf(stderr, Name ": Could not update uuid on external bitmap.\n");
pr_err("Could not update uuid on external bitmap.\n");
else
bitmap_done = 1;
}
@ -823,7 +820,7 @@ int Assemble(struct supertype *st, char *mddev,
dfd = dev_open(devname, O_RDWR|O_EXCL);
if (dfd < 0 || tst->ss->load_super(tst, dfd, NULL) != 0) {
fprintf(stderr, Name ": cannot re-read metadata from %s - aborting\n",
pr_err("cannot re-read metadata from %s - aborting\n",
devname);
if (dfd >= 0)
close(dfd);
@ -840,7 +837,7 @@ int Assemble(struct supertype *st, char *mddev,
stat(devname, &stb);
if (verbose > 0)
fprintf(stderr, Name ": %s is identified as a member of %s, slot %d.\n",
pr_err("%s is identified as a member of %s, slot %d.\n",
devname, mddev, content->disk.raid_disk);
devices[devcnt].devname = devname;
devices[devcnt].uptodate = 0;
@ -891,7 +888,7 @@ int Assemble(struct supertype *st, char *mddev,
* Could be a mis-detection caused by overlapping
* partitions. fail-safe.
*/
fprintf(stderr, Name ": WARNING %s and %s appear"
pr_err("WARNING %s and %s appear"
" to have very similar superblocks.\n"
" If they are really different, "
"please --zero the superblock on one\n"
@ -915,7 +912,7 @@ int Assemble(struct supertype *st, char *mddev,
}
if (devcnt == 0) {
fprintf(stderr, Name ": no devices found for %s\n",
pr_err("no devices found for %s\n",
mddev);
if (st)
st->ss->free_super(st);
@ -965,7 +962,7 @@ int Assemble(struct supertype *st, char *mddev,
devices[most_recent].i.disk.raid_disk >= 0 &&
devmap[j * content->array.raid_disks + devices[most_recent].i.disk.raid_disk] == 0) {
if (verbose > -1)
fprintf(stderr, Name ": ignoring %s as it reports %s as failed\n",
pr_err("ignoring %s as it reports %s as failed\n",
devices[j].devname, devices[most_recent].devname);
best[i] = -1;
continue;
@ -1022,14 +1019,14 @@ int Assemble(struct supertype *st, char *mddev,
current_events = devices[chosen_drive].i.events;
add_another:
if (verbose >= 0)
fprintf(stderr, Name ": forcing event count in %s(%d) from %d upto %d\n",
pr_err("forcing event count in %s(%d) from %d upto %d\n",
devices[chosen_drive].devname,
devices[chosen_drive].i.disk.raid_disk,
(int)(devices[chosen_drive].i.events),
(int)(devices[most_recent].i.events));
fd = dev_open(devices[chosen_drive].devname, O_RDWR|O_EXCL);
if (fd < 0) {
fprintf(stderr, Name ": Couldn't open %s for write - not updating\n",
pr_err("Couldn't open %s for write - not updating\n",
devices[chosen_drive].devname);
devices[chosen_drive].i.events = 0;
continue;
@ -1037,7 +1034,7 @@ int Assemble(struct supertype *st, char *mddev,
tst = dup_super(st);
if (tst->ss->load_super(tst,fd, NULL)) {
close(fd);
fprintf(stderr, Name ": RAID superblock disappeared from %s - not updating.\n",
pr_err("RAID superblock disappeared from %s - not updating.\n",
devices[chosen_drive].devname);
devices[chosen_drive].i.events = 0;
continue;
@ -1049,7 +1046,7 @@ int Assemble(struct supertype *st, char *mddev,
if (tst->ss->store_super(tst, fd)) {
close(fd);
fprintf(stderr, Name ": Could not re-write superblock on %s\n",
pr_err("Could not re-write superblock on %s\n",
devices[chosen_drive].devname);
devices[chosen_drive].i.events = 0;
tst->ss->free_super(tst);
@ -1097,7 +1094,7 @@ int Assemble(struct supertype *st, char *mddev,
continue;
chosen_drive = j;
if ((fd=dev_open(devices[j].devname, O_RDONLY|O_EXCL))< 0) {
fprintf(stderr, Name ": Cannot open %s: %s\n",
pr_err("Cannot open %s: %s\n",
devices[j].devname, strerror(errno));
close(mdfd);
free(devices);
@ -1105,7 +1102,7 @@ int Assemble(struct supertype *st, char *mddev,
}
if (st->ss->load_super(st,fd, NULL)) {
close(fd);
fprintf(stderr, Name ": RAID superblock has disappeared from %s\n",
pr_err("RAID superblock has disappeared from %s\n",
devices[j].devname);
close(mdfd);
free(devices);
@ -1114,7 +1111,7 @@ int Assemble(struct supertype *st, char *mddev,
close(fd);
}
if (st->sb == NULL) {
fprintf(stderr, Name ": No suitable drives found for %s\n", mddev);
pr_err("No suitable drives found for %s\n", mddev);
close(mdfd);
free(devices);
return 1;
@ -1145,20 +1142,18 @@ int Assemble(struct supertype *st, char *mddev,
verbose, 0, NULL)) {
if (force) {
if (verbose >= 0)
fprintf(stderr, Name ": "
"clearing FAULTY flag for device %d in %s for %s\n",
pr_err("clearing FAULTY flag for device %d in %s for %s\n",
j, mddev, devices[j].devname);
change = 1;
} else {
if (verbose >= -1)
fprintf(stderr, Name ": "
"device %d in %s has wrong state in superblock, but %s seems ok\n",
pr_err("device %d in %s has wrong state in superblock, but %s seems ok\n",
i, mddev, devices[j].devname);
}
}
#if 0
if (!(super.disks[i].i.disk.state & (1 << MD_DISK_FAULTY))) {
fprintf(stderr, Name ": devices %d of %s is not marked FAULTY in superblock, but cannot be found\n",
pr_err("devices %d of %s is not marked FAULTY in superblock, but cannot be found\n",
i, mddev);
}
#endif
@ -1177,7 +1172,7 @@ int Assemble(struct supertype *st, char *mddev,
int fd;
fd = dev_open(devices[chosen_drive].devname, O_RDWR|O_EXCL);
if (fd < 0) {
fprintf(stderr, Name ": Could not open %s for write - cannot Assemble array.\n",
pr_err("Could not open %s for write - cannot Assemble array.\n",
devices[chosen_drive].devname);
close(mdfd);
free(devices);
@ -1185,14 +1180,14 @@ int Assemble(struct supertype *st, char *mddev,
}
if (st->ss->store_super(st, fd)) {
close(fd);
fprintf(stderr, Name ": Could not re-write superblock on %s\n",
pr_err("Could not re-write superblock on %s\n",
devices[chosen_drive].devname);
close(mdfd);
free(devices);
return 1;
}
if (verbose >= 0)
fprintf(stderr, Name ": Marking array %s as 'clean'\n",
pr_err("Marking array %s as 'clean'\n",
mddev);
close(fd);
}
@ -1206,7 +1201,7 @@ int Assemble(struct supertype *st, char *mddev,
int err = 0;
int *fdlist = malloc(sizeof(int)* bestcnt);
if (verbose > 0)
fprintf(stderr, Name ":%s has an active reshape - checking "
pr_err(":%s has an active reshape - checking "
"if critical section needs to be restored\n",
chosen_name);
for (i=0; i<bestcnt; i++) {
@ -1214,7 +1209,7 @@ int Assemble(struct supertype *st, char *mddev,
if (j >= 0) {
fdlist[i] = dev_open(devices[j].devname, O_RDWR|O_EXCL);
if (fdlist[i] < 0) {
fprintf(stderr, Name ": Could not open %s for write - cannot Assemble array.\n",
pr_err("Could not open %s for write - cannot Assemble array.\n",
devices[j].devname);
err = 1;
break;
@ -1230,7 +1225,7 @@ int Assemble(struct supertype *st, char *mddev,
backup_file, verbose > 0);
if (err && invalid_backup) {
if (verbose > 0)
fprintf(stderr, Name ": continuing"
pr_err("continuing"
" without restoring backup\n");
err = 0;
}
@ -1240,9 +1235,9 @@ int Assemble(struct supertype *st, char *mddev,
if (fdlist[i]>=0) close(fdlist[i]);
}
if (err) {
fprintf(stderr, Name ": Failed to restore critical section for reshape, sorry.\n");
pr_err("Failed to restore critical section for reshape, sorry.\n");
if (backup_file == NULL)
fprintf(stderr," Possibly you needed to specify the --backup-file\n");
cont_err("Possibly you needed to specify the --backup-file\n");
close(mdfd);
free(devices);
return err;
@ -1266,7 +1261,7 @@ int Assemble(struct supertype *st, char *mddev,
rv = set_array_info(mdfd, st, content);
if (rv) {
fprintf(stderr, Name ": failed to set array info for %s: %s\n",
pr_err("failed to set array info for %s: %s\n",
mddev, strerror(errno));
ioctl(mdfd, STOP_ARRAY, NULL);
close(mdfd);
@ -1275,7 +1270,7 @@ int Assemble(struct supertype *st, char *mddev,
}
if (ident->bitmap_fd >= 0) {
if (ioctl(mdfd, SET_BITMAP_FILE, ident->bitmap_fd) != 0) {
fprintf(stderr, Name ": SET_BITMAP_FILE failed.\n");
pr_err("SET_BITMAP_FILE failed.\n");
ioctl(mdfd, STOP_ARRAY, NULL);
close(mdfd);
free(devices);
@ -1285,7 +1280,7 @@ int Assemble(struct supertype *st, char *mddev,
/* From config file */
int bmfd = open(ident->bitmap_file, O_RDWR);
if (bmfd < 0) {
fprintf(stderr, Name ": Could not open bitmap file %s\n",
pr_err("Could not open bitmap file %s\n",
ident->bitmap_file);
ioctl(mdfd, STOP_ARRAY, NULL);
close(mdfd);
@ -1293,7 +1288,7 @@ int Assemble(struct supertype *st, char *mddev,
return 1;
}
if (ioctl(mdfd, SET_BITMAP_FILE, bmfd) != 0) {
fprintf(stderr, Name ": Failed to set bitmapfile for %s\n", mddev);
pr_err("Failed to set bitmapfile for %s\n", mddev);
close(bmfd);
ioctl(mdfd, STOP_ARRAY, NULL);
close(mdfd);
@ -1323,32 +1318,31 @@ int Assemble(struct supertype *st, char *mddev,
rv = add_disk(mdfd, st, content, &devices[j].i);
if (rv) {
fprintf(stderr, Name ": failed to add "
"%s to %s: %s\n",
devices[j].devname,
mddev,
strerror(errno));
pr_err("failed to add "
"%s to %s: %s\n",
devices[j].devname,
mddev,
strerror(errno));
if (i < content->array.raid_disks
|| i == bestcnt)
okcnt--;
else
sparecnt--;
} else if (verbose > 0)
fprintf(stderr, Name ": added %s "
"to %s as %d%s\n",
devices[j].devname, mddev,
devices[j].i.disk.raid_disk,
devices[j].uptodate?"":
" (possibly out of date)");
pr_err("added %s to %s as %d%s\n",
devices[j].devname, mddev,
devices[j].i.disk.raid_disk,
devices[j].uptodate?"":
" (possibly out of date)");
} else if (verbose > 0 && i < content->array.raid_disks)
fprintf(stderr, Name ": no uptodate device for "
pr_err("no uptodate device for "
"slot %d of %s\n",
i, mddev);
}
if (content->array.level == LEVEL_CONTAINER) {
if (verbose >= 0) {
fprintf(stderr, Name ": Container %s has been "
pr_err("Container %s has been "
"assembled with %d drive%s",
mddev, okcnt+sparecnt, okcnt+sparecnt==1?"":"s");
if (okcnt < (unsigned)content->array.raid_disks)
@ -1390,7 +1384,7 @@ int Assemble(struct supertype *st, char *mddev,
rv = ioctl(mdfd, RUN_ARRAY, NULL);
if (rv == 0) {
if (verbose >= 0) {
fprintf(stderr, Name ": %s has been started with %d drive%s",
pr_err("%s has been started with %d drive%s",
mddev, okcnt, okcnt==1?"":"s");
if (okcnt < (unsigned)content->array.raid_disks)
fprintf(stderr, " (out of %d)", content->array.raid_disks);
@ -1432,9 +1426,8 @@ int Assemble(struct supertype *st, char *mddev,
rv = add_disk(mdfd, st, content,
&devices[j].i);
if (rv == 0 && verbose >= 0)
fprintf(stderr,
Name ": %s has been re-added.\n",
devices[j].devname);
pr_err("%s has been re-added.\n",
devices[j].devname);
}
}
}
@ -1469,18 +1462,18 @@ int Assemble(struct supertype *st, char *mddev,
free(devices);
return 0;
}
fprintf(stderr, Name ": failed to RUN_ARRAY %s: %s\n",
pr_err("failed to RUN_ARRAY %s: %s\n",
mddev, strerror(errno));
if (!enough(content->array.level, content->array.raid_disks,
content->array.layout, 1, avail))
fprintf(stderr, Name ": Not enough devices to "
pr_err("Not enough devices to "
"start the array.\n");
else if (!enough(content->array.level,
content->array.raid_disks,
content->array.layout, clean,
avail))
fprintf(stderr, Name ": Not enough devices to "
pr_err("Not enough devices to "
"start the array while not clean "
"- consider --force.\n");
@ -1491,8 +1484,8 @@ int Assemble(struct supertype *st, char *mddev,
return 1;
}
if (runstop == -1) {
fprintf(stderr, Name ": %s assembled from %d drive%s",
mddev, okcnt, okcnt==1?"":"s");
pr_err("%s assembled from %d drive%s",
mddev, okcnt, okcnt==1?"":"s");
if (okcnt != (unsigned)content->array.raid_disks)
fprintf(stderr, " (out of %d)", content->array.raid_disks);
fprintf(stderr, ", but not started.\n");
@ -1501,7 +1494,7 @@ int Assemble(struct supertype *st, char *mddev,
return 0;
}
if (verbose >= -1) {
fprintf(stderr, Name ": %s assembled from %d drive%s", mddev, okcnt, okcnt==1?"":"s");
pr_err("%s assembled from %d drive%s", mddev, okcnt, okcnt==1?"":"s");
if (rebuilding_cnt)
fprintf(stderr, "%s %d rebuilding", sparecnt?", ":" and ", rebuilding_cnt);
if (sparecnt)
@ -1538,7 +1531,7 @@ int Assemble(struct supertype *st, char *mddev,
dev = makedev(devices[chosen_drive].i.disk.major,
devices[chosen_drive].i.disk.minor);
if (ioctl(mdfd, START_ARRAY, dev)) {
fprintf(stderr, Name ": Cannot start array: %s\n",
pr_err("Cannot start array: %s\n",
strerror(errno));
}
@ -1662,15 +1655,13 @@ int assemble_container_content(struct supertype *st, int mdfd,
if (verbose >= 0) {
if (err)
fprintf(stderr, Name
": array %s now has %d device%s",
chosen_name, working + preexist,
working + preexist == 1 ? "":"s");
pr_err("array %s now has %d device%s",
chosen_name, working + preexist,
working + preexist == 1 ? "":"s");
else
fprintf(stderr, Name
": Started %s with %d device%s",
chosen_name, working + preexist,
working + preexist == 1 ? "":"s");
pr_err("Started %s with %d device%s",
chosen_name, working + preexist,
working + preexist == 1 ? "":"s");
if (preexist)
fprintf(stderr, " (%d new)", working);
if (expansion)
@ -1684,10 +1675,9 @@ int assemble_container_content(struct supertype *st, int mdfd,
/* FIXME should have an O_EXCL and wait for read-auto */
} else {
if (verbose >= 0) {
fprintf(stderr, Name
": %s assembled with %d device%s",
chosen_name, preexist + working,
preexist + working == 1 ? "":"s");
pr_err("%s assembled with %d device%s",
chosen_name, preexist + working,
preexist + working == 1 ? "":"s");
if (preexist)
fprintf(stderr, " (%d new)", working);
fprintf(stderr, " but not started\n");

49
Build.c
View File

@ -66,19 +66,19 @@ int Build(char *mddev, int chunk, int level, int layout,
continue;
}
if (stat(dv->devname, &stb)) {
fprintf(stderr, Name ": Cannot find %s: %s\n",
pr_err("Cannot find %s: %s\n",
dv->devname, strerror(errno));
return 1;
}
if ((stb.st_mode & S_IFMT) != S_IFBLK) {
fprintf(stderr, Name ": %s is not a block device.\n",
pr_err("%s is not a block device.\n",
dv->devname);
return 1;
}
}
if (raiddisks != subdevs) {
fprintf(stderr, Name ": requested %d devices in array but listed %d\n",
pr_err("requested %d devices in array but listed %d\n",
raiddisks, subdevs);
return 1;
}
@ -91,22 +91,19 @@ int Build(char *mddev, int chunk, int level, int layout,
case 10:
layout = 0x102; /* near=2, far=1 */
if (verbose > 0)
fprintf(stderr,
Name ": layout defaults to n1\n");
pr_err("layout defaults to n1\n");
break;
case 5:
case 6:
layout = map_name(r5layout, "default");
if (verbose > 0)
fprintf(stderr,
Name ": layout defaults to %s\n", map_num(r5layout, layout));
pr_err("layout defaults to %s\n", map_num(r5layout, layout));
break;
case LEVEL_FAULTY:
layout = map_name(faultylayout, "default");
if (verbose > 0)
fprintf(stderr,
Name ": layout defaults to %s\n", map_num(faultylayout, layout));
pr_err("layout defaults to %s\n", map_num(faultylayout, layout));
break;
}
@ -148,17 +145,17 @@ int Build(char *mddev, int chunk, int level, int layout,
array.chunk_size = chunk*1024;
array.layout = layout;
if (ioctl(mdfd, SET_ARRAY_INFO, &array)) {
fprintf(stderr, Name ": SET_ARRAY_INFO failed for %s: %s\n",
pr_err("SET_ARRAY_INFO failed for %s: %s\n",
mddev, strerror(errno));
goto abort;
}
} else if (bitmap_file) {
fprintf(stderr, Name ": bitmaps not supported with this kernel\n");
pr_err("bitmaps not supported with this kernel\n");
goto abort;
}
if (bitmap_file && level <= 0) {
fprintf(stderr, Name ": bitmaps not meaningful with level %s\n",
pr_err("bitmaps not meaningful with level %s\n",
map_num(pers, level)?:"given");
goto abort;
}
@ -169,18 +166,18 @@ int Build(char *mddev, int chunk, int level, int layout,
if (strcmp("missing", dv->devname) == 0)
continue;
if (stat(dv->devname, &stb)) {
fprintf(stderr, Name ": Weird: %s has disappeared.\n",
pr_err("Weird: %s has disappeared.\n",
dv->devname);
goto abort;
}
if ((stb.st_mode & S_IFMT)!= S_IFBLK) {
fprintf(stderr, Name ": Wierd: %s is no longer a block device.\n",
pr_err("Wierd: %s is no longer a block device.\n",
dv->devname);
goto abort;
}
fd = open(dv->devname, O_RDONLY|O_EXCL);
if (fd < 0) {
fprintf(stderr, Name ": Cannot open %s: %s\n",
pr_err("Cannot open %s: %s\n",
dv->devname, strerror(errno));
goto abort;
}
@ -198,13 +195,13 @@ int Build(char *mddev, int chunk, int level, int layout,
disk.major = major(stb.st_rdev);
disk.minor = minor(stb.st_rdev);
if (ioctl(mdfd, ADD_NEW_DISK, &disk)) {
fprintf(stderr, Name ": ADD_NEW_DISK failed for %s: %s\n",
pr_err("ADD_NEW_DISK failed for %s: %s\n",
dv->devname, strerror(errno));
goto abort;
}
} else {
if (ioctl(mdfd, REGISTER_DEV, &stb.st_rdev)) {
fprintf(stderr, Name ": REGISTER_DEV failed for %s: %s.\n",
pr_err("REGISTER_DEV failed for %s: %s.\n",
dv->devname, strerror(errno));
goto abort;
}
@ -219,7 +216,7 @@ int Build(char *mddev, int chunk, int level, int layout,
int major = BITMAP_MAJOR_HI;
#if 0
if (bitmap_chunk == UnSet) {
fprintf(stderr, Name ": %s cannot be openned.",
pr_err("%s cannot be openned.",
bitmap_file);
goto abort;
}
@ -227,7 +224,7 @@ int Build(char *mddev, int chunk, int level, int layout,
if (vers < 9003) {
major = BITMAP_MAJOR_HOSTENDIAN;
#ifdef __BIG_ENDIAN
fprintf(stderr, Name ": Warning - bitmaps created on this kernel are not portable\n"
pr_err("Warning - bitmaps created on this kernel are not portable\n"
" between different architectures. Consider upgrading the Linux kernel.\n");
#endif
}
@ -238,25 +235,25 @@ int Build(char *mddev, int chunk, int level, int layout,
}
bitmap_fd = open(bitmap_file, O_RDWR);
if (bitmap_fd < 0) {
fprintf(stderr, Name ": %s cannot be openned.",
pr_err("%s cannot be openned.",
bitmap_file);
goto abort;
}
}
if (bitmap_fd >= 0) {
if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) {
fprintf(stderr, Name ": Cannot set bitmap file for %s: %s\n",
pr_err("Cannot set bitmap file for %s: %s\n",
mddev, strerror(errno));
goto abort;
}
}
}
if (ioctl(mdfd, RUN_ARRAY, &param)) {
fprintf(stderr, Name ": RUN_ARRAY failed: %s\n",
pr_err("RUN_ARRAY failed: %s\n",
strerror(errno));
if (chunk & (chunk-1)) {
fprintf(stderr, " : Problem may be that chunk size"
" is not a power of 2\n");
cont_err("Problem may be that chunk size"
" is not a power of 2\n");
}
goto abort;
}
@ -271,13 +268,13 @@ int Build(char *mddev, int chunk, int level, int layout,
chunk |= 0x20000;
else chunk |= 0x10000;
if (ioctl(mdfd, START_MD, arg)) {
fprintf(stderr, Name ": START_MD failed: %s\n",
pr_err("START_MD failed: %s\n",
strerror(errno));
goto abort;
}
}
if (verbose >= 0)
fprintf(stderr, Name ": array %s built and started.\n",
pr_err("array %s built and started.\n",
mddev);
wait_for(mddev, mdfd);
close(mdfd);

148
Create.c
View File

@ -42,22 +42,19 @@ static int default_layout(struct supertype *st, int level, int verbose)
case 10:
layout = 0x102; /* near=2, far=1 */
if (verbose > 0)
fprintf(stderr,
Name ": layout defaults to n2\n");
pr_err("layout defaults to n2\n");
break;
case 5:
case 6:
layout = map_name(r5layout, "default");
if (verbose > 0)
fprintf(stderr,
Name ": layout defaults to %s\n", map_num(r5layout, layout));
pr_err("layout defaults to %s\n", map_num(r5layout, layout));
break;
case LEVEL_FAULTY:
layout = map_name(faultylayout, "default");
if (verbose > 0)
fprintf(stderr,
Name ": layout defaults to %s\n", map_num(faultylayout, layout));
pr_err("layout defaults to %s\n", map_num(faultylayout, layout));
break;
}
@ -126,28 +123,23 @@ int Create(struct supertype *st, char *mddev,
if (level == UnSet && st && st->ss->default_geometry)
st->ss->default_geometry(st, &level, NULL, NULL);
if (level == UnSet) {
fprintf(stderr,
Name ": a RAID level is needed to create an array.\n");
pr_err("a RAID level is needed to create an array.\n");
return 1;
}
if (raiddisks < 4 && level == 6) {
fprintf(stderr,
Name ": at least 4 raid-devices needed for level 6\n");
pr_err("at least 4 raid-devices needed for level 6\n");
return 1;
}
if (raiddisks > 256 && level == 6) {
fprintf(stderr,
Name ": no more than 256 raid-devices supported for level 6\n");
pr_err("no more than 256 raid-devices supported for level 6\n");
return 1;
}
if (raiddisks < 2 && level >= 4) {
fprintf(stderr,
Name ": at least 2 raid-devices needed for level 4 or 5\n");
pr_err("at least 2 raid-devices needed for level 4 or 5\n");
return 1;
}
if (level <= 0 && sparedisks) {
fprintf(stderr,
Name ": This level does not support spare devices\n");
pr_err("This level does not support spare devices\n");
return 1;
}
@ -189,21 +181,20 @@ int Create(struct supertype *st, char *mddev,
close(fd);
}
if (st && st->ss->external && sparedisks) {
fprintf(stderr,
Name ": This metadata type does not support "
"spare disks at create time\n");
pr_err("This metadata type does not support "
"spare disks at create time\n");
return 1;
}
if (subdevs > raiddisks+sparedisks) {
fprintf(stderr, Name ": You have listed more devices (%d) than are in the array(%d)!\n", subdevs, raiddisks+sparedisks);
pr_err("You have listed more devices (%d) than are in the array(%d)!\n", subdevs, raiddisks+sparedisks);
return 1;
}
if (!have_container && subdevs < raiddisks+sparedisks) {
fprintf(stderr, Name ": You haven't given enough devices (real or missing) to create this array\n");
pr_err("You haven't given enough devices (real or missing) to create this array\n");
return 1;
}
if (bitmap_file && level <= 0) {
fprintf(stderr, Name ": bitmaps not meaningful with level %s\n",
pr_err("bitmaps not meaningful with level %s\n",
map_num(pers, level)?:"given");
return 1;
}
@ -219,7 +210,7 @@ int Create(struct supertype *st, char *mddev,
if (level == 10)
/* check layout fits in array*/
if ((layout&255) * ((layout>>8)&255) > raiddisks) {
fprintf(stderr, Name ": that layout requires at least %d devices\n",
pr_err("that layout requires at least %d devices\n",
(layout&255) * ((layout>>8)&255));
return 1;
}
@ -241,7 +232,7 @@ int Create(struct supertype *st, char *mddev,
if (get_linux_version() < 2006016 && chunk == 0) {
chunk = 64;
if (verbose > 0)
fprintf(stderr, Name ": chunk size defaults to 64K\n");
pr_err("chunk size defaults to 64K\n");
}
break;
case 1:
@ -251,11 +242,11 @@ int Create(struct supertype *st, char *mddev,
if (chunk) {
chunk = 0;
if (verbose > 0)
fprintf(stderr, Name ": chunk size ignored for this level\n");
pr_err("chunk size ignored for this level\n");
}
break;
default:
fprintf(stderr, Name ": unknown level %d\n", level);
pr_err("unknown level %d\n", level);
return 1;
}
@ -271,7 +262,7 @@ int Create(struct supertype *st, char *mddev,
if (do_default_chunk) {
/* default chunk was just set */
if (verbose > 0)
fprintf(stderr, Name ": chunk size "
pr_err("chunk size "
"defaults to %dK\n", chunk);
size &= ~(unsigned long long)(chunk - 1);
do_default_chunk = 0;
@ -288,7 +279,7 @@ int Create(struct supertype *st, char *mddev,
size &= ~(64ULL-1);
if (size && verbose > 0)
fprintf(stderr, Name ": setting size to %lluK\n",
pr_err("setting size to %lluK\n",
(unsigned long long)size);
}
@ -311,14 +302,14 @@ int Create(struct supertype *st, char *mddev,
}
dfd = open(dname, O_RDONLY);
if (dfd < 0) {
fprintf(stderr, Name ": cannot open %s: %s\n",
pr_err("cannot open %s: %s\n",
dname, strerror(errno));
exit(2);
}
if (fstat(dfd, &stb) != 0 ||
(stb.st_mode & S_IFMT) != S_IFBLK) {
close(dfd);
fprintf(stderr, Name ": %s is not a block device\n",
pr_err("%s is not a block device\n",
dname);
exit(2);
}
@ -364,11 +355,11 @@ int Create(struct supertype *st, char *mddev,
if (!st) {
int dfd = open(dname, O_RDONLY|O_EXCL);
if (dfd < 0) {
fprintf(stderr, Name ": cannot open %s: %s\n",
pr_err("cannot open %s: %s\n",
dname, strerror(errno));
exit(2);
}
fprintf(stderr, Name ": device %s not suitable "
pr_err("device %s not suitable "
"for any style of array\n",
dname);
exit(2);
@ -385,10 +376,9 @@ int Create(struct supertype *st, char *mddev,
&freesize,
verbose >= 0)) {
fprintf(stderr,
Name ": %s is not suitable for "
"this array.\n",
dname);
pr_err("%s is not suitable for "
"this array.\n",
dname);
fail = 1;
continue;
}
@ -401,7 +391,7 @@ int Create(struct supertype *st, char *mddev,
if (do_default_chunk) {
/* default chunk was just set */
if (verbose > 0)
fprintf(stderr, Name ": chunk size "
pr_err("chunk size "
"defaults to %dK\n", chunk);
size &= ~(unsigned long long)(chunk - 1);
do_default_chunk = 0;
@ -409,7 +399,7 @@ int Create(struct supertype *st, char *mddev,
}
if (size && freesize < size) {
fprintf(stderr, Name ": %s is smaller than given size."
pr_err("%s is smaller than given size."
" %lluK < %lluK + metadata\n",
dname, freesize, size);
fail = 1;
@ -426,7 +416,7 @@ int Create(struct supertype *st, char *mddev,
if (runstop != 1 || verbose >= 0) {
int fd = open(dname, O_RDONLY);
if (fd <0 ) {
fprintf(stderr, Name ": Cannot open %s: %s\n",
pr_err("Cannot open %s: %s\n",
dname, strerror(errno));
fail=1;
continue;
@ -451,7 +441,7 @@ int Create(struct supertype *st, char *mddev,
level == 1 &&
(warn & 1024) == 0) {
warn |= 1024;
fprintf(stderr, Name ": Note: this array has metadata at the start and\n"
pr_err("Note: this array has metadata at the start and\n"
" may not be suitable as a boot device. If you plan to\n"
" store '/boot' on this device please ensure that\n"
" your boot-loader understands md/v1.x metadata, or use\n"
@ -461,7 +451,7 @@ int Create(struct supertype *st, char *mddev,
}
}
if (raiddisks + sparedisks > st->max_devs) {
fprintf(stderr, Name ": Too many devices:"
pr_err("Too many devices:"
" %s metadata only supports %d\n",
st->ss->name, st->max_devs);
return 1;
@ -469,12 +459,12 @@ int Create(struct supertype *st, char *mddev,
if (have_container)
info.array.working_disks = raiddisks;
if (fail) {
fprintf(stderr, Name ": create aborted\n");
pr_err("create aborted\n");
return 1;
}
if (size == 0) {
if (mindisc == NULL && !have_container) {
fprintf(stderr, Name ": no size and no drives given - aborting create.\n");
pr_err("no size and no drives given - aborting create.\n");
return 1;
}
if (level > 0 || level == LEVEL_MULTIPATH
@ -485,7 +475,7 @@ int Create(struct supertype *st, char *mddev,
raiddisks,
&chunk, minsize*2,
NULL, NULL, 0)) {
fprintf(stderr, Name ": devices too large for RAID level %d\n", level);
pr_err("devices too large for RAID level %d\n", level);
return 1;
}
size = minsize;
@ -496,19 +486,19 @@ int Create(struct supertype *st, char *mddev,
*/
size &= ~(64ULL-1);
if (verbose > 0)
fprintf(stderr, Name ": size set to %lluK\n", size);
pr_err("size set to %lluK\n", size);
}
}
if (!have_container && level > 0 && ((maxsize-size)*100 > maxsize)) {
if (runstop != 1 || verbose >= 0)
fprintf(stderr, Name ": largest drive (%s) exceeds size (%lluK) by more than 1%%\n",
pr_err("largest drive (%s) exceeds size (%lluK) by more than 1%%\n",
maxdisc, size);
warn = 1;
}
if (st->ss->detail_platform && st->ss->detail_platform(0, 1) != 0) {
if (runstop != 1 || verbose >= 0)
fprintf(stderr, Name ": %s unable to enumerate platform support\n"
pr_err("%s unable to enumerate platform support\n"
" array may not be compatible with hardware/firmware\n",
st->ss->name);
warn = 1;
@ -517,12 +507,12 @@ int Create(struct supertype *st, char *mddev,
if (warn) {
if (runstop!= 1) {
if (!ask("Continue creating array? ")) {
fprintf(stderr, Name ": create aborted.\n");
pr_err("create aborted.\n");
return 1;
}
} else {
if (verbose > 0)
fprintf(stderr, Name ": creation continuing despite oddities due to --run\n");
pr_err("creation continuing despite oddities due to --run\n");
}
}
@ -559,8 +549,7 @@ int Create(struct supertype *st, char *mddev,
}
if (level <= 0 && first_missing < subdevs * 2) {
fprintf(stderr,
Name ": This level does not support missing devices\n");
pr_err("This level does not support missing devices\n");
return 1;
}
@ -577,7 +566,7 @@ int Create(struct supertype *st, char *mddev,
*/
if (strncmp(chosen_name, "/dev/md/", 8) == 0
&& map_by_name(&map, chosen_name+8) != NULL) {
fprintf(stderr, Name ": Array name %s is in use already.\n",
pr_err("Array name %s is in use already.\n",
chosen_name);
close(mdfd);
map_unlock(&map);
@ -587,14 +576,14 @@ int Create(struct supertype *st, char *mddev,
vers = md_get_version(mdfd);
if (vers < 9000) {
fprintf(stderr, Name ": Create requires md driver version 0.90.0 or later\n");
pr_err("Create requires md driver version 0.90.0 or later\n");
goto abort_locked;
} else {
mdu_array_info_t inf;
memset(&inf, 0, sizeof(inf));
ioctl(mdfd, GET_ARRAY_INFO, &inf);
if (inf.working_disks != 0) {
fprintf(stderr, Name ": another array by this name"
pr_err("another array by this name"
" is already running.\n");
goto abort_locked;
}
@ -711,12 +700,12 @@ int Create(struct supertype *st, char *mddev,
mdi = sysfs_read(-1, dnum, GET_VERSION);
fprintf(stderr, Name ": Creating array inside "
pr_err("Creating array inside "
"%s container %s\n",
mdi?mdi->text_version:"managed", path);
sysfs_free(mdi);
} else
fprintf(stderr, Name ": Defaulting to version"
pr_err("Defaulting to version"
" %s metadata\n", info.text_version);
}
@ -727,25 +716,25 @@ int Create(struct supertype *st, char *mddev,
if (bitmap_file && vers < 9003) {
major_num = BITMAP_MAJOR_HOSTENDIAN;
#ifdef __BIG_ENDIAN
fprintf(stderr, Name ": Warning - bitmaps created on this kernel are not portable\n"
pr_err("Warning - bitmaps created on this kernel are not portable\n"
" between different architectured. Consider upgrading the Linux kernel.\n");
#endif
}
if (bitmap_file && strcmp(bitmap_file, "internal")==0) {
if ((vers%100) < 2) {
fprintf(stderr, Name ": internal bitmaps not supported by this kernel.\n");
pr_err("internal bitmaps not supported by this kernel.\n");
goto abort;
}
if (!st->ss->add_internal_bitmap) {
fprintf(stderr, Name ": internal bitmaps not supported with %s metadata\n",
pr_err("internal bitmaps not supported with %s metadata\n",
st->ss->name);
goto abort;
}
if (!st->ss->add_internal_bitmap(st, &bitmap_chunk,
delay, write_behind,
bitmapsize, 1, major_num)) {
fprintf(stderr, Name ": Given bitmap chunk size not supported.\n");
pr_err("Given bitmap chunk size not supported.\n");
goto abort;
}
bitmap_file = NULL;
@ -771,13 +760,13 @@ int Create(struct supertype *st, char *mddev,
*/
container_fd = open_dev_excl(st->container_dev);
if (container_fd < 0) {
fprintf(stderr, Name ": Cannot get exclusive "
pr_err("Cannot get exclusive "
"open on container - weird.\n");
goto abort;
}
if (mdmon_running(st->container_dev)) {
if (verbose)
fprintf(stderr, Name ": reusing mdmon "
pr_err("reusing mdmon "
"for %s.\n",
devnum2devname(st->container_dev));
st->update_tail = &st->updates;
@ -786,7 +775,7 @@ int Create(struct supertype *st, char *mddev,
}
rv = set_array_info(mdfd, st, &info);
if (rv) {
fprintf(stderr, Name ": failed to set array info for %s: %s\n",
pr_err("failed to set array info for %s: %s\n",
mddev, strerror(errno));
goto abort;
}
@ -803,12 +792,12 @@ int Create(struct supertype *st, char *mddev,
}
bitmap_fd = open(bitmap_file, O_RDWR);
if (bitmap_fd < 0) {
fprintf(stderr, Name ": weird: %s cannot be openned\n",
pr_err("weird: %s cannot be openned\n",
bitmap_file);
goto abort;
}
if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) {
fprintf(stderr, Name ": Cannot set bitmap file for %s: %s\n",
pr_err("Cannot set bitmap file for %s: %s\n",
mddev, strerror(errno));
goto abort;
}
@ -816,7 +805,7 @@ int Create(struct supertype *st, char *mddev,
infos = malloc(sizeof(*infos) * total_slots);
if (!infos) {
fprintf(stderr, Name ": Unable to allocate memory\n");
pr_err("Unable to allocate memory\n");
goto abort;
}
@ -868,7 +857,7 @@ int Create(struct supertype *st, char *mddev,
fd = open(dv->devname, O_RDWR|O_EXCL);
if (fd < 0) {
fprintf(stderr, Name ": failed to open %s "
pr_err("failed to open %s "
"after earlier success - aborting\n",
dv->devname);
goto abort;
@ -888,7 +877,7 @@ int Create(struct supertype *st, char *mddev,
safe_mode_delay = inf->safe_mode_delay;
if (have_container && verbose > 0)
fprintf(stderr, Name ": Using %s for device %d\n",
pr_err("Using %s for device %d\n",
map_dev(inf->disk.major,
inf->disk.minor,
0), dnum);
@ -905,10 +894,9 @@ int Create(struct supertype *st, char *mddev,
rv = add_disk(mdfd, st, &info, inf);
if (rv) {
fprintf(stderr,
Name ": ADD_NEW_DISK for %s "
"failed: %s\n",
dv->devname, strerror(errno));
pr_err("ADD_NEW_DISK for %s "
"failed: %s\n",
dv->devname, strerror(errno));
goto abort;
}
break;
@ -964,7 +952,7 @@ int Create(struct supertype *st, char *mddev,
* create links */
sysfs_uevent(&info, "change");
if (verbose >= 0)
fprintf(stderr, Name ": container %s prepared.\n", mddev);
pr_err("container %s prepared.\n", mddev);
wait_for(chosen_name, mdfd);
} else if (runstop == 1 || subdevs >= raiddisks) {
if (st->ss->external) {
@ -984,8 +972,8 @@ int Create(struct supertype *st, char *mddev,
}
sysfs_set_safemode(&info, safe_mode_delay);
if (err) {
fprintf(stderr, Name ": failed to"
" activate array.\n");
pr_err("failed to"
" activate array.\n");
ioctl(mdfd, STOP_ARRAY, NULL);
goto abort;
}
@ -993,18 +981,18 @@ int Create(struct supertype *st, char *mddev,
/* param is not actually used */
mdu_param_t param;
if (ioctl(mdfd, RUN_ARRAY, &param)) {
fprintf(stderr, Name ": RUN_ARRAY failed: %s\n",
pr_err("RUN_ARRAY failed: %s\n",
strerror(errno));
if (info.array.chunk_size & (info.array.chunk_size-1)) {
fprintf(stderr, " : Problem may be that "
"chunk size is not a power of 2\n");
cont_err("Problem may be that "
"chunk size is not a power of 2\n");
}
ioctl(mdfd, STOP_ARRAY, NULL);
goto abort;
}
}
if (verbose >= 0)
fprintf(stderr, Name ": array %s started.\n", mddev);
pr_err("array %s started.\n", mddev);
if (st->ss->external && st->container_dev != NoMdDev) {
if (need_mdmon)
start_mdmon(st->container_dev);
@ -1014,7 +1002,7 @@ int Create(struct supertype *st, char *mddev,
}
wait_for(chosen_name, mdfd);
} else {
fprintf(stderr, Name ": not starting array - not enough devices.\n");
pr_err("not starting array - not enough devices.\n");
}
close(mdfd);
return 0;

View File

@ -61,29 +61,29 @@ int Detail(char *dev, int brief, int export, int test, char *homehost, char *pre
char *avail = NULL;
if (fd < 0) {
fprintf(stderr, Name ": cannot open %s: %s\n",
pr_err("cannot open %s: %s\n",
dev, strerror(errno));
return rv;
}
vers = md_get_version(fd);
if (vers < 0) {
fprintf(stderr, Name ": %s does not appear to be an md device\n",
pr_err("%s does not appear to be an md device\n",
dev);
close(fd);
return rv;
}
if (vers < 9000) {
fprintf(stderr, Name ": cannot get detail for md device %s: driver version too old.\n",
pr_err("cannot get detail for md device %s: driver version too old.\n",
dev);
close(fd);
return rv;
}
if (ioctl(fd, GET_ARRAY_INFO, &array)<0) {
if (errno == ENODEV)
fprintf(stderr, Name ": md device %s does not appear to be active.\n",
pr_err("md device %s does not appear to be active.\n",
dev);
else
fprintf(stderr, Name ": cannot get array detail for %s: %s\n",
pr_err("cannot get array detail for %s: %s\n",
dev, strerror(errno));
close(fd);
return rv;
@ -239,7 +239,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost, char *pre
disk.number = d;
if (ioctl(fd, GET_DISK_INFO, &disk) < 0) {
if (d < array.raid_disks)
fprintf(stderr, Name ": cannot get device detail for device %d: %s\n",
pr_err("cannot get device detail for device %d: %s\n",
d, strerror(errno));
continue;
}
@ -617,11 +617,11 @@ int Detail_Platform(struct superswitch *ss, int scan, int verbose)
err = ss->detail_platform(verbose, 0);
else if (ss) {
if (verbose)
fprintf(stderr, Name ": %s metadata is platform independent\n",
pr_err("%s metadata is platform independent\n",
ss->name ? : "[no name]");
} else if (!scan) {
if (verbose)
fprintf(stderr, Name ": specify a metadata type or --scan\n");
pr_err("specify a metadata type or --scan\n");
}
if (!scan)
@ -633,11 +633,11 @@ int Detail_Platform(struct superswitch *ss, int scan, int verbose)
if (meta == ss)
continue;
if (verbose)
fprintf(stderr, Name ": checking metadata %s\n",
pr_err("checking metadata %s\n",
meta->name ? : "[no name]");
if (!meta->detail_platform) {
if (verbose)
fprintf(stderr, Name ": %s metadata is platform independent\n",
pr_err("%s metadata is platform independent\n",
meta->name ? : "[no name]");
} else
err |= meta->detail_platform(verbose, 0);

View File

@ -69,8 +69,8 @@ int Examine(struct mddev_dev *devlist, int brief, int export, int scan,
fd = dev_open(devlist->devname, O_RDONLY);
if (fd < 0) {
if (!scan) {
fprintf(stderr,Name ": cannot open %s: %s\n",
devlist->devname, strerror(errno));
pr_err("cannot open %s: %s\n",
devlist->devname, strerror(errno));
rv = 1;
}
err = 1;
@ -102,7 +102,7 @@ int Examine(struct mddev_dev *devlist, int brief, int export, int scan,
st->ignore_hw_compat = 0;
} else {
if (!brief) {
fprintf(stderr, Name ": No md superblock detected on %s.\n", devlist->devname);
pr_err("No md superblock detected on %s.\n", devlist->devname);
rv = 1;
}
err = 1;
@ -119,7 +119,7 @@ int Examine(struct mddev_dev *devlist, int brief, int export, int scan,
if (brief && st->ss->brief_examine_super == NULL) {
if (!scan)
fprintf(stderr, Name ": No brief listing for %s on %s\n",
pr_err("No brief listing for %s on %s\n",
st->ss->name, devlist->devname);
} else if (brief) {
struct array *ap;

388
Grow.c

File diff suppressed because it is too large Load Diff

View File

@ -109,20 +109,20 @@ int Incremental(char *devname, int verbose, int runstop,
if (stat(devname, &stb) < 0) {
if (verbose >= 0)
fprintf(stderr, Name ": stat failed for %s: %s.\n",
pr_err("stat failed for %s: %s.\n",
devname, strerror(errno));
return rv;
}
if ((stb.st_mode & S_IFMT) != S_IFBLK) {
if (verbose >= 0)
fprintf(stderr, Name ": %s is not a block device.\n",
pr_err("%s is not a block device.\n",
devname);
return rv;
}
dfd = dev_open(devname, O_RDONLY|O_EXCL);
if (dfd < 0) {
if (verbose >= 0)
fprintf(stderr, Name ": cannot open %s: %s.\n",
pr_err("cannot open %s: %s.\n",
devname, strerror(errno));
return rv;
}
@ -136,8 +136,8 @@ int Incremental(char *devname, int verbose, int runstop,
close(dfd);
if (!rv && st->ss->container_content) {
if (map_lock(&map))
fprintf(stderr, Name ": failed to get "
"exclusive lock on mapfile\n");
pr_err("failed to get "
"exclusive lock on mapfile\n");
rv = Incremental_container(st, devname, homehost,
verbose, runstop, autof,
freeze_reshape);
@ -145,7 +145,7 @@ int Incremental(char *devname, int verbose, int runstop,
return rv;
}
fprintf(stderr, Name ": %s is not part of an md array.\n",
pr_err("%s is not part of an md array.\n",
devname);
return rv;
}
@ -154,9 +154,8 @@ int Incremental(char *devname, int verbose, int runstop,
if (!conf_test_dev(devname)) {
if (verbose >= 0)
fprintf(stderr, Name
": %s not permitted by mdadm.conf.\n",
devname);
pr_err("%s not permitted by mdadm.conf.\n",
devname);
goto out;
}
@ -165,13 +164,13 @@ int Incremental(char *devname, int verbose, int runstop,
if (fstat(dfd, &stb) < 0) {
if (verbose >= 0)
fprintf(stderr, Name ": fstat failed for %s: %s.\n",
pr_err("fstat failed for %s: %s.\n",
devname, strerror(errno));
goto out;
}
if ((stb.st_mode & S_IFMT) != S_IFBLK) {
if (verbose >= 0)
fprintf(stderr, Name ": %s is not a block device.\n",
pr_err("%s is not a block device.\n",
devname);
goto out;
}
@ -184,9 +183,8 @@ int Incremental(char *devname, int verbose, int runstop,
if (st == NULL && (st = guess_super(dfd)) == NULL) {
if (verbose >= 0)
fprintf(stderr, Name
": no recognisable superblock on %s.\n",
devname);
pr_err("no recognisable superblock on %s.\n",
devname);
rv = try_spare(devname, &dfd, policy,
have_target ? &target_array : NULL,
st, verbose);
@ -195,7 +193,7 @@ int Incremental(char *devname, int verbose, int runstop,
if (st->ss->compare_super == NULL ||
st->ss->load_super(st, dfd, NULL)) {
if (verbose >= 0)
fprintf(stderr, Name ": no RAID superblock on %s.\n",
pr_err("no RAID superblock on %s.\n",
devname);
rv = try_spare(devname, &dfd, policy,
have_target ? &target_array : NULL,
@ -215,7 +213,7 @@ int Incremental(char *devname, int verbose, int runstop,
if (match && match->devname
&& strcasecmp(match->devname, "<ignore>") == 0) {
if (verbose >= 0)
fprintf(stderr, Name ": array containing %s is explicitly"
pr_err("array containing %s is explicitly"
" ignored by mdadm.conf\n",
devname);
goto out;
@ -238,10 +236,9 @@ int Incremental(char *devname, int verbose, int runstop,
if (!match && !conf_test_metadata(st->ss->name, policy,
(trustworthy == LOCAL))) {
if (verbose >= 1)
fprintf(stderr, Name
": %s has metadata type %s for which "
"auto-assembly is disabled\n",
devname, st->ss->name);
pr_err("%s has metadata type %s for which "
"auto-assembly is disabled\n",
devname, st->ss->name);
goto out;
}
if (trustworthy == LOCAL_ANY)
@ -277,7 +274,7 @@ int Incremental(char *devname, int verbose, int runstop,
/* 4/ Check if array exists.
*/
if (map_lock(&map))
fprintf(stderr, Name ": failed to get exclusive lock on "
pr_err("failed to get exclusive lock on "
"mapfile\n");
mp = map_by_uuid(&map, info.uuid);
if (mp)
@ -297,7 +294,7 @@ int Incremental(char *devname, int verbose, int runstop,
sysfs_init(&info, mdfd, 0);
if (set_array_info(mdfd, st, &info) != 0) {
fprintf(stderr, Name ": failed to set array info for %s: %s\n",
pr_err("failed to set array info for %s: %s\n",
chosen_name, strerror(errno));
rv = 2;
goto out_unlock;
@ -307,7 +304,7 @@ int Incremental(char *devname, int verbose, int runstop,
dinfo.disk.major = major(stb.st_rdev);
dinfo.disk.minor = minor(stb.st_rdev);
if (add_disk(mdfd, st, &info, &dinfo) != 0) {
fprintf(stderr, Name ": failed to add %s to %s: %s.\n",
pr_err("failed to add %s to %s: %s.\n",
devname, chosen_name, strerror(errno));
ioctl(mdfd, STOP_ARRAY, 0);
rv = 2;
@ -322,9 +319,8 @@ int Incremental(char *devname, int verbose, int runstop,
* So reject it.
*/
ioctl(mdfd, STOP_ARRAY, NULL);
fprintf(stderr, Name
": You have an old buggy kernel which cannot support\n"
" --incremental reliably. Aborting.\n");
pr_err("You have an old buggy kernel which cannot support\n"
" --incremental reliably. Aborting.\n");
rv = 2;
goto out_unlock;
}
@ -369,9 +365,8 @@ int Incremental(char *devname, int verbose, int runstop,
act_re_add)
&& runstop < 1) {
if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
fprintf(stderr, Name
": not adding %s to active array (without --run) %s\n",
devname, chosen_name);
pr_err("not adding %s to active array (without --run) %s\n",
devname, chosen_name);
rv = 2;
goto out_unlock;
}
@ -385,18 +380,16 @@ int Incremental(char *devname, int verbose, int runstop,
sra->devs->disk.minor);
dfd2 = dev_open(dn, O_RDONLY);
if (dfd2 < 0) {
fprintf(stderr, Name
": unable to open %s\n", devname);
pr_err("unable to open %s\n", devname);
rv = 2;
goto out_unlock;
}
st2 = dup_super(st);
if (st2->ss->load_super(st2, dfd2, NULL) ||
st->ss->compare_super(st, st2) != 0) {
fprintf(stderr, Name
": metadata mismatch between %s and "
"chosen array %s\n",
devname, chosen_name);
pr_err("metadata mismatch between %s and "
"chosen array %s\n",
devname, chosen_name);
close(dfd2);
rv = 2;
goto out_unlock;
@ -407,9 +400,8 @@ int Incremental(char *devname, int verbose, int runstop,
if (info.array.level != info2.array.level ||
memcmp(info.uuid, info2.uuid, 16) != 0 ||
info.array.raid_disks != info2.array.raid_disks) {
fprintf(stderr, Name
": unexpected difference between %s and %s.\n",
chosen_name, devname);
pr_err("unexpected difference between %s and %s.\n",
chosen_name, devname);
rv = 2;
goto out_unlock;
}
@ -429,7 +421,7 @@ int Incremental(char *devname, int verbose, int runstop,
err = add_disk(mdfd, st, sra, &info);
}
if (err < 0) {
fprintf(stderr, Name ": failed to add %s to %s: %s.\n",
pr_err("failed to add %s to %s: %s.\n",
devname, chosen_name, strerror(errno));
rv = 2;
goto out_unlock;
@ -447,10 +439,9 @@ int Incremental(char *devname, int verbose, int runstop,
/* Try to assemble within the container */
sysfs_uevent(sra, "change");
if (verbose >= 0)
fprintf(stderr, Name
": container %s now has %d device%s\n",
chosen_name, info.array.working_disks,
info.array.working_disks==1?"":"s");
pr_err("container %s now has %d device%s\n",
chosen_name, info.array.working_disks,
info.array.working_disks==1?"":"s");
wait_for(chosen_name, mdfd);
if (st->ss->external)
devnum = fd2devnum(mdfd);
@ -487,9 +478,8 @@ int Incremental(char *devname, int verbose, int runstop,
info.array.layout, info.array.state & 1,
avail) == 0) {
if (verbose >= 0)
fprintf(stderr, Name
": %s attached to %s, not enough to start (%d).\n",
devname, chosen_name, active_disks);
pr_err("%s attached to %s, not enough to start (%d).\n",
devname, chosen_name, active_disks);
rv = 0;
goto out_unlock;
}
@ -502,9 +492,8 @@ int Incremental(char *devname, int verbose, int runstop,
if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
if (verbose >= 0)
fprintf(stderr, Name
": %s attached to %s which is already active.\n",
devname, chosen_name);
pr_err("%s attached to %s which is already active.\n",
devname, chosen_name);
rv = 0;
goto out_unlock;
}
@ -516,16 +505,14 @@ int Incremental(char *devname, int verbose, int runstop,
if (match && match->bitmap_file) {
int bmfd = open(match->bitmap_file, O_RDWR);
if (bmfd < 0) {
fprintf(stderr, Name
": Could not open bitmap file %s.\n",
match->bitmap_file);
pr_err("Could not open bitmap file %s.\n",
match->bitmap_file);
goto out;
}
if (ioctl(mdfd, SET_BITMAP_FILE, bmfd) != 0) {
close(bmfd);
fprintf(stderr, Name
": Failed to set bitmapfile for %s.\n",
chosen_name);
pr_err("Failed to set bitmapfile for %s.\n",
chosen_name);
goto out;
}
close(bmfd);
@ -545,9 +532,8 @@ int Incremental(char *devname, int verbose, int runstop,
"array_state", "read-auto");
if (rv == 0) {
if (verbose >= 0)
fprintf(stderr, Name
": %s attached to %s, which has been started.\n",
devname, chosen_name);
pr_err("%s attached to %s, which has been started.\n",
devname, chosen_name);
rv = 0;
wait_for(chosen_name, mdfd);
/* We just started the array, so some devices
@ -559,21 +545,18 @@ int Incremental(char *devname, int verbose, int runstop,
for (dsk = sra->devs; dsk ; dsk = dsk->next) {
if (disk_action_allows(dsk, st->ss->name, act_re_add) &&
add_disk(mdfd, st, sra, dsk) == 0)
fprintf(stderr, Name
": %s re-added to %s\n",
dsk->sys_name, chosen_name);
pr_err("%s re-added to %s\n",
dsk->sys_name, chosen_name);
}
} else {
fprintf(stderr, Name
": %s attached to %s, but failed to start: %s.\n",
devname, chosen_name, strerror(errno));
pr_err("%s attached to %s, but failed to start: %s.\n",
devname, chosen_name, strerror(errno));
rv = 1;
}
} else {
if (verbose >= 0)
fprintf(stderr, Name
": %s attached to %s, not enough to start safely.\n",
devname, chosen_name);
pr_err("%s attached to %s, not enough to start safely.\n",
devname, chosen_name);
rv = 0;
}
out:
@ -630,9 +613,8 @@ static void find_reject(int mdfd, struct supertype *st, struct mdinfo *sra,
sysfs_set_str(sra, d, "slot", "none");
if (sysfs_set_str(sra, d, "state", "remove") == 0)
if (verbose >= 0)
fprintf(stderr, Name
": removing old device %s from %s\n",
d->sys_name+4, array_name);
pr_err("removing old device %s from %s\n",
d->sys_name+4, array_name);
}
}
@ -677,7 +659,7 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
raid_disks = info.array.raid_disks;
avail = calloc(raid_disks, 1);
if (!avail) {
fprintf(stderr, Name ": out of memory.\n");
pr_err("out of memory.\n");
exit(1);
}
*availp = avail;
@ -811,7 +793,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
*/
if (map_lock(&map)) {
fprintf(stderr, Name ": failed to get exclusive lock on "
pr_err("failed to get exclusive lock on "
"mapfile\n");
return 1;
}
@ -830,7 +812,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
(st->minor_version >= 0 &&
st->minor_version != st2->minor_version)) {
if (verbose > 1)
fprintf(stderr, Name ": not adding %s to %s as metadata type doesn't match\n",
pr_err("not adding %s to %s as metadata type doesn't match\n",
devname, mp->path);
free(st2);
continue;
@ -858,7 +840,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
sra->text_version);
if (!st2) {
if (verbose > 1)
fprintf(stderr, Name ": not adding %s to %s"
pr_err("not adding %s to %s"
" as metadata not recognised.\n",
devname, mp->path);
goto next;
@ -901,7 +883,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
||
(sra->component_size == 0 && devsize < component_size)) {
if (verbose > 1)
fprintf(stderr, Name ": not adding %s to %s as it is too small\n",
pr_err("not adding %s to %s as it is too small\n",
devname, mp->path);
goto next;
}
@ -937,7 +919,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
if (domain_test(dl, pol, st2->ss->name) != 1) {
/* domain test fails */
if (verbose > 1)
fprintf(stderr, Name ": not adding %s to %s as"
pr_err("not adding %s to %s as"
" it is not in a compatible domain\n",
devname, mp->path);
@ -982,10 +964,10 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
}
if (verbose > 0) {
if (rv == 0)
fprintf(stderr, Name ": added %s as spare for %s\n",
pr_err("added %s as spare for %s\n",
devname, chosen->sys_name);
else
fprintf(stderr, Name ": failed to add %s as spare for %s\n",
pr_err("failed to add %s as spare for %s\n",
devname, chosen->sys_name);
}
sysfs_free(chosen);
@ -1211,7 +1193,7 @@ static int try_spare(char *devname, int *dfdp, struct dev_policy *pol,
!policy_action_allows(pol, st?st->ss->name:NULL,
act_spare_same_slot)) {
if (verbose > 1)
fprintf(stderr, Name ": %s is not bare, so not "
pr_err("%s is not bare, so not "
"considering as a spare\n",
devname);
return 1;
@ -1305,13 +1287,11 @@ int IncrementalScan(int verbose)
}
if (verbose >= 0) {
if (added == 0)
fprintf(stderr, Name
": Added bitmap %s to %s\n",
mddev->bitmap_file, me->path);
pr_err("Added bitmap %s to %s\n",
mddev->bitmap_file, me->path);
else if (errno != EEXIST)
fprintf(stderr, Name
": Failed to add bitmap to %s: %s\n",
me->path, strerror(errno));
pr_err("Failed to add bitmap to %s: %s\n",
me->path, strerror(errno));
}
}
sra = sysfs_read(mdfd, 0, 0);
@ -1319,14 +1299,12 @@ int IncrementalScan(int verbose)
if (sysfs_set_str(sra, NULL,
"array_state", "read-auto") == 0) {
if (verbose >= 0)
fprintf(stderr, Name
": started array %s\n",
me->path ?: devnum2devname(me->devnum));
pr_err("started array %s\n",
me->path ?: devnum2devname(me->devnum));
} else {
fprintf(stderr, Name
": failed to start array %s: %s\n",
me->path ?: devnum2devname(me->devnum),
strerror(errno));
pr_err("failed to start array %s: %s\n",
me->path ?: devnum2devname(me->devnum),
strerror(errno));
rv = 1;
}
sysfs_free(sra);
@ -1389,7 +1367,7 @@ static int Incremental_container(struct supertype *st, char *devname,
/* pass */;
else {
if (verbose)
fprintf(stderr, Name ": not enough devices to start the container\n");
pr_err("not enough devices to start the container\n");
return 0;
}
@ -1420,7 +1398,7 @@ static int Incremental_container(struct supertype *st, char *devname,
ra_all++;
/* do not activate arrays blocked by metadata handler */
if (ra->array.state & (1 << MD_SB_BLOCK_VOLUME)) {
fprintf(stderr, Name ": Cannot activate array %s in %s.\n",
pr_err("Cannot activate array %s in %s.\n",
ra->text_version, devname);
ra_blocked++;
continue;
@ -1468,7 +1446,7 @@ static int Incremental_container(struct supertype *st, char *devname,
/* we have a match */
match = array_list;
if (verbose>0)
fprintf(stderr, Name ": match found for member %s\n",
pr_err("match found for member %s\n",
array_list->member);
break;
}
@ -1476,9 +1454,9 @@ static int Incremental_container(struct supertype *st, char *devname,
if (match && match->devname &&
strcasecmp(match->devname, "<ignore>") == 0) {
if (verbose > 0)
fprintf(stderr, Name ": array %s/%s is "
"explicitly ignored by mdadm.conf\n",
match->container, match->member);
pr_err("array %s/%s is "
"explicitly ignored by mdadm.conf\n",
match->container, match->member);
return 2;
}
if (match)
@ -1492,7 +1470,7 @@ static int Incremental_container(struct supertype *st, char *devname,
}
if (mdfd < 0) {
fprintf(stderr, Name ": failed to open %s: %s.\n",
pr_err("failed to open %s: %s.\n",
chosen_name, strerror(errno));
return 2;
}
@ -1544,9 +1522,8 @@ static int Incremental_container(struct supertype *st, char *devname,
disks = disks->next;
}
if (count)
fprintf(stderr, Name
": Added %d spare%s to %s\n",
count, count>1?"s":"", devname);
pr_err("Added %d spare%s to %s\n",
count, count>1?"s":"", devname);
}
sysfs_free(sinfo);
} else
@ -1579,19 +1556,19 @@ int IncrementalRemove(char *devname, char *id_path, int verbose)
"port\n");
if (strchr(devname, '/')) {
fprintf(stderr, Name ": incremental removal requires a "
pr_err("incremental removal requires a "
"kernel device name, not a file: %s\n", devname);
return 1;
}
ent = mdstat_by_component(devname);
if (!ent) {
fprintf(stderr, Name ": %s does not appear to be a component "
pr_err("%s does not appear to be a component "
"of any array\n", devname);
return 1;
}
mdfd = open_dev(ent->devnum);
if (mdfd < 0) {
fprintf(stderr, Name ": Cannot open array %s!!\n", ent->dev);
pr_err("Cannot open array %s!!\n", ent->dev);
free_mdstat(ent);
return 1;
}

28
Kill.c
View File

@ -47,7 +47,7 @@ int Kill(char *dev, struct supertype *st, int force, int quiet, int noexcl)
fd = open(dev, O_RDWR|(noexcl ? 0 : O_EXCL));
if (fd < 0) {
if (!quiet)
fprintf(stderr, Name ": Couldn't open %s for write - not zeroing\n",
pr_err("Couldn't open %s for write - not zeroing\n",
dev);
return 2;
}
@ -55,7 +55,7 @@ int Kill(char *dev, struct supertype *st, int force, int quiet, int noexcl)
st = guess_super(fd);
if (st == NULL || st->ss->init_super == NULL) {
if (!quiet)
fprintf(stderr, Name ": Unrecognised md component device - %s\n", dev);
pr_err("Unrecognised md component device - %s\n", dev);
close(fd);
return 2;
}
@ -66,12 +66,12 @@ int Kill(char *dev, struct supertype *st, int force, int quiet, int noexcl)
st->ss->init_super(st, NULL, 0, "", NULL, NULL);
if (st->ss->store_super(st, fd)) {
if (!quiet)
fprintf(stderr, Name ": Could not zero superblock on %s\n",
pr_err("Could not zero superblock on %s\n",
dev);
rv = 1;
} else if (rv) {
if (!quiet)
fprintf(stderr, Name ": superblock zeroed anyway\n");
pr_err("superblock zeroed anyway\n");
rv = 0;
}
}
@ -101,17 +101,15 @@ int Kill_subarray(char *dev, char *subarray, int quiet)
if (!st->ss->kill_subarray) {
if (!quiet)
fprintf(stderr,
Name ": Operation not supported for %s metadata\n",
st->ss->name);
pr_err("Operation not supported for %s metadata\n",
st->ss->name);
goto free_super;
}
if (is_subarray_active(subarray, st->devname)) {
if (!quiet)
fprintf(stderr,
Name ": Subarray-%s still active, aborting\n",
subarray);
pr_err("Subarray-%s still active, aborting\n",
subarray);
goto free_super;
}
@ -122,9 +120,8 @@ int Kill_subarray(char *dev, char *subarray, int quiet)
rv = st->ss->kill_subarray(st);
if (rv) {
if (!quiet)
fprintf(stderr,
Name ": Failed to delete subarray-%s from %s\n",
subarray, dev);
pr_err("Failed to delete subarray-%s from %s\n",
subarray, dev);
goto free_super;
}
@ -135,9 +132,8 @@ int Kill_subarray(char *dev, char *subarray, int quiet)
st->ss->sync_metadata(st);
if (!quiet)
fprintf(stderr,
Name ": Deleted subarray-%s from %s, UUIDs may have changed\n",
subarray, dev);
pr_err("Deleted subarray-%s from %s, UUIDs may have changed\n",
subarray, dev);
rv = 0;

204
Manage.c
View File

@ -47,7 +47,7 @@ int Manage_ro(char *devname, int fd, int readonly)
int rv = 0;
if (md_get_version(fd) < 9000) {
fprintf(stderr, Name ": need md driver version 0.90.0 or later\n");
pr_err("need md driver version 0.90.0 or later\n");
return 1;
}
#ifndef MDASSEMBLE
@ -71,7 +71,7 @@ int Manage_ro(char *devname, int fd, int readonly)
rv = sysfs_set_str(mdi, NULL, "array_state", "readonly");
if (rv < 0) {
fprintf(stderr, Name ": failed to set readonly for %s: %s\n",
pr_err("failed to set readonly for %s: %s\n",
devname, strerror(errno));
vers[9] = mdi->text_version[0];
@ -96,7 +96,7 @@ int Manage_ro(char *devname, int fd, int readonly)
}
#endif
if (ioctl(fd, GET_ARRAY_INFO, &array)) {
fprintf(stderr, Name ": %s does not appear to be active.\n",
pr_err("%s does not appear to be active.\n",
devname);
rv = 1;
goto out;
@ -104,14 +104,14 @@ int Manage_ro(char *devname, int fd, int readonly)
if (readonly>0) {
if (ioctl(fd, STOP_ARRAY_RO, NULL)) {
fprintf(stderr, Name ": failed to set readonly for %s: %s\n",
pr_err("failed to set readonly for %s: %s\n",
devname, strerror(errno));
rv = 1;
goto out;
}
} else if (readonly < 0) {
if (ioctl(fd, RESTART_ARRAY_RW, NULL)) {
fprintf(stderr, Name ": failed to set writable for %s: %s\n",
pr_err("failed to set writable for %s: %s\n",
devname, strerror(errno));
rv = 1;
goto out;
@ -187,33 +187,32 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
if (runstop == -1 && md_get_version(fd) < 9000) {
if (ioctl(fd, STOP_MD, 0)) {
if (quiet == 0) fprintf(stderr,
Name ": stopping device %s "
"failed: %s\n",
devname, strerror(errno));
pr_err("stopping device %s "
"failed: %s\n",
devname, strerror(errno));
return 1;
}
}
if (md_get_version(fd) < 9000) {
fprintf(stderr, Name ": need md driver version 0.90.0 or later\n");
pr_err("need md driver version 0.90.0 or later\n");
return 1;
}
/*
if (ioctl(fd, GET_ARRAY_INFO, &array)) {
fprintf(stderr, Name ": %s does not appear to be active.\n",
pr_err("%s does not appear to be active.\n",
devname);
return 1;
}
*/
if (runstop>0) {
if (ioctl(fd, RUN_ARRAY, &param)) {
fprintf(stderr, Name ": failed to run array %s: %s\n",
pr_err("failed to run array %s: %s\n",
devname, strerror(errno));
return 1;
}
if (quiet <= 0)
fprintf(stderr, Name ": started %s\n", devname);
pr_err("started %s\n", devname);
} else if (runstop < 0){
struct map_ent *map = NULL;
struct stat stb;
@ -233,12 +232,11 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
if (fd < 0 || fd2devnum(fd) != devnum) {
if (fd >= 0)
close(fd);
fprintf(stderr,
Name ": Cannot get exclusive access to %s:"
"Perhaps a running "
"process, mounted filesystem "
"or active volume group?\n",
devname);
pr_err("Cannot get exclusive access to %s:"
"Perhaps a running "
"process, mounted filesystem "
"or active volume group?\n",
devname);
return 1;
}
mdi = sysfs_read(fd, -1, GET_LEVEL|GET_VERSION);
@ -259,9 +257,8 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
count--;
}
if (err && !quiet) {
fprintf(stderr, Name
": failed to stop array %s: %s\n",
devname, strerror(errno));
pr_err("failed to stop array %s: %s\n",
devname, strerror(errno));
rv = 1;
goto out;
}
@ -271,10 +268,9 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
fd = open_dev_excl(devnum);
if (fd < 0) {
fprintf(stderr, Name
": failed to completely stop %s"
": Device is busy\n",
devname);
pr_err("failed to completely stop %s"
": Device is busy\n",
devname);
rv = 1;
goto out;
}
@ -299,10 +295,9 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
is_subarray(m->metadata_version+9) &&
devname2devnum(m->metadata_version+10) == devnum) {
if (!quiet)
fprintf(stderr, Name
": Cannot stop container %s: "
"member %s still active\n",
devname, m->dev);
pr_err("Cannot stop container %s: "
"member %s still active\n",
devname, m->dev);
free_mdstat(mds);
rv = 1;
goto out;
@ -322,9 +317,8 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
}
if (fd >= 0 && err) {
if (quiet == 0) {
fprintf(stderr, Name
": failed to stop array %s: %s\n",
devname, strerror(errno));
pr_err("failed to stop array %s: %s\n",
devname, strerror(errno));
if (errno == EBUSY)
fprintf(stderr, "Perhaps a running "
"process, mounted filesystem "
@ -352,7 +346,7 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
if (quiet <= 0)
fprintf(stderr, Name ": stopped %s\n", devname);
pr_err("stopped %s\n", devname);
map_lock(&map);
map_remove(&map, devnum);
map_unlock(&map);
@ -367,7 +361,7 @@ int Manage_resize(char *devname, int fd, long long size, int raid_disks)
{
mdu_array_info_t info;
if (ioctl(fd, GET_ARRAY_INFO, &info) != 0) {
fprintf(stderr, Name ": Cannot get array information for %s: %s\n",
pr_err("Cannot get array information for %s: %s\n",
devname, strerror(errno));
return 1;
}
@ -376,7 +370,7 @@ int Manage_resize(char *devname, int fd, long long size, int raid_disks)
if (raid_disks > 0)
info.raid_disks = raid_disks;
if (ioctl(fd, SET_ARRAY_INFO, &info) != 0) {
fprintf(stderr, Name ": Cannot set device size/shape for %s: %s\n",
pr_err("Cannot set device size/shape for %s: %s\n",
devname, strerror(errno));
return 1;
}
@ -420,7 +414,7 @@ int Manage_subdevs(char *devname, int fd,
int frozen = 0;
if (ioctl(fd, GET_ARRAY_INFO, &array)) {
fprintf(stderr, Name ": cannot get array info for %s\n",
pr_err("cannot get array info for %s\n",
devname);
goto abort;
}
@ -436,7 +430,7 @@ int Manage_subdevs(char *devname, int fd,
tst = super_by_fd(fd, &subarray);
if (!tst) {
fprintf(stderr, Name ": unsupport array - version %d.%d\n",
pr_err("unsupport array - version %d.%d\n",
array.major_version, array.minor_version);
goto abort;
}
@ -457,7 +451,7 @@ int Manage_subdevs(char *devname, int fd,
strcmp(dv->devname, "faulty")==0) {
int remaining_disks = array.nr_disks;
if (dv->disposition != 'r') {
fprintf(stderr, Name ": %s only meaningful "
pr_err("%s only meaningful "
"with -r, not -%c\n",
dv->devname, dv->disposition);
goto abort;
@ -490,7 +484,7 @@ int Manage_subdevs(char *devname, int fd,
} else if (strcmp(dv->devname, "detached") == 0) {
int remaining_disks = array.nr_disks;
if (dv->disposition != 'r' && dv->disposition != 'f') {
fprintf(stderr, Name ": %s only meaningful "
pr_err("%s only meaningful "
"with -r of -f, not -%c\n",
dv->devname, dv->disposition);
goto abort;
@ -531,14 +525,14 @@ int Manage_subdevs(char *devname, int fd,
continue;
} else if (strcmp(dv->devname, "missing") == 0) {
if (dv->disposition != 'a' || dv->re_add == 0) {
fprintf(stderr, Name ": 'missing' only meaningful "
pr_err("'missing' only meaningful "
"with --re-add\n");
goto abort;
}
if (add_devlist == NULL)
add_devlist = conf_get_devs();
if (add_devlist == NULL) {
fprintf(stderr, Name ": no devices to scan for missing members.");
pr_err("no devices to scan for missing members.");
continue;
}
add_dev = add_devlist->devname;
@ -554,7 +548,7 @@ int Manage_subdevs(char *devname, int fd,
int found = 0;
char dname[55];
if (dv->disposition != 'r' && dv->disposition != 'f') {
fprintf(stderr, Name ": %s only meaningful "
pr_err("%s only meaningful "
"with -r or -f, not -%c\n",
dv->devname, dv->disposition);
goto abort;
@ -576,7 +570,7 @@ int Manage_subdevs(char *devname, int fd,
if (!found) {
sysfd = sysfs_open(fd2devnum(fd), dname, "state");
if (sysfd < 0) {
fprintf(stderr, Name ": %s does not appear "
pr_err("%s does not appear "
"to be a component of %s\n",
dv->devname, devname);
goto abort;
@ -594,7 +588,7 @@ int Manage_subdevs(char *devname, int fd,
;
else {
if (tfd < 0 || fstat(tfd, &stb) != 0) {
fprintf(stderr, Name ": cannot find %s: %s\n",
pr_err("cannot find %s: %s\n",
dv->devname, strerror(errno));
if (tfd >= 0)
close(tfd);
@ -604,7 +598,7 @@ int Manage_subdevs(char *devname, int fd,
tfd = -1;
}
if ((stb.st_mode & S_IFMT) != S_IFBLK) {
fprintf(stderr, Name ": %s is not a "
pr_err("%s is not a "
"block device.\n",
dv->devname);
goto abort;
@ -612,13 +606,13 @@ int Manage_subdevs(char *devname, int fd,
}
switch(dv->disposition){
default:
fprintf(stderr, Name ": internal error - devmode[%s]=%d\n",
pr_err("internal error - devmode[%s]=%d\n",
dv->devname, dv->disposition);
goto abort;
case 'a':
/* add the device */
if (subarray) {
fprintf(stderr, Name ": Cannot add disks to a"
pr_err("Cannot add disks to a"
" \'member\' array, perform this"
" operation on the parent container\n");
goto abort;
@ -628,7 +622,7 @@ int Manage_subdevs(char *devname, int fd,
if (tfd < 0 && add_dev != dv->devname)
continue;
if (tfd < 0) {
fprintf(stderr, Name ": Cannot open %s: %s\n",
pr_err("Cannot open %s: %s\n",
dv->devname, strerror(errno));
goto abort;
}
@ -662,22 +656,20 @@ int Manage_subdevs(char *devname, int fd,
array.raid_disks, NULL,
ldsize >> 9, NULL, NULL, 0) == 0) {
if (!force) {
fprintf(stderr, Name
": %s is larger than %s can "
"effectively use.\n"
" Add --force is you "
"really want to add this device.\n",
add_dev, devname);
pr_err("%s is larger than %s can "
"effectively use.\n"
" Add --force is you "
"really want to add this device.\n",
add_dev, devname);
st->ss->free_super(st);
close(tfd);
goto abort;
}
fprintf(stderr, Name
": %s is larger than %s can "
"effectively use.\n"
" Adding anyway as --force "
"was given.\n",
add_dev, devname);
pr_err("%s is larger than %s can "
"effectively use.\n"
" Adding anyway as --force "
"was given.\n",
add_dev, devname);
}
if (!tst->ss->external &&
array.major_version == 0 &&
@ -688,12 +680,12 @@ int Manage_subdevs(char *devname, int fd,
if (ioctl(fd, HOT_ADD_DISK,
(unsigned long)stb.st_rdev)==0) {
if (verbose >= 0)
fprintf(stderr, Name ": hot added %s\n",
pr_err("hot added %s\n",
add_dev);
continue;
}
fprintf(stderr, Name ": hot add failed for %s: %s\n",
pr_err("hot add failed for %s: %s\n",
add_dev, strerror(errno));
goto abort;
}
@ -741,7 +733,7 @@ int Manage_subdevs(char *devname, int fd,
} else if (!tst->sb) {
close(tfd);
st->ss->free_super(st);
fprintf(stderr, Name ": cannot load array metadata from %s\n", devname);
pr_err("cannot load array metadata from %s\n", devname);
goto abort;
}
@ -753,7 +745,7 @@ int Manage_subdevs(char *devname, int fd,
st->ss->free_super(st);
if (add_dev != dv->devname)
continue;
fprintf(stderr, Name ": %s not large enough to join array\n",
pr_err("%s not large enough to join array\n",
dv->devname);
goto abort;
}
@ -805,7 +797,7 @@ int Manage_subdevs(char *devname, int fd,
int rv = -1;
tfd = dev_open(dv->devname, O_RDWR);
if (tfd < 0) {
fprintf(stderr, Name ": failed to open %s for"
pr_err("failed to open %s for"
" superblock update during re-add\n", dv->devname);
st->ss->free_super(st);
goto abort;
@ -828,8 +820,8 @@ int Manage_subdevs(char *devname, int fd,
close(tfd);
tfd = -1;
if (rv != 0) {
fprintf(stderr, Name ": failed to update"
" superblock during re-add\n");
pr_err("failed to update"
" superblock during re-add\n");
st->ss->free_super(st);
goto abort;
}
@ -838,13 +830,13 @@ int Manage_subdevs(char *devname, int fd,
errno = 0;
if (ioctl(fd, ADD_NEW_DISK, &disc) == 0) {
if (verbose >= 0)
fprintf(stderr, Name ": re-added %s\n", add_dev);
pr_err("re-added %s\n", add_dev);
count++;
st->ss->free_super(st);
continue;
}
if (errno == ENOMEM || errno == EROFS) {
fprintf(stderr, Name ": add new device failed for %s: %s\n",
pr_err("add new device failed for %s: %s\n",
add_dev, strerror(errno));
st->ss->free_super(st);
if (add_dev != dv->devname)
@ -857,9 +849,8 @@ int Manage_subdevs(char *devname, int fd,
}
if (add_dev != dv->devname) {
if (verbose > 0)
fprintf(stderr, Name
": --re-add for %s to %s is not possible\n",
add_dev, devname);
pr_err("--re-add for %s to %s is not possible\n",
add_dev, devname);
if (tfd >= 0) {
close(tfd);
tfd = -1;
@ -869,9 +860,8 @@ int Manage_subdevs(char *devname, int fd,
if (dv->re_add) {
if (tfd >= 0)
close(tfd);
fprintf(stderr, Name
": --re-add for %s to %s is not possible\n",
dv->devname, devname);
pr_err("--re-add for %s to %s is not possible\n",
dv->devname, devname);
goto abort;
}
if (array.active_disks < array.raid_disks) {
@ -895,9 +885,9 @@ int Manage_subdevs(char *devname, int fd,
} else
array_failed = 0;
if (array_failed) {
fprintf(stderr, Name ": %s has failed so using --add cannot work and might destroy\n",
pr_err("%s has failed so using --add cannot work and might destroy\n",
devname);
fprintf(stderr, Name ": data on %s. You should stop the array and re-assemble it.\n",
pr_err("data on %s. You should stop the array and re-assemble it.\n",
dv->devname);
if (tfd >= 0)
close(tfd);
@ -908,7 +898,7 @@ int Manage_subdevs(char *devname, int fd,
* is at least array.size big.
*/
if (ldsize/512 < array_size) {
fprintf(stderr, Name ": %s not large enough to join array\n",
pr_err("%s not large enough to join array\n",
dv->devname);
if (tfd >= 0)
close(tfd);
@ -996,9 +986,9 @@ int Manage_subdevs(char *devname, int fd,
container_fd = open_dev_excl(devnum);
if (container_fd < 0) {
fprintf(stderr, Name ": add failed for %s:"
" could not get exclusive access to container\n",
dv->devname);
pr_err("add failed for %s:"
" could not get exclusive access to container\n",
dv->devname);
tst->ss->free_super(tst);
goto abort;
}
@ -1019,7 +1009,7 @@ int Manage_subdevs(char *devname, int fd,
sra = sysfs_read(container_fd, -1, 0);
if (!sra) {
fprintf(stderr, Name ": add failed for %s: sysfs_read failed\n",
pr_err("add failed for %s: sysfs_read failed\n",
dv->devname);
close(container_fd);
tst->ss->free_super(tst);
@ -1035,7 +1025,7 @@ int Manage_subdevs(char *devname, int fd,
* would block add_disk */
tst->ss->free_super(tst);
if (sysfs_add_disk(sra, &new_mdi, 0) != 0) {
fprintf(stderr, Name ": add new device to external metadata"
pr_err("add new device to external metadata"
" failed for %s\n", dv->devname);
close(container_fd);
sysfs_free(sra);
@ -1047,19 +1037,19 @@ int Manage_subdevs(char *devname, int fd,
} else {
tst->ss->free_super(tst);
if (ioctl(fd, ADD_NEW_DISK, &disc)) {
fprintf(stderr, Name ": add new device failed for %s as %d: %s\n",
pr_err("add new device failed for %s as %d: %s\n",
dv->devname, j, strerror(errno));
goto abort;
}
}
if (verbose >= 0)
fprintf(stderr, Name ": added %s\n", dv->devname);
pr_err("added %s\n", dv->devname);
break;
case 'r':
/* hot remove */
if (subarray) {
fprintf(stderr, Name ": Cannot remove disks from a"
pr_err("Cannot remove disks from a"
" \'member\' array, perform this"
" operation on the parent container\n");
if (sysfd >= 0)
@ -1079,9 +1069,8 @@ int Manage_subdevs(char *devname, int fd,
int dnum = fd2devnum(fd);
lfd = open_dev_excl(dnum);
if (lfd < 0) {
fprintf(stderr, Name
": Cannot get exclusive access "
" to container - odd\n");
pr_err("Cannot get exclusive access "
" to container - odd\n");
if (sysfd >= 0)
close(sysfd);
goto abort;
@ -1095,11 +1084,10 @@ int Manage_subdevs(char *devname, int fd,
sysfs_unique_holder(dnum, stb.st_rdev))
/* pass */;
else {
fprintf(stderr, Name
": %s is %s, cannot remove.\n",
dnprintable,
errno == EEXIST ? "still in use":
"not a member");
pr_err("%s is %s, cannot remove.\n",
dnprintable,
errno == EEXIST ? "still in use":
"not a member");
close(lfd);
goto abort;
}
@ -1139,9 +1127,9 @@ int Manage_subdevs(char *devname, int fd,
}
}
if (err) {
fprintf(stderr, Name ": hot remove failed "
"for %s: %s\n", dnprintable,
strerror(errno));
pr_err("hot remove failed "
"for %s: %s\n", dnprintable,
strerror(errno));
if (lfd >= 0)
close(lfd);
goto abort;
@ -1156,7 +1144,7 @@ int Manage_subdevs(char *devname, int fd,
char *name = devnum2devname(fd2devnum(fd));
if (!name) {
fprintf(stderr, Name ": unable to get container name\n");
pr_err("unable to get container name\n");
goto abort;
}
@ -1167,7 +1155,7 @@ int Manage_subdevs(char *devname, int fd,
close(lfd);
count++;
if (verbose >= 0)
fprintf(stderr, Name ": hot removed %s from %s\n",
pr_err("hot removed %s from %s\n",
dnprintable, devname);
break;
@ -1176,7 +1164,7 @@ int Manage_subdevs(char *devname, int fd,
if ((sysfd >= 0 && write(sysfd, "faulty", 6) != 6) ||
(sysfd < 0 && ioctl(fd, SET_DISK_FAULTY,
(unsigned long) stb.st_rdev))) {
fprintf(stderr, Name ": set device faulty failed for %s: %s\n",
pr_err("set device faulty failed for %s: %s\n",
dnprintable, strerror(errno));
if (sysfd >= 0)
close(sysfd);
@ -1187,7 +1175,7 @@ int Manage_subdevs(char *devname, int fd,
sysfd = -1;
count++;
if (verbose >= 0)
fprintf(stderr, Name ": set %s faulty in %s\n",
pr_err("set %s faulty in %s\n",
dnprintable, devname);
break;
}
@ -1230,9 +1218,8 @@ int Update_subarray(char *dev, char *subarray, char *update, struct mddev_ident
if (!st->ss->update_subarray) {
if (!quiet)
fprintf(stderr,
Name ": Operation not supported for %s metadata\n",
st->ss->name);
pr_err("Operation not supported for %s metadata\n",
st->ss->name);
goto free_super;
}
@ -1243,7 +1230,7 @@ int Update_subarray(char *dev, char *subarray, char *update, struct mddev_ident
if (rv) {
if (!quiet)
fprintf(stderr, Name ": Failed to update %s of subarray-%s in %s\n",
pr_err("Failed to update %s of subarray-%s in %s\n",
update, subarray, dev);
} else if (st->update_tail)
flush_metadata_updates(st);
@ -1251,9 +1238,8 @@ int Update_subarray(char *dev, char *subarray, char *update, struct mddev_ident
st->ss->sync_metadata(st);
if (rv == 0 && strcmp(update, "name") == 0 && !quiet)
fprintf(stderr,
Name ": Updated subarray-%s name from %s, UUIDs may have changed\n",
subarray, dev);
pr_err("Updated subarray-%s name from %s, UUIDs may have changed\n",
subarray, dev);
free_super:
st->ss->free_super(st);

View File

@ -128,7 +128,7 @@ int Monitor(struct mddev_dev *devlist,
if (!mailaddr) {
mailaddr = conf_get_mailaddr();
if (mailaddr && ! scan)
fprintf(stderr, Name ": Monitor using email address \"%s\" from config file\n",
pr_err("Monitor using email address \"%s\" from config file\n",
mailaddr);
}
mailfrom = conf_get_mailfrom();
@ -136,11 +136,11 @@ int Monitor(struct mddev_dev *devlist,
if (!alert_cmd) {
alert_cmd = conf_get_program();
if (alert_cmd && ! scan)
fprintf(stderr, Name ": Monitor using program \"%s\" from config file\n",
pr_err("Monitor using program \"%s\" from config file\n",
alert_cmd);
}
if (scan && !mailaddr && !alert_cmd && !dosyslog) {
fprintf(stderr, Name ": No mail address or alert command - not monitoring.\n");
pr_err("No mail address or alert command - not monitoring.\n");
return 1;
}
info.alert_cmd = alert_cmd;
@ -301,13 +301,13 @@ static int check_one_sharer(int scan)
rv = stat(dir, &buf);
if (rv != -1) {
if (scan) {
fprintf(stderr, Name ": Only one "
pr_err("Only one "
"autorebuild process allowed"
" in scan mode, aborting\n");
fclose(fp);
return 1;
} else {
fprintf(stderr, Name ": Warning: One"
pr_err("Warning: One"
" autorebuild process already"
" running.\n");
}
@ -317,12 +317,12 @@ static int check_one_sharer(int scan)
if (scan) {
if (mkdir(MDMON_DIR, S_IRWXU) < 0 &&
errno != EEXIST) {
fprintf(stderr, Name ": Can't create "
pr_err("Can't create "
"autorebuild.pid file\n");
} else {
fp = fopen(path, "w");
if (!fp)
fprintf(stderr, Name ": Cannot create"
pr_err("Cannot create"
" autorebuild.pid"
"file\n");
else {
@ -962,7 +962,7 @@ int Wait(char *dev)
int rv = 1;
if (stat(dev, &stb) != 0) {
fprintf(stderr, Name ": Cannot find %s: %s\n", dev,
pr_err("Cannot find %s: %s\n", dev,
strerror(errno));
return 2;
}
@ -1008,7 +1008,7 @@ int WaitClean(char *dev, int sock, int verbose)
fd = open(dev, O_RDONLY);
if (fd < 0) {
if (verbose)
fprintf(stderr, Name ": Couldn't open %s: %s\n", dev, strerror(errno));
pr_err("Couldn't open %s: %s\n", dev, strerror(errno));
return 1;
}
@ -1016,8 +1016,8 @@ int WaitClean(char *dev, int sock, int verbose)
mdi = sysfs_read(fd, devnum, GET_VERSION|GET_LEVEL|GET_SAFEMODE);
if (!mdi) {
if (verbose)
fprintf(stderr, Name ": Failed to read sysfs attributes for "
"%s\n", dev);
pr_err("Failed to read sysfs attributes for "
"%s\n", dev);
close(fd);
return 0;
}
@ -1080,7 +1080,7 @@ int WaitClean(char *dev, int sock, int verbose)
} else
rv = 1;
if (rv && verbose)
fprintf(stderr, Name ": Error waiting for %s to be clean\n",
pr_err("Error waiting for %s to be clean\n",
dev);
/* restore the original safe_mode_delay */

View File

@ -47,7 +47,7 @@ int Query(char *dev)
char *activity;
if (fd < 0){
fprintf(stderr, Name ": cannot open %s: %s\n",
pr_err("cannot open %s: %s\n",
dev, strerror(errno));
return 1;
}

View File

@ -133,7 +133,7 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
unsigned int n, skip;
if (posix_memalign(&buf, 4096, 8192) != 0) {
fprintf(stderr, Name ": failed to allocate 8192 bytes\n");
pr_err("failed to allocate 8192 bytes\n");
return NULL;
}
n = read(fd, buf, 8192);
@ -141,10 +141,10 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
info = malloc(sizeof(*info));
if (info == NULL) {
#if __GNUC__ < 3
fprintf(stderr, Name ": failed to allocate %d bytes\n",
pr_err("failed to allocate %d bytes\n",
(int)sizeof(*info));
#else
fprintf(stderr, Name ": failed to allocate %zd bytes\n",
pr_err("failed to allocate %zd bytes\n",
sizeof(*info));
#endif
free(buf);
@ -152,8 +152,8 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
}
if (n < sizeof(info->sb)) {
fprintf(stderr, Name ": failed to read superblock of bitmap "
"file: %s\n", strerror(errno));
pr_err("failed to read superblock of bitmap "
"file: %s\n", strerror(errno));
free(info);
free(buf);
return NULL;
@ -194,7 +194,7 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
}
if (read_bits < total_bits) { /* file truncated... */
fprintf(stderr, Name ": WARNING: bitmap file is not large "
pr_err("WARNING: bitmap file is not large "
"enough for array size %llu!\n\n",
(unsigned long long)info->sb.sync_size);
total_bits = read_bits;
@ -214,14 +214,14 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
struct supertype *st = *stp;
if (stat(filename, &stb) < 0) {
fprintf(stderr, Name ": failed to find file %s: %s\n",
pr_err("failed to find file %s: %s\n",
filename, strerror(errno));
return NULL;
}
if ((S_IFMT & stb.st_mode) == S_IFBLK) {
fd = open(filename, O_RDONLY);
if (fd < 0) {
fprintf(stderr, Name ": failed to open bitmap file %s: %s\n",
pr_err("failed to open bitmap file %s: %s\n",
filename, strerror(errno));
return NULL;
}
@ -231,7 +231,7 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
/* just look at device... */
lseek(fd, 0, 0);
} else if (!st->ss->locate_bitmap) {
fprintf(stderr, Name ": No bitmap possible with %s metadata\n",
pr_err("No bitmap possible with %s metadata\n",
st->ss->name);
return NULL;
} else
@ -242,7 +242,7 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
} else {
fd = open(filename, O_RDONLY|O_DIRECT);
if (fd < 0) {
fprintf(stderr, Name ": failed to open bitmap file %s: %s\n",
pr_err("failed to open bitmap file %s: %s\n",
filename, strerror(errno));
return NULL;
}
@ -286,12 +286,12 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
printf(" Filename : %s\n", filename);
printf(" Magic : %08x\n", sb->magic);
if (sb->magic != BITMAP_MAGIC) {
fprintf(stderr, Name ": invalid bitmap magic 0x%x, the bitmap file appears to be corrupted\n", sb->magic);
pr_err("invalid bitmap magic 0x%x, the bitmap file appears to be corrupted\n", sb->magic);
}
printf(" Version : %d\n", sb->version);
if (sb->version < BITMAP_MAJOR_LO ||
sb->version > BITMAP_MAJOR_HI) {
fprintf(stderr, Name ": unknown bitmap version %d, either the bitmap file is corrupted or you need to upgrade your tools\n", sb->version);
pr_err("unknown bitmap version %d, either the bitmap file is corrupted or you need to upgrade your tools\n", sb->version);
goto free_info;
}
@ -357,13 +357,13 @@ int CreateBitmap(char *filename, int force, char uuid[16],
long long bytes, filesize;
if (!force && access(filename, F_OK) == 0) {
fprintf(stderr, Name ": bitmap file %s already exists, use --force to overwrite\n", filename);
pr_err("bitmap file %s already exists, use --force to overwrite\n", filename);
return rv;
}
fp = fopen(filename, "w");
if (fp == NULL) {
fprintf(stderr, Name ": failed to open bitmap file %s: %s\n",
pr_err("failed to open bitmap file %s: %s\n",
filename, strerror(errno));
return rv;
}
@ -393,7 +393,7 @@ int CreateBitmap(char *filename, int force, char uuid[16],
sb_cpu_to_le(&sb); /* convert to on-disk byte ordering */
if (fwrite(&sb, sizeof(sb), 1, fp) != 1) {
fprintf(stderr, Name ": failed to write superblock to bitmap file %s: %s\n", filename, strerror(errno));
pr_err("failed to write superblock to bitmap file %s: %s\n", filename, strerror(errno));
goto out;
}
@ -410,7 +410,7 @@ int CreateBitmap(char *filename, int force, char uuid[16],
while (bytes > 0) {
if (fwrite(block, sizeof(block), 1, fp) != 1) {
fprintf(stderr, Name ": failed to write bitmap file %s: %s\n", filename, strerror(errno));
pr_err("failed to write bitmap file %s: %s\n", filename, strerror(errno));
goto out;
}
bytes -= sizeof(block);

108
config.c
View File

@ -159,7 +159,7 @@ struct mddev_dev *load_partitions(void)
char buf[1024];
struct mddev_dev *rv = NULL;
if (f == NULL) {
fprintf(stderr, Name ": cannot open /proc/partitions\n");
pr_err("cannot open /proc/partitions\n");
return NULL;
}
while (fgets(buf, 1024, f)) {
@ -264,7 +264,7 @@ int parse_auto(char *str, char *msg, int config)
(len >= 4 && strncasecmp(str,"part",4)==0)) {
autof = 6;
} else {
fprintf(stderr, Name ": %s arg of \"%s\" unrecognised: use no,yes,md,mdp,part\n"
pr_err("%s arg of \"%s\" unrecognised: use no,yes,md,mdp,part\n"
" optionally followed by a number.\n",
msg, str);
exit(2);
@ -284,7 +284,7 @@ static void createline(char *line)
createinfo.autof = parse_auto(w+5, "auto=", 1);
else if (strncasecmp(w, "owner=", 6) == 0) {
if (w[6] == 0) {
fprintf(stderr, Name ": missing owner name\n");
pr_err("missing owner name\n");
continue;
}
createinfo.uid = strtoul(w+6, &ep, 10);
@ -295,11 +295,11 @@ static void createline(char *line)
if (pw)
createinfo.uid = pw->pw_uid;
else
fprintf(stderr, Name ": CREATE user %s not found\n", w+6);
pr_err("CREATE user %s not found\n", w+6);
}
} else if (strncasecmp(w, "group=", 6) == 0) {
if (w[6] == 0) {
fprintf(stderr, Name ": missing group name\n");
pr_err("missing group name\n");
continue;
}
createinfo.gid = strtoul(w+6, &ep, 10);
@ -310,17 +310,17 @@ static void createline(char *line)
if (gr)
createinfo.gid = gr->gr_gid;
else
fprintf(stderr, Name ": CREATE group %s not found\n", w+6);
pr_err("CREATE group %s not found\n", w+6);
}
} else if (strncasecmp(w, "mode=", 5) == 0) {
if (w[5] == 0) {
fprintf(stderr, Name ": missing CREATE mode\n");
pr_err("missing CREATE mode\n");
continue;
}
createinfo.mode = strtoul(w+5, &ep, 8);
if (*ep != 0) {
createinfo.mode = 0600;
fprintf(stderr, Name ": unrecognised CREATE mode %s\n",
pr_err("unrecognised CREATE mode %s\n",
w+5);
}
} else if (strncasecmp(w, "metadata=", 9) == 0) {
@ -330,14 +330,14 @@ static void createline(char *line)
createinfo.supertype =
superlist[i]->match_metadata_desc(w+9);
if (!createinfo.supertype)
fprintf(stderr, Name ": metadata format %s unknown, ignoring\n",
pr_err("metadata format %s unknown, ignoring\n",
w+9);
} else if (strncasecmp(w, "symlinks=yes", 12) == 0)
createinfo.symlinks = 1;
else if (strncasecmp(w, "symlinks=no", 11) == 0)
createinfo.symlinks = 0;
else {
fprintf(stderr, Name ": unrecognised word on CREATE line: %s\n",
pr_err("unrecognised word on CREATE line: %s\n",
w);
}
}
@ -356,7 +356,7 @@ void devline(char *line)
cd->next = cdevlist;
cdevlist = cd;
} else {
fprintf(stderr, Name ": unreconised word on DEVICE line: %s\n",
pr_err("unreconised word on DEVICE line: %s\n",
w);
}
}
@ -421,64 +421,64 @@ void arrayline(char *line)
) {
/* This is acceptable */;
if (mis.devname)
fprintf(stderr, Name ": only give one "
pr_err("only give one "
"device per ARRAY line: %s and %s\n",
mis.devname, w);
else
mis.devname = w;
}else {
fprintf(stderr, Name ": %s is an invalid name for "
pr_err("%s is an invalid name for "
"an md device - ignored.\n", w);
}
} else if (strncasecmp(w, "uuid=", 5)==0 ) {
if (mis.uuid_set)
fprintf(stderr, Name ": only specify uuid once, %s ignored.\n",
pr_err("only specify uuid once, %s ignored.\n",
w);
else {
if (parse_uuid(w+5, mis.uuid))
mis.uuid_set = 1;
else
fprintf(stderr, Name ": bad uuid: %s\n", w);
pr_err("bad uuid: %s\n", w);
}
} else if (strncasecmp(w, "super-minor=", 12)==0 ) {
if (mis.super_minor != UnSet)
fprintf(stderr, Name ": only specify super-minor once, %s ignored.\n",
pr_err("only specify super-minor once, %s ignored.\n",
w);
else {
char *endptr;
int minor = strtol(w+12, &endptr, 10);
if (w[12]==0 || endptr[0]!=0 || minor < 0)
fprintf(stderr, Name ": invalid super-minor number: %s\n",
pr_err("invalid super-minor number: %s\n",
w);
else
mis.super_minor = minor;
}
} else if (strncasecmp(w, "name=", 5)==0) {
if (mis.name[0])
fprintf(stderr, Name ": only specify name once, %s ignored.\n",
pr_err("only specify name once, %s ignored.\n",
w);
else if (strlen(w+5) > 32)
fprintf(stderr, Name ": name too long, ignoring %s\n", w);
pr_err("name too long, ignoring %s\n", w);
else
strcpy(mis.name, w+5);
} else if (strncasecmp(w, "bitmap=", 7) == 0) {
if (mis.bitmap_file)
fprintf(stderr, Name ": only specify bitmap file once. %s ignored\n",
pr_err("only specify bitmap file once. %s ignored\n",
w);
else
mis.bitmap_file = strdup(w+7);
} else if (strncasecmp(w, "devices=", 8 ) == 0 ) {
if (mis.devices)
fprintf(stderr, Name ": only specify devices once (use a comma separated list). %s ignored\n",
pr_err("only specify devices once (use a comma separated list). %s ignored\n",
w);
else
mis.devices = strdup(w+8);
} else if (strncasecmp(w, "spare-group=", 12) == 0 ) {
if (mis.spare_group)
fprintf(stderr, Name ": only specify one spare group per array. %s ignored.\n",
pr_err("only specify one spare group per array. %s ignored.\n",
w);
else
mis.spare_group = strdup(w+12);
@ -502,7 +502,7 @@ void arrayline(char *line)
mis.st = superlist[i]->match_metadata_desc(w+9);
if (!mis.st)
fprintf(stderr, Name ": metadata format %s unknown, ignored.\n", w+9);
pr_err("metadata format %s unknown, ignored.\n", w+9);
} else if (strncasecmp(w, "auto=", 5) == 0 ) {
/* whether to create device special files as needed */
mis.autof = parse_auto(w+5, "auto type", 0);
@ -514,14 +514,14 @@ void arrayline(char *line)
* or a uuid */
mis.container = strdup(w+10);
} else {
fprintf(stderr, Name ": unrecognised word on ARRAY line: %s\n",
pr_err("unrecognised word on ARRAY line: %s\n",
w);
}
}
if (mis.uuid_set == 0 && mis.devices == NULL &&
mis.super_minor == UnSet && mis.name[0] == 0 &&
(mis.container == NULL || mis.member == NULL))
fprintf(stderr, Name ": ARRAY line %s has no identity information.\n", mis.devname);
pr_err("ARRAY line %s has no identity information.\n", mis.devname);
else {
mi = malloc(sizeof(*mi));
*mi = mis;
@ -541,7 +541,7 @@ void mailline(char *line)
if (alert_email == NULL)
alert_email = strdup(w);
else
fprintf(stderr, Name ": excess address on MAIL line: %s - ignored\n",
pr_err("excess address on MAIL line: %s - ignored\n",
w);
}
}
@ -575,7 +575,7 @@ void programline(char *line)
if (alert_program == NULL)
alert_program = strdup(w);
else
fprintf(stderr, Name ": excess program on PROGRAM line: %s - ignored\n",
pr_err("excess program on PROGRAM line: %s - ignored\n",
w);
}
}
@ -595,7 +595,7 @@ void homehostline(char *line)
else
home_host = strdup(w);
}else
fprintf(stderr, Name ": excess host name on HOMEHOST line: %s - ignored\n",
pr_err("excess host name on HOMEHOST line: %s - ignored\n",
w);
}
}
@ -615,7 +615,7 @@ void autoline(char *line)
int i;
if (auto_seen) {
fprintf(stderr, Name ": AUTO line may only be give once."
pr_err("AUTO line may only be give once."
" Subsequent lines ignored\n");
return;
}
@ -790,7 +790,7 @@ void load_conffile(void)
policyline(line, rule_part);
break;
default:
fprintf(stderr, Name ": Unknown keyword %s\n", line);
pr_err("Unknown keyword %s\n", line);
}
free_line(line);
}
@ -1032,33 +1032,29 @@ struct mddev_ident *conf_match(struct supertype *st,
same_uuid(array_list->uuid, info->uuid, st->ss->swapuuid)
== 0) {
if (verbose >= 2 && array_list->devname)
fprintf(stderr, Name
": UUID differs from %s.\n",
array_list->devname);
pr_err("UUID differs from %s.\n",
array_list->devname);
continue;
}
if (array_list->name[0] &&
strcasecmp(array_list->name, info->name) != 0) {
if (verbose >= 2 && array_list->devname)
fprintf(stderr, Name
": Name differs from %s.\n",
array_list->devname);
pr_err("Name differs from %s.\n",
array_list->devname);
continue;
}
if (array_list->devices && devname &&
!match_oneof(array_list->devices, devname)) {
if (verbose >= 2 && array_list->devname)
fprintf(stderr, Name
": Not a listed device for %s.\n",
array_list->devname);
pr_err("Not a listed device for %s.\n",
array_list->devname);
continue;
}
if (array_list->super_minor != UnSet &&
array_list->super_minor != info->array.md_minor) {
if (verbose >= 2 && array_list->devname)
fprintf(stderr, Name
": Different super-minor to %s.\n",
array_list->devname);
pr_err("Different super-minor to %s.\n",
array_list->devname);
continue;
}
if (!array_list->uuid_set &&
@ -1066,10 +1062,9 @@ struct mddev_ident *conf_match(struct supertype *st,
!array_list->devices &&
array_list->super_minor == UnSet) {
if (verbose >= 2 && array_list->devname)
fprintf(stderr, Name
": %s doesn't have any identifying"
" information.\n",
array_list->devname);
pr_err("%s doesn't have any identifying"
" information.\n",
array_list->devname);
continue;
}
/* FIXME, should I check raid_disks and level too?? */
@ -1077,15 +1072,13 @@ struct mddev_ident *conf_match(struct supertype *st,
if (match) {
if (verbose >= 0) {
if (match->devname && array_list->devname)
fprintf(stderr, Name
": we match both %s and %s - "
"cannot decide which to use.\n",
match->devname,
array_list->devname);
pr_err("we match both %s and %s - "
"cannot decide which to use.\n",
match->devname,
array_list->devname);
else
fprintf(stderr, Name
": multiple lines in mdadm.conf"
" match\n");
pr_err("multiple lines in mdadm.conf"
" match\n");
}
if (rvp)
*rvp = 2;
@ -1113,15 +1106,14 @@ int conf_verify_devnames(struct mddev_ident *array_list)
if (a1->uuid_set && a2->uuid_set) {
char nbuf[64];
__fname_from_uuid(a1->uuid, 0, nbuf, ':');
fprintf(stderr,
Name ": Devices %s and ",
nbuf);
pr_err("Devices %s and ",
nbuf);
__fname_from_uuid(a2->uuid, 0, nbuf, ':');
fprintf(stderr,
"%s have the same name: %s\n",
nbuf, a1->devname);
} else
fprintf(stderr, Name ": Device %s given twice"
pr_err("Device %s given twice"
" in config file\n", a1->devname);
return 1;
}

256
mdadm.c
View File

@ -289,7 +289,7 @@ int main(int argc, char *argv[])
/* everybody happy ! */
} else if (mode && newmode != mode) {
/* not allowed.. */
fprintf(stderr, Name ": ");
pr_err("");
if (option_index >= 0)
fprintf(stderr, "--%s", long_options[option_index].name);
else
@ -301,7 +301,7 @@ int main(int argc, char *argv[])
} else if (!mode && newmode) {
mode = newmode;
if (mode == MISC && devs_found) {
fprintf(stderr, Name ": No action given for %s in --misc mode\n",
pr_err("No action given for %s in --misc mode\n",
devlist->devname);
fprintf(stderr," Action options must come before device names\n");
exit(2);
@ -320,7 +320,7 @@ int main(int argc, char *argv[])
if (devs_found == 0) {
dv = malloc(sizeof(*dv));
if (dv == NULL) {
fprintf(stderr, Name ": malloc failed\n");
pr_err("malloc failed\n");
exit(3);
}
dv->devname = optarg;
@ -336,14 +336,14 @@ int main(int argc, char *argv[])
continue;
}
/* No mode yet, and this is the second device ... */
fprintf(stderr, Name ": An option must be given to set the mode before a second device\n"
pr_err("An option must be given to set the mode before a second device\n"
" (%s) is listed\n", optarg);
exit(2);
}
if (option_index >= 0)
fprintf(stderr, Name ": --%s", long_options[option_index].name);
pr_err("--%s", long_options[option_index].name);
else
fprintf(stderr, Name ": -%c", opt);
pr_err("-%c", opt);
fprintf(stderr, " does not set the mode, and so cannot be the first option.\n");
exit(2);
}
@ -365,18 +365,18 @@ int main(int argc, char *argv[])
/* an undecorated option - must be a device name.
*/
if (devs_found > 0 && mode == MANAGE && !devmode) {
fprintf(stderr, Name ": Must give one of -a/-r/-f"
pr_err("Must give one of -a/-r/-f"
" for subsequent devices at %s\n", optarg);
exit(2);
}
if (devs_found > 0 && mode == GROW && !devmode) {
fprintf(stderr, Name ": Must give -a/--add for"
" devices to add: %s\n", optarg);
pr_err("Must give -a/--add for"
" devices to add: %s\n", optarg);
exit(2);
}
dv = malloc(sizeof(*dv));
if (dv == NULL) {
fprintf(stderr, Name ": malloc failed\n");
pr_err("malloc failed\n");
exit(3);
}
dv->devname = optarg;
@ -403,13 +403,13 @@ int main(int argc, char *argv[])
case O(BUILD,'c'): /* chunk or rounding */
case O(BUILD,ChunkSize): /* chunk or rounding */
if (chunk) {
fprintf(stderr, Name ": chunk/rounding may only be specified once. "
pr_err("chunk/rounding may only be specified once. "
"Second value is %s.\n", optarg);
exit(2);
}
chunk = parse_size(optarg);
if (chunk < 8 || (chunk&1)) {
fprintf(stderr, Name ": invalid chunk/rounding value: %s\n",
pr_err("invalid chunk/rounding value: %s\n",
optarg);
exit(2);
}
@ -422,14 +422,14 @@ int main(int argc, char *argv[])
case O(ASSEMBLE,'e'):
case O(MISC,'e'): /* set metadata (superblock) information */
if (ss) {
fprintf(stderr, Name ": metadata information already given\n");
pr_err("metadata information already given\n");
exit(2);
}
for(i=0; !ss && superlist[i]; i++)
ss = superlist[i]->match_metadata_desc(optarg);
if (!ss) {
fprintf(stderr, Name ": unrecognised metadata identifier: %s\n", optarg);
pr_err("unrecognised metadata identifier: %s\n", optarg);
exit(2);
}
continue;
@ -454,7 +454,7 @@ int main(int argc, char *argv[])
case O(CREATE,'z'):
case O(BUILD,'z'): /* size */
if (size >= 0) {
fprintf(stderr, Name ": size may only be specified once. "
pr_err("size may only be specified once. "
"Second value is %s.\n", optarg);
exit(2);
}
@ -463,7 +463,7 @@ int main(int argc, char *argv[])
else {
size = parse_size(optarg);
if (size < 8) {
fprintf(stderr, Name ": invalid size: %s\n",
pr_err("invalid size: %s\n",
optarg);
exit(2);
}
@ -474,7 +474,7 @@ int main(int argc, char *argv[])
case O(GROW,'Z'): /* array size */
if (array_size >= 0) {
fprintf(stderr, Name ": array-size may only be specified once. "
pr_err("array-size may only be specified once. "
"Second value is %s.\n", optarg);
exit(2);
}
@ -483,7 +483,7 @@ int main(int argc, char *argv[])
else {
array_size = parse_size(optarg);
if (array_size <= 0) {
fprintf(stderr, Name ": invalid array size: %s\n",
pr_err("invalid array size: %s\n",
optarg);
exit(2);
}
@ -494,13 +494,13 @@ int main(int argc, char *argv[])
case O(CREATE,'l'):
case O(BUILD,'l'): /* set raid level*/
if (level != UnSet) {
fprintf(stderr, Name ": raid level may only be set once. "
pr_err("raid level may only be set once. "
"Second value is %s.\n", optarg);
exit(2);
}
level = map_name(pers, optarg);
if (level == UnSet) {
fprintf(stderr, Name ": invalid raid level: %s\n",
pr_err("invalid raid level: %s\n",
optarg);
exit(2);
}
@ -508,12 +508,12 @@ int main(int argc, char *argv[])
level != LEVEL_MULTIPATH && level != LEVEL_FAULTY &&
level != 10 &&
mode == BUILD) {
fprintf(stderr, Name ": Raid level %s not permitted with --build.\n",
pr_err("Raid level %s not permitted with --build.\n",
optarg);
exit(2);
}
if (sparedisks > 0 && level < 1 && level >= -1) {
fprintf(stderr, Name ": raid level %s is incompatible with spare-devices setting.\n",
pr_err("raid level %s is incompatible with spare-devices setting.\n",
optarg);
exit(2);
}
@ -523,8 +523,8 @@ int main(int argc, char *argv[])
case O(GROW, 'p'): /* new layout */
case O(GROW, Layout):
if (layout_str) {
fprintf(stderr,Name ": layout may only be sent once. "
"Second value was %s\n", optarg);
pr_err("layout may only be sent once. "
"Second value was %s\n", optarg);
exit(2);
}
layout_str = optarg;
@ -536,23 +536,23 @@ int main(int argc, char *argv[])
case O(BUILD,'p'): /* faulty layout */
case O(BUILD,Layout):
if (layout != UnSet) {
fprintf(stderr,Name ": layout may only be sent once. "
"Second value was %s\n", optarg);
pr_err("layout may only be sent once. "
"Second value was %s\n", optarg);
exit(2);
}
switch(level) {
default:
fprintf(stderr, Name ": layout not meaningful for %s arrays.\n",
pr_err("layout not meaningful for %s arrays.\n",
map_num(pers, level));
exit(2);
case UnSet:
fprintf(stderr, Name ": raid level must be given before layout.\n");
pr_err("raid level must be given before layout.\n");
exit(2);
case 5:
layout = map_name(r5layout, optarg);
if (layout==UnSet) {
fprintf(stderr, Name ": layout %s not understood for raid5.\n",
pr_err("layout %s not understood for raid5.\n",
optarg);
exit(2);
}
@ -560,7 +560,7 @@ int main(int argc, char *argv[])
case 6:
layout = map_name(r6layout, optarg);
if (layout==UnSet) {
fprintf(stderr, Name ": layout %s not understood for raid6.\n",
pr_err("layout %s not understood for raid6.\n",
optarg);
exit(2);
}
@ -569,7 +569,7 @@ int main(int argc, char *argv[])
case 10:
layout = parse_layout_10(optarg);
if (layout < 0) {
fprintf(stderr, Name ": layout for raid10 must be 'nNN', 'oNN' or 'fNN' where NN is a number, not %s\n", optarg);
pr_err("layout for raid10 must be 'nNN', 'oNN' or 'fNN' where NN is a number, not %s\n", optarg);
exit(2);
}
break;
@ -579,7 +579,7 @@ int main(int argc, char *argv[])
*/
layout = parse_layout_faulty(optarg);
if (layout == -1) {
fprintf(stderr, Name ": layout %s not understood for faulty.\n",
pr_err("layout %s not understood for faulty.\n",
optarg);
exit(2);
}
@ -597,13 +597,13 @@ int main(int argc, char *argv[])
case O(CREATE,'n'):
case O(BUILD,'n'): /* number of raid disks */
if (raiddisks) {
fprintf(stderr, Name ": raid-devices set twice: %d and %s\n",
pr_err("raid-devices set twice: %d and %s\n",
raiddisks, optarg);
exit(2);
}
raiddisks = strtol(optarg, &c, 10);
if (!optarg[0] || *c || raiddisks<=0) {
fprintf(stderr, Name ": invalid number of raid devices: %s\n",
pr_err("invalid number of raid devices: %s\n",
optarg);
exit(2);
}
@ -612,18 +612,18 @@ int main(int argc, char *argv[])
case O(CREATE,'x'): /* number of spare (eXtra) disks */
if (sparedisks) {
fprintf(stderr,Name ": spare-devices set twice: %d and %s\n",
sparedisks, optarg);
pr_err("spare-devices set twice: %d and %s\n",
sparedisks, optarg);
exit(2);
}
if (level != UnSet && level <= 0 && level >= -1) {
fprintf(stderr, Name ": spare-devices setting is incompatible with raid level %d\n",
pr_err("spare-devices setting is incompatible with raid level %d\n",
level);
exit(2);
}
sparedisks = strtol(optarg, &c, 10);
if (!optarg[0] || *c || sparedisks < 0) {
fprintf(stderr, Name ": invalid number of spare-devices: %s\n",
pr_err("invalid number of spare-devices: %s\n",
optarg);
exit(2);
}
@ -668,14 +668,14 @@ int main(int argc, char *argv[])
case O(CREATE,'u'): /* uuid of array */
case O(ASSEMBLE,'u'): /* uuid of array */
if (ident.uuid_set) {
fprintf(stderr, Name ": uuid cannot be set twice. "
pr_err("uuid cannot be set twice. "
"Second value %s.\n", optarg);
exit(2);
}
if (parse_uuid(optarg, ident.uuid))
ident.uuid_set = 1;
else {
fprintf(stderr,Name ": Bad uuid: %s\n", optarg);
pr_err("Bad uuid: %s\n", optarg);
exit(2);
}
continue;
@ -684,16 +684,16 @@ int main(int argc, char *argv[])
case O(ASSEMBLE,'N'):
case O(MISC,'N'):
if (ident.name[0]) {
fprintf(stderr, Name ": name cannot be set twice. "
pr_err("name cannot be set twice. "
"Second value %s.\n", optarg);
exit(2);
}
if (mode == MISC && !subarray) {
fprintf(stderr, Name ": -N/--name only valid with --update-subarray in misc mode\n");
pr_err("-N/--name only valid with --update-subarray in misc mode\n");
exit(2);
}
if (strlen(optarg) > 32) {
fprintf(stderr, Name ": name '%s' is too long, 32 chars max.\n",
pr_err("name '%s' is too long, 32 chars max.\n",
optarg);
exit(2);
}
@ -703,7 +703,7 @@ int main(int argc, char *argv[])
case O(ASSEMBLE,'m'): /* super-minor for array */
case O(ASSEMBLE,SuperMinor):
if (ident.super_minor != UnSet) {
fprintf(stderr, Name ": super-minor cannot be set twice. "
pr_err("super-minor cannot be set twice. "
"Second value: %s.\n", optarg);
exit(2);
}
@ -712,7 +712,7 @@ int main(int argc, char *argv[])
else {
ident.super_minor = strtoul(optarg, &cp, 10);
if (!optarg[0] || *cp) {
fprintf(stderr, Name ": Bad super-minor number: %s.\n", optarg);
pr_err("Bad super-minor number: %s.\n", optarg);
exit(2);
}
}
@ -721,13 +721,13 @@ int main(int argc, char *argv[])
case O(ASSEMBLE,'U'): /* update the superblock */
case O(MISC,'U'):
if (update) {
fprintf(stderr, Name ": Can only update one aspect"
pr_err("Can only update one aspect"
" of superblock, both %s and %s given.\n",
update, optarg);
exit(2);
}
if (mode == MISC && !subarray) {
fprintf(stderr, Name ": Only subarrays can be"
pr_err("Only subarrays can be"
" updated in misc mode\n");
exit(2);
}
@ -752,16 +752,15 @@ int main(int argc, char *argv[])
continue;
if (strcmp(update, "byteorder")==0) {
if (ss) {
fprintf(stderr,
Name ": must not set metadata"
" type with --update=byteorder.\n");
pr_err("must not set metadata"
" type with --update=byteorder.\n");
exit(2);
}
for(i=0; !ss && superlist[i]; i++)
ss = superlist[i]->match_metadata_desc(
"0.swap");
if (!ss) {
fprintf(stderr, Name ": INTERNAL ERROR"
pr_err("INTERNAL ERROR"
" cannot find 0.swap\n");
exit(2);
}
@ -787,26 +786,26 @@ int main(int argc, char *argv[])
case O(MANAGE,'U'):
/* update=devicesize is allowed with --re-add */
if (devmode != 'a' || re_add != 1) {
fprintf(stderr, Name "--update in Manage mode only"
pr_err("--update in Manage mode only"
" allowed with --re-add.\n");
exit(1);
}
if (update) {
fprintf(stderr, Name ": Can only update one aspect"
pr_err("Can only update one aspect"
" of superblock, both %s and %s given.\n",
update, optarg);
exit(2);
}
update = optarg;
if (strcmp(update, "devicesize") != 0) {
fprintf(stderr, Name ": only 'devicesize' can be"
pr_err("only 'devicesize' can be"
" updated with --re-add\n");
exit(2);
}
continue;
case O(INCREMENTAL,NoDegraded):
fprintf(stderr, Name ": --no-degraded is deprecated in Incremental mode\n");
pr_err("--no-degraded is deprecated in Incremental mode\n");
case O(ASSEMBLE,NoDegraded): /* --no-degraded */
runstop = -1; /* --stop isn't allowed for --assemble,
* so we overload slightly */
@ -821,7 +820,7 @@ int main(int argc, char *argv[])
case O(MONITOR,'c'):
case O(MONITOR,ConfigFile):
if (configfile) {
fprintf(stderr, Name ": configfile cannot be set twice. "
pr_err("configfile cannot be set twice. "
"Second value is %s.\n", optarg);
exit(2);
}
@ -839,7 +838,7 @@ int main(int argc, char *argv[])
case O(MONITOR,'m'): /* mail address */
case O(MONITOR,EMail):
if (mailaddr)
fprintf(stderr, Name ": only specify one mailaddress. %s ignored.\n",
pr_err("only specify one mailaddress. %s ignored.\n",
optarg);
else
mailaddr = optarg;
@ -848,7 +847,7 @@ int main(int argc, char *argv[])
case O(MONITOR,'p'): /* alert program */
case O(MONITOR,ProgramOpt): /* alert program */
if (program)
fprintf(stderr, Name ": only specify one alter program. %s ignored.\n",
pr_err("only specify one alter program. %s ignored.\n",
optarg);
else
program = optarg;
@ -858,7 +857,7 @@ int main(int argc, char *argv[])
case O(MONITOR,Increment):
increments = atoi(optarg);
if (increments > 99 || increments < 1) {
fprintf(stderr, Name ": please specify positive integer between 1 and 99 as rebuild increments.\n");
pr_err("please specify positive integer between 1 and 99 as rebuild increments.\n");
exit(2);
}
continue;
@ -868,12 +867,12 @@ int main(int argc, char *argv[])
case O(BUILD,'d'): /* delay for bitmap updates */
case O(CREATE,'d'):
if (delay)
fprintf(stderr, Name ": only specify delay once. %s ignored.\n",
pr_err("only specify delay once. %s ignored.\n",
optarg);
else {
delay = strtol(optarg, &c, 10);
if (!optarg[0] || *c || delay<1) {
fprintf(stderr, Name ": invalid delay: %s\n",
pr_err("invalid delay: %s\n",
optarg);
exit(2);
}
@ -885,7 +884,7 @@ int main(int argc, char *argv[])
continue;
case O(MONITOR,'i'): /* pid */
if (pidfile)
fprintf(stderr, Name ": only specify one pid file. %s ignored.\n",
pr_err("only specify one pid file. %s ignored.\n",
optarg);
else
pidfile = optarg;
@ -938,14 +937,14 @@ int main(int argc, char *argv[])
case O(BUILD,'R'):
case O(CREATE,'R'): /* Run the array */
if (runstop < 0) {
fprintf(stderr, Name ": Cannot both Stop and Run an array\n");
pr_err("Cannot both Stop and Run an array\n");
exit(2);
}
runstop = 1;
continue;
case O(MANAGE,'S'):
if (runstop > 0) {
fprintf(stderr, Name ": Cannot both Run and Stop an array\n");
pr_err("Cannot both Run and Stop an array\n");
exit(2);
}
runstop = -1;
@ -971,7 +970,7 @@ int main(int argc, char *argv[])
case O(MISC, UpdateSubarray):
if (opt == KillSubarray || opt == UpdateSubarray) {
if (subarray) {
fprintf(stderr, Name ": subarray can only"
pr_err("subarray can only"
" be specified once\n");
exit(2);
}
@ -979,7 +978,7 @@ int main(int argc, char *argv[])
}
if (devmode && devmode != opt &&
(devmode == 'E' || (opt == 'E' && devmode != 'Q'))) {
fprintf(stderr, Name ": --examine/-E cannot be given with ");
pr_err("--examine/-E cannot be given with ");
if (devmode == 'E') {
if (option_index >= 0)
fprintf(stderr, "--%s\n",
@ -996,11 +995,11 @@ int main(int argc, char *argv[])
continue;
case O(MISC, UdevRules):
if (devmode && devmode != opt) {
fprintf(stderr, Name ": --udev-rules must"
" be the only option.\n");
pr_err("--udev-rules must"
" be the only option.\n");
} else {
if (udev_filename)
fprintf(stderr, Name ": only specify one udev "
pr_err("only specify one udev "
"rule filename. %s ignored.\n",
optarg);
else
@ -1014,7 +1013,7 @@ int main(int argc, char *argv[])
case O(MISC, Sparc22):
if (devmode != 'E') {
fprintf(stderr, Name ": --sparc2.2 only allowed with --examine\n");
pr_err("--sparc2.2 only allowed with --examine\n");
exit(2);
}
SparcAdjust = 1;
@ -1023,16 +1022,16 @@ int main(int argc, char *argv[])
case O(ASSEMBLE,'b'): /* here we simply set the bitmap file */
case O(ASSEMBLE,Bitmap):
if (!optarg) {
fprintf(stderr, Name ": bitmap file needed with -b in --assemble mode\n");
pr_err("bitmap file needed with -b in --assemble mode\n");
exit(2);
}
if (strcmp(optarg, "internal")==0) {
fprintf(stderr, Name ": there is no need to specify --bitmap when assembling arrays with internal bitmaps\n");
pr_err("there is no need to specify --bitmap when assembling arrays with internal bitmaps\n");
continue;
}
bitmap_fd = open(optarg, O_RDWR);
if (!*optarg || bitmap_fd < 0) {
fprintf(stderr, Name ": cannot open bitmap file %s: %s\n", optarg, strerror(errno));
pr_err("cannot open bitmap file %s: %s\n", optarg, strerror(errno));
exit(2);
}
ident.bitmap_fd = bitmap_fd; /* for Assemble */
@ -1044,7 +1043,7 @@ int main(int argc, char *argv[])
* or from which assemble might recover a backup
*/
if (backup_file) {
fprintf(stderr, Name ": backup file already specified, rejecting %s\n", optarg);
pr_err("backup file already specified, rejecting %s\n", optarg);
exit(2);
}
backup_file = optarg;
@ -1067,7 +1066,7 @@ int main(int argc, char *argv[])
case O(CREATE,'b'):
case O(CREATE,Bitmap): /* here we create the bitmap */
if (strcmp(optarg, "none") == 0) {
fprintf(stderr, Name ": '--bitmap none' only"
pr_err("'--bitmap none' only"
" supported for --grow\n");
exit(2);
}
@ -1081,7 +1080,7 @@ int main(int argc, char *argv[])
continue;
}
/* probable typo */
fprintf(stderr, Name ": bitmap file must contain a '/', or be 'internal', or 'none'\n"
pr_err("bitmap file must contain a '/', or be 'internal', or 'none'\n"
" not '%s'\n", optarg);
exit(2);
@ -1091,9 +1090,8 @@ int main(int argc, char *argv[])
bitmap_chunk = parse_size(optarg);
if (bitmap_chunk <= 0 ||
bitmap_chunk & (bitmap_chunk - 1)) {
fprintf(stderr,
Name ": invalid bitmap chunksize: %s\n",
optarg);
pr_err("invalid bitmap chunksize: %s\n",
optarg);
exit(2);
}
bitmap_chunk = bitmap_chunk * 512;
@ -1107,7 +1105,7 @@ int main(int argc, char *argv[])
write_behind = strtol(optarg, &c, 10);
if (write_behind < 0 || *c ||
write_behind > 16383) {
fprintf(stderr, Name ": Invalid value for maximum outstanding write-behind writes: %s.\n\tMust be between 0 and 16383.\n", optarg);
pr_err("Invalid value for maximum outstanding write-behind writes: %s.\n\tMust be between 0 and 16383.\n", optarg);
exit(2);
}
}
@ -1125,11 +1123,11 @@ int main(int argc, char *argv[])
* an error
*/
if (option_index > 0)
fprintf(stderr, Name ":option --%s not valid in %s mode\n",
pr_err(":option --%s not valid in %s mode\n",
long_options[option_index].name,
map_num(modes, mode));
else
fprintf(stderr, Name ": option -%c not valid in %s mode\n",
pr_err("option -%c not valid in %s mode\n",
opt, map_num(modes, mode));
exit(2);
@ -1166,7 +1164,7 @@ int main(int argc, char *argv[])
else if (strcasecmp(symlinks, "no") == 0)
ci->symlinks = 0;
else {
fprintf(stderr, Name ": option --symlinks must be 'no' or 'yes'\n");
pr_err("option --symlinks must be 'no' or 'yes'\n");
exit(2);
}
}
@ -1184,11 +1182,11 @@ int main(int argc, char *argv[])
|| mode == GROW
|| (mode == ASSEMBLE && ! scan)) {
if (devs_found < 1) {
fprintf(stderr, Name ": an md device must be given in this mode\n");
pr_err("an md device must be given in this mode\n");
exit(2);
}
if ((int)ident.super_minor == -2 && autof) {
fprintf(stderr, Name ": --super-minor=dev is incompatible with --auto\n");
pr_err("--super-minor=dev is incompatible with --auto\n");
exit(2);
}
if (mode == MANAGE || mode == GROW) {
@ -1199,14 +1197,14 @@ int main(int argc, char *argv[])
/* non-existent device is OK */
mdfd = open_mddev(devlist->devname, 0);
if (mdfd == -2) {
fprintf(stderr, Name ": device %s exists but is not an "
pr_err("device %s exists but is not an "
"md array.\n", devlist->devname);
exit(1);
}
if ((int)ident.super_minor == -2) {
struct stat stb;
if (mdfd < 0) {
fprintf(stderr, Name ": --super-minor=dev given, and "
pr_err("--super-minor=dev given, and "
"listed device %s doesn't exist.\n",
devlist->devname);
exit(1);
@ -1225,7 +1223,7 @@ int main(int argc, char *argv[])
if (raiddisks) {
if (raiddisks == 1 && !force && level != LEVEL_FAULTY) {
fprintf(stderr, Name ": '1' is an unusual number of drives for an array, so it is probably\n"
pr_err("'1' is an unusual number of drives for an array, so it is probably\n"
" a mistake. If you really mean it you will need to specify --force before\n"
" setting the number of drives.\n");
exit(2);
@ -1249,7 +1247,7 @@ int main(int argc, char *argv[])
|| (mode == MONITOR && spare_sharing == 0))
/* Anyone may try this */;
else if (geteuid() != 0) {
fprintf(stderr, Name ": must be super-user to perform this action\n");
pr_err("must be super-user to perform this action\n");
exit(1);
}
@ -1276,7 +1274,7 @@ int main(int argc, char *argv[])
/* Only a device has been given, so get details from config file */
struct mddev_ident *array_ident = conf_get_ident(devlist->devname);
if (array_ident == NULL) {
fprintf(stderr, Name ": %s not identified in config file.\n",
pr_err("%s not identified in config file.\n",
devlist->devname);
rv |= 1;
if (mdfd >= 0)
@ -1300,17 +1298,17 @@ int main(int argc, char *argv[])
freeze_reshape);
else if (devs_found > 0) {
if (update && devs_found > 1) {
fprintf(stderr, Name ": can only update a single array at a time\n");
pr_err("can only update a single array at a time\n");
exit(1);
}
if (backup_file && devs_found > 1) {
fprintf(stderr, Name ": can only assemble a single array when providing a backup file.\n");
pr_err("can only assemble a single array when providing a backup file.\n");
exit(1);
}
for (dv = devlist ; dv ; dv=dv->next) {
struct mddev_ident *array_ident = conf_get_ident(dv->devname);
if (array_ident == NULL) {
fprintf(stderr, Name ": %s not identified in config file.\n",
pr_err("%s not identified in config file.\n",
dv->devname);
rv |= 1;
continue;
@ -1326,11 +1324,11 @@ int main(int argc, char *argv[])
}
} else {
if (update) {
fprintf(stderr, Name ": --update not meaningful with a --scan assembly.\n");
pr_err("--update not meaningful with a --scan assembly.\n");
exit(1);
}
if (backup_file) {
fprintf(stderr, Name ": --backup_file not meaningful with a --scan assembly.\n");
pr_err("--backup_file not meaningful with a --scan assembly.\n");
exit(1);
}
rv = scan_assemble(autof, ss, readonly, runstop,
@ -1344,19 +1342,19 @@ int main(int argc, char *argv[])
case BUILD:
if (delay == 0) delay = DEFAULT_BITMAP_DELAY;
if (write_behind && !bitmap_file) {
fprintf(stderr, Name ": write-behind mode requires a bitmap.\n");
pr_err("write-behind mode requires a bitmap.\n");
rv = 1;
break;
}
if (raiddisks == 0) {
fprintf(stderr, Name ": no raid-devices specified.\n");
pr_err("no raid-devices specified.\n");
rv = 1;
break;
}
if (bitmap_file) {
if (strcmp(bitmap_file, "internal")==0) {
fprintf(stderr, Name ": 'internal' bitmaps not supported with --build\n");
pr_err("'internal' bitmaps not supported with --build\n");
rv |= 1;
break;
}
@ -1369,12 +1367,12 @@ int main(int argc, char *argv[])
case CREATE:
if (delay == 0) delay = DEFAULT_BITMAP_DELAY;
if (write_behind && !bitmap_file) {
fprintf(stderr, Name ": write-behind mode requires a bitmap.\n");
pr_err("write-behind mode requires a bitmap.\n");
rv = 1;
break;
}
if (raiddisks == 0) {
fprintf(stderr, Name ": no raid-devices specified.\n");
pr_err("no raid-devices specified.\n");
rv = 1;
break;
}
@ -1388,13 +1386,13 @@ int main(int argc, char *argv[])
case MISC:
if (devmode == 'E') {
if (devlist == NULL && !scan) {
fprintf(stderr, Name ": No devices to examine\n");
pr_err("No devices to examine\n");
exit(2);
}
if (devlist == NULL)
devlist = conf_get_devs();
if (devlist == NULL) {
fprintf(stderr, Name ": No devices listed in %s\n", configfile?configfile:DefaultConfFile);
pr_err("No devices listed in %s\n", configfile?configfile:DefaultConfFile);
exit(1);
}
if (brief && verbose)
@ -1413,7 +1411,7 @@ int main(int argc, char *argv[])
else if (devmode == UdevRules)
rv = Write_rules(udev_filename);
else {
fprintf(stderr, Name ": No devices given.\n");
pr_err("No devices given.\n");
exit(2);
}
} else
@ -1424,12 +1422,12 @@ int main(int argc, char *argv[])
break;
case MONITOR:
if (!devlist && !scan) {
fprintf(stderr, Name ": Cannot monitor: need --scan or at least one device\n");
pr_err("Cannot monitor: need --scan or at least one device\n");
rv = 1;
break;
}
if (pidfile && !daemonise) {
fprintf(stderr, Name ": Cannot write a pid file when not in daemon mode\n");
pr_err("Cannot write a pid file when not in daemon mode\n");
rv = 1;
break;
}
@ -1456,7 +1454,7 @@ int main(int argc, char *argv[])
struct mdinfo sra;
int err;
if (raiddisks || level != UnSet) {
fprintf(stderr, Name ": cannot change array size in same operation "
pr_err("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;
@ -1469,10 +1467,10 @@ int main(int argc, char *argv[])
err = sysfs_set_num(&sra, NULL, "array_size", array_size / 2);
if (err < 0) {
if (errno == E2BIG)
fprintf(stderr, Name ": --array-size setting"
pr_err("--array-size setting"
" is too large.\n");
else
fprintf(stderr, Name ": current kernel does"
pr_err("current kernel does"
" not support setting --array-size\n");
rv = 1;
break;
@ -1481,7 +1479,7 @@ int main(int argc, char *argv[])
if (devs_found > 1 && raiddisks == 0) {
/* must be '-a'. */
if (size >= 0 || chunk || layout_str != NULL || bitmap_file) {
fprintf(stderr, Name ": --add cannot be used with "
pr_err("--add cannot be used with "
"other geometry changes in --grow mode\n");
rv = 1;
break;
@ -1495,7 +1493,7 @@ int main(int argc, char *argv[])
} else if (bitmap_file) {
if (size >= 0 || raiddisks || chunk ||
layout_str != NULL || devs_found > 1) {
fprintf(stderr, Name ": --bitmap changes cannot be "
pr_err("--bitmap changes cannot be "
"used with other geometry changes "
"in --grow mode\n");
rv = 1;
@ -1516,7 +1514,7 @@ int main(int argc, char *argv[])
devlist->next,
assume_clean, force);
} else if (array_size < 0)
fprintf(stderr, Name ": no changes to --grow\n");
pr_err("no changes to --grow\n");
break;
case INCREMENTAL:
if (rebuild_map) {
@ -1524,28 +1522,24 @@ int main(int argc, char *argv[])
}
if (scan) {
if (runstop <= 0) {
fprintf(stderr, Name
": --incremental --scan meaningless without --run.\n");
pr_err("--incremental --scan meaningless without --run.\n");
break;
}
if (devmode == 'f') {
fprintf(stderr, Name
": --incremental --scan --fail not supported.\n");
pr_err("--incremental --scan --fail not supported.\n");
break;
}
rv = IncrementalScan(verbose);
}
if (!devlist) {
if (!rebuild_map && !scan) {
fprintf(stderr, Name
": --incremental requires a device.\n");
pr_err("--incremental requires a device.\n");
rv = 1;
}
break;
}
if (devlist->next) {
fprintf(stderr, Name
": --incremental can only handle one device.\n");
pr_err("--incremental can only handle one device.\n");
rv = 1;
break;
}
@ -1580,13 +1574,12 @@ static int scan_assemble(int autof, struct supertype *ss,
int failures, successes;
if (conf_verify_devnames(array_list)) {
fprintf(stderr, Name
": Duplicate MD device names in "
"conf file were found.\n");
pr_err("Duplicate MD device names in "
"conf file were found.\n");
return 1;
}
if (devlist == NULL) {
fprintf(stderr, Name ": No devices listed in conf file were found.\n");
pr_err("No devices listed in conf file were found.\n");
return 1;
}
for (a = array_list; a ; a = a->next) {
@ -1595,9 +1588,9 @@ static int scan_assemble(int autof, struct supertype *ss,
a->autof = autof;
}
if (map_lock(&map))
fprintf(stderr, Name " %s: failed to get "
"exclusive lock on mapfile\n",
__func__);
pr_err("%s: failed to get "
"exclusive lock on mapfile\n",
__func__);
do {
failures = 0;
successes = 0;
@ -1656,12 +1649,12 @@ static int scan_assemble(int autof, struct supertype *ss,
/* Incase there are stacked devices, we need to go around again */
} while (acnt);
if (cnt == 0 && rv == 0) {
fprintf(stderr, Name ": No arrays found in config file or automatically\n");
pr_err("No arrays found in config file or automatically\n");
rv = 1;
} else if (cnt)
rv = 0;
} else if (cnt == 0 && rv == 0) {
fprintf(stderr, Name ": No arrays found in config file\n");
pr_err("No arrays found in config file\n");
rv = 1;
}
map_unlock(&map);
@ -1698,7 +1691,7 @@ static int misc_scan(char devmode, int verbose, int export, int test,
name = get_md_name(e->devnum);
if (!name) {
fprintf(stderr, Name ": cannot find device file for %s\n",
pr_err("cannot find device file for %s\n",
e->dev);
continue;
}
@ -1735,7 +1728,7 @@ static int stop_scan(int quiet)
int mdfd;
if (!name) {
fprintf(stderr, Name ": cannot find device file for %s\n",
pr_err("cannot find device file for %s\n",
e->dev);
continue;
}
@ -1801,8 +1794,7 @@ static int misc_list(struct mddev_dev *devlist,
continue;
case UpdateSubarray:
if (update == NULL) {
fprintf(stderr,
Name ": -U/--update must be specified with --update-subarray\n");
pr_err("-U/--update must be specified with --update-subarray\n");
rv |= 1;
continue;
}

View File

@ -1310,6 +1310,9 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
return ret;
}
#define pr_err(fmt ...) fprintf(stderr, Name ": " fmt)
#define cont_err(fmt ...) fprintf(stderr, " " fmt)
#define LEVEL_MULTIPATH (-4)
#define LEVEL_LINEAR (-1)
#define LEVEL_FAULTY (-5)

View File

@ -32,10 +32,10 @@ int open_mddev(char *dev, int report_errors/*unused*/)
{
int mdfd = open(dev, O_RDWR);
if (mdfd < 0)
fprintf(stderr, Name ": error opening %s: %s\n",
pr_err("error opening %s: %s\n",
dev, strerror(errno));
else if (md_get_version(mdfd) <= 0) {
fprintf(stderr, Name ": %s does not appear to be an md device\n",
pr_err("%s does not appear to be an md device\n",
dev);
close(mdfd);
mdfd = -1;
@ -68,7 +68,7 @@ int force = 0;
int main(int argc, char *argv[]) {
struct mddev_ident *array_list = conf_get_ident(NULL);
if (!array_list) {
fprintf(stderr, Name ": No arrays found in config file\n");
pr_err("No arrays found in config file\n");
rv = 1;
} else
for (; array_list; array_list = array_list->next) {

View File

@ -175,7 +175,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
/* name *must* be mdXX or md_dXX in this context */
if (num < 0 ||
(strcmp(cname, "md") != 0 && strcmp(cname, "md_d") != 0)) {
fprintf(stderr, Name ": %s is an invalid name "
pr_err("%s is an invalid name "
"for an md device. Try /dev/md/%s\n",
dev, dev+5);
return -1;
@ -193,12 +193,12 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
* empty.
*/
if (strchr(cname, '/') != NULL) {
fprintf(stderr, Name ": %s is an invalid name "
pr_err("%s is an invalid name "
"for an md device.\n", dev);
return -1;
}
if (cname[0] == 0) {
fprintf(stderr, Name ": %s is an invalid name "
pr_err("%s is an invalid name "
"for an md device (empty!).", dev);
return -1;
}
@ -225,7 +225,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
if (name && name[0] == 0)
name = NULL;
if (name && trustworthy == METADATA && use_mdp == 1) {
fprintf(stderr, Name ": %s is not allowed for a %s container. "
pr_err("%s is not allowed for a %s container. "
"Consider /dev/md%d.\n", dev, name, num);
return -1;
}
@ -260,13 +260,13 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
/* need to choose a free number. */
num = find_free_devnum(use_mdp);
if (num == NoMdDev) {
fprintf(stderr, Name ": No avail md devices - aborting\n");
pr_err("No avail md devices - aborting\n");
return -1;
}
} else {
num = use_mdp ? (-1-num) : num;
if (mddev_busy(num)) {
fprintf(stderr, Name ": %s is already in use.\n",
pr_err("%s is already in use.\n",
dev);
return -1;
}
@ -328,14 +328,14 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
/* Must be the correct device, else error */
if ((stb.st_mode&S_IFMT) != S_IFBLK ||
stb.st_rdev != makedev(dev2major(num),dev2minor(num))) {
fprintf(stderr, Name ": %s exists but looks wrong, please fix\n",
pr_err("%s exists but looks wrong, please fix\n",
devname);
return -1;
}
} else {
if (mknod(devname, S_IFBLK|0600,
makedev(dev2major(num),dev2minor(num))) != 0) {
fprintf(stderr, Name ": failed to create %s\n",
pr_err("failed to create %s\n",
devname);
return -1;
}
@ -370,12 +370,12 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
if ((stb.st_mode & S_IFMT) != S_IFLNK ||
link_len < 0 ||
strcmp(buf, devname) != 0) {
fprintf(stderr, Name ": %s exists - ignoring\n",
pr_err("%s exists - ignoring\n",
chosen);
strcpy(chosen, devname);
}
} else if (symlink(devname, chosen) != 0)
fprintf(stderr, Name ": failed to create %s: %s\n",
pr_err("failed to create %s: %s\n",
chosen, strerror(errno));
if (use_mdp && strcmp(chosen, devname) != 0)
make_parts(chosen, parts);
@ -383,7 +383,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
}
mdfd = open_dev_excl(num);
if (mdfd < 0)
fprintf(stderr, Name ": unexpected failure opening %s\n",
pr_err("unexpected failure opening %s\n",
devname);
return mdfd;
}
@ -401,14 +401,14 @@ int open_mddev(char *dev, int report_errors)
mdfd = open(dev, O_RDONLY);
if (mdfd < 0) {
if (report_errors)
fprintf(stderr, Name ": error opening %s: %s\n",
pr_err("error opening %s: %s\n",
dev, strerror(errno));
return -1;
}
if (md_get_version(mdfd) <= 0) {
close(mdfd);
if (report_errors)
fprintf(stderr, Name ": %s does not appear to be "
pr_err("%s does not appear to be "
"an md device\n", dev);
return -2;
}

View File

@ -173,13 +173,13 @@ struct mdstat_ent *mdstat_read(int hold, int start)
else
continue;
if (ep == NULL || *ep ) {
/* fprintf(stderr, Name ": bad /proc/mdstat line starts: %s\n", line); */
/* pr_err("bad /proc/mdstat line starts: %s\n", line); */
continue;
}
ent = malloc(sizeof(*ent));
if (!ent) {
fprintf(stderr, Name ": malloc failed reading /proc/mdstat.\n");
pr_err("malloc failed reading /proc/mdstat.\n");
free_line(line);
break;
}

22
msg.c
View File

@ -310,9 +310,8 @@ int check_mdmon_version(char *container)
ver = version ? mdadm_version(version) : -1;
free(version);
if (ver < 3002000) {
fprintf(stderr, Name
": mdmon instance for %s cannot be disabled\n",
container);
pr_err("mdmon instance for %s cannot be disabled\n",
container);
return -1;
}
}
@ -351,8 +350,7 @@ int block_monitor(char *container, const int freeze)
ent = mdstat_read(0, 0);
if (!ent) {
fprintf(stderr, Name
": failed to read /proc/mdstat while disabling mdmon\n");
pr_err("failed to read /proc/mdstat while disabling mdmon\n");
return -1;
}
@ -363,9 +361,8 @@ int block_monitor(char *container, const int freeze)
sysfs_free(sra);
sra = sysfs_read(-1, e->devnum, GET_VERSION);
if (!sra) {
fprintf(stderr, Name
": failed to read sysfs for subarray%s\n",
to_subarray(e, container));
pr_err("failed to read sysfs for subarray%s\n",
to_subarray(e, container));
break;
}
/* can't reshape an array that we can't monitor */
@ -406,7 +403,7 @@ int block_monitor(char *container, const int freeze)
}
if (e) {
fprintf(stderr, Name ": failed to freeze subarray%s\n",
pr_err("failed to freeze subarray%s\n",
to_subarray(e, container));
/* thaw the partially frozen container */
@ -416,7 +413,7 @@ int block_monitor(char *container, const int freeze)
sysfs_free(sra);
sra = sysfs_read(-1, e2->devnum, GET_VERSION);
if (unblock_subarray(sra, freeze))
fprintf(stderr, Name ": Failed to unfreeze %s\n", e2->dev);
pr_err("Failed to unfreeze %s\n", e2->dev);
}
ping_monitor(container); /* cleared frozen */
@ -437,8 +434,7 @@ void unblock_monitor(char *container, const int unfreeze)
ent = mdstat_read(0, 0);
if (!ent) {
fprintf(stderr, Name
": failed to read /proc/mdstat while unblocking container\n");
pr_err("failed to read /proc/mdstat while unblocking container\n");
return;
}
@ -453,7 +449,7 @@ void unblock_monitor(char *container, const int unfreeze)
if (sra->array.level > 0)
to_ping++;
if (unblock_subarray(sra, unfreeze))
fprintf(stderr, Name ": Failed to unfreeze %s\n", e->dev);
pr_err("Failed to unfreeze %s\n", e->dev);
}
if (to_ping)
ping_monitor(container);

View File

@ -67,7 +67,7 @@ static void pol_new(struct dev_policy **pol, char *name, const char *val,
if (!real_metadata) {
static const char *prev = NULL;
if (prev != metadata) {
fprintf(stderr, Name ": metadata=%s unrecognised - ignoring rule\n",
pr_err("metadata=%s unrecognised - ignoring rule\n",
metadata);
prev = metadata;
}
@ -479,7 +479,7 @@ void policyline(char *line, char *type)
! try_rule(w, pol_act, &pr->rule) &&
! try_rule(w, pol_domain, &pr->rule) &&
! try_rule(w, pol_auto, &pr->rule))
fprintf(stderr, Name ": policy rule %s unrecognised and ignored\n",
pr_err("policy rule %s unrecognised and ignored\n",
w);
}
pr->next = config_rules;
@ -731,7 +731,7 @@ void policy_save_path(char *id_path, struct map_ent *array)
FILE *f = NULL;
if (mkdir(FAILED_SLOTS_DIR, S_IRWXU) < 0 && errno != EEXIST) {
fprintf(stderr, Name ": can't create file to save path "
pr_err("can't create file to save path "
"to old disk: %s\n", strerror(errno));
return;
}
@ -739,7 +739,7 @@ void policy_save_path(char *id_path, struct map_ent *array)
snprintf(path, PATH_MAX, FAILED_SLOTS_DIR "/%s", id_path);
f = fopen(path, "w");
if (!f) {
fprintf(stderr, Name ": can't create file to"
pr_err("can't create file to"
" save path to old disk: %s\n",
strerror(errno));
return;
@ -749,8 +749,8 @@ void policy_save_path(char *id_path, struct map_ent *array)
array->metadata,
array->uuid[0], array->uuid[1],
array->uuid[2], array->uuid[3]) <= 0)
fprintf(stderr, Name ": Failed to write to "
"<id_path> cookie\n");
pr_err("Failed to write to "
"<id_path> cookie\n");
fclose(f);
}

View File

@ -263,7 +263,7 @@ int main(int argc, char *argv[])
mdfd = open(argv[1], O_RDONLY);
if(mdfd < 0) {
perror(argv[1]);
fprintf(stderr,"%s: cannot open %s\n", prg, argv[1]);
fprintf(stderr, "%s: cannot open %s\n", prg, argv[1]);
exit_err = 2;
goto exitHere;
}

View File

@ -543,34 +543,32 @@ static int load_ddf_headers(int fd, struct ddf_super *super, char *devname)
if (lseek64(fd, dsize-512, 0) < 0) {
if (devname)
fprintf(stderr,
Name": Cannot seek to anchor block on %s: %s\n",
devname, strerror(errno));
pr_err("Cannot seek to anchor block on %s: %s\n",
devname, strerror(errno));
return 1;
}
if (read(fd, &super->anchor, 512) != 512) {
if (devname)
fprintf(stderr,
Name ": Cannot read anchor block on %s: %s\n",
devname, strerror(errno));
pr_err("Cannot read anchor block on %s: %s\n",
devname, strerror(errno));
return 1;
}
if (super->anchor.magic != DDF_HEADER_MAGIC) {
if (devname)
fprintf(stderr, Name ": no DDF anchor found on %s\n",
pr_err("no DDF anchor found on %s\n",
devname);
return 2;
}
if (calc_crc(&super->anchor, 512) != super->anchor.crc) {
if (devname)
fprintf(stderr, Name ": bad CRC on anchor on %s\n",
pr_err("bad CRC on anchor on %s\n",
devname);
return 2;
}
if (memcmp(super->anchor.revision, DDF_REVISION_0, 8) != 0 &&
memcmp(super->anchor.revision, DDF_REVISION_2, 8) != 0) {
if (devname)
fprintf(stderr, Name ": can only support super revision"
pr_err("can only support super revision"
" %.8s and earlier, not %.8s on %s\n",
DDF_REVISION_2, super->anchor.revision,devname);
return 2;
@ -579,9 +577,8 @@ static int load_ddf_headers(int fd, struct ddf_super *super, char *devname)
dsize >> 9, 1,
&super->primary, &super->anchor) == 0) {
if (devname)
fprintf(stderr,
Name ": Failed to load primary DDF header "
"on %s\n", devname);
pr_err("Failed to load primary DDF header "
"on %s\n", devname);
return 2;
}
super->active = &super->primary;
@ -652,7 +649,7 @@ static int load_ddf_local(int fd, struct ddf_super *super,
if (posix_memalign((void**)&dl, 512,
sizeof(*dl) +
(super->max_part) * sizeof(dl->vlist[0])) != 0) {
fprintf(stderr, Name ": %s could not allocate disk info buffer\n",
pr_err("%s could not allocate disk info buffer\n",
__func__);
return 1;
}
@ -706,9 +703,8 @@ static int load_ddf_local(int fd, struct ddf_super *super,
continue;
if (posix_memalign((void**)&dl->spare, 512,
super->conf_rec_len*512) != 0) {
fprintf(stderr, Name
": %s could not allocate spare info buf\n",
__func__);
pr_err("%s could not allocate spare info buf\n",
__func__);
return 1;
}
@ -732,9 +728,8 @@ static int load_ddf_local(int fd, struct ddf_super *super,
if (posix_memalign((void**)&vcl, 512,
(super->conf_rec_len*512 +
offsetof(struct vcl, conf))) != 0) {
fprintf(stderr, Name
": %s could not allocate vcl buf\n",
__func__);
pr_err("%s could not allocate vcl buf\n",
__func__);
return 1;
}
vcl->next = super->conflist;
@ -782,25 +777,23 @@ static int load_super_ddf(struct supertype *st, int fd,
/* 32M is a lower bound */
if (dsize <= 32*1024*1024) {
if (devname)
fprintf(stderr,
Name ": %s is too small for ddf: "
"size is %llu sectors.\n",
devname, dsize>>9);
pr_err("%s is too small for ddf: "
"size is %llu sectors.\n",
devname, dsize>>9);
return 1;
}
if (dsize & 511) {
if (devname)
fprintf(stderr,
Name ": %s is an odd size for ddf: "
"size is %llu bytes.\n",
devname, dsize);
pr_err("%s is an odd size for ddf: "
"size is %llu bytes.\n",
devname, dsize);
return 1;
}
free_super_ddf(st);
if (posix_memalign((void**)&super, 512, sizeof(*super))!= 0) {
fprintf(stderr, Name ": malloc of %zu failed.\n",
pr_err("malloc of %zu failed.\n",
sizeof(*super));
return 1;
}
@ -818,9 +811,8 @@ static int load_super_ddf(struct supertype *st, int fd,
if (rv) {
if (devname)
fprintf(stderr,
Name ": Failed to load all information "
"sections on %s\n", devname);
pr_err("Failed to load all information "
"sections on %s\n", devname);
free(super);
return rv;
}
@ -829,9 +821,8 @@ static int load_super_ddf(struct supertype *st, int fd,
if (rv) {
if (devname)
fprintf(stderr,
Name ": Failed to load all information "
"sections on %s\n", devname);
pr_err("Failed to load all information "
"sections on %s\n", devname);
free(super);
return rv;
}
@ -1629,7 +1620,7 @@ static int init_super_ddf(struct supertype *st,
return init_super_ddf_bvd(st, info, size, name, homehost, uuid);
if (posix_memalign((void**)&ddf, 512, sizeof(*ddf)) != 0) {
fprintf(stderr, Name ": %s could not allocate superblock\n", __func__);
pr_err("%s could not allocate superblock\n", __func__);
return 0;
}
memset(ddf, 0, sizeof(*ddf));
@ -1767,7 +1758,7 @@ static int init_super_ddf(struct supertype *st,
strcpy((char*)ddf->controller.vendor_data, homehost);
if (posix_memalign((void**)&pd, 512, pdsize) != 0) {
fprintf(stderr, Name ": %s could not allocate pd\n", __func__);
pr_err("%s could not allocate pd\n", __func__);
return 0;
}
ddf->phys = pd;
@ -1781,7 +1772,7 @@ static int init_super_ddf(struct supertype *st,
memset(pd->pad, 0xff, 52);
if (posix_memalign((void**)&vd, 512, vdsize) != 0) {
fprintf(stderr, Name ": %s could not allocate vd\n", __func__);
pr_err("%s could not allocate vd\n", __func__);
return 0;
}
ddf->virt = vd;
@ -1970,9 +1961,9 @@ static int init_super_ddf_bvd(struct supertype *st,
if (__be16_to_cpu(ddf->virt->populated_vdes)
>= __be16_to_cpu(ddf->virt->max_vdes)) {
fprintf(stderr, Name": This ddf already has the "
"maximum of %d virtual devices\n",
__be16_to_cpu(ddf->virt->max_vdes));
pr_err("This ddf already has the "
"maximum of %d virtual devices\n",
__be16_to_cpu(ddf->virt->max_vdes));
return 0;
}
@ -1982,9 +1973,9 @@ static int init_super_ddf_bvd(struct supertype *st,
char *n = ddf->virt->entries[venum].name;
if (strncmp(name, n, 16) == 0) {
fprintf(stderr, Name ": This ddf already"
" has an array called %s\n",
name);
pr_err("This ddf already"
" has an array called %s\n",
name);
return 0;
}
}
@ -1993,7 +1984,7 @@ static int init_super_ddf_bvd(struct supertype *st,
if (all_ff(ddf->virt->entries[venum].guid))
break;
if (venum == __be16_to_cpu(ddf->virt->max_vdes)) {
fprintf(stderr, Name ": Cannot find spare slot for "
pr_err("Cannot find spare slot for "
"virtual disk - DDF is corrupt\n");
return 0;
}
@ -2023,7 +2014,7 @@ static int init_super_ddf_bvd(struct supertype *st,
/* Now create a new vd_config */
if (posix_memalign((void**)&vcl, 512,
(offsetof(struct vcl, conf) + ddf->conf_rec_len * 512)) != 0) {
fprintf(stderr, Name ": %s could not allocate vd_config\n", __func__);
pr_err("%s could not allocate vd_config\n", __func__);
return 0;
}
vcl->lba_offset = (__u64*) &vcl->conf.phys_refnum[ddf->mppe];
@ -2208,9 +2199,8 @@ static int add_to_super_ddf(struct supertype *st,
fstat(fd, &stb);
if (posix_memalign((void**)&dd, 512,
sizeof(*dd) + sizeof(dd->vlist[0]) * ddf->max_part) != 0) {
fprintf(stderr, Name
": %s could allocate buffer for new disk, aborting\n",
__func__);
pr_err("%s could allocate buffer for new disk, aborting\n",
__func__);
return 1;
}
dd->major = major(stb.st_rdev);
@ -2554,7 +2544,7 @@ static int reserve_space(struct supertype *st, int raiddisks,
free(e);
}
if (cnt < raiddisks) {
fprintf(stderr, Name ": not enough devices with space to create array.\n");
pr_err("not enough devices with space to create array.\n");
return 0; /* No enough free spaces large enough */
}
if (size == 0) {
@ -2577,7 +2567,7 @@ static int reserve_space(struct supertype *st, int raiddisks,
}
*freesize = size;
if (size < 32) {
fprintf(stderr, Name ": not enough spare devices to create array.\n");
pr_err("not enough spare devices to create array.\n");
return 0;
}
}
@ -2646,7 +2636,7 @@ static int validate_geometry_ddf(struct supertype *st,
break;
if (ddf_level_num[i].num1 == MAXINT) {
if (verbose)
fprintf(stderr, Name ": DDF does not support level %d arrays\n",
pr_err("DDF does not support level %d arrays\n",
level);
return 0;
}
@ -2695,15 +2685,14 @@ static int validate_geometry_ddf(struct supertype *st,
}
if (verbose)
fprintf(stderr,
Name ": ddf: Cannot create this array "
"on device %s - a container is required.\n",
dev);
pr_err("ddf: Cannot create this array "
"on device %s - a container is required.\n",
dev);
return 0;
}
if (errno != EBUSY || (fd = open(dev, O_RDONLY, 0)) < 0) {
if (verbose)
fprintf(stderr, Name ": ddf: Cannot open %s: %s\n",
pr_err("ddf: Cannot open %s: %s\n",
dev, strerror(errno));
return 0;
}
@ -2712,7 +2701,7 @@ static int validate_geometry_ddf(struct supertype *st,
if (cfd < 0) {
close(fd);
if (verbose)
fprintf(stderr, Name ": ddf: Cannot use %s: %s\n",
pr_err("ddf: Cannot use %s: %s\n",
dev, strerror(EBUSY));
return 0;
}
@ -2758,7 +2747,7 @@ validate_geometry_ddf_container(struct supertype *st,
fd = open(dev, O_RDONLY|O_EXCL, 0);
if (fd < 0) {
if (verbose)
fprintf(stderr, Name ": ddf: Cannot open %s: %s\n",
pr_err("ddf: Cannot open %s: %s\n",
dev, strerror(errno));
return 0;
}
@ -2791,7 +2780,7 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
/* ddf/bvd supports lots of things, but not containers */
if (level == LEVEL_CONTAINER) {
if (verbose)
fprintf(stderr, Name ": DDF cannot create a container within an container\n");
pr_err("DDF cannot create a container within an container\n");
return 0;
}
/* We must have the container info already read in. */
@ -2828,10 +2817,9 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
}
if (dcnt < raiddisks) {
if (verbose)
fprintf(stderr,
Name ": ddf: Not enough devices with "
"space for this array (%d < %d)\n",
dcnt, raiddisks);
pr_err("ddf: Not enough devices with "
"space for this array (%d < %d)\n",
dcnt, raiddisks);
return 0;
}
return 1;
@ -2848,7 +2836,7 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
}
if (!dl) {
if (verbose)
fprintf(stderr, Name ": ddf: %s is not in the "
pr_err("ddf: %s is not in the "
"same DDF set\n",
dev);
return 0;

View File

@ -77,7 +77,7 @@ static int load_gpt(struct supertype *st, int fd, char *devname)
free_gpt(st);
if (posix_memalign((void**)&super, 4096, 32*512) != 0) {
fprintf(stderr, Name ": %s could not allocate superblock\n",
pr_err("%s could not allocate superblock\n",
__func__);
return 1;
}
@ -88,7 +88,7 @@ static int load_gpt(struct supertype *st, int fd, char *devname)
if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
no_read:
if (devname)
fprintf(stderr, Name ": Cannot read partition table on %s\n",
pr_err("Cannot read partition table on %s\n",
devname);
free(super);
return 1;
@ -98,7 +98,7 @@ static int load_gpt(struct supertype *st, int fd, char *devname)
super->parts[0].part_type != MBR_GPT_PARTITION_TYPE) {
not_found:
if (devname)
fprintf(stderr, Name ": No partition table found on %s\n",
pr_err("No partition table found on %s\n",
devname);
free(super);
return 1;
@ -199,7 +199,7 @@ static int validate_geometry(struct supertype *st, int level,
char *subdev, unsigned long long *freesize,
int verbose)
{
fprintf(stderr, Name ": gpt metadata cannot be used this way\n");
pr_err("gpt metadata cannot be used this way\n");
return 0;
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,7 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
free_mbr(st);
if (posix_memalign((void**)&super, 512, 512) != 0) {
fprintf(stderr, Name ": %s could not allocate superblock\n",
pr_err("%s could not allocate superblock\n",
__func__);
return 1;
}
@ -91,7 +91,7 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
lseek(fd, 0, 0);
if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
if (devname)
fprintf(stderr, Name ": Cannot read partition table on %s\n",
pr_err("Cannot read partition table on %s\n",
devname);
free(super);
return 1;
@ -99,7 +99,7 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
if (super->magic != MBR_SIGNATURE_MAGIC) {
if (devname)
fprintf(stderr, Name ": No partition table found on %s\n",
pr_err("No partition table found on %s\n",
devname);
free(super);
return 1;
@ -121,7 +121,7 @@ static int store_mbr(struct supertype *st, int fd)
struct MBR *old, *super;
if (posix_memalign((void**)&old, 512, 512) != 0) {
fprintf(stderr, Name ": %s could not allocate superblock\n",
pr_err("%s could not allocate superblock\n",
__func__);
return 1;
}
@ -192,7 +192,7 @@ static int validate_geometry(struct supertype *st, int level,
char *subdev, unsigned long long *freesize,
int verbose)
{
fprintf(stderr, Name ": mbr metadata cannot be used this way\n");
pr_err("mbr metadata cannot be used this way\n");
return 0;
}
#endif

View File

@ -445,12 +445,12 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
sb32+MD_SB_GENERIC_CONSTANT_WORDS+7+1,
(MD_SB_WORDS - (MD_SB_GENERIC_CONSTANT_WORDS+7+1))*4);
if (verbose >= 0)
fprintf (stderr, Name ": adjusting superblock of %s for 2.2/sparc compatability.\n",
devname);
pr_err("adjusting superblock of %s for 2.2/sparc compatability.\n",
devname);
} else if (strcmp(update, "super-minor") ==0) {
sb->md_minor = info->array.md_minor;
if (verbose > 0)
fprintf(stderr, Name ": updating superblock of %s with minor number %d\n",
pr_err("updating superblock of %s with minor number %d\n",
devname, info->array.md_minor);
} else if (strcmp(update, "summaries") == 0) {
unsigned int i;
@ -608,7 +608,7 @@ static int init_super0(struct supertype *st, mdu_array_info_t *info,
if (posix_memalign((void**)&sb, 4096,
MD_SB_BYTES + ROUND_UP(sizeof(bitmap_super_t), 4096)) != 0) {
fprintf(stderr, Name ": %s could not allocate superblock\n", __func__);
pr_err("%s could not allocate superblock\n", __func__);
return 0;
}
memset(sb, 0, MD_SB_BYTES + sizeof(bitmap_super_t));
@ -621,7 +621,7 @@ static int init_super0(struct supertype *st, mdu_array_info_t *info,
spares = info->working_disks - info->active_disks;
if (info->raid_disks + spares > MD_SB_DISKS) {
fprintf(stderr, Name ": too many devices requested: %d+%d > %d\n",
pr_err("too many devices requested: %d+%d > %d\n",
info->raid_disks , spares, MD_SB_DISKS);
return 0;
}
@ -781,9 +781,8 @@ static int write_init_super0(struct supertype *st)
rv = st->ss->write_bitmap(st, di->fd);
if (rv)
fprintf(stderr,
Name ": failed to write superblock to %s\n",
di->devname);
pr_err("failed to write superblock to %s\n",
di->devname);
}
return rv;
}
@ -808,8 +807,7 @@ static int compare_super0(struct supertype *st, struct supertype *tst)
if (posix_memalign((void**)&first, 4096,
MD_SB_BYTES +
ROUND_UP(sizeof(struct bitmap_super_s), 4096)) != 0) {
fprintf(stderr, Name
": %s could not allocate superblock\n", __func__);
pr_err("%s could not allocate superblock\n", __func__);
return 1;
}
memcpy(first, second, MD_SB_BYTES + sizeof(struct bitmap_super_s));
@ -858,9 +856,8 @@ static int load_super0(struct supertype *st, int fd, char *devname)
if (dsize < MD_RESERVED_SECTORS*512) {
if (devname)
fprintf(stderr, Name
": %s is too small for md: size is %llu sectors.\n",
devname, dsize);
pr_err("%s is too small for md: size is %llu sectors.\n",
devname, dsize);
return 1;
}
@ -872,7 +869,7 @@ static int load_super0(struct supertype *st, int fd, char *devname)
if (lseek64(fd, offset, 0)< 0LL) {
if (devname)
fprintf(stderr, Name ": Cannot seek to superblock on %s: %s\n",
pr_err("Cannot seek to superblock on %s: %s\n",
devname, strerror(errno));
return 1;
}
@ -880,14 +877,13 @@ static int load_super0(struct supertype *st, int fd, char *devname)
if (posix_memalign((void**)&super, 4096,
MD_SB_BYTES +
ROUND_UP(sizeof(bitmap_super_t), 4096)) != 0) {
fprintf(stderr, Name
": %s could not allocate superblock\n", __func__);
pr_err("%s could not allocate superblock\n", __func__);
return 1;
}
if (read(fd, super, sizeof(*super)) != MD_SB_BYTES) {
if (devname)
fprintf(stderr, Name ": Cannot read superblock on %s\n",
pr_err("Cannot read superblock on %s\n",
devname);
free(super);
return 1;
@ -898,7 +894,7 @@ static int load_super0(struct supertype *st, int fd, char *devname)
if (super->md_magic != MD_SB_MAGIC) {
if (devname)
fprintf(stderr, Name ": No super block found on %s (Expected magic %08x, got %08x)\n",
pr_err("No super block found on %s (Expected magic %08x, got %08x)\n",
devname, MD_SB_MAGIC, super->md_magic);
free(super);
return 2;
@ -906,7 +902,7 @@ static int load_super0(struct supertype *st, int fd, char *devname)
if (super->major_version != 0) {
if (devname)
fprintf(stderr, Name ": Cannot interpret superblock on %s - version is %d\n",
pr_err("Cannot interpret superblock on %s - version is %d\n",
devname, super->major_version);
free(super);
return 2;
@ -1142,19 +1138,19 @@ static int validate_geometry0(struct supertype *st, int level,
if (level == LEVEL_CONTAINER) {
if (verbose)
fprintf(stderr, Name ": 0.90 metadata does not support containers\n");
pr_err("0.90 metadata does not support containers\n");
return 0;
}
if (raiddisks > MD_SB_DISKS) {
if (verbose)
fprintf(stderr, Name ": 0.90 metadata supports at most %d devices per array\n",
pr_err("0.90 metadata supports at most %d devices per array\n",
MD_SB_DISKS);
return 0;
}
if (size >= tbmax * 2ULL*1024*1024*1024) {
if (verbose)
fprintf(stderr, Name ": 0.90 metadata supports at most "
"%d terabytes per device\n", tbmax);
pr_err("0.90 metadata supports at most "
"%d terabytes per device\n", tbmax);
return 0;
}
if (chunk && *chunk == UnSet)
@ -1166,7 +1162,7 @@ static int validate_geometry0(struct supertype *st, int level,
fd = open(subdev, O_RDONLY|O_EXCL, 0);
if (fd < 0) {
if (verbose)
fprintf(stderr, Name ": super0.90 cannot open %s: %s\n",
pr_err("super0.90 cannot open %s: %s\n",
subdev, strerror(errno));
return 0;
}

View File

@ -871,8 +871,7 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info,
int sbsize;
if (posix_memalign((void**)&sb, 4096, SUPER1_SIZE) != 0) {
fprintf(stderr, Name
": %s could not allocate superblock\n", __func__);
pr_err("%s could not allocate superblock\n", __func__);
return 0;
}
memset(sb, 0, SUPER1_SIZE);
@ -885,7 +884,7 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info,
spares = info->working_disks - info->active_disks;
if (info->raid_disks + spares > MAX_DEVS) {
fprintf(stderr, Name ": too many devices requested: %d+%d > %d\n",
pr_err("too many devices requested: %d+%d > %d\n",
info->raid_disks , spares, MAX_DEVS);
return 0;
}
@ -1039,7 +1038,7 @@ static int store_super1(struct supertype *st, int fd)
if (sb_offset != __le64_to_cpu(sb->super_offset) &&
0 != __le64_to_cpu(sb->super_offset)
) {
fprintf(stderr, Name ": internal error - sb_offset is wrong\n");
pr_err("internal error - sb_offset is wrong\n");
abort();
}
@ -1229,9 +1228,9 @@ static int write_init_super1(struct supertype *st)
sb->data_size = __cpu_to_le64(dsize - reserved);
break;
default:
fprintf(stderr, Name ": Failed to write invalid "
"metadata format 1.%i to %s\n",
st->minor_version, di->devname);
pr_err("Failed to write invalid "
"metadata format 1.%i to %s\n",
st->minor_version, di->devname);
rv = -EINVAL;
goto out;
}
@ -1247,8 +1246,8 @@ static int write_init_super1(struct supertype *st)
}
error_out:
if (rv)
fprintf(stderr, Name ": Failed to write metadata to %s\n",
di->devname);
pr_err("Failed to write metadata to %s\n",
di->devname);
out:
return rv;
}
@ -1273,8 +1272,7 @@ static int compare_super1(struct supertype *st, struct supertype *tst)
if (!first) {
if (posix_memalign((void**)&first, 4096, SUPER1_SIZE) != 0) {
fprintf(stderr, Name
": %s could not allocate superblock\n", __func__);
pr_err("%s could not allocate superblock\n", __func__);
return 1;
}
memcpy(first, second, SUPER1_SIZE);
@ -1348,7 +1346,7 @@ static int load_super1(struct supertype *st, int fd, char *devname)
if (dsize < 24) {
if (devname)
fprintf(stderr, Name ": %s is too small for md: size is %llu sectors.\n",
pr_err("%s is too small for md: size is %llu sectors.\n",
devname, dsize);
return 1;
}
@ -1382,20 +1380,20 @@ static int load_super1(struct supertype *st, int fd, char *devname)
if (lseek64(fd, sb_offset << 9, 0)< 0LL) {
if (devname)
fprintf(stderr, Name ": Cannot seek to superblock on %s: %s\n",
pr_err("Cannot seek to superblock on %s: %s\n",
devname, strerror(errno));
return 1;
}
if (posix_memalign((void**)&super, 4096, SUPER1_SIZE) != 0) {
fprintf(stderr, Name ": %s could not allocate superblock\n",
pr_err("%s could not allocate superblock\n",
__func__);
return 1;
}
if (aread(&afd, super, MAX_SB_SIZE) != MAX_SB_SIZE) {
if (devname)
fprintf(stderr, Name ": Cannot read superblock on %s\n",
pr_err("Cannot read superblock on %s\n",
devname);
free(super);
return 1;
@ -1403,7 +1401,7 @@ static int load_super1(struct supertype *st, int fd, char *devname)
if (__le32_to_cpu(super->magic) != MD_SB_MAGIC) {
if (devname)
fprintf(stderr, Name ": No super block found on %s (Expected magic %08x, got %08x)\n",
pr_err("No super block found on %s (Expected magic %08x, got %08x)\n",
devname, MD_SB_MAGIC, __le32_to_cpu(super->magic));
free(super);
return 2;
@ -1411,14 +1409,14 @@ static int load_super1(struct supertype *st, int fd, char *devname)
if (__le32_to_cpu(super->major_version) != 1) {
if (devname)
fprintf(stderr, Name ": Cannot interpret superblock on %s - version is %d\n",
pr_err("Cannot interpret superblock on %s - version is %d\n",
devname, __le32_to_cpu(super->major_version));
free(super);
return 2;
}
if (__le64_to_cpu(super->super_offset) != sb_offset) {
if (devname)
fprintf(stderr, Name ": No superblock found on %s (super_offset is wrong)\n",
pr_err("No superblock found on %s (super_offset is wrong)\n",
devname);
free(super);
return 2;
@ -1760,7 +1758,7 @@ static int validate_geometry1(struct supertype *st, int level,
if (level == LEVEL_CONTAINER) {
if (verbose)
fprintf(stderr, Name ": 1.x metadata does not support containers\n");
pr_err("1.x metadata does not support containers\n");
return 0;
}
if (chunk && *chunk == UnSet)
@ -1772,7 +1770,7 @@ static int validate_geometry1(struct supertype *st, int level,
fd = open(subdev, O_RDONLY|O_EXCL, 0);
if (fd < 0) {
if (verbose)
fprintf(stderr, Name ": super1.x cannot open %s: %s\n",
pr_err("super1.x cannot open %s: %s\n",
subdev, strerror(errno));
return 0;
}

View File

@ -580,7 +580,7 @@ int sysfs_set_array(struct mdinfo *info, int vers)
if ((vers % 100) < 2 ||
sysfs_set_str(info, NULL, "metadata_version",
ver) < 0) {
fprintf(stderr, Name ": This kernel does not "
pr_err("This kernel does not "
"support external metadata.\n");
return 1;
}
@ -601,7 +601,7 @@ int sysfs_set_array(struct mdinfo *info, int vers)
rc = sysfs_set_num(info, NULL, "array_size",
info->custom_array_size/2);
if (rc && errno == ENOENT) {
fprintf(stderr, Name ": This kernel does not "
pr_err("This kernel does not "
"have the md/array_size attribute, "
"the array may be larger than expected\n");
rc = 0;

55
util.c
View File

@ -505,7 +505,7 @@ int check_ext2(int fd, char *name)
mtime = sb[44]|(sb[45]|(sb[46]|sb[47]<<8)<<8)<<8;
bsize = sb[24]|(sb[25]|(sb[26]|sb[27]<<8)<<8)<<8;
size = sb[4]|(sb[5]|(sb[6]|sb[7]<<8)<<8)<<8;
fprintf(stderr, Name ": %s appears to contain an ext2fs file system\n",
pr_err("%s appears to contain an ext2fs file system\n",
name);
fprintf(stderr," size=%dK mtime=%s",
size*(1<<bsize), ctime(&mtime));
@ -529,7 +529,7 @@ int check_reiser(int fd, char *name)
if (strncmp((char*)sb+52, "ReIsErFs",8)!=0 &&
strncmp((char*)sb+52, "ReIsEr2Fs",9)!=0)
return 0;
fprintf(stderr, Name ": %s appears to contain a reiserfs file system\n",name);
pr_err("%s appears to contain a reiserfs file system\n",name);
size = sb[0]|(sb[1]|(sb[2]|sb[3]<<8)<<8)<<8;
fprintf(stderr, " size = %luK\n", size*4);
@ -547,7 +547,7 @@ int check_raid(int fd, char *name)
st->ignore_hw_compat = 1;
st->ss->load_super(st, fd, name);
/* Looks like a raid array .. */
fprintf(stderr, Name ": %s appears to be part of a raid array:\n",
pr_err("%s appears to be part of a raid array:\n",
name);
st->ss->getinfo_super(st, &info, NULL);
st->ss->free_super(st);
@ -575,7 +575,7 @@ int ask(char *mesg)
return 0;
add = "(y/n) ";
}
fprintf(stderr, Name ": assuming 'no'\n");
pr_err("assuming 'no'\n");
return 0;
}
#endif /* MDASSEMBLE */
@ -1106,7 +1106,7 @@ int get_dev_size(int fd, char *dname, unsigned long long *sizep)
ldsize <<= 9;
} else {
if (dname)
fprintf(stderr, Name ": Cannot get size of %s: %s\b",
pr_err("Cannot get size of %s: %s\b",
dname, strerror(errno));
return 0;
}
@ -1248,22 +1248,19 @@ int check_partitions(int fd, char *dname, unsigned long long freesize,
/* There appears to be a partition table here */
if (freesize == 0) {
/* partitions will not be visible in new device */
fprintf(stderr,
Name ": partition table exists on %s but will be lost or\n"
" meaningless after creating array\n",
dname);
pr_err("partition table exists on %s but will be lost or\n"
" meaningless after creating array\n",
dname);
return 1;
} else if (endofpart > freesize) {
/* last partition overlaps metadata */
fprintf(stderr,
Name ": metadata will over-write last partition on %s.\n",
dname);
pr_err("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);
pr_err("array size is too small to cover all partitions on %s.\n",
dname);
return 1;
}
}
@ -1389,7 +1386,7 @@ int open_subarray(char *dev, char *subarray, struct supertype *st, int quiet)
fd = open(dev, O_RDWR|O_EXCL);
if (fd < 0) {
if (!quiet)
fprintf(stderr, Name ": Couldn't open %s, aborting\n",
pr_err("Couldn't open %s, aborting\n",
dev);
return -1;
}
@ -1397,51 +1394,49 @@ int open_subarray(char *dev, char *subarray, struct supertype *st, int quiet)
st->devnum = fd2devnum(fd);
if (st->devnum == NoMdDev) {
if (!quiet)
fprintf(stderr,
Name ": Failed to determine device number for %s\n",
dev);
pr_err("Failed to determine device number for %s\n",
dev);
goto close_fd;
}
mdi = sysfs_read(fd, st->devnum, GET_VERSION|GET_LEVEL);
if (!mdi) {
if (!quiet)
fprintf(stderr, Name ": Failed to read sysfs for %s\n",
pr_err("Failed to read sysfs for %s\n",
dev);
goto close_fd;
}
if (mdi->array.level != UnSet) {
if (!quiet)
fprintf(stderr, Name ": %s is not a container\n", dev);
pr_err("%s is not a container\n", dev);
goto free_sysfs;
}
st->ss = version_to_superswitch(mdi->text_version);
if (!st->ss) {
if (!quiet)
fprintf(stderr,
Name ": Operation not supported for %s metadata\n",
mdi->text_version);
pr_err("Operation not supported for %s metadata\n",
mdi->text_version);
goto free_sysfs;
}
st->devname = devnum2devname(st->devnum);
if (!st->devname) {
if (!quiet)
fprintf(stderr, Name ": Failed to allocate device name\n");
pr_err("Failed to allocate device name\n");
goto free_sysfs;
}
if (!st->ss->load_container) {
if (!quiet)
fprintf(stderr, Name ": %s is not a container\n", dev);
pr_err("%s is not a container\n", dev);
goto free_name;
}
if (st->ss->load_container(st, fd, NULL)) {
if (!quiet)
fprintf(stderr, Name ": Failed to load metadata for %s\n",
pr_err("Failed to load metadata for %s\n",
dev);
goto free_name;
}
@ -1449,7 +1444,7 @@ int open_subarray(char *dev, char *subarray, struct supertype *st, int quiet)
info = st->ss->container_content(st, subarray);
if (!info) {
if (!quiet)
fprintf(stderr, Name ": Failed to find subarray-%s in %s\n",
pr_err("Failed to find subarray-%s in %s\n",
subarray, dev);
goto free_super;
}
@ -1645,7 +1640,7 @@ int start_mdmon(int devnum)
}
}
exit(1);
case -1: fprintf(stderr, Name ": cannot run mdmon. "
case -1: pr_err("cannot run mdmon. "
"Array remains readonly\n");
return -1;
default: /* parent - good */
@ -1731,7 +1726,7 @@ int experimental(void)
if (check_env("MDADM_EXPERIMENTAL"))
return 1;
else {
fprintf(stderr, Name ": To use this feature MDADM_EXPERIMENTAL"
pr_err("To use this feature MDADM_EXPERIMENTAL"
" environment variable has to be defined.\n");
return 0;
}