~ubuntu-branches/ubuntu/vivid/aufs/vivid

« back to all changes in this revision

Viewing changes to fs/aufs/robr.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080506183550-0b6c974kkgc46oeh
Tags: 0+20080506-1
* New upstream release, supports Kernel 2.6.25 (Closes: #479717)
* Fix building with older Kernels (Closes: #475042)
* Update the patches 01, 04 and 07 to also patch fs/aufs25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2008 Junjiro 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
 * 'robr', aufs as readonly branch of another aufs
 
21
 *
 
22
 * $Id: robr.c,v 1.2 2008/04/13 23:44:36 sfjro Exp $
 
23
 */
 
24
 
 
25
#include "aufs.h"
 
26
 
 
27
/* ---------------------------------------------------------------------- */
 
28
 
 
29
int au_test_robr_wh(struct qstr *name, struct dentry *h_parent,
 
30
                    struct qstr *wh_name, int try_sio, struct au_ndx *ndx)
 
31
{
 
32
        if (strncmp(name->name, AUFS_WH_PFX, AUFS_WH_PFX_LEN))
 
33
                return au_wh_test(h_parent, wh_name, try_sio, ndx);
 
34
        return -EPERM;
 
35
}
 
36
 
 
37
int au_test_robr_shwh(struct super_block *sb, const struct qstr *name)
 
38
{
 
39
        return 0;
 
40
}
 
41
 
 
42
/* ---------------------------------------------------------------------- */
 
43
 
 
44
struct au_robr_lvma {
 
45
        struct list_head list;
 
46
        struct vm_area_struct *vma;
 
47
};
 
48
 
 
49
struct file *au_robr_safe_file(struct vm_area_struct *vma)
 
50
{
 
51
        struct file *file = vma->vm_file;
 
52
        struct super_block *sb = file->f_dentry->d_sb;
 
53
        struct au_robr_lvma *lvma, *entry;
 
54
        struct au_sbinfo *sbinfo;
 
55
        int found, warn;
 
56
 
 
57
        AuTraceEnter();
 
58
        AuDebugOn(!au_test_aufs(sb));
 
59
 
 
60
        warn = 0;
 
61
        found = 0;
 
62
        sbinfo = au_sbi(sb);
 
63
        spin_lock(&sbinfo->si_lvma_lock);
 
64
        list_for_each_entry(entry, &sbinfo->si_lvma, list) {
 
65
                found = (entry->vma == vma);
 
66
                if (unlikely(found))
 
67
                        break;
 
68
        }
 
69
        if (!found) {
 
70
                lvma = kmalloc(sizeof(*lvma), GFP_ATOMIC);
 
71
                if (lvma) {
 
72
                        lvma->vma = vma;
 
73
                        list_add(&lvma->list, &sbinfo->si_lvma);
 
74
                } else {
 
75
                        warn = 1;
 
76
                        file = NULL;
 
77
                }
 
78
        } else
 
79
                file = NULL;
 
80
        spin_unlock(&sbinfo->si_lvma_lock);
 
81
 
 
82
        if (unlikely(warn))
 
83
                AuWarn1("no memory for lvma\n");
 
84
        return file;
 
85
}
 
86
 
 
87
void au_robr_reset_file(struct vm_area_struct *vma, struct file *file)
 
88
{
 
89
        struct super_block *sb = file->f_dentry->d_sb;
 
90
        struct au_robr_lvma *entry, *found;
 
91
        struct au_sbinfo *sbinfo;
 
92
 
 
93
        AuTraceEnter();
 
94
        AuDebugOn(!au_test_aufs(sb));
 
95
 
 
96
        vma->vm_file = file;
 
97
 
 
98
        found = NULL;
 
99
        sbinfo = au_sbi(sb);
 
100
        spin_lock(&sbinfo->si_lvma_lock);
 
101
        list_for_each_entry(entry, &sbinfo->si_lvma, list)
 
102
                if (entry->vma == vma) {
 
103
                        found = entry;
 
104
                        break;
 
105
                }
 
106
        AuDebugOn(!found);
 
107
        list_del(&found->list);
 
108
        spin_unlock(&sbinfo->si_lvma_lock);
 
109
        kfree(found);
 
110
}