2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * Linux module support routines.
14 #include <afsconfig.h>
15 #include "afs/param.h"
18 #include <linux/module.h> /* early to avoid printf->printk mapping */
19 #include "afs/sysincludes.h"
20 #include "afsincludes.h"
21 #include <linux/unistd.h> /* For syscall numbers. */
24 #ifdef AFS_AMD64_LINUX20_ENV
25 #include <asm/ia32_unistd.h>
28 #include <linux/slab.h>
29 #include <linux/init.h>
30 #include <linux/sched.h>
31 #include <linux/kernel.h>
33 #include "osi_compat.h"
35 extern struct proc_dir_entry *openafs_procfs;
37 extern asmlinkage long
38 afs_syscall(long syscall, long parm1, long parm2, long parm3, long parm4);
41 afs_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
45 struct afsprocdata sysargs;
47 if (cmd != VIOC_SYSCALL && cmd != VIOC_SYSCALL32) return -EINVAL;
50 if (afs_in_compat_syscall()) {
51 struct afsprocdata32 sysargs32;
53 if (copy_from_user(&sysargs32, (void *)arg,
54 sizeof(struct afsprocdata32)))
57 return afs_syscall((unsigned long)sysargs32.syscall,
58 (unsigned long)sysargs32.param1,
59 (unsigned long)sysargs32.param2,
60 (unsigned long)sysargs32.param3,
61 (unsigned long)sysargs32.param4);
63 #endif /* NEED_IOCTL32 */
65 if (copy_from_user(&sysargs, (void *)arg, sizeof(struct afsprocdata)))
68 return afs_syscall(sysargs.syscall, sysargs.param1,
69 sysargs.param2, sysargs.param3, sysargs.param4);
73 static long afs_unlocked_ioctl(struct file *file, unsigned int cmd,
75 return afs_ioctl(FILE_INODE(file), file, cmd, arg);
78 #if defined(HAVE_LINUX_STRUCT_PROC_OPS)
79 static struct proc_ops afs_syscall_ops = {
80 .proc_ioctl = afs_unlocked_ioctl,
81 # ifdef STRUCT_PROC_OPS_HAS_PROC_COMPAT_IOCTL
82 .proc_compat_ioctl = afs_unlocked_ioctl,
86 static struct file_operations afs_syscall_ops = {
87 .unlocked_ioctl = afs_unlocked_ioctl,
88 .compat_ioctl = afs_unlocked_ioctl,
90 #endif /* HAVE_LINUX_STRUCT_PROC_OPS */
95 struct proc_dir_entry *entry;
97 entry = afs_proc_create(PROC_SYSCALL_NAME, 0666, openafs_procfs, &afs_syscall_ops);
98 #if defined(STRUCT_PROC_DIR_ENTRY_HAS_OWNER)
100 entry->owner = THIS_MODULE;
106 osi_ioctl_clean(void)
108 remove_proc_entry(PROC_SYSCALL_NAME, openafs_procfs);