dev.c (45714d65618407bce1fd0271bc58303ce14b0785) dev.c (1d3d752b471d2a3a1d5e4fe177e5e7d52abb4e4c)
1/*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
4
5 This program can be distributed under the terms of the GNU GPL.
6 See the file COPYING.
7*/
8

--- 603 unchanged lines hidden (view full) ---

612{
613 int err;
614 struct fuse_conn *fc;
615 struct fuse_req *req;
616 struct fuse_in *in;
617 struct fuse_copy_state cs;
618 unsigned reqsize;
619
1/*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
4
5 This program can be distributed under the terms of the GNU GPL.
6 See the file COPYING.
7*/
8

--- 603 unchanged lines hidden (view full) ---

612{
613 int err;
614 struct fuse_conn *fc;
615 struct fuse_req *req;
616 struct fuse_in *in;
617 struct fuse_copy_state cs;
618 unsigned reqsize;
619
620 restart:
620 spin_lock(&fuse_lock);
621 fc = file->private_data;
622 err = -EPERM;
623 if (!fc)
624 goto err_unlock;
625 request_wait(fc);
626 err = -ENODEV;
627 if (!fc->mounted)
628 goto err_unlock;
629 err = -ERESTARTSYS;
630 if (list_empty(&fc->pending))
631 goto err_unlock;
632
633 req = list_entry(fc->pending.next, struct fuse_req, list);
634 list_del_init(&req->list);
621 spin_lock(&fuse_lock);
622 fc = file->private_data;
623 err = -EPERM;
624 if (!fc)
625 goto err_unlock;
626 request_wait(fc);
627 err = -ENODEV;
628 if (!fc->mounted)
629 goto err_unlock;
630 err = -ERESTARTSYS;
631 if (list_empty(&fc->pending))
632 goto err_unlock;
633
634 req = list_entry(fc->pending.next, struct fuse_req, list);
635 list_del_init(&req->list);
635 spin_unlock(&fuse_lock);
636
637 in = &req->in;
636
637 in = &req->in;
638 reqsize = req->in.h.len;
639 fuse_copy_init(&cs, 1, req, iov, nr_segs);
640 err = -EINVAL;
641 if (iov_length(iov, nr_segs) >= reqsize) {
642 err = fuse_copy_one(&cs, &in->h, sizeof(in->h));
643 if (!err)
644 err = fuse_copy_args(&cs, in->numargs, in->argpages,
645 (struct fuse_arg *) in->args, 0);
638 reqsize = in->h.len;
639 /* If request is too large, reply with an error and restart the read */
640 if (iov_length(iov, nr_segs) < reqsize) {
641 req->out.h.error = -EIO;
642 /* SETXATTR is special, since it may contain too large data */
643 if (in->h.opcode == FUSE_SETXATTR)
644 req->out.h.error = -E2BIG;
645 request_end(fc, req);
646 goto restart;
646 }
647 }
648 spin_unlock(&fuse_lock);
649 fuse_copy_init(&cs, 1, req, iov, nr_segs);
650 err = fuse_copy_one(&cs, &in->h, sizeof(in->h));
651 if (!err)
652 err = fuse_copy_args(&cs, in->numargs, in->argpages,
653 (struct fuse_arg *) in->args, 0);
647 fuse_copy_finish(&cs);
654 fuse_copy_finish(&cs);
648
649 spin_lock(&fuse_lock);
650 req->locked = 0;
651 if (!err && req->interrupted)
652 err = -ENOENT;
653 if (err) {
654 if (!req->interrupted)
655 req->out.h.error = -EIO;
656 request_end(fc, req);

--- 230 unchanged lines hidden ---
655 spin_lock(&fuse_lock);
656 req->locked = 0;
657 if (!err && req->interrupted)
658 err = -ENOENT;
659 if (err) {
660 if (!req->interrupted)
661 req->out.h.error = -EIO;
662 request_end(fc, req);

--- 230 unchanged lines hidden ---