cuse: convert init to simple api
This is a straightforward conversion. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
615047eff1
commit
b50ef7c52a
|
@ -298,6 +298,14 @@ static void cuse_gendev_release(struct device *dev)
|
||||||
kfree(dev);
|
kfree(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct cuse_init_args {
|
||||||
|
struct fuse_args_pages ap;
|
||||||
|
struct cuse_init_in in;
|
||||||
|
struct cuse_init_out out;
|
||||||
|
struct page *page;
|
||||||
|
struct fuse_page_desc desc;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cuse_process_init_reply - finish initializing CUSE channel
|
* cuse_process_init_reply - finish initializing CUSE channel
|
||||||
*
|
*
|
||||||
|
@ -305,21 +313,22 @@ static void cuse_gendev_release(struct device *dev)
|
||||||
* required data structures for it. Please read the comment at the
|
* required data structures for it. Please read the comment at the
|
||||||
* top of this file for high level overview.
|
* top of this file for high level overview.
|
||||||
*/
|
*/
|
||||||
static void cuse_process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
|
static void cuse_process_init_reply(struct fuse_conn *fc,
|
||||||
|
struct fuse_args *args, int error)
|
||||||
{
|
{
|
||||||
|
struct cuse_init_args *ia = container_of(args, typeof(*ia), ap.args);
|
||||||
|
struct fuse_args_pages *ap = &ia->ap;
|
||||||
struct cuse_conn *cc = fc_to_cc(fc), *pos;
|
struct cuse_conn *cc = fc_to_cc(fc), *pos;
|
||||||
struct cuse_init_out *arg = req->out.args[0].value;
|
struct cuse_init_out *arg = &ia->out;
|
||||||
struct page *page = req->pages[0];
|
struct page *page = ap->pages[0];
|
||||||
struct cuse_devinfo devinfo = { };
|
struct cuse_devinfo devinfo = { };
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct cdev *cdev;
|
struct cdev *cdev;
|
||||||
dev_t devt;
|
dev_t devt;
|
||||||
int rc, i;
|
int rc, i;
|
||||||
|
|
||||||
if (req->out.h.error ||
|
if (error || arg->major != FUSE_KERNEL_VERSION || arg->minor < 11)
|
||||||
arg->major != FUSE_KERNEL_VERSION || arg->minor < 11) {
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
fc->minor = arg->minor;
|
fc->minor = arg->minor;
|
||||||
fc->max_read = max_t(unsigned, arg->max_read, 4096);
|
fc->max_read = max_t(unsigned, arg->max_read, 4096);
|
||||||
|
@ -328,7 +337,7 @@ static void cuse_process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
|
||||||
/* parse init reply */
|
/* parse init reply */
|
||||||
cc->unrestricted_ioctl = arg->flags & CUSE_UNRESTRICTED_IOCTL;
|
cc->unrestricted_ioctl = arg->flags & CUSE_UNRESTRICTED_IOCTL;
|
||||||
|
|
||||||
rc = cuse_parse_devinfo(page_address(page), req->out.args[1].size,
|
rc = cuse_parse_devinfo(page_address(page), ap->args.out_args[1].size,
|
||||||
&devinfo);
|
&devinfo);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -395,7 +404,7 @@ static void cuse_process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
|
||||||
dev_set_uevent_suppress(dev, 0);
|
dev_set_uevent_suppress(dev, 0);
|
||||||
kobject_uevent(&dev->kobj, KOBJ_ADD);
|
kobject_uevent(&dev->kobj, KOBJ_ADD);
|
||||||
out:
|
out:
|
||||||
kfree(arg);
|
kfree(ia);
|
||||||
__free_page(page);
|
__free_page(page);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -414,55 +423,49 @@ err:
|
||||||
static int cuse_send_init(struct cuse_conn *cc)
|
static int cuse_send_init(struct cuse_conn *cc)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct fuse_req *req;
|
|
||||||
struct page *page;
|
struct page *page;
|
||||||
struct fuse_conn *fc = &cc->fc;
|
struct fuse_conn *fc = &cc->fc;
|
||||||
struct cuse_init_in *arg;
|
struct cuse_init_args *ia;
|
||||||
void *outarg;
|
struct fuse_args_pages *ap;
|
||||||
|
|
||||||
BUILD_BUG_ON(CUSE_INIT_INFO_MAX > PAGE_SIZE);
|
BUILD_BUG_ON(CUSE_INIT_INFO_MAX > PAGE_SIZE);
|
||||||
|
|
||||||
req = fuse_get_req_for_background(fc, 1);
|
|
||||||
if (IS_ERR(req)) {
|
|
||||||
rc = PTR_ERR(req);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
page = alloc_page(GFP_KERNEL | __GFP_ZERO);
|
page = alloc_page(GFP_KERNEL | __GFP_ZERO);
|
||||||
if (!page)
|
if (!page)
|
||||||
goto err_put_req;
|
goto err;
|
||||||
|
|
||||||
outarg = kzalloc(sizeof(struct cuse_init_out), GFP_KERNEL);
|
ia = kzalloc(sizeof(*ia), GFP_KERNEL);
|
||||||
if (!outarg)
|
if (!ia)
|
||||||
goto err_free_page;
|
goto err_free_page;
|
||||||
|
|
||||||
arg = &req->misc.cuse_init_in;
|
ap = &ia->ap;
|
||||||
arg->major = FUSE_KERNEL_VERSION;
|
ia->in.major = FUSE_KERNEL_VERSION;
|
||||||
arg->minor = FUSE_KERNEL_MINOR_VERSION;
|
ia->in.minor = FUSE_KERNEL_MINOR_VERSION;
|
||||||
arg->flags |= CUSE_UNRESTRICTED_IOCTL;
|
ia->in.flags |= CUSE_UNRESTRICTED_IOCTL;
|
||||||
req->in.h.opcode = CUSE_INIT;
|
ap->args.opcode = CUSE_INIT;
|
||||||
req->in.numargs = 1;
|
ap->args.in_numargs = 1;
|
||||||
req->in.args[0].size = sizeof(struct cuse_init_in);
|
ap->args.in_args[0].size = sizeof(ia->in);
|
||||||
req->in.args[0].value = arg;
|
ap->args.in_args[0].value = &ia->in;
|
||||||
req->out.numargs = 2;
|
ap->args.out_numargs = 2;
|
||||||
req->out.args[0].size = sizeof(struct cuse_init_out);
|
ap->args.out_args[0].size = sizeof(ia->out);
|
||||||
req->out.args[0].value = outarg;
|
ap->args.out_args[0].value = &ia->out;
|
||||||
req->out.args[1].size = CUSE_INIT_INFO_MAX;
|
ap->args.out_args[1].size = CUSE_INIT_INFO_MAX;
|
||||||
req->out.argvar = 1;
|
ap->args.out_argvar = 1;
|
||||||
req->out.argpages = 1;
|
ap->args.out_pages = 1;
|
||||||
req->pages[0] = page;
|
ap->num_pages = 1;
|
||||||
req->page_descs[0].length = req->out.args[1].size;
|
ap->pages = &ia->page;
|
||||||
req->num_pages = 1;
|
ap->descs = &ia->desc;
|
||||||
req->end = cuse_process_init_reply;
|
ia->page = page;
|
||||||
fuse_request_send_background(fc, req);
|
ia->desc.length = ap->args.out_args[1].size;
|
||||||
|
ap->args.end = cuse_process_init_reply;
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
rc = fuse_simple_background(fc, &ap->args, GFP_KERNEL);
|
||||||
|
if (rc) {
|
||||||
|
kfree(ia);
|
||||||
err_free_page:
|
err_free_page:
|
||||||
__free_page(page);
|
__free_page(page);
|
||||||
err_put_req:
|
}
|
||||||
fuse_put_request(fc, req);
|
|
||||||
err:
|
err:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue