1 #define DEBUG_SUBSYSTEM S_SM
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/string.h>
10 #include <linux/slab.h>
11 #include <linux/stat.h>
12 #include <linux/unistd.h>
13 #include <linux/miscdevice.h>
14 #include <linux/obd_class.h>
15 #include <linux/obd_support.h>
16 #include <linux/lustre_lib.h>
17 #include <linux/lustre_idl.h>
18 #include <linux/lustre_debug.h>
19 #include <linux/lustre_smfs.h>
21 #include "smfs_internal.h"
24 struct smfs_control_device smfs_dev;
26 static int smfs_handle_ioctl(unsigned int cmd, unsigned long arg)
28 struct obd_ioctl_data *data = NULL;
29 struct super_block *sb = NULL;
30 char *buf = NULL, *dir = NULL;
31 int err = 0, len = 0, count = 0, do_kml = 0;
33 if (obd_ioctl_getdata(&buf, &len, (void *)arg)) {
34 CERROR("OBD ioctl: data error\n");
35 GOTO(out, err = -EINVAL);
37 data = (struct obd_ioctl_data *)buf;
45 if (!data->ioc_inllen1 || !data->ioc_inlbuf1) {
46 CERROR("No mountpoint passed!\n");
47 GOTO(out, err = -EINVAL);
49 name = (char*) data->ioc_inlbuf1;
50 sb = smfs_get_sb_by_path(name, data->ioc_inllen1);
52 CERROR("can not find superblock at %s\n", buf);
53 GOTO(out, err = -EINVAL);
56 if (data->ioc_inllen2 && data->ioc_inlbuf2) {
57 dir = (char *)data->ioc_inlbuf2;
60 count = *((int*)data->ioc_pbuf1);
62 do_kml = *((int*)data->ioc_pbuf2);
66 CERROR("The command passed in is Invalid\n");
67 GOTO(out, err = -EINVAL);
73 err = smfs_start_rec(sb);
76 err = smfs_stop_rec(sb);
81 if (cmd == IOC_SMFS_REINT)
82 SET_REC_OP_FLAGS(flags, SMFS_REINT_REC);
84 SET_REC_OP_FLAGS(flags, SMFS_UNDO_REC);
86 SET_REC_COUNT_FLAGS(flags, SMFS_REC_ALL);
88 SET_REC_WRITE_KML_FLAGS(flags, SMFS_WRITE_KML);
89 err = smfs_process_rec(sb, count, dir, flags);
95 obd_ioctl_freedata(buf, len);
98 static int smfs_psdev_ioctl (struct inode * inode, struct file * filp,
99 unsigned int cmd, unsigned long arg)
102 rc = smfs_handle_ioctl(cmd, arg);
106 /* called when opening /dev/device */
107 static int smfs_psdev_open(struct inode * inode, struct file * file)
114 dev = MINOR(inode->i_rdev);
115 if (dev != SMFS_PSDEV_MINOR)
121 /* called when closing /dev/device */
122 static int smfs_psdev_release(struct inode * inode, struct file * file)
129 dev = MINOR(inode->i_rdev);
130 if (dev != SMFS_PSDEV_MINOR)
136 /* declare character device */
137 static struct file_operations smfscontrol_fops = {
138 ioctl: smfs_psdev_ioctl, /* ioctl */
139 open: smfs_psdev_open, /* open */
140 release: smfs_psdev_release, /* release */
143 #define SMFS_MINOR 250
144 static struct miscdevice smfscontrol_dev = {
147 fops: &smfscontrol_fops
150 int init_smfs_psdev(void)
152 printk(KERN_INFO "SMFS psdev driver v0.01, braam@clusterfs.com\n");
154 misc_register(&smfscontrol_dev);
159 void smfs_cleanup_psdev(void)
162 misc_deregister(&smfscontrol_dev);