Actually make use of the md_version field of 'struct mdio'. In order
not to needlessly break compatibility, decrement MDIOVERSION to 0. Approved by: phk
This commit is contained in:
parent
1a7c0630db
commit
53d745bc7c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=88249
@ -161,6 +161,7 @@ main(int argc, char **argv)
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mdio.md_version = MDIOVERSION;
|
||||||
|
|
||||||
mdmaybeload();
|
mdmaybeload();
|
||||||
fd = open("/dev/" MDCTL_NAME, O_RDWR, 0);
|
fd = open("/dev/" MDCTL_NAME, O_RDWR, 0);
|
||||||
@ -253,6 +254,7 @@ int
|
|||||||
query(const int fd, const int unit)
|
query(const int fd, const int unit)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
mdio.md_version = MDIOVERSION;
|
||||||
mdio.md_unit = unit;
|
mdio.md_unit = unit;
|
||||||
|
|
||||||
if (ioctl(fd, MDIOCQUERY, &mdio) < 0)
|
if (ioctl(fd, MDIOCQUERY, &mdio) < 0)
|
||||||
|
@ -831,9 +831,18 @@ mdctlioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td)
|
|||||||
printf("mdctlioctl(%s %lx %p %x %p)\n",
|
printf("mdctlioctl(%s %lx %p %x %p)\n",
|
||||||
devtoname(dev), cmd, addr, flags, td);
|
devtoname(dev), cmd, addr, flags, td);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We assert the version number in the individual ioctl
|
||||||
|
* handlers instead of out here because (a) it is possible we
|
||||||
|
* may add another ioctl in the future which doesn't read an
|
||||||
|
* mdio, and (b) the correct return value for an unknown ioctl
|
||||||
|
* is ENOIOCTL, not EINVAL.
|
||||||
|
*/
|
||||||
mdio = (struct md_ioctl *)addr;
|
mdio = (struct md_ioctl *)addr;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case MDIOCATTACH:
|
case MDIOCATTACH:
|
||||||
|
if (mdio->md_version != MDIOVERSION)
|
||||||
|
return (EINVAL);
|
||||||
switch (mdio->md_type) {
|
switch (mdio->md_type) {
|
||||||
case MD_MALLOC:
|
case MD_MALLOC:
|
||||||
return (mdcreate_malloc(mdio));
|
return (mdcreate_malloc(mdio));
|
||||||
@ -847,11 +856,15 @@ mdctlioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td)
|
|||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
case MDIOCDETACH:
|
case MDIOCDETACH:
|
||||||
|
if (mdio->md_version != MDIOVERSION)
|
||||||
|
return (EINVAL);
|
||||||
if (mdio->md_file != NULL || mdio->md_size != 0 ||
|
if (mdio->md_file != NULL || mdio->md_size != 0 ||
|
||||||
mdio->md_options != 0)
|
mdio->md_options != 0)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
return (mddetach(mdio->md_unit, td));
|
return (mddetach(mdio->md_unit, td));
|
||||||
case MDIOCQUERY:
|
case MDIOCQUERY:
|
||||||
|
if (mdio->md_version != MDIOVERSION)
|
||||||
|
return (EINVAL);
|
||||||
sc = mdfind(mdio->md_unit);
|
sc = mdfind(mdio->md_unit);
|
||||||
if (sc == NULL)
|
if (sc == NULL)
|
||||||
return (ENOENT);
|
return (ENOENT);
|
||||||
|
@ -66,7 +66,7 @@ struct md_ioctl {
|
|||||||
|
|
||||||
#define MD_NAME "md"
|
#define MD_NAME "md"
|
||||||
#define MDCTL_NAME "mdctl"
|
#define MDCTL_NAME "mdctl"
|
||||||
#define MDIOVERSION 1
|
#define MDIOVERSION 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Before you can use a unit, it must be configured with MDIOCSET.
|
* Before you can use a unit, it must be configured with MDIOCSET.
|
||||||
|
Loading…
Reference in New Issue
Block a user