]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Release some compile fixes.
authorNeil Brown <neilb@suse.de>
Mon, 6 Feb 2006 04:18:12 +0000 (04:18 +0000)
committerNeil Brown <neilb@suse.de>
Mon, 6 Feb 2006 04:18:12 +0000 (04:18 +0000)
Signed-off-by: Neil Brown <neilb@suse.de>
14 files changed:
ChangeLog
Makefile
ReadMe.c
bitmap.c
inventory
makedist
mdadm.8
mdadm.c
mdadm.h
mdadm.spec
mdassemble.8
mdopen.c
super0.c
super1.c

index 372c1fc5ecdea4928092e36475b0223c8413ac30..c7722b0ff6584bba0fb31916e76096584b632ce7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,12 @@
-Changes Prior to this release
+Changes Prior to 2.3.1 release
+    -   Fixed -O2 compile so I could make and RPM.
+    -   Type cast number to be printed %llu so it compiles on 64bit
+        machines. (Thanks Luca).
+    -   Stop using asm/byteorder.h - to make Redhat happy :-(
+    -   Require bitmap files to have a '/' in their name.
+    -   Error-check a few syscalls - code from SuSE package.
+
+Changes Prior to 2.3 release
     -   Try /etc/mdadm/mdadm.conf if /etc/mdadm.conf doesn't exist.
        This provided compatability for Debian.
     -   Fixed for version-1 superblock:
index 5f9ba314eb5b287f7fd672a6804ffbd4728ec551..c310fca7bd1f5c5e06f831ed4b43de9be9e5c5e9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -137,5 +137,8 @@ clean :
 dist : clean
        ./makedist
 
+testdist : everything clean
+       ./makedist test
+
 TAGS :
        etags *.h *.c
index 2aaa6f14a6f830f133aba41b5e4767f990c9c382..2e13b5d92e6f127a5f5d68a30f8e88fc30998650 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -30,7 +30,7 @@
 
 #include "mdadm.h"
 
-char Version[] = Name " - v2.3 - 2 February 2006\n";
+char Version[] = Name " - v2.3.1 - 6 February 2006\n";
 
 /*
  * File: ReadMe.c
index afa10cf00d21cc67b48debf2be35174a69424f05..b044cd822d57aaedfd4fc79930ea6da1943a585b 100644 (file)
--- a/bitmap.c
+++ b/bitmap.c
@@ -21,7 +21,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "mdadm.h"
-#include <asm/byteorder.h>
 
 #define min(a,b) (((a) < (b)) ? (a) : (b))
 
@@ -357,7 +356,8 @@ int CreateBitmap(char *filename, int force, char uuid[16],
        
        rv = 0;
        /* make the file be the right size (well, to the nearest byte) */
-       ftruncate(fileno(fp), filesize);
+       if (ftruncate(fileno(fp), filesize))
+               perror("ftrunace");
 out:
        fclose(fp);
        if (rv)
index eab31945e82d1ec656889f194ff941fffe6e7096..f885957fafd850e3db58172684d42b9804c81290 100644 (file)
--- a/inventory
+++ b/inventory
@@ -3,6 +3,7 @@ ANNOUNCE-2.0
 ANNOUNCE-2.1
 ANNOUNCE-2.2
 ANNOUNCE-2.3
+ANNOUNCE-2.3.1
 Assemble.c
 Build.c
 COPYING
index 9c41233c3d06273b9448ce21e1730cd92f198809..b7fbc8e8ce166256980f1a199addd891172bc069 100755 (executable)
--- a/makedist
+++ b/makedist
@@ -1,6 +1,12 @@
 #!/bin/sh
 arg=$1
 target=~/public_html/source/mdadm
+if [ " $arg" = " test" ]
+then
+  target=/tmp/mdadm-test
+  rm -rf $target
+  mkdir -p $target
+fi
 if [ -d $target ]
 then :
 else echo $target is not a directory
@@ -48,13 +54,16 @@ then
        rm $target/$base
        exit 1
   fi
-  rpmbuild -ta $target/$base
+  rpmbuild -ta $target/$base || exit 1
   find /home/neilb/src/RPM -name "*mdadm-$version-*" \
      -exec cp {} $target/RPM \;
   cp ANNOUNCE-$version $target/ANNOUNCE
   cp ChangeLog $target/ChangeLog
-  scp $target/$base master.kernel.org:/pub/linux/utils/raid/mdadm/mdadm-$version.tar.gz
-  scp $target/ANNOUNCE $target/ChangeLog master.kernel.org:/pub/linux/utils/raid/mdadm/
+  if [ " $arg" != " test" ]
+  then
+    scp $target/$base master.kernel.org:/pub/linux/utils/raid/mdadm/mdadm-$version.tar.gz
+    scp $target/ANNOUNCE $target/ChangeLog master.kernel.org:/pub/linux/utils/raid/mdadm/
+  fi
 else
   if [ ! -f $target/$base ] 
   then 
diff --git a/mdadm.8 b/mdadm.8
index 649a381d86a459d646167e0cc4529af610268417..15cc178ee90e4d33858ab87afe9fe80808d23bdf 100644 (file)
--- a/mdadm.8
+++ b/mdadm.8
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.TH MDADM 8 "" v2.3
+.TH MDADM 8 "" v2.3.1
 .SH NAME
 mdadm \- manage MD devices
 .I aka
@@ -249,6 +249,12 @@ The file
 .B none
 can be given when used with --grow to remove a bitmap.
 
+To help catch typing errors, the filename must contain at least one
+slash ('/') if it is a real file (not 'internal' or 'none').
+
+Note: bitmaps are only known to work on ext2 and ext3.  Using other
+filesystems may result in serious problems.
+
 .TP
 .BR --bitmap-chunk=
 Set the Chunksize of the bitmap. Each bit corresponds to that many
diff --git a/mdadm.c b/mdadm.c
index 7b6c3d01039c3d463494fb7f19131cf1596e64f9..1c9388c2e2ae052bbdc6fdf10a176307c7a68ef3 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -772,8 +772,15 @@ int main(int argc, char *argv[])
                case O(GROW,'b'):
                case O(BUILD,'b'):
                case O(CREATE,'b'): /* here we create the bitmap */
-                       bitmap_file = optarg;
-                       continue;
+                       if (strcmp(optarg, "internal")== 0 ||
+                           strcmp(optarg, "none")== 0 ||
+                           strchr(optarg, '/') != NULL) {
+                               bitmap_file = optarg;
+                               continue;
+                       }
+                       /* probable typo */
+                       fprintf(stderr, Name ": bitmap file must contain a '/', or be 'internal', or 'none'\n");
+                       exit(2);
 
                case O(GROW,4):
                case O(BUILD,4):
diff --git a/mdadm.h b/mdadm.h
index 5df6eeedd2aa44b8a1f14769a4548061abfd59a8..00abefe03c0fc8c99db68117a5b6d68daea6d616 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -71,6 +71,20 @@ char *strncpy(char *dest, const char *src, size_t n) __THROW;
 #include       "md_p.h"
 #include       "bitmap.h"
 
+#include <endian.h>
+/* #include "asm/byteorder.h" Redhat don't like this so... */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#  include <linux/byteorder/little_endian.h>
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#  include <linux/byteorder/big_endian.h>
+#elif __BYTE_ORDER == __PDP_ENDIAN
+#  include <linux/byteorder/pdp_endian.h>
+#else
+#  error "unknown endianness."
+#endif
+
+
+
 /* general information that might be extracted from a superblock */
 struct mdinfo {
        mdu_array_info_t        array;
index 18ff5d13b9b30d5b5d31f2b2a9b9b554ddacff3f..86482571760edb83543c4ca5bd49c80a2208dd05 100644 (file)
@@ -1,6 +1,6 @@
 Summary:     mdadm is used for controlling Linux md devices (aka RAID arrays)
 Name:        mdadm
-Version:     2.3
+Version:     2.3.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/
index da888c5fc7f8cb144e90436de40e3dad64d61122..f2aea6876e2242ded73b2db1c5f68e8f7f3738f2 100644 (file)
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.TH MDASSEMBLE 8 "" v2.3
+.TH MDASSEMBLE 8 "" v2.3.1
 .SH NAME
 mdassemble \- assemble MD devices
 .I aka
index 0656ce26dd3ee2f04f06a3ccd39f8226600a0c0c..e4139e551e92251655704683a1859cb8c78d1145 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -64,9 +64,12 @@ void make_parts(char *dev, int cnt)
                } else {
                        stb2 = stb;
                }
-               mknod(name, S_IFBLK | 0600, makedev(major, minor+i));
-               chown(name, stb2.st_uid, stb2.st_gid);
-               chmod(name, stb2.st_mode & 07777);
+               if (mknod(name, S_IFBLK | 0600, makedev(major, minor+i)))
+                       perror("mknod");
+               if (chown(name, stb2.st_uid, stb2.st_gid))
+                       perror("chown");
+               if (chmod(name, stb2.st_mode & 07777))
+                       perror("chmod");
                stat(name, &stb2);
                add_dev(name, &stb2, 0, NULL);
        }
@@ -205,8 +208,10 @@ int open_mddev(char *dev, int autof)
                                return -1;
                        }
                        if (must_remove) {
-                               chown(dev, stb.st_uid, stb.st_gid);
-                               chmod(dev, stb.st_mode & 07777);
+                               if (chown(dev, stb.st_uid, stb.st_gid))
+                                       perror("chown");
+                               if (chmod(dev, stb.st_mode & 07777))
+                                       perror("chmod");
                        }
                        stat(dev, &stb);
                        add_dev(dev, &stb, 0, NULL);
index 84930d8a4ab04dd21ef55c00d355b94fe587ac5c..52be23ddd15c54130aa6a2c05c655c5aaa8c6e5a 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -28,7 +28,6 @@
  */
 
 #include "mdadm.h"
-#include <asm/byteorder.h>
 
 /*
  * All handling for the 0.90.0 version superblock is in
@@ -124,7 +123,7 @@ static void examine_super0(void *sbv)
        printf("Preferred Minor : %d\n", sb->md_minor);
        printf("\n");
        if (sb->minor_version > 90 && (sb->reshape_position+1) != 0) {
-               printf("  Reshape pos'n : %llu%s\n", sb->reshape_position/2, human_size((long long)sb->reshape_position<<9));
+               printf("  Reshape pos'n : %llu%s\n", (unsigned long long)sb->reshape_position/2, human_size((long long)sb->reshape_position<<9));
                if (sb->delta_disks) {
                        printf("  Delta Devices : %d", sb->delta_disks);
                        if (sb->delta_disks)
@@ -807,7 +806,9 @@ int write_bitmap0(struct supertype *st, int fd, void *sbv)
                return 3;
 
 
-       write(fd, ((char*)sb)+MD_SB_BYTES, sizeof(bitmap_super_t));
+       if (write(fd, ((char*)sb)+MD_SB_BYTES, sizeof(bitmap_super_t)) !=
+           sizeof(bitmap_super_t))
+               return -2;
        towrite = 64*1024 - MD_SB_BYTES - sizeof(bitmap_super_t);
        memset(buf, 0xff, sizeof(buf));
        while (towrite > 0) {
index b4af6cc82deca7ca9bf602b9710cac11e82962cb..dd852e583fca0f97be8ba158f2302e6d30b09a49 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -28,8 +28,6 @@
  */
 
 #include "mdadm.h"
-#include <endian.h>
-#include "asm/byteorder.h"
 /*
  * The version-1 superblock :
  * All numeric fields are little-endian.
@@ -198,7 +196,7 @@ static void examine_super1(void *sbv)
                       (long)__le32_to_cpu(sb->bitmap_offset));
        }
        if (sb->feature_map & __le32_to_cpu(MD_FEATURE_RESHAPE_ACTIVE)) {
-               printf("  Reshape pos'n : %llu%s\n", __le64_to_cpu(sb->reshape_position)/2,
+               printf("  Reshape pos'n : %llu%s\n", (unsigned long long)__le64_to_cpu(sb->reshape_position)/2,
                       human_size(__le64_to_cpu(sb->reshape_position)<<9));
                if (__le32_to_cpu(sb->delta_disks)) {
                        printf("  Delta Devices : %d", __le32_to_cpu(sb->delta_disks));
@@ -1019,17 +1017,19 @@ add_internal_bitmap1(struct supertype *st, void *sbv,
 void locate_bitmap1(struct supertype *st, int fd, void *sbv)
 {
        unsigned long long offset;
-       struct mdp_superblock_1 *sb = NULL;
+       struct mdp_superblock_1 *sb;
+       int mustfree = 0;
 
-       if (sbv)
-               sb = sbv;
-       else
-               if (st->ss->load_super(st, fd, (void **)&sb, NULL))
+       if (!sbv) {
+               if (st->ss->load_super(st, fd, &sbv, NULL))
                        return; /* no error I hope... */
+               mustfree = 1;
+       }
+       sb = sbv;
 
        offset = __le64_to_cpu(sb->super_offset);
        offset += (long) __le32_to_cpu(sb->bitmap_offset);
-       if (!sbv)
+       if (mustfree)
                free(sb);
        lseek64(fd, offset<<9, 0);
 }
@@ -1045,7 +1045,9 @@ int write_bitmap1(struct supertype *st, int fd, void *sbv)
 
        locate_bitmap1(st, fd, sbv);
 
-       write(fd, ((char*)sb)+1024, sizeof(bitmap_super_t));
+       if (write(fd, ((char*)sb)+1024, sizeof(bitmap_super_t)) !=
+           sizeof(bitmap_super_t))
+               return -2;
        towrite = __le64_to_cpu(bms->sync_size) / (__le32_to_cpu(bms->chunksize)>>9);
        towrite = (towrite+7) >> 3; /* bits to bytes */
        memset(buf, 0xff, sizeof(buf));