diff options
author | obrien <obrien@FreeBSD.org> | 2008-09-22 16:24:36 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2008-09-22 16:24:36 +0000 |
commit | f419b74a96a07076040b8fd85cc326c97f79cf22 (patch) | |
tree | e9b67a08ff330a68056612303dce551d33e42361 /sys/compat | |
parent | 6c1702dda9549dad4438209c6c929bf74d32c680 (diff) | |
download | FreeBSD-src-f419b74a96a07076040b8fd85cc326c97f79cf22.zip FreeBSD-src-f419b74a96a07076040b8fd85cc326c97f79cf22.tar.gz |
Add freebsd32 compat shims for ioctl(2)
CDIOREADTOCHEADER and CDIOREADTOCENTRYS requests.
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/freebsd32/freebsd32_ioctl.c | 62 | ||||
-rw-r--r-- | sys/compat/freebsd32/freebsd32_ioctl.h | 16 |
2 files changed, 78 insertions, 0 deletions
diff --git a/sys/compat/freebsd32/freebsd32_ioctl.c b/sys/compat/freebsd32/freebsd32_ioctl.c index a46b0b9..5cca29a 100644 --- a/sys/compat/freebsd32/freebsd32_ioctl.c +++ b/sys/compat/freebsd32/freebsd32_ioctl.c @@ -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; diff --git a/sys/compat/freebsd32/freebsd32_ioctl.h b/sys/compat/freebsd32/freebsd32_ioctl.h index 772c8b4..7844066 100644 --- a/sys/compat/freebsd32/freebsd32_ioctl.h +++ b/sys/compat/freebsd32/freebsd32_ioctl.h @@ -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) |