X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fmdadm.git;a=blobdiff_plain;f=Examine.c;h=1f2374586fae5373854fff437a03867b1ddfdf7b;hp=2bc3806aaeb7a52c04d4ed99b067982246b6dfa3;hb=dd0781e50555c32ff2f808ec46f4b03a5693ea47;hpb=b83d95f362ff41e5ce63baa3bbcf0a76ea1f15aa diff --git a/Examine.c b/Examine.c index 2bc3806a..1f237458 100644 --- a/Examine.c +++ b/Examine.c @@ -35,7 +35,7 @@ #endif #include "md_u.h" #include "md_p.h" -int Examine(mddev_dev_t devlist, int brief, int scan) +int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust) { /* Read the raid superblock from a device and @@ -60,6 +60,7 @@ int Examine(mddev_dev_t devlist, int brief, int scan) char *c; int rv = 0; int err; + int spares = 0; struct array { mdp_super_t super; @@ -151,9 +152,8 @@ int Examine(mddev_dev_t devlist, int brief, int scan) printf("\n"); atime = super.utime; printf(" Update Time : %.24s\n", ctime(&atime)); - printf(" State : %s, %serrors\n", - (super.state&(1<state & (1<state & (1<state & (1<state == 0) { printf(" spare"); spares++; } if ((dv=map_dev(dp->major, dp->minor))) printf(" %s", dv); printf("\n"); } } + if (SparcAdjust == 2) { + printf(" ----- updating superblock on device ----\n"); + fd = open(devlist->devname, O_RDWR); + if (fd < 0) { + fprintf(stderr, Name ": cannot open %s to update superblock: %s\n", + devlist->devname, strerror(errno)); + err = 1; + } else { + super.sb_csum = calc_sb_csum(&super); + if (store_super(fd, &super)) { + fprintf(stderr, Name ": Count not re-write superblock on %s\n", + devlist->devname); + err = 1; + } + close(fd); + } + } } if (brief) { struct array *ap; @@ -206,8 +235,10 @@ int Examine(mddev_dev_t devlist, int brief, int scan) char sep='='; char *c=map_num(pers, ap->super.level); char *d; - printf("ARRAY /dev/md%d level=%s num-devices=%d UUID=", - ap->super.md_minor, c?c:"-unknown-", ap->super.raid_disks); + printf("ARRAY %s level=%s num-devices=%d UUID=", + get_md_name(ap->super.md_minor), + c?c:"-unknown-", ap->super.raid_disks); + if (spares) printf(" spares=%d", spares); if (ap->super.minor_version >= 90) printf("%08x:%08x:%08x:%08x", ap->super.set_uuid0, ap->super.set_uuid1, ap->super.set_uuid2, ap->super.set_uuid3);