1 /*
2 * Pioctl operations for Coda.
3 * Original version: (C) 1996 Peter Braam
4 * Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University
5 *
6 * Carnegie Mellon encourages users of this code to contribute improvements
7 * to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>.
8 */
9
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 #define __NO_VERSION__
20 #include <linux/module.h>
21 #include <asm/uaccess.h>
22
23 #include <linux/coda.h>
24 #include <linux/coda_linux.h>
25 #include <linux/coda_fs_i.h>
26 #include <linux/coda_psdev.h>
27
28 /* pioctl ops */
29 static int coda_ioctl_permission(struct inode *inode, int mask);
30 static int coda_pioctl(struct inode * inode, struct file * filp,
31 unsigned int cmd, unsigned long user_data);
32
33 /* exported from this file */
34 struct inode_operations coda_ioctl_inode_operations =
35 {
36 permission: coda_ioctl_permission,
37 setattr: coda_notify_change,
38 };
39
40 struct file_operations coda_ioctl_operations = {
41 owner: THIS_MODULE,
42 ioctl: coda_pioctl,
43 };
44
45 /* the coda pioctl inode ops */
46 static int coda_ioctl_permission(struct inode *inode, int mask)
47 {
48 ENTRY;
49
50 return 0;
51 }
52
53 static int coda_pioctl(struct inode * inode, struct file * filp,
54 unsigned int cmd, unsigned long user_data)
55 {
56 struct nameidata nd;
57 int error;
58 struct PioctlData data;
59 struct inode *target_inode = NULL;
60 struct coda_inode_info *cnp;
61
62 ENTRY;
63 /* get the Pioctl data arguments from user space */
64 if (copy_from_user(&data, (int *)user_data, sizeof(data))) {
65 return -EINVAL;
66 }
67
68 /*
69 * Look up the pathname. Note that the pathname is in
70 * user memory, and namei takes care of this
71 */
72 CDEBUG(D_PIOCTL, "namei, data.follow = %d\n",
73 data.follow);
74 if ( data.follow ) {
75 error = user_path_walk(data.path, &nd);
76 } else {
77 error = user_path_walk_link(data.path, &nd);
78 }
79
80 if ( error ) {
81 CDEBUG(D_PIOCTL, "error: lookup fails.\n");
82 return error;
83 } else {
84 target_inode = nd.dentry->d_inode;
85 }
86
87 CDEBUG(D_PIOCTL, "target ino: 0x%ld, dev: 0x%x\n",
88 target_inode->i_ino, target_inode->i_dev);
89
90 /* return if it is not a Coda inode */
91 if ( target_inode->i_sb != inode->i_sb ) {
92 path_release(&nd);
93 return -EINVAL;
94 }
95
96 /* now proceed to make the upcall */
97 cnp = ITOC(target_inode);
98
99 error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
100
101 CDEBUG(D_PIOCTL, "ioctl on inode %ld\n", target_inode->i_ino);
102 CDEBUG(D_DOWNCALL, "dput on ino: %ld, icount %d, dcount %d\n", target_inode->i_ino,
103 atomic_read(&target_inode->i_count), atomic_read(&nd.dentry->d_count));
104 path_release(&nd);
105 return error;
106 }
107
108
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.