Import 2.3.25pre1
[davej-history.git] / fs / coda / pioctl.c
blob3e6924f15f6dd6ed4f2677905f33c6005404bfe7
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 &coda_ioctl_operations,
38 NULL, /* create */
39 NULL, /* lookup */
40 NULL, /* link */
41 NULL, /* unlink */
42 NULL, /* symlink */
43 NULL, /* mkdir */
44 NULL, /* rmdir */
45 NULL, /* mknod */
46 NULL, /* rename */
47 NULL, /* readlink */
48 NULL, /* follow_link */
49 NULL, /* get_block */
50 NULL, /* readpage */
51 NULL, /* writepage */
52 NULL, /* flushpage */
53 NULL, /* truncate */
54 coda_ioctl_permission, /* permission */
55 NULL, /* smap */
56 NULL /* revalidate */
59 struct file_operations coda_ioctl_operations = {
60 NULL, /* lseek - default should work for coda */
61 NULL, /* read */
62 NULL, /* write */
63 NULL, /* readdir */
64 NULL, /* select - default */
65 coda_pioctl, /* ioctl */
66 NULL, /* mmap */
67 coda_ioctl_open, /* open */
68 NULL,
69 coda_ioctl_release, /* release */
70 NULL, /* fsync */
73 /* the coda pioctl inode ops */
74 static int coda_ioctl_permission(struct inode *inode, int mask)
76 ENTRY;
78 return 0;
81 /* The pioctl file ops*/
82 int coda_ioctl_open(struct inode *i, struct file *f)
85 ENTRY;
87 CDEBUG(D_PIOCTL, "File inode number: %ld\n",
88 f->f_dentry->d_inode->i_ino);
90 EXIT;
91 return 0;
94 int coda_ioctl_release(struct inode *i, struct file *f)
96 return 0;
100 static int coda_pioctl(struct inode * inode, struct file * filp,
101 unsigned int cmd, unsigned long user_data)
103 struct dentry *target_de;
104 int error;
105 struct PioctlData data;
106 struct inode *target_inode = NULL;
107 struct coda_inode_info *cnp;
109 ENTRY;
110 /* get the Pioctl data arguments from user space */
111 if (copy_from_user(&data, (int *)user_data, sizeof(data))) {
112 return -EINVAL;
116 * Look up the pathname. Note that the pathname is in
117 * user memory, and namei takes care of this
119 CDEBUG(D_PIOCTL, "namei, data.follow = %d\n",
120 data.follow);
121 if ( data.follow ) {
122 target_de = namei(data.path);
123 } else {
124 target_de = lnamei(data.path);
127 if ( IS_ERR(target_de) ) {
128 CDEBUG(D_PIOCTL, "error: lookup fails.\n");
129 return PTR_ERR(target_de);
130 } else {
131 target_inode = target_de->d_inode;
134 CDEBUG(D_PIOCTL, "target ino: 0x%ld, dev: 0x%d\n",
135 target_inode->i_ino, target_inode->i_dev);
137 /* return if it is not a Coda inode */
138 if ( target_inode->i_sb != inode->i_sb ) {
139 if ( target_de )
140 dput(target_de);
141 return -EINVAL;
144 /* now proceed to make the upcall */
145 cnp = ITOC(target_inode);
147 error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
149 CDEBUG(D_PIOCTL, "ioctl on inode %ld\n", target_inode->i_ino);
150 CDEBUG(D_DOWNCALL, "dput on ino: %ld, icount %d, dcount %d\n", target_inode->i_ino,
151 target_inode->i_count, target_de->d_count);
152 if ( target_de )
153 dput(target_de);
154 return error;