Index: sys/cam/cam_compat.c =================================================================== --- sys/cam/cam_compat.c +++ sys/cam/cam_compat.c @@ -54,6 +54,12 @@ #include "opt_cam.h" +/* + * Note: struct cdev *dev parameter here is simply passed through. For cdioctl + * we need to pass down a struct periph * which has been cast to a cdev and that + * is cast back again in cdioctl_dev(). + */ + static int cam_compat_handle_0x17(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td, d_ioctl_t *cbfnp); static int cam_compat_handle_0x18(struct cdev *dev, u_long cmd, caddr_t addr, Index: sys/cam/scsi/scsi_cd.c =================================================================== --- sys/cam/scsi/scsi_cd.c +++ sys/cam/scsi/scsi_cd.c @@ -76,6 +76,7 @@ #include #include #include +#include #include #include @@ -1752,6 +1753,20 @@ } } +static int +cdioctl_dev(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) +{ + struct cam_periph *periph; + + /* + * For compat, we need to cast struct periph * into struct cdev *dev and + * then back again. + */ + periph = (struct cam_periph *)(void *)dev; + cam_periph_assert(periph, MA_OWNED); + return (cam_periph_ioctl(periph, cmd, addr, cderror)); +} + static int cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) { @@ -2608,6 +2623,15 @@ default: cam_periph_lock(periph); error = cam_periph_ioctl(periph, cmd, addr, cderror); + if (error == ENOTTY) { + /* + * We assume that the compat layer doesn't care about + * the dev parameter. It just passes it through, so + * cheat a little. + */ + error = cam_compat_ioctl((struct cdev *)(void *)periph, + cmd, addr, flag, td, cdioctl_dev); + } cam_periph_unlock(periph); break; }