int Build(char *mddev, int chunk, int level, int layout,
int raiddisks, mddev_dev_t devlist, int assume_clean,
char *bitmap_file, int bitmap_chunk, int write_behind,
- int delay, int verbose, int autof)
+ int delay, int verbose, int autof, unsigned long long size)
{
/* Build a linear or raid0 arrays without superblocks
* We cannot really do any checks, we just do it.
int subdevs = 0, missing_disks = 0;
mddev_dev_t dv;
int bitmap_fd;
- unsigned long long size = ~0ULL;
unsigned long long bitmapsize;
int mdfd;
char chosen_name[1024];
if (vers >= 9000) {
mdu_array_info_t array;
array.level = level;
- array.size = 0;
+ array.size = size;
array.nr_disks = raiddisks;
array.raid_disks = raiddisks;
array.md_minor = 0;
(size == 0 || dsize < size))
size = dsize;
close(fd);
- if (vers>= 9000) {
+ if (vers >= 9000) {
mdu_disk_info_t disk;
disk.number = i;
disk.raid_disk = i;
mdadm.klibc : $(SRCS) mdadm.h
rm -f $(OBJS)
- gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 $(CFLAGS) $(SRCS)
+ $(CC) -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 $(CFLAGS) $(SRCS)
mdadm.Os : $(SRCS) mdadm.h
- gcc -o mdadm.Os $(CFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
+ $(CC) -o mdadm.Os $(CFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
mdadm.O2 : $(SRCS) mdadm.h
- gcc -o mdadm.O2 $(CFLAGS) -DHAVE_STDINT_H -O2 $(SRCS)
+ $(CC) -o mdadm.O2 $(CFLAGS) -DHAVE_STDINT_H -O2 $(SRCS)
mdmon : $(MON_OBJS)
$(CC) $(LDFLAGS) -o mdmon $(MON_OBJS) $(LDLIBS)
fprintf(stderr, Name ": re-added %s\n", dv->devname);
continue;
}
+ if (errno == ENOMEM || errno == EROFS) {
+ fprintf(stderr, Name ": add new device failed for %s: %s\n",
+ dv->devname, strerror(errno));
+ return 1;
+ }
/* fall back on normal-add */
}
}
int rv = 1;
char buf[64];
int swap;
+ __u32 uuid32[4];
info = bitmap_file_read(filename, brief, &st);
if (!info)
#else
swap = 1;
#endif
- if (swap) {
- printf(" UUID : %08x:%08x:%08x:%08x\n",
- swapl(*(__u32 *)(sb->uuid+0)),
- swapl(*(__u32 *)(sb->uuid+4)),
- swapl(*(__u32 *)(sb->uuid+8)),
- swapl(*(__u32 *)(sb->uuid+12)));
- } else {
- printf(" UUID : %08x:%08x:%08x:%08x\n",
- *(__u32 *)(sb->uuid+0),
- *(__u32 *)(sb->uuid+4),
- *(__u32 *)(sb->uuid+8),
- *(__u32 *)(sb->uuid+12));
- }
+ memcpy(uuid32, sb->uuid, 16);
+ if (swap)
+ printf(" UUID : %08x:%08x:%08x:%08x\n",
+ swapl(uuid32[0]),
+ swapl(uuid32[1]),
+ swapl(uuid32[2]),
+ swapl(uuid32[3]));
+ else
+ printf(" UUID : %08x:%08x:%08x:%08x\n",
+ uuid32[0],
+ uuid32[1],
+ uuid32[2],
+ uuid32[3]);
+
printf(" Events : %llu\n", (unsigned long long)sb->events);
printf(" Events Cleared : %llu\n", (unsigned long long)sb->events_cleared);
printf(" State : %s\n", bitmap_state(sb->state));
case O(GROW,'z'):
- case O(CREATE,'z'): /* size */
+ case O(CREATE,'z'):
+ case O(BUILD,'z'): /* size */
if (size >= 0) {
fprintf(stderr, Name ": size may only be specified once. "
"Second value is %s.\n", optarg);
rv = Build(devlist->devname, chunk, level, layout,
raiddisks, devlist->next, assume_clean,
bitmap_file, bitmap_chunk, write_behind,
- delay, verbose-quiet, autof);
+ delay, verbose-quiet, autof, size);
break;
case CREATE:
if (delay == 0) delay = DEFAULT_BITMAP_DELAY;
extern int Build(char *mddev, int chunk, int level, int layout,
int raiddisks, mddev_dev_t devlist, int assume_clean,
char *bitmap_file, int bitmap_chunk, int write_behind,
- int delay, int verbose, int autof);
+ int delay, int verbose, int autof, unsigned long long size);
extern int Create(struct supertype *st, char *mddev,
if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 ||
read(rfd, sb->device_uuid, 16) != 16) {
- *(__u32*)(sb->device_uuid) = random();
- *(__u32*)(sb->device_uuid+4) = random();
- *(__u32*)(sb->device_uuid+8) = random();
- *(__u32*)(sb->device_uuid+12) = random();
+ __u32 r[4] = {random(), random(), random(), random()};
+ memcpy(sb->device_uuid, r, 16);
}
sb->dev_roles[i] =
else {
if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 ||
read(rfd, sb->set_uuid, 16) != 16) {
- *(__u32*)(sb->set_uuid) = random();
- *(__u32*)(sb->set_uuid+4) = random();
- *(__u32*)(sb->set_uuid+8) = random();
- *(__u32*)(sb->set_uuid+12) = random();
+ __u32 r[4] = {random(), random(), random(), random()};
+ memcpy(sb->set_uuid, r, 16);
}
if (rfd >= 0) close(rfd);
}
if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 ||
read(rfd, sb->device_uuid, 16) != 16) {
- *(__u32*)(sb->device_uuid) = random();
- *(__u32*)(sb->device_uuid+4) = random();
- *(__u32*)(sb->device_uuid+8) = random();
- *(__u32*)(sb->device_uuid+12) = random();
+ __u32 r[4] = {random(), random(), random(), random()};
+ memcpy(sb->device_uuid, r, 16);
}
- if (rfd >= 0) close(rfd);
+ if (rfd >= 0)
+ close(rfd);
+
sb->events = 0;
refst =*st;