Import 2.3.99pre7-7
[davej-history.git] / fs / coda / pioctl.c
blobd29c18ccd88251f72cc0b172a06314284d088eef
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 nameidata nd;
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 error = user_path_walk(data.path, &nd);
96 } else {
97 error = user_path_walk_link(data.path, &nd);
100 if ( error ) {
101 CDEBUG(D_PIOCTL, "error: lookup fails.\n");
102 return error;
103 } else {
104 target_inode = nd.dentry->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 path_release(&nd);
113 return -EINVAL;
116 /* now proceed to make the upcall */
117 cnp = ITOC(target_inode);
119 error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
121 CDEBUG(D_PIOCTL, "ioctl on inode %ld\n", target_inode->i_ino);
122 CDEBUG(D_DOWNCALL, "dput on ino: %ld, icount %d, dcount %d\n", target_inode->i_ino,
123 target_inode->i_count, nd.dentry->d_count);
124 path_release(&nd);
125 return error;