diff -u utio.orig/utio.c utio/utio.c --- utio.orig/utio.c 2007-08-02 00:45:50.000000000 +0200 +++ utio/utio.c 2007-10-14 02:01:21.000000000 +0200 @@ -9,7 +9,9 @@ static char __attribute__ ((unused)) *_SCCSid = "@(#)utio.c 1.9 06/09/07 SMI"; #endif /* defined _SCCSID */ -#include +#ifdef WHO_NEEDS_THIS +# include +#endif #include #include #include @@ -26,6 +28,9 @@ #include #include #include +#ifdef HAVE_COMPAT_IOCTL +# include /* (un)lock_kernel() */ +#endif #include #include @@ -1647,7 +1652,11 @@ if (MINOR(inode->i_rdev) == UTSERIALD_MINOR) { ret = seriald_ioctl(inode, file, cmd, arg); } else if (MINOR(inode->i_rdev) == UTPARALLELD_MINOR) { +#ifndef HAVE_COMPAT_IOCTL ret = paralleld_ioctl(inode, file, cmd, arg); +#else /* !HAVE_COMPAT_IOCTL */ + ret = compat_paralleld_ioctl(0, cmd, arg, file); +#endif /* !HAVE_COMPAT_IOCTL */ } else { return (-ENXIO); } @@ -1997,6 +2006,39 @@ return (ret); } +#ifdef HAVE_COMPAT_IOCTL +/* 32bit compat ioctl */ +static long +utio_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + int ret; + struct uta_connect *conn; + + DPRINTF(2, "entering %s() cmd=0x%x\n", __FUNCTION__, cmd); + + if (!file->private_data) { + DPRINTF(3, "No connection...\n"); + return (-ENODEV); + } + + conn = file->private_data; + + /* + * syscall_rwsem locks are acquired + * inside user_ioctl() or daemon_ioctl(), + * so no locks are needed here. + */ + lock_kernel(); + if (conn->role == UTA_USER) + ret = user_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); + else + ret = compat_daemon_ioctl(0, cmd, arg, file); + unlock_kernel(); + + return ret; +} +#endif /* HAVE_COMPAT_IOCTL */ + static int utio_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) @@ -2187,6 +2229,9 @@ write: utio_write, poll: utio_poll, ioctl: utio_ioctl, +#ifdef HAVE_COMPAT_IOCTL + compat_ioctl: utio_compat_ioctl, +#endif open: utio_open, release: utio_release, }; @@ -2256,12 +2301,14 @@ } #if defined(CONFIG_COMPAT) || defined(CONFIG_SPARC64) || defined(CONFIG_X86_64) || defined(CONFIG_PPC64) +#ifndef HAVE_COMPAT_IOCTL register_ioctl32_conversion(COMPAT_UTIO_GETMSG, &compat_daemon_ioctl); register_ioctl32_conversion(COMPAT_UTIO_PUTMSG, &compat_daemon_ioctl); register_ioctl32_conversion(COMPAT_PPGETTIME, &compat_paralleld_ioctl); register_ioctl32_conversion(UTIO_GETVERSION, (ioctl_trans_handler_t)0UL); register_ioctl32_conversion(UTIO_GETMAJOR, (ioctl_trans_handler_t)0UL); register_ioctl32_conversion(UTIO_GETDEVID, (ioctl_trans_handler_t)0UL); +#endif /* HAVE_COMPAT_IOCTL */ #endif /* CONFIG_COMPAT */ /* init successful */ @@ -2274,12 +2321,14 @@ DPRINTF(2, "entering %s()\n", __FUNCTION__); #if defined(CONFIG_COMPAT) || defined(CONFIG_SPARC64) || defined(CONFIG_X86_64) || defined(CONFIG_PPC64) +#ifndef HAVE_COMPAT_IOCTL unregister_ioctl32_conversion(COMPAT_UTIO_GETMSG); unregister_ioctl32_conversion(COMPAT_UTIO_PUTMSG); unregister_ioctl32_conversion(COMPAT_PPGETTIME); unregister_ioctl32_conversion(UTIO_GETVERSION); unregister_ioctl32_conversion(UTIO_GETMAJOR); unregister_ioctl32_conversion(UTIO_GETDEVID); +#endif /* HAVE_COMPAT_IOCTL */ #endif /* CONFIG_COMPAT */ /* diff -u utio.orig/utio.h utio/utio.h --- utio.orig/utio.h 2007-08-02 00:45:50.000000000 +0200 +++ utio/utio.h 2007-10-13 23:57:50.000000000 +0200 @@ -9,7 +9,9 @@ #if defined(CONFIG_COMPAT) || defined(CONFIG_SPARC64) || defined(CONFIG_X86_64) || defined(CONFIG_PPC64) #include -#include +#ifndef HAVE_COMPAT_IOCTL +# include +#endif #include #endif /* CONFIG_COMPAT */