From 1e0d770c0f2e78bb334cd75d3d71c8c7d3b8f621 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 6 Feb 2006 04:18:12 +0000 Subject: [PATCH] Release some compile fixes. Signed-off-by: Neil Brown --- ChangeLog | 10 +++++++++- Makefile | 3 +++ ReadMe.c | 2 +- bitmap.c | 4 ++-- inventory | 1 + makedist | 15 ++++++++++++--- mdadm.8 | 8 +++++++- mdadm.c | 11 +++++++++-- mdadm.h | 14 ++++++++++++++ mdadm.spec | 2 +- mdassemble.8 | 2 +- mdopen.c | 15 ++++++++++----- super0.c | 7 ++++--- super1.c | 22 ++++++++++++---------- 14 files changed, 86 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 372c1fc5..c7722b0f 100644 --- 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: diff --git a/Makefile b/Makefile index 5f9ba314..c310fca7 100644 --- a/Makefile +++ b/Makefile @@ -137,5 +137,8 @@ clean : dist : clean ./makedist +testdist : everything clean + ./makedist test + TAGS : etags *.h *.c diff --git a/ReadMe.c b/ReadMe.c index 2aaa6f14..2e13b5d9 100644 --- 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 diff --git a/bitmap.c b/bitmap.c index afa10cf0..b044cd82 100644 --- a/bitmap.c +++ b/bitmap.c @@ -21,7 +21,6 @@ #include #include #include "mdadm.h" -#include #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) diff --git a/inventory b/inventory index eab31945..f885957f 100644 --- 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 diff --git a/makedist b/makedist index 9c41233c..b7fbc8e8 100755 --- 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 649a381d..15cc178e 100644 --- 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 7b6c3d01..1c9388c2 100644 --- 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 5df6eeed..00abefe0 100644 --- 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 +/* #include "asm/byteorder.h" Redhat don't like this so... */ +#if __BYTE_ORDER == __LITTLE_ENDIAN +# include +#elif __BYTE_ORDER == __BIG_ENDIAN +# include +#elif __BYTE_ORDER == __PDP_ENDIAN +# include +#else +# error "unknown endianness." +#endif + + + /* general information that might be extracted from a superblock */ struct mdinfo { mdu_array_info_t array; diff --git a/mdadm.spec b/mdadm.spec index 18ff5d13..86482571 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -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/ diff --git a/mdassemble.8 b/mdassemble.8 index da888c5f..f2aea687 100644 --- a/mdassemble.8 +++ b/mdassemble.8 @@ -1,5 +1,5 @@ .\" -*- nroff -*- -.TH MDASSEMBLE 8 "" v2.3 +.TH MDASSEMBLE 8 "" v2.3.1 .SH NAME mdassemble \- assemble MD devices .I aka diff --git a/mdopen.c b/mdopen.c index 0656ce26..e4139e55 100644 --- 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); diff --git a/super0.c b/super0.c index 84930d8a..52be23dd 100644 --- a/super0.c +++ b/super0.c @@ -28,7 +28,6 @@ */ #include "mdadm.h" -#include /* * 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) { diff --git a/super1.c b/super1.c index b4af6cc8..dd852e58 100644 --- a/super1.c +++ b/super1.c @@ -28,8 +28,6 @@ */ #include "mdadm.h" -#include -#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)); -- 2.39.2