]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm-1.0.1 mdadm-1.0.1
authorNeil Brown <neilb@suse.de>
Mon, 20 May 2002 11:17:18 +0000 (11:17 +0000)
committerNeil Brown <neilb@suse.de>
Mon, 20 May 2002 11:17:18 +0000 (11:17 +0000)
ChangeLog
Examine.c
ReadMe.c
mdadm.8
mdadm.c
mdadm.h
mdadm.spec
util.c

index a5ed49fd1090294e1998191f5457971a5a91f004..43adfa24390fbf316a56d71df936045d7c6f44b3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-Changes Prior to 1.0.0 reease
+Changes Prior to this release
+    -   Round off MB/GiB etc values instead of round down.
+    -   Add --sparc2.2 option to examine to shift superblock around
+       and --sparc2.2update to rewrite the superblock
+       
+Changes Prior to 1.0.0 release
     -   Allow --config with Misc mode (for --examine --scan)
     -   Add $(CXFLAGS) to end of CFLAGS in makefile
     -   When making an N disk raid5 array, the Nth drive
     -   Allow --config with Misc mode (for --examine --scan)
     -   Add $(CXFLAGS) to end of CFLAGS in makefile
     -   When making an N disk raid5 array, the Nth drive
index 2bc3806aaeb7a52c04d4ed99b067982246b6dfa3..b886afc27f75612646b836c42cd3bd155f0cb63c 100644 (file)
--- a/Examine.c
+++ b/Examine.c
@@ -35,7 +35,7 @@
 #endif
 #include       "md_u.h"
 #include       "md_p.h"
 #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
 {
 
        /* Read the raid superblock from a device and
@@ -162,6 +162,17 @@ int Examine(mddev_dev_t devlist, int brief, int scan)
                                printf("       Checksum : %x - correct\n", super.sb_csum);
                        else
                                printf("       Checksum : %x - expected %x\n", super.sb_csum, calc_sb_csum(&super));
                                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) {
                        printf("         Events : %d.%d\n", super.events_hi, super.events_lo);
                        printf("\n");
                        if (super.level == 5) {
@@ -199,6 +210,23 @@ int Examine(mddev_dev_t devlist, int brief, int scan)
                                printf("\n");
                        }
                }
                                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;
        }
        if (brief) {
                struct array *ap;
index afb26d2f2fae3c4cad058cc84c3b85c46432d933..5c67eebaf950bc3de87d1296c12904c2a8cc2193 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -29,7 +29,7 @@
 
 #include "mdadm.h"
 
 
 #include "mdadm.h"
 
-char Version[] = Name " - v1.0.0 - 10 May 2002\n";
+char Version[] = Name " - v1.0.1 - 20 May 2002\n";
 /*
  * File: ReadMe.c
  *
 /*
  * File: ReadMe.c
  *
@@ -138,6 +138,8 @@ struct option long_options[] = {
 
     /* For Detail/Examine */
     {"brief",    0, 0, 'b'},
 
     /* For Detail/Examine */
     {"brief",    0, 0, 'b'},
+    {"sparc2.2",  0, 0, 22},
+    {"sparc2.2update", 0, 0, 23},
 
     /* For Follow/monitor */
     {"mail",      1, 0, 'm'},
 
     /* For Follow/monitor */
     {"mail",      1, 0, 'm'},
diff --git a/mdadm.8 b/mdadm.8
index 2d45ff01e04aca362775ad0fafa41d975e48615a..a64ae65651e1e5a8279e041407188a842f737048 100644 (file)
--- a/mdadm.8
+++ b/mdadm.8
@@ -594,9 +594,14 @@ is given, then any other md devices that appear in
 will also be monitored.
 
 The result of monitoring the arrays is the generation of events.
 will also be monitored.
 
 The result of monitoring the arrays is the generation of events.
-These events are passed to a separate program (is specified) and may
+These events are passed to a separate program (if specified) and may
 be mailed to a given E-mail address.
 
 be mailed to a given E-mail address.
 
+When passing event to program, the program is run once for each event
+and is given 2 or 3 command-line arguements.  The first is the
+name of the event (see below).  The second is the name of the
+md device which is affected, and the third is the name of a related
+device if relevant, such as a component device that has failed.
 
 If
 .B --scan
 
 If
 .B --scan
diff --git a/mdadm.c b/mdadm.c
index b01af945da754527f233ee8092128cfe5f82c282..95e7005a9c40920ca9132a973f94ec4390a2205d 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -69,6 +69,7 @@ int main(int argc, char *argv[])
        char devmode = 0;
        int runstop = 0;
        int readonly = 0;
        char devmode = 0;
        int runstop = 0;
        int readonly = 0;
+       int SparcAdjust = 0;
        mddev_dev_t devlist = NULL;
        mddev_dev_t *devlistend = & devlist;
        mddev_dev_t dv;
        mddev_dev_t devlist = NULL;
        mddev_dev_t *devlistend = & devlist;
        mddev_dev_t dv;
@@ -481,6 +482,20 @@ int main(int argc, char *argv[])
                        devmode = opt;
                        continue;
 
                        devmode = opt;
                        continue;
 
+               case O(MISC, 22):
+                       if (devmode != 'E') {
+                               fprintf(stderr, Name ": --sparc2.2 only allowed with --examine\n");
+                               exit(2);
+                       }
+                       SparcAdjust = 1;
+                       continue;
+               case O(MISC,23):
+                       if (devmode != 'E') {
+                               fprintf(stderr, Name ": --sparc2.2update only allowed with --examine\n");
+                               exit(2);
+                       }
+                       SparcAdjust = 2;
+                       continue;
                }
                /* We have now processed all the valid options. Anything else is
                 * an error
                }
                /* We have now processed all the valid options. Anything else is
                 * an error
@@ -596,7 +611,7 @@ int main(int argc, char *argv[])
                                fprintf(stderr, Name ": No devices listed in %s\n", configfile?configfile:DefaultConfFile);
                                exit(1);
                        }
                                fprintf(stderr, Name ": No devices listed in %s\n", configfile?configfile:DefaultConfFile);
                                exit(1);
                        }
-                       rv = Examine(devlist, scan?!verbose:brief, scan);
+                       rv = Examine(devlist, scan?!verbose:brief, scan, SparcAdjust);
                } else {
                        if (devlist == NULL) {
                                if ((devmode == 'S' ||devmode=='D') && scan) {
                } else {
                        if (devlist == NULL) {
                                if ((devmode == 'S' ||devmode=='D') && scan) {
diff --git a/mdadm.h b/mdadm.h
index a44ce9505a9e079ff328cba840b3ed706d0cf8fa..50860ed5acee394eeb56767798dd98c241c247bf 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -164,7 +164,7 @@ extern int Create(char *mddev, int mdfd,
 
 extern int Detail(char *dev, int brief);
 extern int Query(char *dev);
 
 extern int Detail(char *dev, int brief);
 extern int Query(char *dev);
-extern int Examine(mddev_dev_t devlist, int brief, int scan);
+extern int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust);
 extern int Monitor(mddev_dev_t devlist,
                   char *mailaddr, char *alert_cmd,
                   int period, int scan,
 extern int Monitor(mddev_dev_t devlist,
                   char *mailaddr, char *alert_cmd,
                   int period, int scan,
index fffd1888deb13eb4950c95cb2d7fead9e539a1c6..04d6ec260ce4c7b2a34d86606a194f3d5e67a27e 100644 (file)
@@ -1,6 +1,6 @@
 Summary:     mdadm is used for controlling Linux md devices (aka RAID arrays)
 Name:        mdadm
 Summary:     mdadm is used for controlling Linux md devices (aka RAID arrays)
 Name:        mdadm
-Version:     1.0.0
+Version:     1.0.1
 Release:     1
 Source:      http://www.cse.unsw.edu.au/~neilb/source/mdadm/mdadm-%{version}.tgz
 URL:         http://www.cse.unsw.edu.au/~neilb/source/mdadm/
 Release:     1
 Source:      http://www.cse.unsw.edu.au/~neilb/source/mdadm/mdadm-%{version}.tgz
 URL:         http://www.cse.unsw.edu.au/~neilb/source/mdadm/
diff --git a/util.c b/util.c
index f818eabc6998b7316ab2f507ebe1625d3417d6d8..f2d16be149ff23750cd9204b98b6d69ec777c790 100644 (file)
--- a/util.c
+++ b/util.c
@@ -437,16 +437,16 @@ char *human_size(long long bytes)
        else if (bytes < 2*1024LL*1024LL*1024LL)
                sprintf(buf, " (%ld.%02ld MiB %ld.%02ld MB)",
                        (long)(bytes>>20),
        else if (bytes < 2*1024LL*1024LL*1024LL)
                sprintf(buf, " (%ld.%02ld MiB %ld.%02ld MB)",
                        (long)(bytes>>20),
-                       (long)(bytes&0xfffff)/(0x100000/100),
+                       (long)((bytes&0xfffff)+0x100000/200)/(0x100000/100),
                        (long)(bytes/1000/1000),
                        (long)(bytes/1000/1000),
-                       (long)((bytes%1000000)/10000)
+                       (long)(((bytes%1000000)+5000)/10000)
                        );
        else
                sprintf(buf, " (%ld.%02ld GiB %ld.%02ld GB)",
                        (long)(bytes>>30),
                        );
        else
                sprintf(buf, " (%ld.%02ld GiB %ld.%02ld GB)",
                        (long)(bytes>>30),
-                       (long)((bytes>>10)&0xfffff)/(0x100000/100),
+                       (long)(((bytes>>10)&0xfffff)+0x100000/200)/(0x100000/100),
                        (long)(bytes/1000LL/1000LL/1000LL),
                        (long)(bytes/1000LL/1000LL/1000LL),
-                       (long)(((bytes/1000)%1000000)/10000)
+                       (long)((((bytes/1000)%1000000)+50000)/10000)
                        );
        return buf;
 }
                        );
        return buf;
 }
@@ -458,17 +458,17 @@ char *human_size_brief(long long bytes)
 
        if (bytes < 5000*1024)
                sprintf(buf, "%ld.%02ldKiB",
 
        if (bytes < 5000*1024)
                sprintf(buf, "%ld.%02ldKiB",
-                       (long)(bytes>>10), (long)((bytes&1023)*100/1024)
+                       (long)(bytes>>10), (long)(((bytes&1023)*100+512)/1024)
                        );
        else if (bytes < 2*1024LL*1024LL*1024LL)
                sprintf(buf, "%ld.%02ldMiB",
                        (long)(bytes>>20),
                        );
        else if (bytes < 2*1024LL*1024LL*1024LL)
                sprintf(buf, "%ld.%02ldMiB",
                        (long)(bytes>>20),
-                       (long)(bytes&0xfffff)/(0x100000/100)
+                       (long)((bytes&0xfffff)+0x100000/200)/(0x100000/100)
                        );
        else
                sprintf(buf, "%ld.%02ldGiB",
                        (long)(bytes>>30),
                        );
        else
                sprintf(buf, "%ld.%02ldGiB",
                        (long)(bytes>>30),
-                       (long)((bytes>>10)&0xfffff)/(0x100000/100)
+                       (long)(((bytes>>10)&0xfffff)+0x100000/200)/(0x100000/100)
                        );
        return buf;
 }
                        );
        return buf;
 }