Blame view
fs/coda/pioctl.c
2.15 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 |
/* * Pioctl operations for Coda. |
1977bb2ed coda: Clean-up wh... |
3 |
* Original version: (C) 1996 Peter Braam |
1da177e4c Linux-2.6.12-rc2 |
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
* Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University * * Carnegie Mellon encourages users of this code to contribute improvements * to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>. */ #include <linux/types.h> #include <linux/kernel.h> #include <linux/time.h> #include <linux/fs.h> #include <linux/stat.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/namei.h> #include <linux/module.h> #include <asm/uaccess.h> #include <linux/coda.h> |
1da177e4c Linux-2.6.12-rc2 |
22 |
#include <linux/coda_psdev.h> |
31a203df9 take coda-private... |
23 |
#include "coda_linux.h" |
1da177e4c Linux-2.6.12-rc2 |
24 |
/* pioctl ops */ |
10556cb21 ->permission() sa... |
25 |
static int coda_ioctl_permission(struct inode *inode, int mask); |
2ff82f852 coda: BKL ioctl p... |
26 27 |
static long coda_pioctl(struct file *filp, unsigned int cmd, unsigned long user_data); |
1da177e4c Linux-2.6.12-rc2 |
28 29 |
/* exported from this file */ |
1977bb2ed coda: Clean-up wh... |
30 |
const struct inode_operations coda_ioctl_inode_operations = { |
1da177e4c Linux-2.6.12-rc2 |
31 32 33 |
.permission = coda_ioctl_permission, .setattr = coda_setattr, }; |
4b6f5d20b [PATCH] Make most... |
34 |
const struct file_operations coda_ioctl_operations = { |
1da177e4c Linux-2.6.12-rc2 |
35 |
.owner = THIS_MODULE, |
2ff82f852 coda: BKL ioctl p... |
36 |
.unlocked_ioctl = coda_pioctl, |
6038f373a llseek: automatic... |
37 |
.llseek = noop_llseek, |
1da177e4c Linux-2.6.12-rc2 |
38 39 40 |
}; /* the coda pioctl inode ops */ |
10556cb21 ->permission() sa... |
41 |
static int coda_ioctl_permission(struct inode *inode, int mask) |
1da177e4c Linux-2.6.12-rc2 |
42 |
{ |
f696a3659 [PATCH] move exec... |
43 |
return (mask & MAY_EXEC) ? -EACCES : 0; |
1da177e4c Linux-2.6.12-rc2 |
44 |
} |
2ff82f852 coda: BKL ioctl p... |
45 46 |
static long coda_pioctl(struct file *filp, unsigned int cmd, unsigned long user_data) |
1da177e4c Linux-2.6.12-rc2 |
47 |
{ |
2d8f30380 [PATCH] sanitize ... |
48 |
struct path path; |
1977bb2ed coda: Clean-up wh... |
49 |
int error; |
1da177e4c Linux-2.6.12-rc2 |
50 |
struct PioctlData data; |
2ff82f852 coda: BKL ioctl p... |
51 |
struct inode *inode = filp->f_dentry->d_inode; |
1977bb2ed coda: Clean-up wh... |
52 53 |
struct inode *target_inode = NULL; struct coda_inode_info *cnp; |
1da177e4c Linux-2.6.12-rc2 |
54 |
|
1977bb2ed coda: Clean-up wh... |
55 |
/* get the Pioctl data arguments from user space */ |
f7cc02b87 Coda: push BKL re... |
56 57 |
if (copy_from_user(&data, (void __user *)user_data, sizeof(data))) return -EINVAL; |
1977bb2ed coda: Clean-up wh... |
58 59 60 61 62 |
/* * Look up the pathname. Note that the pathname is in * user memory, and namei takes care of this */ |
2ff82f852 coda: BKL ioctl p... |
63 |
if (data.follow) |
1977bb2ed coda: Clean-up wh... |
64 |
error = user_path(data.path, &path); |
2ff82f852 coda: BKL ioctl p... |
65 |
else |
1977bb2ed coda: Clean-up wh... |
66 |
error = user_lpath(data.path, &path); |
2ff82f852 coda: BKL ioctl p... |
67 68 |
if (error) |
f7cc02b87 Coda: push BKL re... |
69 70 71 |
return error; target_inode = path.dentry->d_inode; |
2ff82f852 coda: BKL ioctl p... |
72 |
|
1da177e4c Linux-2.6.12-rc2 |
73 |
/* return if it is not a Coda inode */ |
1977bb2ed coda: Clean-up wh... |
74 |
if (target_inode->i_sb != inode->i_sb) { |
2ff82f852 coda: BKL ioctl p... |
75 76 |
error = -EINVAL; goto out; |
1da177e4c Linux-2.6.12-rc2 |
77 78 79 |
} /* now proceed to make the upcall */ |
1977bb2ed coda: Clean-up wh... |
80 |
cnp = ITOC(target_inode); |
1da177e4c Linux-2.6.12-rc2 |
81 82 |
error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); |
2ff82f852 coda: BKL ioctl p... |
83 |
out: |
f7cc02b87 Coda: push BKL re... |
84 |
path_put(&path); |
1977bb2ed coda: Clean-up wh... |
85 |
return error; |
1da177e4c Linux-2.6.12-rc2 |
86 |
} |