return (a*1000000)+(b*1000)+c;
}
-int enough(int level, int raid_disks, int avail_disks)
+int enough(int level, int raid_disks, int layout,
+ char *avail, int avail_disks)
{
+ int copies, first;
switch (level) {
- case 10: return 1; /* a lie, but it is hard to tell */
+ case 10:
+ /* This is the tricky one - we need to check
+ * which actual disks are present.
+ */
+ copies = (layout&255)* (layout>>8);
+ first=0;
+ do {
+ /* there must be one of the 'copies' form 'first' */
+ int n = copies;
+ int cnt=0;
+ while (n--) {
+ if (avail[first])
+ cnt++;
+ first = (first+1) % raid_disks;
+ }
+ if (cnt == 0)
+ return 0;
+
+ } while (first != 0);
+ return 1;
case -4:
return avail_disks>= 1;
*
*/
unsigned char sb[1024];
- int size;
+ unsigned long size;
if (lseek(fd, 64*1024, 0) != 64*1024)
return 0;
if (read(fd, sb, 1024) != 1024)
return 0;
fprintf(stderr, Name ": %s appears to contain a reiserfs file system\n",name);
size = sb[0]|(sb[1]|(sb[2]|sb[3]<<8)<<8)<<8;
- fprintf(stderr, " size = %dK\n", size*4);
+ fprintf(stderr, " size = %luK\n", size*4);
return 1;
}
struct mdinfo info;
struct mddev_ident_s ident;
time_t crtime;
+ char *level;
struct supertype *st = guess_super(fd);
if (!st) return 0;
st->ss->getinfo_super(&info, &ident, super);
free(super);
crtime = info.array.ctime;
- fprintf(stderr, " level=%d devices=%d ctime=%s",
- info.array.level, info.array.raid_disks, ctime(&crtime));
+ level = map_num(pers, info.array.level);
+ if (!level) level = "-unknown-";
+ fprintf(stderr, " level=%s devices=%d ctime=%s",
+ level, info.array.raid_disks, ctime(&crtime));
return 1;
}
unlink(name);
}
-
+int dev_open(char *dev, int flags)
+{
+ /* like 'open', but if 'dev' matches %d:%d, create a temp
+ * block device and open that
+ */
+ char *e;
+ int fd = -1;
+ char devname[32];
+ int major = strtoul(dev, &e, 0);
+ int minor;
+ if (e > dev && *e == ':' && e[1] &&
+ (minor = strtoul(e+1, &e, 0)) >= 0 &&
+ *e == 0) {
+ snprintf(devname, sizeof(devname), "/dev/.tmp.md.%d:%d", major, minor);
+ if (mknod(devname, S_IFBLK|0600, makedev(major, minor))==0) {
+ fd = open(devname, flags);
+ unlink(devname);
+ }
+ } else
+ fd = open(dev, flags);
+ return fd;
+}
struct superswitch *superlist[] = { &super0, &super1, NULL };
return NULL;
}
+
#ifdef __TINYC__
/* tinyc doesn't optimize this check in ioctl.h out ... */
unsigned int __invalid_size_argument_for_IOC = 0;