~barry/ubuntu/maverick/fuse/bug-697792-m

« back to all changes in this revision

Viewing changes to kernel/inode.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2007-08-04 08:09:00 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070804080900-m1e9xpk5eitzmelg
Tags: 2.7.0-1ubuntu1
* Resynchronise with Debian (LP: #128292). Remaining changes:
  - Don't install the init script; install the udev rule and the module
    configuration file instead.
  - debian/45-fuse.rules: set /dev/fuse group to fuse.
  - debian/fuse-utils.modprobe: module configuration file that mounts the
    control filesystem when fuse is loaded and unmounts it when fuse is
    unloaded, along with checking that the control FS is mounting before
    unmounting it.
  - debian/fuse-utils.install: add the udev rule, the module configuration
    file, and ulockmgr_server.
  - Load fuse on install, and set it so it gets loaded on reboot.
  - Move fusermount and ulockmgr_server to /bin and associated libraries
    to /lib.
* Use dpkg-query to fetch conffile md5sums rather than parsing
  /var/lib/dpkg/status directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
  FUSE: Filesystem in Userspace
3
 
  Copyright (C) 2001-2006  Miklos Szeredi <miklos@szeredi.hu>
 
3
  Copyright (C) 2001-2007  Miklos Szeredi <miklos@szeredi.hu>
4
4
 
5
5
  This program can be distributed under the terms of the GNU GPL.
6
6
  See the file COPYING.
17
17
#include <linux/parser.h>
18
18
#include <linux/statfs.h>
19
19
#include <linux/random.h>
 
20
#include <linux/sched.h>
20
21
 
21
22
MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
22
23
MODULE_DESCRIPTION("Filesystem in Userspace");
24
25
MODULE_LICENSE("GPL");
25
26
#endif
26
27
 
27
 
static kmem_cache_t *fuse_inode_cachep;
 
28
static struct kmem_cache *fuse_inode_cachep;
28
29
struct list_head fuse_conn_list;
29
30
DEFINE_MUTEX(fuse_mutex);
30
31
 
124
125
{
125
126
        struct fuse_conn *fc = get_fuse_conn(inode);
126
127
        if (S_ISREG(inode->i_mode) && i_size_read(inode) != attr->size)
 
128
#ifdef KERNEL_2_6_21_PLUS
 
129
                invalidate_mapping_pages(inode->i_mapping, 0, -1);
 
130
#else
127
131
                invalidate_inode_pages(inode->i_mapping);
 
132
#endif
128
133
 
129
134
        inode->i_ino     = attr->ino;
130
135
        inode->i_mode    = (inode->i_mode & S_IFMT) + (attr->mode & 07777);
341
346
        d->max_read = ~0;
342
347
        d->blksize = 512;
343
348
 
 
349
        /*
 
350
         * For unprivileged mounts use current uid/gid.  Still allow
 
351
         * "user_id" and "group_id" options for compatibility, but
 
352
         * only if they match these values.
 
353
         */
 
354
        if (!capable(CAP_SYS_ADMIN)) {
 
355
                d->user_id = current->uid;
 
356
                d->user_id_present = 1;
 
357
                d->group_id = current->gid;
 
358
                d->group_id_present = 1;
 
359
 
 
360
        }
 
361
 
344
362
        while ((p = strsep(&opt, ",")) != NULL) {
345
363
                int token;
346
364
                int value;
360
378
                case OPT_ROOTMODE:
361
379
                        if (match_octal(&args[0], &value))
362
380
                                return 0;
 
381
                        if (!fuse_valid_type(value))
 
382
                                return 0;
363
383
                        d->rootmode = value;
364
384
                        d->rootmode_present = 1;
365
385
                        break;
367
387
                case OPT_USER_ID:
368
388
                        if (match_int(&args[0], &value))
369
389
                                return 0;
 
390
                        if (d->user_id_present && d->user_id != value)
 
391
                                return 0;
370
392
                        d->user_id = value;
371
393
                        d->user_id_present = 1;
372
394
                        break;
374
396
                case OPT_GROUP_ID:
375
397
                        if (match_int(&args[0], &value))
376
398
                                return 0;
 
399
                        if (d->group_id_present && d->group_id != value)
 
400
                                return 0;
377
401
                        d->group_id = value;
378
402
                        d->group_id_present = 1;
379
403
                        break;
485
509
        return fuse_iget(sb, 1, 0, &attr);
486
510
}
487
511
#ifndef FUSE_MAINLINE
 
512
#ifdef HAVE_EXPORTFS_H
 
513
#include <linux/exportfs.h>
 
514
#endif
488
515
static struct dentry *fuse_get_dentry(struct super_block *sb, void *vobjp)
489
516
{
490
517
        __u32 *objp = vobjp;
552
579
        .destroy_inode  = fuse_destroy_inode,
553
580
        .read_inode     = fuse_read_inode,
554
581
        .clear_inode    = fuse_clear_inode,
 
582
        .drop_inode     = generic_delete_inode,
555
583
        .remount_fs     = fuse_remount_fs,
556
584
        .put_super      = fuse_put_super,
557
585
        .umount_begin   = fuse_umount_begin,
635
663
        if (!parse_fuse_opt((char *) data, &d, is_bdev))
636
664
                return -EINVAL;
637
665
 
 
666
        /* This is a privileged option */
 
667
        if ((d.flags & FUSE_ALLOW_OTHER) && !capable(CAP_SYS_ADMIN))
 
668
                return -EPERM;
 
669
 
638
670
        if (is_bdev) {
639
671
#ifdef CONFIG_BLOCK
640
672
                if (!sb_set_blocksize(sb, d.blksize))
749
781
        .name           = "fuse",
750
782
        .get_sb         = fuse_get_sb,
751
783
        .kill_sb        = kill_anon_super,
 
784
        .fs_flags       = FS_HAS_SUBTYPE | FS_SAFE,
752
785
};
753
786
 
754
787
#ifdef CONFIG_BLOCK
775
808
        .name           = "fuseblk",
776
809
        .get_sb         = fuse_get_sb_blk,
777
810
        .kill_sb        = kill_block_super,
778
 
        .fs_flags       = FS_REQUIRES_DEV,
 
811
        .fs_flags       = FS_REQUIRES_DEV | FS_HAS_SUBTYPE,
779
812
};
780
813
 
781
814
static inline int register_fuseblk(void)
804
837
static decl_subsys(fuse, NULL, NULL);
805
838
static decl_subsys(connections, NULL, NULL);
806
839
 
807
 
static void fuse_inode_init_once(void *foo, kmem_cache_t *cachep,
 
840
static void fuse_inode_init_once(void *foo, struct kmem_cache *cachep,
808
841
                                 unsigned long flags)
809
842
{
810
843
        struct inode * inode = foo;
811
844
 
 
845
#ifndef KERNEL_2_6_22_PLUS
812
846
        if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
813
847
            SLAB_CTOR_CONSTRUCTOR)
814
 
                inode_init_once(inode);
 
848
#endif
 
849
        inode_init_once(inode);
815
850
}
816
851
 
817
852
static int __init fuse_fs_init(void)
860
895
        if (err)
861
896
                return err;
862
897
#endif
 
898
#ifdef KERNEL_2_6_22_PLUS
 
899
        kobj_set_kset_s(&fuse_subsys, fs_subsys);
 
900
#else
863
901
        kset_set_kset_s(&fuse_subsys, fs_subsys);
 
902
#endif
864
903
        err = subsystem_register(&fuse_subsys);
865
904
        if (err)
866
905
                goto out_err;
867
906
 
 
907
#ifdef KERNEL_2_6_22_PLUS
 
908
        kobj_set_kset_s(&connections_subsys, fuse_subsys);
 
909
#else
868
910
        kset_set_kset_s(&connections_subsys, fuse_subsys);
 
911
#endif
869
912
        err = subsystem_register(&connections_subsys);
870
913
        if (err)
871
914
                goto out_fuse_unregister;