Don't overwrite the cache exception handler.
[linux-2.6/linux-mips.git] / fs / coda / pioctl.c
blob533e83a54ef2731e6e378986959528361b312116
1 /*
2 * Pioctl operations for Coda.
3 * Original version: (C) 1996 Peter Braam
4 * Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University
6 * Carnegie Mellon encourages users of this code to contribute improvements
7 * to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>.
8 */
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/sched.h>
13 #include <linux/fs.h>
14 #include <linux/stat.h>
15 #include <linux/errno.h>
16 #include <linux/locks.h>
17 #include <asm/segment.h>
18 #include <linux/string.h>
19 #include <asm/uaccess.h>
21 #include <linux/coda.h>
22 #include <linux/coda_linux.h>
23 #include <linux/coda_fs_i.h>
24 #include <linux/coda_cache.h>
25 #include <linux/coda_psdev.h>
27 /* pioctl ops */
28 static int coda_ioctl_permission(struct inode *inode, int mask);
29 static int coda_ioctl_open(struct inode *i, struct file *f);
30 static int coda_ioctl_release(struct inode *i, struct file *f);
31 static int coda_pioctl(struct inode * inode, struct file * filp,
32 unsigned int cmd, unsigned long arg);
34 /* exported from this file */
35 struct inode_operations coda_ioctl_inode_operations =
37 permission: coda_ioctl_permission,
38 setattr: coda_notify_change,
41 struct file_operations coda_ioctl_operations = {
42 ioctl: coda_pioctl,
43 open: coda_ioctl_open,
44 release: coda_ioctl_release,
47 /* the coda pioctl inode ops */
48 static int coda_ioctl_permission(struct inode *inode, int mask)
50 ENTRY;
52 return 0;
55 /* The pioctl file ops*/
56 int coda_ioctl_open(struct inode *i, struct file *f)
58 ENTRY;
60 CDEBUG(D_PIOCTL, "File inode number: %ld\n",
61 f->f_dentry->d_inode->i_ino);
63 EXIT;
64 return 0;
67 int coda_ioctl_release(struct inode *i, struct file *f)
69 return 0;
73 static int coda_pioctl(struct inode * inode, struct file * filp,
74 unsigned int cmd, unsigned long user_data)
76 struct dentry *target_de;
77 int error;
78 struct PioctlData data;
79 struct inode *target_inode = NULL;
80 struct coda_inode_info *cnp;
82 ENTRY;
83 /* get the Pioctl data arguments from user space */
84 if (copy_from_user(&data, (int *)user_data, sizeof(data))) {
85 return -EINVAL;
88 /*
89 * Look up the pathname. Note that the pathname is in
90 * user memory, and namei takes care of this
92 CDEBUG(D_PIOCTL, "namei, data.follow = %d\n",
93 data.follow);
94 if ( data.follow ) {
95 target_de = namei(data.path);
96 } else {
97 target_de = lnamei(data.path);
100 if ( IS_ERR(target_de) ) {
101 CDEBUG(D_PIOCTL, "error: lookup fails.\n");
102 return PTR_ERR(target_de);
103 } else {
104 target_inode = target_de->d_inode;
107 CDEBUG(D_PIOCTL, "target ino: 0x%ld, dev: 0x%d\n",
108 target_inode->i_ino, target_inode->i_dev);
110 /* return if it is not a Coda inode */
111 if ( target_inode->i_sb != inode->i_sb ) {
112 if ( target_de )
113 dput(target_de);
114 return -EINVAL;
117 /* now proceed to make the upcall */
118 cnp = ITOC(target_inode);
120 error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
122 CDEBUG(D_PIOCTL, "ioctl on inode %ld\n", target_inode->i_ino);
123 CDEBUG(D_DOWNCALL, "dput on ino: %ld, icount %d, dcount %d\n", target_inode->i_ino,
124 target_inode->i_count, target_de->d_count);
125 if ( target_de )
126 dput(target_de);
127 return error;