Compiple fixes for mdassemble and diet-libc
This commit is contained in:
parent
54097ce72b
commit
ea24acd073
8
sysfs.c
8
sysfs.c
|
@ -84,10 +84,10 @@ struct mdinfo *sysfs_read(int fd, int devnum, unsigned long options)
|
||||||
if (ioctl(fd, RAID_VERSION, &vers) != 0)
|
if (ioctl(fd, RAID_VERSION, &vers) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (major(stb.st_rdev)==9)
|
if (major(stb.st_rdev)==9)
|
||||||
sprintf(sra->sys_name, "md%d", minor(stb.st_rdev));
|
sprintf(sra->sys_name, "md%d", (int)minor(stb.st_rdev));
|
||||||
else
|
else
|
||||||
sprintf(sra->sys_name, "md_d%d",
|
sprintf(sra->sys_name, "md_d%d",
|
||||||
minor(stb.st_rdev)>>MdpMinorShift);
|
(int)minor(stb.st_rdev)>>MdpMinorShift);
|
||||||
} else {
|
} else {
|
||||||
if (devnum >= 0)
|
if (devnum >= 0)
|
||||||
sprintf(sra->sys_name, "md%d", devnum);
|
sprintf(sra->sys_name, "md%d", devnum);
|
||||||
|
@ -246,10 +246,10 @@ unsigned long long get_component_size(int fd)
|
||||||
if (fstat(fd, &stb)) return 0;
|
if (fstat(fd, &stb)) return 0;
|
||||||
if (major(stb.st_rdev) == 9)
|
if (major(stb.st_rdev) == 9)
|
||||||
sprintf(fname, "/sys/block/md%d/md/component_size",
|
sprintf(fname, "/sys/block/md%d/md/component_size",
|
||||||
minor(stb.st_rdev));
|
(int)minor(stb.st_rdev));
|
||||||
else
|
else
|
||||||
sprintf(fname, "/sys/block/md_d%d/md/component_size",
|
sprintf(fname, "/sys/block/md_d%d/md/component_size",
|
||||||
minor(stb.st_rdev)>>MdpMinorShift);
|
(int)minor(stb.st_rdev)>>MdpMinorShift);
|
||||||
fd = open(fname, O_RDONLY);
|
fd = open(fname, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
80
util.c
80
util.c
|
@ -692,6 +692,44 @@ void put_md_name(char *name)
|
||||||
if (strncmp(name, "/dev/.tmp.md", 12)==0)
|
if (strncmp(name, "/dev/.tmp.md", 12)==0)
|
||||||
unlink(name);
|
unlink(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dev2major(int d)
|
||||||
|
{
|
||||||
|
if (d >= 0)
|
||||||
|
return MD_MAJOR;
|
||||||
|
else
|
||||||
|
return get_mdp_major();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dev2minor(int d)
|
||||||
|
{
|
||||||
|
if (d >= 0)
|
||||||
|
return d;
|
||||||
|
return (-1-d) << MdpMinorShift;
|
||||||
|
}
|
||||||
|
|
||||||
|
int find_free_devnum(int use_partitions)
|
||||||
|
{
|
||||||
|
int devnum;
|
||||||
|
for (devnum = 127; devnum != 128;
|
||||||
|
devnum = devnum ? devnum-1 : (1<<22)-1) {
|
||||||
|
char *dn;
|
||||||
|
int _devnum;
|
||||||
|
|
||||||
|
_devnum = use_partitions ? (-1-devnum) : devnum;
|
||||||
|
if (mddev_busy(_devnum))
|
||||||
|
continue;
|
||||||
|
/* make sure it is new to /dev too, at least as a
|
||||||
|
* non-standard */
|
||||||
|
dn = map_dev(dev2major(_devnum), dev2minor(_devnum), 0);
|
||||||
|
if (dn && ! is_standard(dn, NULL))
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (devnum == 128)
|
||||||
|
return NoMdDev;
|
||||||
|
return use_partitions ? (-1-devnum) : devnum;
|
||||||
|
}
|
||||||
#endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
|
#endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
|
||||||
|
|
||||||
int dev_open(char *dev, int flags)
|
int dev_open(char *dev, int flags)
|
||||||
|
@ -723,6 +761,7 @@ int dev_open(char *dev, int flags)
|
||||||
|
|
||||||
struct superswitch *superlist[] = { &super0, &super1, NULL };
|
struct superswitch *superlist[] = { &super0, &super1, NULL };
|
||||||
|
|
||||||
|
#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
|
||||||
struct supertype *super_by_fd(int fd)
|
struct supertype *super_by_fd(int fd)
|
||||||
{
|
{
|
||||||
mdu_array_info_t array;
|
mdu_array_info_t array;
|
||||||
|
@ -761,6 +800,8 @@ struct supertype *super_by_fd(int fd)
|
||||||
st->sb = NULL;
|
st->sb = NULL;
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
#endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
|
||||||
|
|
||||||
|
|
||||||
struct supertype *dup_super(struct supertype *st)
|
struct supertype *dup_super(struct supertype *st)
|
||||||
{
|
{
|
||||||
|
@ -865,45 +906,6 @@ void get_one_disk(int mdfd, mdu_array_info_t *ainf, mdu_disk_info_t *disk)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev2major(int d)
|
|
||||||
{
|
|
||||||
if (d >= 0)
|
|
||||||
return MD_MAJOR;
|
|
||||||
else
|
|
||||||
return get_mdp_major();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dev2minor(int d)
|
|
||||||
{
|
|
||||||
if (d >= 0)
|
|
||||||
return d;
|
|
||||||
return (-1-d) << MdpMinorShift;
|
|
||||||
}
|
|
||||||
|
|
||||||
int find_free_devnum(int use_partitions)
|
|
||||||
{
|
|
||||||
int devnum;
|
|
||||||
for (devnum = 127; devnum != 128;
|
|
||||||
devnum = devnum ? devnum-1 : (1<<22)-1) {
|
|
||||||
char *dn;
|
|
||||||
int _devnum;
|
|
||||||
|
|
||||||
_devnum = use_partitions ? (-1-devnum) : devnum;
|
|
||||||
if (mddev_busy(_devnum))
|
|
||||||
continue;
|
|
||||||
/* make sure it is new to /dev too, at least as a
|
|
||||||
* non-standard */
|
|
||||||
dn = map_dev(dev2major(_devnum), dev2minor(_devnum), 0);
|
|
||||||
if (dn && ! is_standard(dn, NULL))
|
|
||||||
continue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (devnum == 128)
|
|
||||||
return NoMdDev;
|
|
||||||
return use_partitions ? (-1-devnum) : devnum;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __TINYC__
|
#ifdef __TINYC__
|
||||||
/* tinyc doesn't optimize this check in ioctl.h out ... */
|
/* tinyc doesn't optimize this check in ioctl.h out ... */
|
||||||
unsigned int __invalid_size_argument_for_IOC = 0;
|
unsigned int __invalid_size_argument_for_IOC = 0;
|
||||||
|
|
Loading…
Reference in New Issue