Lines Matching +full:key +full:- +full:release

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2008-2009 SUSE Linux Products GmbH
6 * Copyright (C) 2008-2009 Tejun Heo <tj@kernel.org>
116 dev_t devt = inode->i_cdev->dev; in cuse_open()
123 if (pos->dev->devt == devt) { in cuse_open()
124 fuse_conn_get(&pos->fc); in cuse_open()
132 return -ENODEV; in cuse_open()
138 rc = fuse_do_open(&cc->fm, 0, file, 0); in cuse_open()
140 fuse_conn_put(&cc->fc); in cuse_open()
146 struct fuse_file *ff = file->private_data; in cuse_release()
147 struct fuse_mount *fm = ff->fm; in cuse_release()
149 fuse_sync_release(NULL, ff, file->f_flags); in cuse_release()
150 fuse_conn_put(fm->fc); in cuse_release()
158 struct fuse_file *ff = file->private_data; in cuse_file_ioctl()
159 struct cuse_conn *cc = fc_to_cc(ff->fm->fc); in cuse_file_ioctl()
162 if (cc->unrestricted_ioctl) in cuse_file_ioctl()
171 struct fuse_file *ff = file->private_data; in cuse_file_compat_ioctl()
172 struct cuse_conn *cc = fc_to_cc(ff->fm->fc); in cuse_file_compat_ioctl()
175 if (cc->unrestricted_ioctl) in cuse_file_compat_ioctl()
186 .release = cuse_release,
203 * cuse_parse_one - parse one key=value pair
206 * @keyp: out parameter for key
209 * *@pp points to packed strings - "key0=val0\0key1=val1\0" which ends
210 * at @end - 1. This function parses one pair and set *@keyp to the
211 * start of the key and *@valp to the start of the value. Note that
212 * the original string is modified such that the key string is
216 * 1 on successful parse, 0 on EOF, -errno on failure.
221 char *key, *val; in cuse_parse_one() local
228 if (end[-1] != '\0') { in cuse_parse_one()
230 return -EINVAL; in cuse_parse_one()
233 key = val = p; in cuse_parse_one()
239 val = key + strlen(key); in cuse_parse_one()
240 key = strstrip(key); in cuse_parse_one()
243 key = strstrip(key); in cuse_parse_one()
245 if (!strlen(key)) { in cuse_parse_one()
246 pr_err("zero length info key specified\n"); in cuse_parse_one()
247 return -EINVAL; in cuse_parse_one()
251 *keyp = key; in cuse_parse_one()
259 * cuse_parse_devinfo - parse device info
269 * 0 on success, -errno on failure.
274 char *key, *val; in cuse_parse_devinfo() local
278 rc = cuse_parse_one(&p, end, &key, &val); in cuse_parse_devinfo()
283 if (strcmp(key, "DEVNAME") == 0) in cuse_parse_devinfo()
284 devinfo->name = val; in cuse_parse_devinfo()
286 pr_warn("unknown device info \"%s\"\n", key); in cuse_parse_devinfo()
289 if (!devinfo->name || !strlen(devinfo->name)) { in cuse_parse_devinfo()
291 return -EINVAL; in cuse_parse_devinfo()
311 * cuse_process_init_reply - finish initializing CUSE channel
320 struct fuse_conn *fc = fm->fc; in cuse_process_init_reply()
322 struct fuse_args_pages *ap = &ia->ap; in cuse_process_init_reply()
324 struct cuse_init_out *arg = &ia->out; in cuse_process_init_reply()
325 struct page *page = ap->pages[0]; in cuse_process_init_reply()
332 if (error || arg->major != FUSE_KERNEL_VERSION || arg->minor < 11) in cuse_process_init_reply()
335 fc->minor = arg->minor; in cuse_process_init_reply()
336 fc->max_read = max_t(unsigned, arg->max_read, 4096); in cuse_process_init_reply()
337 fc->max_write = max_t(unsigned, arg->max_write, 4096); in cuse_process_init_reply()
340 cc->unrestricted_ioctl = arg->flags & CUSE_UNRESTRICTED_IOCTL; in cuse_process_init_reply()
342 rc = cuse_parse_devinfo(page_address(page), ap->args.out_args[1].size, in cuse_process_init_reply()
348 devt = MKDEV(arg->dev_major, arg->dev_minor); in cuse_process_init_reply()
359 rc = -ENOMEM; in cuse_process_init_reply()
366 dev->class = cuse_class; in cuse_process_init_reply()
367 dev->devt = devt; in cuse_process_init_reply()
368 dev->release = cuse_gendev_release; in cuse_process_init_reply()
374 /* make sure the device-name is unique */ in cuse_process_init_reply()
377 if (!strcmp(dev_name(pos->dev), dev_name(dev))) in cuse_process_init_reply()
386 rc = -ENOMEM; in cuse_process_init_reply()
391 cdev->owner = THIS_MODULE; in cuse_process_init_reply()
392 cdev->ops = &cuse_frontend_fops; in cuse_process_init_reply()
398 cc->dev = dev; in cuse_process_init_reply()
399 cc->cdev = cdev; in cuse_process_init_reply()
402 list_add(&cc->list, cuse_conntbl_head(devt)); in cuse_process_init_reply()
407 kobject_uevent(&dev->kobj, KOBJ_ADD); in cuse_process_init_reply()
429 struct fuse_mount *fm = &cc->fm; in cuse_send_init()
435 rc = -ENOMEM; in cuse_send_init()
444 ap = &ia->ap; in cuse_send_init()
445 ia->in.major = FUSE_KERNEL_VERSION; in cuse_send_init()
446 ia->in.minor = FUSE_KERNEL_MINOR_VERSION; in cuse_send_init()
447 ia->in.flags |= CUSE_UNRESTRICTED_IOCTL; in cuse_send_init()
448 ap->args.opcode = CUSE_INIT; in cuse_send_init()
449 ap->args.in_numargs = 1; in cuse_send_init()
450 ap->args.in_args[0].size = sizeof(ia->in); in cuse_send_init()
451 ap->args.in_args[0].value = &ia->in; in cuse_send_init()
452 ap->args.out_numargs = 2; in cuse_send_init()
453 ap->args.out_args[0].size = sizeof(ia->out); in cuse_send_init()
454 ap->args.out_args[0].value = &ia->out; in cuse_send_init()
455 ap->args.out_args[1].size = CUSE_INIT_INFO_MAX; in cuse_send_init()
456 ap->args.out_argvar = true; in cuse_send_init()
457 ap->args.out_pages = true; in cuse_send_init()
458 ap->num_pages = 1; in cuse_send_init()
459 ap->pages = &ia->page; in cuse_send_init()
460 ap->descs = &ia->desc; in cuse_send_init()
461 ia->page = page; in cuse_send_init()
462 ia->desc.length = ap->args.out_args[1].size; in cuse_send_init()
463 ap->args.end = cuse_process_init_reply; in cuse_send_init()
465 rc = fuse_simple_background(fm, &ap->args, GFP_KERNEL); in cuse_send_init()
482 * cuse_channel_open - open method for /dev/cuse
494 * 0 on success, -errno on failure.
505 return -ENOMEM; in cuse_channel_open()
509 * be represented in file->f_cred->user_ns. in cuse_channel_open()
511 fuse_conn_init(&cc->fc, &cc->fm, file->f_cred->user_ns, in cuse_channel_open()
514 cc->fc.release = cuse_fc_release; in cuse_channel_open()
515 fud = fuse_dev_alloc_install(&cc->fc); in cuse_channel_open()
516 fuse_conn_put(&cc->fc); in cuse_channel_open()
518 return -ENOMEM; in cuse_channel_open()
520 INIT_LIST_HEAD(&cc->list); in cuse_channel_open()
522 cc->fc.initialized = 1; in cuse_channel_open()
528 file->private_data = fud; in cuse_channel_open()
534 * cuse_channel_release - release method for /dev/cuse
542 * 0 on success, -errno on failure.
546 struct fuse_dev *fud = file->private_data; in cuse_channel_release()
547 struct cuse_conn *cc = fc_to_cc(fud->fc); in cuse_channel_release()
551 list_del_init(&cc->list); in cuse_channel_release()
555 if (cc->dev) in cuse_channel_release()
556 device_unregister(cc->dev); in cuse_channel_release()
557 if (cc->cdev) { in cuse_channel_release()
558 unregister_chrdev_region(cc->cdev->dev, 1); in cuse_channel_release()
559 cdev_del(cc->cdev); in cuse_channel_release()
579 return sprintf(buf, "%d\n", atomic_read(&cc->fc.num_waiting)); in cuse_class_waiting_show()
589 fuse_abort_conn(&cc->fc); in cuse_class_abort_store()
622 cuse_channel_fops.release = cuse_channel_release; in cuse_init()
630 cuse_class->dev_groups = cuse_class_dev_groups; in cuse_init()