X-Git-Url: http://git.thejh.net/?p=moctel.git;a=blobdiff_plain;f=moctel_mod.c;h=7498584725fb64e5ab0815fae185bac81f503b8b;hp=bb0652ef7d7de0ca234236bf23be3c4d585d2de8;hb=18a70c75550a8f74d96c85a9579ad6902eac1b4f;hpb=9ca13033981db455c571e6f54f4ac24938afb94a diff --git a/moctel_mod.c b/moctel_mod.c index bb0652e..7498584 100644 --- a/moctel_mod.c +++ b/moctel_mod.c @@ -1,3 +1,7 @@ +// Copyright (C) 2013 Jann Horn +// This file is licensed under the GNU GPL v2 (see +// the LICENSE file). + #undef __KERNEL__ #define __KERNEL__ #undef MODULE @@ -25,18 +29,18 @@ static int ioctl_open(struct inode *nodp, struct file *filp) { static const struct file_operations dummy_fops = {}; -static long ioctl_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { +static long ioctl_ioctl(struct file *filp_, unsigned int cmd, unsigned long arg) { struct fetch_fops_args args; - struct fd f; + struct file *filp; const struct file_operations *fops; if (cmd != MOCTEL_FETCH_FOPS) return -EINVAL; if (copy_from_user(&args, (struct fetch_fops_args __user *)arg, sizeof(args))) return -EINVAL; - f = fdget(args.fd); - if (!f.file) return -EBADF; - fops = f.file->f_op; - if (!fops) fops = dummy_fops; - fdput(f); + filp = fget(args.fd); + if (!filp) return -EBADF; + fops = filp->f_op; + if (!fops) fops = &dummy_fops; + fput(filp); if (copy_to_user((struct file_operations __user *)args.retp, fops, sizeof(*fops))) return -EINVAL; return 0; } @@ -47,8 +51,7 @@ static int ioctl_release(struct inode *nodp, struct file *filp) { static const struct file_operations ioctl_fops = { .owner = THIS_MODULE, - .ioctl = ioctl_ioctl, /* I have no idea about locking, - so just take the Big Kernel Lock implicitly. */ + .unlocked_ioctl = ioctl_ioctl, .open = ioctl_open, .release = ioctl_release }; @@ -59,7 +62,7 @@ static struct miscdevice ioctl_miscdev = { .fops = &ioctl_fops }; -static int __init init_ioctl() { +static int __init init_ioctl(void) { int ret; printk(KERN_INFO "loading ioctl helper\n"); @@ -67,7 +70,7 @@ static int __init init_ioctl() { return ret; } -static void __exit cleanup_ioctl() { +static void __exit cleanup_ioctl(void) { printk(KERN_INFO "unloading ioctl helper\n"); misc_deregister(&ioctl_miscdev); }