inode.c (ca31fef11dc83e672415d5925a134749761329bd) inode.c (84c215075b5723ab946708a6c74c26bd3c51114c)
1/*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2008 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

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

133 }
134 }
135 if (S_ISREG(inode->i_mode) && !fuse_is_bad(inode)) {
136 WARN_ON(!list_empty(&fi->write_files));
137 WARN_ON(!list_empty(&fi->queued_writes));
138 }
139}
140
1/*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2008 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

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

133 }
134 }
135 if (S_ISREG(inode->i_mode) && !fuse_is_bad(inode)) {
136 WARN_ON(!list_empty(&fi->write_files));
137 WARN_ON(!list_empty(&fi->queued_writes));
138 }
139}
140
141static int fuse_reconfigure(struct fs_context *fc)
141static int fuse_reconfigure(struct fs_context *fsc)
142{
142{
143 struct super_block *sb = fc->root->d_sb;
143 struct super_block *sb = fsc->root->d_sb;
144
145 sync_filesystem(sb);
144
145 sync_filesystem(sb);
146 if (fc->sb_flags & SB_MANDLOCK)
146 if (fsc->sb_flags & SB_MANDLOCK)
147 return -EINVAL;
148
149 return 0;
150}
151
152/*
153 * ino_t is 32-bits on 32-bit arch. We have to squash the 64-bit value down
154 * so that it will fit.

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

568 fsparam_flag ("default_permissions", OPT_DEFAULT_PERMISSIONS),
569 fsparam_flag ("allow_other", OPT_ALLOW_OTHER),
570 fsparam_u32 ("max_read", OPT_MAX_READ),
571 fsparam_u32 ("blksize", OPT_BLKSIZE),
572 fsparam_string ("subtype", OPT_SUBTYPE),
573 {}
574};
575
147 return -EINVAL;
148
149 return 0;
150}
151
152/*
153 * ino_t is 32-bits on 32-bit arch. We have to squash the 64-bit value down
154 * so that it will fit.

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

568 fsparam_flag ("default_permissions", OPT_DEFAULT_PERMISSIONS),
569 fsparam_flag ("allow_other", OPT_ALLOW_OTHER),
570 fsparam_u32 ("max_read", OPT_MAX_READ),
571 fsparam_u32 ("blksize", OPT_BLKSIZE),
572 fsparam_string ("subtype", OPT_SUBTYPE),
573 {}
574};
575
576static int fuse_parse_param(struct fs_context *fc, struct fs_parameter *param)
576static int fuse_parse_param(struct fs_context *fsc, struct fs_parameter *param)
577{
578 struct fs_parse_result result;
577{
578 struct fs_parse_result result;
579 struct fuse_fs_context *ctx = fc->fs_private;
579 struct fuse_fs_context *ctx = fsc->fs_private;
580 int opt;
581
580 int opt;
581
582 if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
582 if (fsc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
583 /*
584 * Ignore options coming from mount(MS_REMOUNT) for backward
585 * compatibility.
586 */
583 /*
584 * Ignore options coming from mount(MS_REMOUNT) for backward
585 * compatibility.
586 */
587 if (fc->oldapi)
587 if (fsc->oldapi)
588 return 0;
589
588 return 0;
589
590 return invalfc(fc, "No changes allowed in reconfigure");
590 return invalfc(fsc, "No changes allowed in reconfigure");
591 }
592
591 }
592
593 opt = fs_parse(fc, fuse_fs_parameters, param, &result);
593 opt = fs_parse(fsc, fuse_fs_parameters, param, &result);
594 if (opt < 0)
595 return opt;
596
597 switch (opt) {
598 case OPT_SOURCE:
594 if (opt < 0)
595 return opt;
596
597 switch (opt) {
598 case OPT_SOURCE:
599 if (fc->source)
600 return invalfc(fc, "Multiple sources specified");
601 fc->source = param->string;
599 if (fsc->source)
600 return invalfc(fsc, "Multiple sources specified");
601 fsc->source = param->string;
602 param->string = NULL;
603 break;
604
605 case OPT_SUBTYPE:
606 if (ctx->subtype)
602 param->string = NULL;
603 break;
604
605 case OPT_SUBTYPE:
606 if (ctx->subtype)
607 return invalfc(fc, "Multiple subtypes specified");
607 return invalfc(fsc, "Multiple subtypes specified");
608 ctx->subtype = param->string;
609 param->string = NULL;
610 return 0;
611
612 case OPT_FD:
613 ctx->fd = result.uint_32;
614 ctx->fd_present = true;
615 break;
616
617 case OPT_ROOTMODE:
618 if (!fuse_valid_type(result.uint_32))
608 ctx->subtype = param->string;
609 param->string = NULL;
610 return 0;
611
612 case OPT_FD:
613 ctx->fd = result.uint_32;
614 ctx->fd_present = true;
615 break;
616
617 case OPT_ROOTMODE:
618 if (!fuse_valid_type(result.uint_32))
619 return invalfc(fc, "Invalid rootmode");
619 return invalfc(fsc, "Invalid rootmode");
620 ctx->rootmode = result.uint_32;
621 ctx->rootmode_present = true;
622 break;
623
624 case OPT_USER_ID:
620 ctx->rootmode = result.uint_32;
621 ctx->rootmode_present = true;
622 break;
623
624 case OPT_USER_ID:
625 ctx->user_id = make_kuid(fc->user_ns, result.uint_32);
625 ctx->user_id = make_kuid(fsc->user_ns, result.uint_32);
626 if (!uid_valid(ctx->user_id))
626 if (!uid_valid(ctx->user_id))
627 return invalfc(fc, "Invalid user_id");
627 return invalfc(fsc, "Invalid user_id");
628 ctx->user_id_present = true;
629 break;
630
631 case OPT_GROUP_ID:
628 ctx->user_id_present = true;
629 break;
630
631 case OPT_GROUP_ID:
632 ctx->group_id = make_kgid(fc->user_ns, result.uint_32);
632 ctx->group_id = make_kgid(fsc->user_ns, result.uint_32);
633 if (!gid_valid(ctx->group_id))
633 if (!gid_valid(ctx->group_id))
634 return invalfc(fc, "Invalid group_id");
634 return invalfc(fsc, "Invalid group_id");
635 ctx->group_id_present = true;
636 break;
637
638 case OPT_DEFAULT_PERMISSIONS:
639 ctx->default_permissions = true;
640 break;
641
642 case OPT_ALLOW_OTHER:
643 ctx->allow_other = true;
644 break;
645
646 case OPT_MAX_READ:
647 ctx->max_read = result.uint_32;
648 break;
649
650 case OPT_BLKSIZE:
651 if (!ctx->is_bdev)
635 ctx->group_id_present = true;
636 break;
637
638 case OPT_DEFAULT_PERMISSIONS:
639 ctx->default_permissions = true;
640 break;
641
642 case OPT_ALLOW_OTHER:
643 ctx->allow_other = true;
644 break;
645
646 case OPT_MAX_READ:
647 ctx->max_read = result.uint_32;
648 break;
649
650 case OPT_BLKSIZE:
651 if (!ctx->is_bdev)
652 return invalfc(fc, "blksize only supported for fuseblk");
652 return invalfc(fsc, "blksize only supported for fuseblk");
653 ctx->blksize = result.uint_32;
654 break;
655
656 default:
657 return -EINVAL;
658 }
659
660 return 0;
661}
662
653 ctx->blksize = result.uint_32;
654 break;
655
656 default:
657 return -EINVAL;
658 }
659
660 return 0;
661}
662
663static void fuse_free_fc(struct fs_context *fc)
663static void fuse_free_fsc(struct fs_context *fsc)
664{
664{
665 struct fuse_fs_context *ctx = fc->fs_private;
665 struct fuse_fs_context *ctx = fsc->fs_private;
666
667 if (ctx) {
668 kfree(ctx->subtype);
669 kfree(ctx);
670 }
671}
672
673static int fuse_show_options(struct seq_file *m, struct dentry *root)

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

1561 kfree(fm);
1562 sb->s_fs_info = NULL;
1563 err_fput:
1564 fput(file);
1565 err:
1566 return err;
1567}
1568
666
667 if (ctx) {
668 kfree(ctx->subtype);
669 kfree(ctx);
670 }
671}
672
673static int fuse_show_options(struct seq_file *m, struct dentry *root)

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

1561 kfree(fm);
1562 sb->s_fs_info = NULL;
1563 err_fput:
1564 fput(file);
1565 err:
1566 return err;
1567}
1568
1569static int fuse_get_tree(struct fs_context *fc)
1569static int fuse_get_tree(struct fs_context *fsc)
1570{
1570{
1571 struct fuse_fs_context *ctx = fc->fs_private;
1571 struct fuse_fs_context *ctx = fsc->fs_private;
1572
1573 if (!ctx->fd_present || !ctx->rootmode_present ||
1574 !ctx->user_id_present || !ctx->group_id_present)
1575 return -EINVAL;
1576
1577#ifdef CONFIG_BLOCK
1578 if (ctx->is_bdev)
1572
1573 if (!ctx->fd_present || !ctx->rootmode_present ||
1574 !ctx->user_id_present || !ctx->group_id_present)
1575 return -EINVAL;
1576
1577#ifdef CONFIG_BLOCK
1578 if (ctx->is_bdev)
1579 return get_tree_bdev(fc, fuse_fill_super);
1579 return get_tree_bdev(fsc, fuse_fill_super);
1580#endif
1581
1580#endif
1581
1582 return get_tree_nodev(fc, fuse_fill_super);
1582 return get_tree_nodev(fsc, fuse_fill_super);
1583}
1584
1585static const struct fs_context_operations fuse_context_ops = {
1583}
1584
1585static const struct fs_context_operations fuse_context_ops = {
1586 .free = fuse_free_fc,
1586 .free = fuse_free_fsc,
1587 .parse_param = fuse_parse_param,
1588 .reconfigure = fuse_reconfigure,
1589 .get_tree = fuse_get_tree,
1590};
1591
1592/*
1593 * Set up the filesystem mount context.
1594 */
1587 .parse_param = fuse_parse_param,
1588 .reconfigure = fuse_reconfigure,
1589 .get_tree = fuse_get_tree,
1590};
1591
1592/*
1593 * Set up the filesystem mount context.
1594 */
1595static int fuse_init_fs_context(struct fs_context *fc)
1595static int fuse_init_fs_context(struct fs_context *fsc)
1596{
1597 struct fuse_fs_context *ctx;
1598
1599 ctx = kzalloc(sizeof(struct fuse_fs_context), GFP_KERNEL);
1600 if (!ctx)
1601 return -ENOMEM;
1602
1603 ctx->max_read = ~0;
1604 ctx->blksize = FUSE_DEFAULT_BLKSIZE;
1605 ctx->legacy_opts_show = true;
1606
1607#ifdef CONFIG_BLOCK
1596{
1597 struct fuse_fs_context *ctx;
1598
1599 ctx = kzalloc(sizeof(struct fuse_fs_context), GFP_KERNEL);
1600 if (!ctx)
1601 return -ENOMEM;
1602
1603 ctx->max_read = ~0;
1604 ctx->blksize = FUSE_DEFAULT_BLKSIZE;
1605 ctx->legacy_opts_show = true;
1606
1607#ifdef CONFIG_BLOCK
1608 if (fc->fs_type == &fuseblk_fs_type) {
1608 if (fsc->fs_type == &fuseblk_fs_type) {
1609 ctx->is_bdev = true;
1610 ctx->destroy = true;
1611 }
1612#endif
1613
1609 ctx->is_bdev = true;
1610 ctx->destroy = true;
1611 }
1612#endif
1613
1614 fc->fs_private = ctx;
1615 fc->ops = &fuse_context_ops;
1614 fsc->fs_private = ctx;
1615 fsc->ops = &fuse_context_ops;
1616 return 0;
1617}
1618
1619bool fuse_mount_remove(struct fuse_mount *fm)
1620{
1621 struct fuse_conn *fc = fm->fc;
1622 bool last = false;
1623

--- 225 unchanged lines hidden ---
1616 return 0;
1617}
1618
1619bool fuse_mount_remove(struct fuse_mount *fm)
1620{
1621 struct fuse_conn *fc = fm->fc;
1622 bool last = false;
1623

--- 225 unchanged lines hidden ---