Add freebsd32 compat shims for ioctl(2)

CDIOREADTOCHEADER and CDIOREADTOCENTRYS requests.
This commit is contained in:
obrien 2008-09-22 16:24:36 +00:00
parent 6c1702dda9
commit f419b74a96
2 changed files with 78 additions and 0 deletions

View File

@ -52,6 +52,8 @@ __FBSDID("$FreeBSD$");
/* Cannot get exact size in 64-bit due to alignment issue of entire struct. */
CTASSERT((sizeof(struct md_ioctl32)+4) == 436);
CTASSERT(sizeof(struct ioc_read_toc_entry32) == 8);
CTASSERT(sizeof(struct ioc_toc_header32) == 4);
static int
@ -123,6 +125,60 @@ freebsd32_ioctl_md(struct thread *td, struct freebsd32_ioctl_args *uap,
}
static int
freebsd32_ioctl_ioc_toc_header(struct thread *td,
struct freebsd32_ioctl_args *uap, struct file *fp)
{
struct ioc_toc_header toch;
struct ioc_toc_header32 toch32;
int error;
if (uap->data == NULL)
panic("%s: where is my ioctl data??", __func__);
if ((error = copyin(uap->data, &toch32, sizeof(toch32))))
return (error);
CP(toch32, toch, len);
CP(toch32, toch, starting_track);
CP(toch32, toch, ending_track);
error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&toch,
td->td_ucred, td);
fdrop(fp, td);
return (error);
}
static int
freebsd32_ioctl_ioc_read_toc(struct thread *td,
struct freebsd32_ioctl_args *uap, struct file *fp)
{
struct ioc_read_toc_entry toce;
struct ioc_read_toc_entry32 toce32;
int error;
if (uap->data == NULL)
panic("%s: where is my ioctl data??", __func__);
if ((error = copyin(uap->data, &toce32, sizeof(toce32))))
return (error);
CP(toce32, toce, address_format);
CP(toce32, toce, starting_track);
CP(toce32, toce, data_len);
PTRIN_CP(toce32, toce, data);
if ((error = fo_ioctl(fp, CDIOREADTOCENTRYS, (caddr_t)&toce,
td->td_ucred, td))) {
CP(toce, toce32, address_format);
CP(toce, toce32, starting_track);
CP(toce, toce32, data_len);
PTROUT_CP(toce, toce32, data);
error = copyout(&toce32, uap->data, sizeof(toce32));
}
fdrop(fp, td);
return error;
}
int
freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap)
{
@ -148,6 +204,12 @@ freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap)
case MDIOCLIST_32:
return freebsd32_ioctl_md(td, uap, fp);
case CDIOREADTOCENTRYS_32:
return freebsd32_ioctl_ioc_read_toc(td, uap, fp);
case CDIOREADTOCHEADER_32:
return freebsd32_ioctl_ioc_toc_header(td, uap, fp);
default:
fdrop(fp, td);
ap.fd = uap->fd;

View File

@ -33,6 +33,20 @@
#define _COMPAT_FREEBSD32_IOCTL_H_
typedef __uint32_t caddr_t32;
struct ioc_toc_header32 {
u_short len;
u_char starting_track;
u_char ending_track;
};
struct ioc_read_toc_entry32 {
u_char address_format;
u_char starting_track;
u_short data_len;
uint32_t data; /* struct cd_toc_entry* */
};
#define MDNPAD32 MDNPAD - 1
struct md_ioctl32 {
unsigned md_version; /* Structure layout version */
@ -48,6 +62,8 @@ struct md_ioctl32 {
int md_pad[MDNPAD32]; /* padding for future ideas */
};
#define CDIOREADTOCENTRYS_32 _IOWR('c', 5, struct ioc_read_toc_entry32)
#define CDIOREADTOCHEADER_32 _IOR('c', 4, struct ioc_toc_header32)
#define MDIOCATTACH_32 _IOC(IOC_INOUT, 'm', 0, sizeof(struct md_ioctl32) + 4)
#define MDIOCDETACH_32 _IOC(IOC_INOUT, 'm', 1, sizeof(struct md_ioctl32) + 4)
#define MDIOCQUERY_32 _IOC(IOC_INOUT, 'm', 2, sizeof(struct md_ioctl32) + 4)