]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Include homehost information in --detail where appropriate.
authorNeil Brown <neilb@suse.de>
Fri, 19 May 2006 07:13:03 +0000 (07:13 +0000)
committerNeil Brown <neilb@suse.de>
Fri, 19 May 2006 07:13:03 +0000 (07:13 +0000)
Signed-off-by: Neil Brown <neilb@suse.de>
Detail.c
mdadm.c
mdadm.h
super0.c
super1.c

index c377f295da7fe8c0e68daa26a6fbf71b2cbf50c4..832e0d8719d1adcf861aacfa3406ba48fafd952d 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -31,7 +31,7 @@
 #include       "md_p.h"
 #include       "md_u.h"
 
-int Detail(char *dev, int brief, int test)
+int Detail(char *dev, int brief, int test, char *homehost)
 {
        /*
         * Print out details for an md array by using
@@ -268,7 +268,7 @@ This is pretty boring
                } else if (e && e->percent >= 0)
                        printf("\n");
                if (super && st)
-                       st->ss->detail_super(super);
+                       st->ss->detail_super(super, homehost);
 
                printf("    Number   Major   Minor   RaidDevice State\n");
        }
diff --git a/mdadm.c b/mdadm.c
index d123e49aafbba6a9fd790e88ded260f61757e258..de0a503e316c58f3558f9dc42fc82b85dfc9903d 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1069,7 +1069,7 @@ int main(int argc, char *argv[])
                                                                e->dev);
                                                        continue;
                                                }
-                                               rv |= Detail(name, verbose>1?0:verbose+1, test);
+                                               rv |= Detail(name, verbose>1?0:verbose+1, test, homehost);
                                                put_md_name(name);
                                        }
                                } else  if (devmode == 'S' && scan) {
@@ -1114,7 +1114,7 @@ int main(int argc, char *argv[])
                        for (dv=devlist ; dv; dv=dv->next) {
                                switch(dv->disposition) {
                                case 'D':
-                                       rv |= Detail(dv->devname, brief?1+verbose:0, test); continue;
+                                       rv |= Detail(dv->devname, brief?1+verbose:0, test, homehost); continue;
                                case 'K': /* Zero superblock */
                                        rv |= Kill(dv->devname, force, quiet); continue;
                                case 'Q':
diff --git a/mdadm.h b/mdadm.h
index 7bfd8cb28e918649fa982320ff8e4cf610feed53..2a2529f3dce1a8de3a59da23e6a10a9b0985aeaf 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -274,7 +274,7 @@ extern char *map_dev(int major, int minor, int create);
 extern struct superswitch {
        void (*examine_super)(void *sbv);
        void (*brief_examine_super)(void *sbv);
-       void (*detail_super)(void *sbv);
+       void (*detail_super)(void *sbv, char *homehost);
        void (*brief_detail_super)(void *sbv);
        void (*uuid_from_super)(int uuid[4], void *sbv);
        void (*getinfo_super)(struct mdinfo *info, void *sbv);
@@ -358,7 +358,7 @@ extern int Create(struct supertype *st, char *mddev, int mdfd,
                  int runstop, int verbose, int force, int assume_clean,
                  char *bitmap_file, int bitmap_chunk, int write_behind, int delay);
 
-extern int Detail(char *dev, int brief, int test);
+extern int Detail(char *dev, int brief, int test, char *homehost);
 extern int Query(char *dev);
 extern int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust,
                   struct supertype *forcest);
index 7fe2336666f8aed2307f831d157c74e51c0e3b49..d1fbfaeee5c9970f5dba82500d2869bb486b46d9 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -231,7 +231,7 @@ static void brief_examine_super0(void *sbv)
        printf("\n");
 }
 
-static void detail_super0(void *sbv)
+static void detail_super0(void *sbv, char *homehost)
 {
        mdp_super_t *sb = sbv;
        printf("           UUID : ");
@@ -240,6 +240,13 @@ static void detail_super0(void *sbv)
                       sb->set_uuid2, sb->set_uuid3);
        else
                printf("%08x", sb->set_uuid0);
+       if (homehost) {
+               unsigned char *hash = SHA1((unsigned char *)homehost,
+                                          strlen(homehost),
+                                          NULL);
+               if (memcmp(&sb->set_uuid2, hash, 8)==0)
+                       printf(" (local to host %s)", homehost);
+       }
        printf("\n         Events : %d.%d\n\n", sb->events_hi, sb->events_lo);
 }
 
index a29795a617225a1fd05e8980d0c2b6f2f52b8293..77118d42b1eee581667764324ef86cfd32b539ad 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -317,13 +317,18 @@ static void brief_examine_super1(void *sbv)
        printf("\n");
 }
 
-static void detail_super1(void *sbv)
+static void detail_super1(void *sbv, char *homehost)
 {
        struct mdp_superblock_1 *sb = sbv;
        int i;
-
-       printf("           Name : %.32s\n", sb->set_name);
-       printf("           UUID : ");
+       int l = homehost ? strlen(homehost) : 0;
+
+       printf("           Name : %.32s", sb->set_name);
+       if (l > 0 && l < 32 &&
+           sb->set_name[l] == ':' &&
+           strncmp(sb->set_name, homehost, l) == 0)
+               printf("  (local to host %s)", homehost);
+       printf("\n           UUID : ");
        for (i=0; i<16; i++) {
                if ((i&3)==0 && i != 0) printf(":");
                printf("%02x", sb->set_uuid[i]);