When building mdadm.O2, set _FORTIFY_SOURCE to get more
warnings, and also build mdmon.O2 to find warnings in that
code too.
Then fix the warnings.
Suggested-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
+/* FIXME return status is never checked */
int grow_backup(struct mdinfo *sra,
unsigned long long offset, /* per device */
unsigned long stripes, /* per device */
int grow_backup(struct mdinfo *sra,
unsigned long long offset, /* per device */
unsigned long stripes, /* per device */
bsb.sb_csum2 = bsb_csum((char*)&bsb,
((char*)&bsb.sb_csum2)-((char*)&bsb));
bsb.sb_csum2 = bsb_csum((char*)&bsb,
((char*)&bsb.sb_csum2)-((char*)&bsb));
- lseek64(destfd[i], destoffsets[i] - 4096, 0);
- write(destfd[i], &bsb, 512);
+ rv |= lseek64(destfd[i], destoffsets[i] - 4096, 0);
+ rv = rv ?: write(destfd[i], &bsb, 512);
if (destoffsets[i] > 4096) {
if (destoffsets[i] > 4096) {
- lseek64(destfd[i], destoffsets[i]+stripes*chunk*odata, 0);
- write(destfd[i], &bsb, 512);
+ rv |= lseek64(destfd[i], destoffsets[i]+stripes*chunk*odata, 0);
+ rv = rv ?: write(destfd[i], &bsb, 512);
}
/* in 2.6.30, the value reported by sync_completed can be
}
/* in 2.6.30, the value reported by sync_completed can be
* The various caller give appropriate values so that
* every works.
*/
* The various caller give appropriate values so that
* every works.
*/
+/* FIXME return value is often ignored */
int wait_backup(struct mdinfo *sra,
unsigned long long offset, /* per device */
unsigned long long blocks, /* per device */
int wait_backup(struct mdinfo *sra,
unsigned long long offset, /* per device */
unsigned long long blocks, /* per device */
int fd = sysfs_get_fd(sra, NULL, "sync_completed");
unsigned long long completed;
int i;
int fd = sysfs_get_fd(sra, NULL, "sync_completed");
unsigned long long completed;
int i;
bsb.length = __cpu_to_le64(0);
}
bsb.mtime = __cpu_to_le64(time(0));
bsb.length = __cpu_to_le64(0);
}
bsb.mtime = __cpu_to_le64(time(0));
for (i = 0; i < dests; i++) {
bsb.devstart = __cpu_to_le64(destoffsets[i]/512);
bsb.sb_csum = bsb_csum((char*)&bsb, ((char*)&bsb.sb_csum)-((char*)&bsb));
if (memcmp(bsb.magic, "md_backup_data-2", 16) == 0)
bsb.sb_csum2 = bsb_csum((char*)&bsb,
((char*)&bsb.sb_csum2)-((char*)&bsb));
for (i = 0; i < dests; i++) {
bsb.devstart = __cpu_to_le64(destoffsets[i]/512);
bsb.sb_csum = bsb_csum((char*)&bsb, ((char*)&bsb.sb_csum)-((char*)&bsb));
if (memcmp(bsb.magic, "md_backup_data-2", 16) == 0)
bsb.sb_csum2 = bsb_csum((char*)&bsb,
((char*)&bsb.sb_csum2)-((char*)&bsb));
- lseek64(destfd[i], destoffsets[i]-4096, 0);
- write(destfd[i], &bsb, 512);
+ rv |= lseek64(destfd[i], destoffsets[i]-4096, 0);
+ rv = rv ?: write(destfd[i], &bsb, 512);
}
static void fail(char *msg)
{
}
static void fail(char *msg)
{
- write(2, msg, strlen(msg));
- write(2, "\n", 1);
- exit(1);
+ int rv;
+ rv = write(2, msg, strlen(msg));
+ rv |= write(2, "\n", 1);
+ exit(rv ? 1 : 2);
}
static char *abuf, *bbuf;
}
static char *abuf, *bbuf;
free(abuf);
free(bbuf);
abuflen = len;
free(abuf);
free(bbuf);
abuflen = len;
- posix_memalign((void**)&abuf, 4096, abuflen);
- posix_memalign((void**)&bbuf, 4096, abuflen);
+ if (posix_memalign((void**)&abuf, 4096, abuflen) ||
+ posix_memalign((void**)&bbuf, 4096, abuflen)) {
+ abuflen = 0;
+ /* just stop validating on mem-alloc failure */
+ return;
+ }
}
lseek64(bfd, offset, 0);
}
lseek64(bfd, offset, 0);
char *buf;
int degraded = 0;
char *buf;
int degraded = 0;
- posix_memalign((void**)&buf, 4096, disks * chunk);
+ if (posix_memalign((void**)&buf, 4096, disks * chunk))
+ /* Don't start the 'reshape' */
+ return 0;
sysfs_set_num(sra, NULL, "suspend_hi", 0);
sysfs_set_num(sra, NULL, "suspend_lo", 0);
grow_backup(sra, 0, stripes,
sysfs_set_num(sra, NULL, "suspend_hi", 0);
sysfs_set_num(sra, NULL, "suspend_lo", 0);
grow_backup(sra, 0, stripes,
int rv;
int degraded = 0;
int rv;
int degraded = 0;
- posix_memalign((void**)&buf, 4096, disks * chunk);
+ if (posix_memalign((void**)&buf, 4096, disks * chunk))
+ return 0;
start = sra->component_size - stripes * chunk/512;
sysfs_set_num(sra, NULL, "sync_max", start);
sysfs_set_str(sra, NULL, "sync_action", "reshape");
start = sra->component_size - stripes * chunk/512;
sysfs_set_num(sra, NULL, "sync_max", start);
sysfs_set_str(sra, NULL, "sync_action", "reshape");
- posix_memalign((void**)&buf, 4096, disks * chunk);
+ if (posix_memalign((void**)&buf, 4096, disks * chunk))
+ return 0;
sysfs_set_num(sra, NULL, "suspend_lo", 0);
sysfs_set_num(sra, NULL, "suspend_hi", 0);
sysfs_set_num(sra, NULL, "suspend_lo", 0);
sysfs_set_num(sra, NULL, "suspend_hi", 0);
super-ddf.o sha1.o crc32.o msg.o bitmap.o \
platform-intel.o probe_roms.o
super-ddf.o sha1.o crc32.o msg.o bitmap.o \
platform-intel.o probe_roms.o
+MON_SRCS = mdmon.c monitor.c managemon.c util.c mdstat.c sysfs.c config.c \
+ Kill.c sg_io.c dlink.c ReadMe.c super0.c super1.c super-intel.c \
+ super-ddf.c sha1.c crc32.c msg.c bitmap.c \
+ platform-intel.c probe_roms.c
STATICSRC = pwgr.c
STATICOBJS = pwgr.o
STATICSRC = pwgr.c
STATICOBJS = pwgr.o
mdadm.Os : $(SRCS) mdadm.h
$(CC) -o mdadm.Os $(CFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
mdadm.Os : $(SRCS) mdadm.h
$(CC) -o mdadm.Os $(CFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
-mdadm.O2 : $(SRCS) mdadm.h
- $(CC) -o mdadm.O2 $(CFLAGS) -DHAVE_STDINT_H -O2 $(SRCS)
+mdadm.O2 : $(SRCS) mdadm.h mdmon.O2
+ $(CC) -o mdadm.O2 $(CFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(SRCS)
+
+mdmon.O2 : $(MON_SRCS) mdadm.h mdmon.h
+ $(CC) -o mdmon.O2 $(CFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(MON_SRCS)
mdmon : $(MON_OBJS)
$(CC) $(LDFLAGS) -o mdmon $(MON_OBJS) $(LDLIBS)
mdmon : $(MON_OBJS)
$(CC) $(LDFLAGS) -o mdmon $(MON_OBJS) $(LDLIBS)
fl = fcntl(sock, F_GETFL, 0);
fl &= ~O_NONBLOCK;
fcntl(sock, F_SETFL, fl);
fl = fcntl(sock, F_GETFL, 0);
fl &= ~O_NONBLOCK;
fcntl(sock, F_SETFL, fl);
+ n = read(sock, buf, 100);
+ /* Ignore result, it is just the wait that
+ * matters
+ */
}
void remove_pidfile(char *devname)
}
void remove_pidfile(char *devname)
int data_disks = raid_disks - (level == 0 ? 0 : level <= 5 ? 1 : 2);
int data_disks = raid_disks - (level == 0 ? 0 : level <= 5 ? 1 : 2);
- posix_memalign((void**)&stripe_buf, 4096, raid_disks * chunk_size);
+ if (posix_memalign((void**)&stripe_buf, 4096, raid_disks * chunk_size))
+ stripe_buf = NULL;
if (zero == NULL) {
zero = malloc(chunk_size);
if (zero)
if (zero == NULL) {
zero = malloc(chunk_size);
if (zero)