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

« back to all changes in this revision

Viewing changes to fs/aufs25/dlgt.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
 * lookup functions in 'delegate' mode
 
21
 *
 
22
 * $Id: dlgt.c,v 1.2 2008/04/21 02:00:37 sfjro Exp $
 
23
 */
 
24
 
 
25
//#include <linux/security.h>
 
26
#include "aufs.h"
 
27
 
 
28
/* ---------------------------------------------------------------------- */
 
29
 
 
30
struct au_lookup_one_len_args {
 
31
        struct dentry **errp;
 
32
        const char *name;
 
33
        struct dentry *parent;
 
34
        int len;
 
35
};
 
36
 
 
37
static void au_call_lookup_one_len(void *args)
 
38
{
 
39
        struct au_lookup_one_len_args *a = args;
 
40
        *a->errp = vfsub_lookup_one_len(a->name, a->parent, a->len);
 
41
}
 
42
 
 
43
struct dentry *au_lkup_one_dlgt(const char *name, struct dentry *parent,
 
44
                                int len, unsigned int flags)
 
45
{
 
46
        struct dentry *dentry;
 
47
        int dirperm1;
 
48
 
 
49
        LKTRTrace("%.*s/%.*s, 0x%x\n", AuDLNPair(parent), len, name, flags);
 
50
 
 
51
        dirperm1 = au_ftest_ndx(flags, DIRPERM1);
 
52
        if (!dirperm1 && !au_ftest_ndx(flags, DLGT))
 
53
                dentry = vfsub_lookup_one_len(name, parent, len);
 
54
        else {
 
55
                int wkq_err;
 
56
                struct au_lookup_one_len_args args = {
 
57
                        .errp   = &dentry,
 
58
                        .name   = name,
 
59
                        .parent = parent,
 
60
                        .len    = len
 
61
                };
 
62
                wkq_err = au_wkq_wait(au_call_lookup_one_len, &args,
 
63
                                      /*dlgt*/!dirperm1);
 
64
                if (unlikely(wkq_err))
 
65
                        dentry = ERR_PTR(wkq_err);
 
66
        }
 
67
 
 
68
        AuTraceErrPtr(dentry);
 
69
        return dentry;
 
70
}
 
71
 
 
72
/* ---------------------------------------------------------------------- */
 
73
 
 
74
struct security_inode_permission_args {
 
75
        int *errp;
 
76
        struct inode *h_inode;
 
77
        int mask;
 
78
        struct nameidata *fake_nd;
 
79
};
 
80
 
 
81
static void call_security_inode_permission(void *args)
 
82
{
 
83
        struct security_inode_permission_args *a = args;
 
84
        LKTRTrace("fsuid %d\n", current->fsuid);
 
85
        *a->errp = security_inode_permission(a->h_inode, a->mask, a->fake_nd);
 
86
}
 
87
 
 
88
int au_security_inode_permission(struct inode *h_inode, int mask,
 
89
                                 struct nameidata *fake_nd, int dlgt)
 
90
{
 
91
        int err;
 
92
 
 
93
        AuTraceEnter();
 
94
 
 
95
        if (!dlgt)
 
96
                err = security_inode_permission(h_inode, mask, fake_nd);
 
97
        else {
 
98
                int wkq_err;
 
99
                struct security_inode_permission_args args = {
 
100
                        .errp           = &err,
 
101
                        .h_inode        = h_inode,
 
102
                        .mask           = mask,
 
103
                        .fake_nd        = fake_nd
 
104
                };
 
105
                wkq_err = au_wkq_wait(call_security_inode_permission, &args,
 
106
                                      /*dlgt*/1);
 
107
                if (unlikely(wkq_err))
 
108
                        err = wkq_err;
 
109
        }
 
110
 
 
111
        AuTraceErr(err);
 
112
        return err;
 
113
}