]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Examine.c
mdadm-1.0.1
[thirdparty/mdadm.git] / Examine.c
index 0473dc16f0b849063859b61b7c9eb5ca43667ebd..b886afc27f75612646b836c42cd3bd155f0cb63c 100644 (file)
--- 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, char *conffile)
+int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust)
 {
 
        /* Read the raid superblock from a device and
@@ -60,7 +60,6 @@ int Examine(mddev_dev_t devlist, int brief, char *conffile)
        char *c;
        int rv = 0;
        int err;
-       int scan= 0;
 
        struct array {
                mdp_super_t super;
@@ -68,15 +67,6 @@ int Examine(mddev_dev_t devlist, int brief, char *conffile)
                struct array *next;
        } *arrays = NULL;
 
-       if (devlist == NULL) {
-               devlist = conf_get_devs(conffile);
-               scan=1;
-       }
-       if (devlist == NULL) {
-               fprintf(stderr, Name ": No devices listed in %s\n", conffile);
-               return 1;
-       }
-
        for (; devlist ; devlist=devlist->next) {
                fd = open(devlist->devname, O_RDONLY);
                if (fd < 0) {
@@ -155,8 +145,8 @@ int Examine(mddev_dev_t devlist, int brief, char *conffile)
                        c=map_num(pers, super.level);
                        printf("     Raid Level : %s\n", c?c:"-unknown-");
                        printf("    Device Size : %d%s\n", super.size, human_size((long long)super.size<<10));
-                       printf("     Raid Disks : %d\n", super.raid_disks);
-                       printf("    Total Disks : %d\n", super.nr_disks);
+                       printf("   Raid Devices : %d\n", super.raid_disks);
+                       printf("  Total Devices : %d\n", super.nr_disks);
                        printf("Preferred Minor : %d\n", super.md_minor);
                        printf("\n");
                        atime = super.utime;
@@ -164,14 +154,25 @@ int Examine(mddev_dev_t devlist, int brief, char *conffile)
                        printf("          State : %s, %serrors\n",
                               (super.state&(1<<MD_SB_CLEAN))?"clean":"dirty",
                               (super.state&(1<<MD_SB_ERRORS))?"":"no-");
-                       printf("  Active Drives : %d\n", super.active_disks);
-                       printf(" Working Drives : %d\n", super.working_disks);
-                       printf("  Failed Drives : %d\n", super.failed_disks);
-                       printf("   Spare Drives : %d\n", super.spare_disks);
+                       printf(" Active Devices : %d\n", super.active_disks);
+                       printf("Working Devices : %d\n", super.working_disks);
+                       printf(" Failed Devices : %d\n", super.failed_disks);
+                       printf("  Spare Devices : %d\n", super.spare_disks);
                        if (calc_sb_csum(&super) == super.sb_csum)
                                printf("       Checksum : %x - correct\n", super.sb_csum);
                        else
                                printf("       Checksum : %x - expected %x\n", super.sb_csum, calc_sb_csum(&super));
+                       if (SparcAdjust) {
+                               /* 2.2 sparc put the events in the wrong place
+                                * So we copy the tail of the superblock
+                                * up 4 bytes before continuing
+                                */
+                               __u32 *sb32 = (__u32*)&super;
+                               memcpy(sb32+MD_SB_GENERIC_CONSTANT_WORDS+7,
+                                      sb32+MD_SB_GENERIC_CONSTANT_WORDS+7+1,
+                                      MD_SB_WORDS - (MD_SB_GENERIC_CONSTANT_WORDS+7+1));
+                               printf (" --- adjusting superblock for 2.2/sparc compatability ---\n");
+                       }
                        printf("         Events : %d.%d\n", super.events_hi, super.events_lo);
                        printf("\n");
                        if (super.level == 5) {
@@ -190,7 +191,7 @@ int Examine(mddev_dev_t devlist, int brief, char *conffile)
                        default: break;         
                        }
                        printf("\n");
-                       printf("      Number   Major   Minor   RaidDisk   State\n");
+                       printf("      Number   Major   Minor   RaidDevice State\n");
                        for (d= -1; d<(signed int)(super.raid_disks+super.spare_disks); d++) {
                                mdp_disk_t *dp;
                                char *dv;
@@ -209,6 +210,23 @@ int Examine(mddev_dev_t devlist, int brief, char *conffile)
                                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;
@@ -216,7 +234,7 @@ int Examine(mddev_dev_t devlist, int brief, char *conffile)
                        char sep='=';
                        char *c=map_num(pers, ap->super.level);
                        char *d;
-                       printf("ARRAY /dev/md%d level=%s disks=%d UUID=",
+                       printf("ARRAY /dev/md%d level=%s num-devices=%d UUID=",
                               ap->super.md_minor, c?c:"-unknown-", ap->super.raid_disks);
                        if (ap->super.minor_version >= 90)
                                printf("%08x:%08x:%08x:%08x", ap->super.set_uuid0, ap->super.set_uuid1,