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

« back to all changes in this revision

Viewing changes to fs/aufs25/br_fuse.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
 * special handling for inode attributes on FUSE branch
 
21
 *
 
22
 * $Id: br_fuse.c,v 1.2 2008/04/21 01:32:05 sfjro Exp $
 
23
 */
 
24
 
 
25
#include "aufs.h"
 
26
 
 
27
/* h_mnt can be NULL, is it safe? */
 
28
int au_update_fuse_h_inode(struct vfsmount *h_mnt, struct dentry *h_dentry)
 
29
{
 
30
        int err;
 
31
        struct kstat st;
 
32
 
 
33
        LKTRTrace("%.*s\n", AuDLNPair(h_dentry));
 
34
 
 
35
        err = 0;
 
36
        if (unlikely(h_dentry->d_inode
 
37
                     //&& atomic_read(&h_dentry->d_inode->i_count)
 
38
                     && au_test_fuse(h_dentry->d_sb))) {
 
39
                err = vfsub_getattr(h_mnt, h_dentry, &st, /*dlgt*/0);
 
40
                if (unlikely(err)) {
 
41
                        AuDbg("err %d\n", err);
 
42
                        au_debug_on();
 
43
                        AuDbgDentry(h_dentry);
 
44
                        au_debug_off();
 
45
                        WARN_ON(err);
 
46
                }
 
47
        }
 
48
        return err;
 
49
}
 
50
 
 
51
/* currently, for fuse only */
 
52
int aufs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *st)
 
53
{
 
54
        int err;
 
55
        struct inode *inode, *h_inode;
 
56
        struct dentry *h_dentry;
 
57
 
 
58
        LKTRTrace("%.*s\n", AuDLNPair(dentry));
 
59
 
 
60
        err = 0;
 
61
        aufs_read_lock(dentry, AuLock_IR);
 
62
        inode = dentry->d_inode;
 
63
        h_inode = au_h_iptr(inode, au_ibstart(inode));
 
64
        if (unlikely(au_test_fuse(h_inode->i_sb))) {
 
65
                h_dentry = d_find_alias(h_inode);
 
66
                /* simply gave up updating fuse inode */
 
67
                if (h_dentry) {
 
68
                        /*ignore*/
 
69
                        if (!au_update_fuse_h_inode(NULL, h_dentry))
 
70
                                au_cpup_attr_all(inode);
 
71
                        dput(h_dentry);
 
72
                }
 
73
        }
 
74
        generic_fillattr(inode, st);
 
75
 
 
76
        aufs_read_unlock(dentry, AuLock_IR);
 
77
        return err;
 
78
}
 
79
 
 
80
#if 0 // temp
 
81
/*
 
82
 * This function was born after a discussion with the FUSE developer.
 
83
 * The inode attributes on a filesystem who defines i_op->getattr()
 
84
 * is unreliable since such fs may not maintain the attributes at lookup.
 
85
 * This function doesn't want the result of stat, instead wants the side-effect
 
86
 * which refreshes the attributes.
 
87
 * Hmm, there seems to be no such filesystem except fuse.
 
88
 */
 
89
int vfsub_i_attr(struct vfsmount *mnt, struct dentry *dentry, int dlgt)
 
90
{
 
91
        int err;
 
92
        struct inode *inode;
 
93
        struct inode_operations *op;
 
94
        struct kstat st;
 
95
 
 
96
        inode = dentry->d_inode;
 
97
        AuDebugOn(!inode);
 
98
 
 
99
        err = 0;
 
100
        op = inode->i_op;
 
101
        if (unlikely(op && op->getattr && !au_test_aufs(dentry->d_sb))) {
 
102
                err = security_inode_getattr(mnt, dentry);
 
103
                if (!err)
 
104
                        err = op->getattr(mnt, dentry, &st);
 
105
        }
 
106
        AuTraceErr(err);
 
107
        return err;
 
108
}
 
109
#endif