2 * Copryright (C) 2001 Cluster File Systems, Inc.
8 #include <linux/config.h>
9 #include <linux/module.h>
10 #include <linux/kernel.h>
12 #include <linux/string.h>
13 #include <linux/stat.h>
14 #include <linux/errno.h>
15 #include <linux/locks.h>
16 #include <linux/unistd.h>
18 #include <asm/system.h>
19 #include <asm/uaccess.h>
22 #include <linux/stat.h>
23 #include <asm/uaccess.h>
24 #include <linux/vmalloc.h>
25 #include <asm/segment.h>
26 #include <linux/miscdevice.h>
28 #include <linux/obd_support.h>
29 #include <linux/lustre_lib.h>
30 #include <linux/lustre_idl.h>
31 #include <linux/lustre_mds.h>
33 #define REQUEST_MINOR 244
34 extern int mds_queue_req(struct mds_request *);
36 static int mds_send_req(struct mds_request *req)
39 init_waitqueue_head(&req->rq_wait_for_rep);
40 /* XXX replace the following with networking code */
41 rc = mds_queue_req(req);
47 printk("-- sleeping\n");
48 interruptible_sleep_on(&req->rq_wait_for_rep);
53 int llight_getattr(ino_t ino, struct mds_rep *rep)
55 struct mds_request *request;
58 request = (struct mds_request *)kmalloc(sizeof(*request),
61 printk("llight request: out of memory\n");
65 rc = mds_pack_req(NULL, 0, NULL, 0,
66 &request->rq_reqhdr, &request->rq_req,
67 &request->rq_reqlen, &request->rq_reqbuf);
69 printk("llight request: cannot pack request %d\n", rc);
72 request->rq_req->fid1.id = ino;
74 request->rq_reqhdr->opc = MDS_GETATTR;
76 rc = mds_send_req(request);
78 printk("llight request: error in handling %d\n", rc);
82 printk("mode: %o\n", request->rq_rep->mode);
84 memcpy(rep, request->rq_repbuf, sizeof(*rep));
86 kfree(request->rq_repbuf);
92 static int request_ioctl(struct inode *inode, struct file *file,
93 unsigned int cmd, unsigned long arg)
99 if (MINOR(inode->i_rdev) != REQUEST_MINOR) {
104 if ( _IOC_TYPE(cmd) != IOC_REQUEST_TYPE ||
105 _IOC_NR(cmd) < IOC_REQUEST_MIN_NR ||
106 _IOC_NR(cmd) > IOC_REQUEST_MAX_NR ) {
107 CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n",
108 _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd));
115 case IOC_REQUEST_GETATTR: {
116 printk("-- getting attr for ino 2\n");
117 err = llight_getattr(2, NULL);
118 printk("-- done err %d\n", err);
131 static struct file_operations requestdev_fops = {
132 ioctl: request_ioctl,
136 static struct miscdevice request_dev = {
143 int init_request_module(void)
145 misc_register( &request_dev );
150 MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
151 MODULE_DESCRIPTION("Lustre MDS Request Tester v1.0");
153 #include <linux/module.h>
155 int init_module(void)
157 return init_request_module();
160 void cleanup_module(void)
162 misc_deregister(&request_dev);