~ubuntu-branches/ubuntu/karmic/linux-mvl-dove/karmic-proposed

« back to all changes in this revision

Viewing changes to ubuntu/aufs/loop.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bader
  • Date: 2010-03-10 22:24:12 UTC
  • mto: (15.1.2 karmic-security)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20100310222412-k86m3r53jw0je7x1
Tags: upstream-2.6.31
ImportĀ upstreamĀ versionĀ 2.6.31

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2005-2009 Junjiro R. Okajima
3
 
 *
4
 
 * This program, aufs is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
7
 
 * (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
 
 */
18
 
 
19
 
/*
20
 
 * support for loopback block device as a branch
21
 
 */
22
 
 
23
 
#include <linux/loop.h>
24
 
#include "aufs.h"
25
 
 
26
 
/*
27
 
 * test if two lower dentries have overlapping branches.
28
 
 */
29
 
int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_d1,
30
 
                             struct dentry *h_d2)
31
 
{
32
 
        struct inode *h_inode;
33
 
        struct loop_device *l;
34
 
 
35
 
        h_inode = h_d1->d_inode;
36
 
        if (MAJOR(h_inode->i_sb->s_dev) != LOOP_MAJOR)
37
 
                return 0;
38
 
 
39
 
        l = h_inode->i_sb->s_bdev->bd_disk->private_data;
40
 
        h_d1 = l->lo_backing_file->f_dentry;
41
 
        /* h_d1 can be local NFS. in this case aufs cannot detect the loop */
42
 
        if (unlikely(h_d1->d_sb == sb))
43
 
                return 1;
44
 
        return !!au_test_subdir(h_d1, h_d2);
45
 
}
46
 
 
47
 
/* true if a kernel thread named 'loop[0-9].*' accesses a file */
48
 
int au_test_loopback_kthread(void)
49
 
{
50
 
        const char c = current->comm[4];
51
 
 
52
 
        return current->mm == NULL
53
 
               && '0' <= c && c <= '9'
54
 
               && strncmp(current->comm, "loop", 4) == 0;
55
 
}