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 <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>
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
,
48 NULL
, /* follow_link */
54 coda_ioctl_permission
, /* permission */
59 struct file_operations coda_ioctl_operations
= {
60 NULL
, /* lseek - default should work for coda */
64 NULL
, /* select - default */
65 coda_pioctl
, /* ioctl */
67 coda_ioctl_open
, /* open */
69 coda_ioctl_release
, /* release */
73 /* the coda pioctl inode ops */
74 static int coda_ioctl_permission(struct inode
*inode
, int mask
)
81 /* The pioctl file ops*/
82 int coda_ioctl_open(struct inode
*i
, struct file
*f
)
87 CDEBUG(D_PIOCTL
, "File inode number: %ld\n",
88 f
->f_dentry
->d_inode
->i_ino
);
94 int coda_ioctl_release(struct inode
*i
, struct file
*f
)
100 static int coda_pioctl(struct inode
* inode
, struct file
* filp
,
101 unsigned int cmd
, unsigned long user_data
)
103 struct dentry
*target_de
;
105 struct PioctlData data
;
106 struct inode
*target_inode
= NULL
;
107 struct coda_inode_info
*cnp
;
110 /* get the Pioctl data arguments from user space */
111 if (copy_from_user(&data
, (int *)user_data
, sizeof(data
))) {
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",
122 target_de
= namei(data
.path
);
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
);
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
) {
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
);