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>.
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/sched.h>
14 #include <linux/stat.h>
15 #include <linux/errno.h>
16 #include <linux/locks.h>
17 #include <linux/string.h>
18 #define __NO_VERSION__
19 #include <linux/module.h>
20 #include <asm/uaccess.h>
22 #include <linux/coda.h>
23 #include <linux/coda_linux.h>
24 #include <linux/coda_fs_i.h>
25 #include <linux/coda_psdev.h>
28 static int coda_ioctl_permission(struct inode *inode, int mask);
29 static int coda_pioctl(struct inode * inode, struct file * filp,
30 unsigned int cmd, unsigned long user_data);
32 /* exported from this file */
33 struct inode_operations coda_ioctl_inode_operations =
35 permission: coda_ioctl_permission,
36 setattr: coda_notify_change,
39 struct file_operations coda_ioctl_operations = {
44 /* the coda pioctl inode ops */
45 static int coda_ioctl_permission(struct inode *inode, int mask)
50 static int coda_pioctl(struct inode * inode, struct file * filp,
51 unsigned int cmd, unsigned long user_data)
55 struct PioctlData data;
56 struct inode *target_inode = NULL;
57 struct coda_inode_info *cnp;
59 /* get the Pioctl data arguments from user space */
60 if (copy_from_user(&data, (int *)user_data, sizeof(data))) {
65 * Look up the pathname. Note that the pathname is in
66 * user memory, and namei takes care of this
68 CDEBUG(D_PIOCTL, "namei, data.follow = %d\n",
71 error = user_path_walk(data.path, &nd);
73 error = user_path_walk_link(data.path, &nd);
77 CDEBUG(D_PIOCTL, "error: lookup fails.\n");
80 target_inode = nd.dentry->d_inode;
83 CDEBUG(D_PIOCTL, "target ino: 0x%ld, dev: 0x%x\n",
84 target_inode->i_ino, target_inode->i_dev);
86 /* return if it is not a Coda inode */
87 if ( target_inode->i_sb != inode->i_sb ) {
92 /* now proceed to make the upcall */
93 cnp = ITOC(target_inode);
95 error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
97 CDEBUG(D_PIOCTL, "ioctl on inode %ld\n", target_inode->i_ino);
98 CDEBUG(D_DOWNCALL, "dput on ino: %ld, icount %d, dcount %d\n", target_inode->i_ino,
99 atomic_read(&target_inode->i_count), atomic_read(&nd.dentry->d_count));