ioctl32 cleanup -- sparc64 parts
Hi!
Please apply when Linus takes the generic parts,
Pavel
arch/sparc64/kernel/ioctl32.c +9 -141
@@ -11,6 +11,7 @@#include <linux/config.h> #include <linux/types.h> #include <linux/compat.h> +#include <linux/ioctl32.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/smp.h>
@@ -678,7 +679,7 @@return (void *) (usp - len); } -static int siocdevprivate_ioctl (unsigned int fd,unsigned int cmd,unsigned long arg) +int siocdevprivate_ioctl (unsigned int fd,unsigned int cmd,unsigned long arg) {struct ifreq *u_ifreq64;struct ifreq32 *u_ifreq32 = (struct ifreq32 *) arg;
@@ -4274,16 +4275,14 @@#define BNEPGETCONNLIST _IOR('B', 210, int)#define BNEPGETCONNINFO _IOR('B', 211, int) -struct ioctl_trans { -unsigned int cmd; -unsigned int handler; -unsigned int next; -}; +typedef int (*ioctl32_handler_t )(unsigned int ,unsigned int ,unsigned long ,struct file *); -#define COMPATIBLE_IOCTL (cmd) asm volatile(".word %0, sys_ioctl, 0" : : "i" (cmd)); -#define HANDLE_IOCTL (cmd,handler) asm volatile(".word %0, %1, 0" : : "i" (cmd), "i" (handler)); -#define IOCTL_TABLE_START void ioctl32_foo(void) { asm volatile(".data\nioctl_translations:"); -#define IOCTL_TABLE_END asm volatile("\nioctl_translations_end:\n\t.previous"); } +#define COMPATIBLE_IOCTL (cmd) HANDLE_IOCTL((cmd),sys_ioctl) +#define HANDLE_IOCTL (cmd,handler) { (cmd), (ioctl32_handler_t)(handler), NULL }, +#define IOCTL_TABLE_START \ + struct ioctl_trans ioctl_start[] = { +#define IOCTL_TABLE_END \ + }; struct ioctl_trans ioctl_end[0];IOCTL_TABLE_START /* List here exlicitly which ioctl's are known to have
@@ -5218,134 +5217,3 @@ HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset) HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64)IOCTL_TABLE_END - -unsigned int ioctl32_hash_table[1024 ]; - -static inline unsigned long ioctl32_hash (unsigned long cmd) -{ -return ((cmd >>6 ) ^ (cmd >>4 ) ^ cmd) &0x3ff ; -} - -static void ioctl32_insert_translation (struct ioctl_trans *trans) -{ -unsigned long hash; -struct ioctl_trans *t; - - hash =ioctl32_hash (trans->cmd); -if (!ioctl32_hash_table[hash]) - ioctl32_hash_table[hash] = (u32 )(long )trans; -else { - t = (struct ioctl_trans *)(long )ioctl32_hash_table[hash]; -while (t->next) - t = (struct ioctl_trans *)(long )t->next; - trans->next =0 ; - t->next = (u32 )(long )trans; - } -} - -static int __init init_sys32_ioctl (void ) -{ -int i; -extern struct ioctl_trans ioctl_translations[], ioctl_translations_end[]; - -for (i =0 ; &ioctl_translations[i] < &ioctl_translations_end[0 ]; i++) -ioctl32_insert_translation (&ioctl_translations[i]); -return 0 ; -} - -__initcall (init_sys32_ioctl); - -static struct ioctl_trans *additional_ioctls; - -/* Always call these with kernel lock held! */ - -int register_ioctl32_conversion (unsigned int cmd,int (*handler)(unsigned int ,unsigned int ,unsigned long ,struct file *)) -{ -int i; -if (!additional_ioctls) { - additional_ioctls =vmalloc (PAGE_SIZE ); -if (!additional_ioctls) -return -ENOMEM ; -memset (additional_ioctls,0 ,PAGE_SIZE ); - } -for (i =0 ; i <PAGE_SIZE /sizeof (struct ioctl_trans ); i++) -if (!additional_ioctls[i].cmd) -break ; -if (i ==PAGE_SIZE /sizeof (struct ioctl_trans )) -return -ENOMEM ; - additional_ioctls[i].cmd = cmd; -if (!handler) - additional_ioctls[i].handler = (u32 )(long )sys_ioctl; -else - additional_ioctls[i].handler = (u32 )(long )handler; -ioctl32_insert_translation (&additional_ioctls[i]); -return 0 ; -} - -int unregister_ioctl32_conversion (unsigned int cmd) -{ -unsigned long hash =ioctl32_hash (cmd); -struct ioctl_trans *t, *t1; - - t = (struct ioctl_trans *)(long )ioctl32_hash_table[hash]; -if (!t)return -EINVAL ; -if (t->cmd == cmd && t >= additional_ioctls && - (unsigned long )t < ((unsigned long )additional_ioctls) +PAGE_SIZE ) { - ioctl32_hash_table[hash] = t->next; - t->cmd =0 ; - t->next =0 ; -return 0 ; - }else while (t->next) { - t1 = (struct ioctl_trans *)(long )t->next; -if (t1->cmd == cmd && t1 >= additional_ioctls && - (unsigned long )t1 < ((unsigned long )additional_ioctls) +PAGE_SIZE ) { - t->next = t1->next; - t1->cmd =0 ; - t1->next =0 ; -return 0 ; - } - t = t1; - } -return -EINVAL ; -} - -asmlinkage int sys32_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) -{ -struct file * filp; -int error = -EBADF ; -int (*handler)(unsigned int ,unsigned int ,unsigned long ,struct file * filp); -struct ioctl_trans *t; - - filp =fget (fd); -if (!filp) - goto out2; - -if (!filp->f_op || !filp->f_op->ioctl) { - error =sys_ioctl (fd, cmd, arg); - goto out; - } - - t = (struct ioctl_trans *)(long )ioctl32_hash_table [ioctl32_hash (cmd)]; - -while (t && t->cmd != cmd) - t = (struct ioctl_trans *)(long )t->next; -if (t) { - handler = (void *)(long )t->handler; - error =handler (fd, cmd, arg, filp); - }else if (cmd >=SIOCDEVPRIVATE && - cmd <= (SIOCDEVPRIVATE +15 )) { - error =siocdevprivate_ioctl (fd, cmd, arg); - }else { -static int count; -if (++count <=20 ) -printk ("sys32_ioctl(%s:%d): Unknown cmd fd(%d) " -"cmd(%08x) arg(%08x)\n" , - current->comm, current->pid, - (int )fd, (unsigned int )cmd, (unsigned int )arg); - error = -EINVAL ; - } -out: -fput (filp); -out2: -return error; -}
arch/sparc64/kernel/sparc64_ksyms.c +2 -2
@@ -89,7 +89,7 @@extern int svr4_getcontext (svr4_ucontext_t *uc,struct pt_regs *regs);extern int svr4_setcontext (svr4_ucontext_t *uc,struct pt_regs *regs);extern int sys_ioctl (unsigned int fd,unsigned int cmd,unsigned long arg); -extern int sys32_ioctl (unsigned int fd,unsigned int cmd,u32 arg); +extern int compact_sys_ioctl (unsigned int fd,unsigned int cmd,u32 arg);extern int (*handle_mathemu)(struct pt_regs *,struct fpustate *);extern long sparc32_open (const char * filename,int flags,int mode);extern int register_ioctl32_conversion (unsigned int cmd,int (*handler)(unsigned int ,unsigned int ,unsigned long ,struct file *));
@@ -318,7 +318,7 @@EXPORT_SYMBOL (svr4_setcontext);EXPORT_SYMBOL (prom_cpu_nodes);EXPORT_SYMBOL (sys_ioctl); -EXPORT_SYMBOL (sys32_ioctl); +EXPORT_SYMBOL (compact_sys_ioctl);EXPORT_SYMBOL (sparc32_open);#endif
arch/sparc64/kernel/sunos_ioctl32.c +26 -26
135 lines not on this page · raw message
arch/sparc64/kernel/systbls.S +1 -1
@@ -29,7 +29,7 @@ .word sys_chown, sys_sync, sys_kill, compat_sys_newstat, sys32_sendfile /*40*/ .word compat_sys_newlstat, sys_dup, sys_pipe, compat_sys_times, sys_getuid .word sys_umount, sys32_setgid16, sys32_getgid16, sys_signal, sys32_geteuid16 -/*50*/ .word sys32_getegid16, sys_acct, sys_nis_syscall, sys_getgid, sys32_ioctl +/*50*/ .word sys32_getegid16, sys_acct, sys_nis_syscall, sys_getgid, compact_sys_ioctl .word sys_reboot, sys32_mmap2, sys_symlink, sys_readlink, sys32_execve /*60*/ .word sys_umask, sys_chroot, compat_sys_newfstat, sys_fstat64, sys_getpagesize .word sys_msync, sys_vfork, sys32_pread64, sys32_pwrite64, sys_geteuid
arch/sparc64/solaris/ioctl.c +24 -23
91 lines not on this page · raw message
arch/sparc64/solaris/timod.c +0 -2
@@ -29,8 +29,6 @@ extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd,unsigned long arg); -extern asmlinkage int sys32_ioctl(unsigned int fd, unsigned int cmd, -u32 arg); asmlinkage int solaris_ioctl(unsigned int fd, unsigned int cmd, u32 arg);static spinlock_t timod_pagelock =SPIN_LOCK_UNLOCKED ;
Signature · 2 lines
When do you have a heart between your knees? [Johanka's followup: and *two* hearts?]