38 #include <linux/device.h>
41 #include <linux/kdev_t.h>
43 #include <linux/list.h>
44 #include <linux/magic.h>
47 #include <linux/slab.h>
49 #include <linux/stat.h>
50 #include <linux/module.h>
54 #define CUSE_CONNTBL_LEN 64
68 static struct class *cuse_class;
100 size_t count, loff_t *ppos)
117 spin_lock(&cuse_lock);
119 if (pos->
dev->devt == devt) {
124 spin_unlock(&cuse_lock);
140 static int cuse_release(
struct inode *inode,
struct file *file)
151 static long cuse_file_ioctl(
struct file *file,
unsigned int cmd,
156 unsigned int flags = 0;
164 static long cuse_file_compat_ioctl(
struct file *file,
unsigned int cmd,
182 .release = cuse_release,
183 .unlocked_ioctl = cuse_file_ioctl,
184 .compat_ioctl = cuse_file_compat_ioctl,
214 static int cuse_parse_one(
char **
pp,
char *
end,
char **keyp,
char **valp)
219 while (p < end && *p ==
'\0')
224 if (end[-1] !=
'\0') {
267 static int cuse_parse_devinfo(
char *p,
size_t len,
struct cuse_devinfo *devinfo)
274 rc = cuse_parse_one(&p, end, &key, &val);
279 if (
strcmp(key,
"DEVNAME") == 0)
294 static void cuse_gendev_release(
struct device *
dev)
317 if (req->
out.h.error ||
352 dev_set_uevent_suppress(dev, 1);
353 dev->
class = cuse_class;
355 dev->
release = cuse_gendev_release;
370 cdev->
ops = &cuse_frontend_fops;
380 spin_lock(&cuse_lock);
381 list_add(&cc->
list, cuse_conntbl_head(devt));
382 spin_unlock(&cuse_lock);
385 dev_set_uevent_suppress(dev, 0);
403 static int cuse_send_init(
struct cuse_conn *cc)
436 req->
in.args[0].value =
arg;
437 req->
out.numargs = 2;
439 req->
out.args[0].value = outarg;
442 req->
out.argpages = 1;
445 req->
end = cuse_process_init_reply;
458 static void cuse_fc_release(
struct fuse_conn *fc)
479 static int cuse_channel_open(
struct inode *inode,
struct file *file)
491 INIT_LIST_HEAD(&cc->
list);
492 cc->
fc.release = cuse_fc_release;
494 cc->
fc.connected = 1;
496 rc = cuse_send_init(cc);
517 static int cuse_channel_release(
struct inode *inode,
struct file *file)
523 spin_lock(&cuse_lock);
524 list_del_init(&cc->
list);
525 spin_unlock(&cuse_lock);
559 const char *buf,
size_t count)
576 .fops = &cuse_channel_fops,
579 static int __init cuse_init(
void)
585 INIT_LIST_HEAD(&cuse_conntbl[i]);
590 cuse_channel_fops.open = cuse_channel_open;
591 cuse_channel_fops.release = cuse_channel_release;
594 if (IS_ERR(cuse_class))
595 return PTR_ERR(cuse_class);
597 cuse_class->
dev_attrs = cuse_class_dev_attrs;
608 static void __exit cuse_exit(
void)