Blame view
fs/coda/pioctl.c
2.23 KB
1da177e4c
|
1 2 |
/* * Pioctl operations for Coda. |
1977bb2ed
|
3 |
* Original version: (C) 1996 Peter Braam |
1da177e4c
|
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
|
22 |
#include <linux/coda_psdev.h> |
31a203df9
|
23 |
#include "coda_linux.h" |
1da177e4c
|
24 |
/* pioctl ops */ |
b74c79e99
|
25 |
static int coda_ioctl_permission(struct inode *inode, int mask, unsigned int flags); |
2ff82f852
|
26 27 |
static long coda_pioctl(struct file *filp, unsigned int cmd, unsigned long user_data); |
1da177e4c
|
28 29 |
/* exported from this file */ |
1977bb2ed
|
30 |
const struct inode_operations coda_ioctl_inode_operations = { |
1da177e4c
|
31 32 33 |
.permission = coda_ioctl_permission, .setattr = coda_setattr, }; |
4b6f5d20b
|
34 |
const struct file_operations coda_ioctl_operations = { |
1da177e4c
|
35 |
.owner = THIS_MODULE, |
2ff82f852
|
36 |
.unlocked_ioctl = coda_pioctl, |
6038f373a
|
37 |
.llseek = noop_llseek, |
1da177e4c
|
38 39 40 |
}; /* the coda pioctl inode ops */ |
b74c79e99
|
41 |
static int coda_ioctl_permission(struct inode *inode, int mask, unsigned int flags) |
1da177e4c
|
42 |
{ |
b74c79e99
|
43 44 |
if (flags & IPERM_FLAG_RCU) return -ECHILD; |
f696a3659
|
45 |
return (mask & MAY_EXEC) ? -EACCES : 0; |
1da177e4c
|
46 |
} |
2ff82f852
|
47 48 |
static long coda_pioctl(struct file *filp, unsigned int cmd, unsigned long user_data) |
1da177e4c
|
49 |
{ |
2d8f30380
|
50 |
struct path path; |
1977bb2ed
|
51 |
int error; |
1da177e4c
|
52 |
struct PioctlData data; |
2ff82f852
|
53 |
struct inode *inode = filp->f_dentry->d_inode; |
1977bb2ed
|
54 55 |
struct inode *target_inode = NULL; struct coda_inode_info *cnp; |
1da177e4c
|
56 |
|
1977bb2ed
|
57 |
/* get the Pioctl data arguments from user space */ |
f7cc02b87
|
58 59 |
if (copy_from_user(&data, (void __user *)user_data, sizeof(data))) return -EINVAL; |
1977bb2ed
|
60 61 62 63 64 |
/* * Look up the pathname. Note that the pathname is in * user memory, and namei takes care of this */ |
2ff82f852
|
65 |
if (data.follow) |
1977bb2ed
|
66 |
error = user_path(data.path, &path); |
2ff82f852
|
67 |
else |
1977bb2ed
|
68 |
error = user_lpath(data.path, &path); |
2ff82f852
|
69 70 |
if (error) |
f7cc02b87
|
71 72 73 |
return error; target_inode = path.dentry->d_inode; |
2ff82f852
|
74 |
|
1da177e4c
|
75 |
/* return if it is not a Coda inode */ |
1977bb2ed
|
76 |
if (target_inode->i_sb != inode->i_sb) { |
2ff82f852
|
77 78 |
error = -EINVAL; goto out; |
1da177e4c
|
79 80 81 |
} /* now proceed to make the upcall */ |
1977bb2ed
|
82 |
cnp = ITOC(target_inode); |
1da177e4c
|
83 84 |
error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); |
2ff82f852
|
85 |
out: |
f7cc02b87
|
86 |
path_put(&path); |
1977bb2ed
|
87 |
return error; |
1da177e4c
|
88 |
} |