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

« back to all changes in this revision

Viewing changes to fs/aufs25/wbr_policy.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-08-21 14:58:54 UTC
  • mfrom: (1.1.8 upstream) (4.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080821145854-4b49x09r4zmvlk5o
Tags: 0+20080719-4
01_vserver_apparmor.dpatch: [UPDATE] Disable vserver patches on kernel 
2.6.26, because they are not needed anymore. (Closes: #495921)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2007-2008 Junjiro Okajima
 
2
 * Copyright (C) 2005-2008 Junjiro Okajima
3
3
 *
4
4
 * This program, aufs is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
19
19
/*
20
20
 * policies for selecting one among multiple writable branches
21
21
 *
22
 
 * $Id: wbr_policy.c,v 1.6 2008/06/09 01:11:08 sfjro Exp $
 
22
 * $Id: wbr_policy.c,v 1.8 2008/07/07 01:12:39 sfjro Exp $
23
23
 */
24
24
 
25
25
#include <linux/statfs.h>
26
26
#include "aufs.h"
27
27
 
28
 
static int au_cpdown_attr(struct dentry *h_dst, struct dentry *h_src)
 
28
static int au_cpdown_attr(struct au_hinode *hdir, struct dentry *h_dst,
 
29
                          struct dentry *h_src)
29
30
{
30
31
        int err, sbits;
31
32
        struct iattr ia;
43
44
        ia.ia_gid = h_isrc->i_gid;
44
45
        sbits = !!(ia.ia_mode & (S_ISUID | S_ISGID));
45
46
 
46
 
        err = vfsub_sio_notify_change(h_dst, &ia);
 
47
        err = vfsub_sio_notify_change(hdir, h_dst, &ia);
47
48
 
48
49
        /* is this nfs only? */
49
50
        if (!err && sbits && au_test_nfs(h_dst->d_sb)) {
50
51
                ia.ia_valid = ATTR_FORCE | ATTR_MODE;
51
52
                ia.ia_mode = h_isrc->i_mode;
52
 
                err = vfsub_sio_notify_change(h_dst, &ia);
 
53
                err = vfsub_sio_notify_change(hdir, h_dst, &ia);
53
54
        }
54
55
 
55
56
        /* todo: necessary? */
71
72
        int err, parent_opq, whed, dlgt, do_opq, made_dir, diropq, rerr;
72
73
        struct au_cpdown_dir_args *args = arg;
73
74
        aufs_bindex_t bend, bopq, bstart;
74
 
        struct dentry *h_dentry, *opq_dentry, *wh_dentry;
75
 
        struct inode *h_dir, *h_inode, *inode;
 
75
        struct dentry *h_dentry, *opq_dentry, *wh_dentry, *parent;
 
76
        struct inode *h_dir, *h_inode, *inode, *dir;
76
77
 
77
78
        LKTRTrace("%.*s, b%d\n", AuDLNPair(dentry), bdst);
78
79
        bstart = au_dbstart(dentry);
80
81
                  && bdst <= au_dbend(dentry)
81
82
                  && au_h_dptr(dentry, bdst));
82
83
        AuDebugOn(!h_parent);
 
84
        /* todo: safe? */
 
85
        parent = dget_parent(dentry);
 
86
        dir = parent->d_inode;
 
87
        dput(parent);
83
88
        h_dir = h_parent->d_inode;
84
89
        AuDebugOn(!h_dir);
 
90
        AuDebugOn(h_dir != au_h_iptr(dir, bdst));
85
91
        IMustLock(h_dir);
86
92
 
87
93
        err = au_lkup_neg(dentry, bdst);
89
95
                goto out;
90
96
        h_dentry = au_h_dptr(dentry, bdst);
91
97
        dlgt = !!au_test_dlgt(au_mntflags(dentry->d_sb));
92
 
        err = vfsub_sio_mkdir(h_dir, h_dentry, S_IRWXU | S_IRUGO | S_IXUGO,
 
98
        err = vfsub_sio_mkdir(au_hi(dir, bdst), h_dentry, S_IRWXU | S_IRUGO | S_IXUGO,
93
99
                              dlgt);
94
100
        if (unlikely(err))
95
101
                goto out_put;
116
122
                diropq = 1;
117
123
        }
118
124
 
119
 
        err = au_cpdown_attr(h_dentry, au_h_dptr(dentry, bstart));
 
125
        err = au_cpdown_attr(au_hi(dir, bdst), h_dentry, au_h_dptr(dentry, bstart));
120
126
        mutex_unlock(&h_inode->i_mutex);
121
127
        if (unlikely(err))
122
128
                goto out_opq;
129
135
                        goto out_opq;
130
136
                err = 0;
131
137
                if (wh_dentry->d_inode)
132
 
                        err = au_wh_unlink_dentry(h_dir, wh_dentry, dentry,
133
 
                                                  NULL, dlgt);
 
138
                        err = au_wh_unlink_dentry(au_hi(dir, bdst), wh_dentry,
 
139
                                                  dentry, dlgt);
134
140
                dput(wh_dentry);
135
141
                if (unlikely(err))
136
142
                        goto out_opq;
157
163
        }
158
164
 out_dir:
159
165
        if (made_dir) {
160
 
                rerr = vfsub_sio_rmdir(h_dir, h_dentry, dlgt);
 
166
                rerr = vfsub_sio_rmdir(au_hi(dir, bdst), h_dentry, dlgt);
161
167
                if (unlikely(rerr)) {
162
168
                        AuIOErr("failed removing %.*s b%d (%d)\n",
163
169
                                AuDLNPair(dentry), bdst, rerr);