~ubuntu-branches/ubuntu/raring/aufs/raring

« back to all changes in this revision

Viewing changes to fs/aufs25/hinode.h

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20080506183550-7y7mrzkzkh2tjlfu
Tags: upstream-0+20080506
ImportĀ upstreamĀ versionĀ 0+20080506

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2005-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
 * lower (branch filesystem) inode and setting inotify
 
21
 *
 
22
 * $Id: hinode.h,v 1.3 2008/04/28 03:08:37 sfjro Exp $
 
23
 */
 
24
 
 
25
#ifndef __AUFS_HINODE_H__
 
26
#define __AUFS_HINODE_H__
 
27
 
 
28
#ifdef __KERNEL__
 
29
 
 
30
#include <linux/fs.h>
 
31
#include <linux/inotify.h>
 
32
#include <linux/aufs_type.h>
 
33
//#include "branch.h"
 
34
//#include "inode.h"
 
35
#include "super.h"
 
36
#include "vfsub.h"
 
37
 
 
38
/* ---------------------------------------------------------------------- */
 
39
 
 
40
struct au_hinotify {
 
41
#ifdef CONFIG_AUFS_HINOTIFY
 
42
        struct inotify_watch    hin_watch;
 
43
        struct inode            *hin_aufs_inode;        /* no get/put */
 
44
 
 
45
        /* an array of atomic_t X au_hin_nignore */
 
46
        atomic_t                hin_ignore[0];
 
47
#endif
 
48
};
 
49
 
 
50
struct au_hinode {
 
51
        struct inode            *hi_inode;
 
52
        aufs_bindex_t           hi_id;
 
53
#ifdef CONFIG_AUFS_HINOTIFY
 
54
        struct au_hinotify      *hi_notify;
 
55
#endif
 
56
 
 
57
        /* reference to the copied-up whiteout with get/put */
 
58
        struct dentry           *hi_whdentry;
 
59
};
 
60
 
 
61
struct au_hin_ignore {
 
62
#ifdef CONFIG_AUFS_HINOTIFY
 
63
        __u32                   ign_events;
 
64
        struct au_hinode        *ign_hinode;
 
65
#endif
 
66
};
 
67
 
 
68
/* ---------------------------------------------------------------------- */
 
69
 
 
70
#ifdef CONFIG_AUFS_HINOTIFY
 
71
static inline
 
72
void au_hin_init(struct au_hinode *hinode, struct au_hinotify *val)
 
73
{
 
74
        hinode->hi_notify = val;
 
75
}
 
76
 
 
77
/* hinotify.c */
 
78
int au_hin_alloc(struct au_hinode *hinode, struct inode *inode,
 
79
                 struct inode *h_inode);
 
80
void au_hin_free(struct au_hinode *hinode);
 
81
void au_do_hdir_lock(struct inode *h_dir, struct inode *dir,
 
82
                     aufs_bindex_t bindex, unsigned int lsc);
 
83
void au_hdir_unlock(struct inode *h_dir, struct inode *dir,
 
84
                    aufs_bindex_t bindex);
 
85
struct dentry *au_hdir_lock_rename(struct dentry **h_parents,
 
86
                                   struct inode **dirs, aufs_bindex_t bindex,
 
87
                                   int issamedir);
 
88
void au_hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
 
89
                           aufs_bindex_t bindex, int issamedir);
 
90
void au_reset_hinotify(struct inode *inode, unsigned int flags);
 
91
 
 
92
void au_hin_ignore(struct au_hinode *hinode, __u32 events);
 
93
void au_hin_unignore(struct au_hinode *hinode, __u32 events);
 
94
 
 
95
int __init au_inotify_init(void);
 
96
void au_inotify_fin(void);
 
97
 
 
98
#else
 
99
 
 
100
static inline
 
101
void au_hin_init(struct au_hinode *hinode, struct au_hinotify *val)
 
102
{
 
103
        /* empty */
 
104
}
 
105
 
 
106
static inline
 
107
int au_hin_alloc(struct au_hinode *hinode, struct inode *inode,
 
108
                 struct inode *h_inode)
 
109
{
 
110
        return -EOPNOTSUPP;
 
111
}
 
112
 
 
113
static inline void au_hin_free(struct au_hinode *hinode)
 
114
{
 
115
        /* nothing */
 
116
}
 
117
 
 
118
static inline
 
119
void au_do_hdir_lock(struct inode *h_dir, struct inode *dir,
 
120
                     aufs_bindex_t bindex, unsigned int lsc)
 
121
{
 
122
        mutex_lock_nested(&h_dir->i_mutex, lsc);
 
123
}
 
124
 
 
125
static inline
 
126
void au_hdir_unlock(struct inode *h_dir, struct inode *dir,
 
127
                    aufs_bindex_t bindex)
 
128
{
 
129
        mutex_unlock(&h_dir->i_mutex);
 
130
}
 
131
 
 
132
static inline
 
133
struct dentry *au_hdir_lock_rename(struct dentry **h_parents,
 
134
                                   struct inode **dirs, aufs_bindex_t bindex,
 
135
                                   int issamedir)
 
136
{
 
137
        return vfsub_lock_rename(h_parents[0], h_parents[1]);
 
138
}
 
139
 
 
140
static inline
 
141
void au_hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
 
142
                           aufs_bindex_t bindex, int issamedir)
 
143
{
 
144
        vfsub_unlock_rename(h_parents[0], h_parents[1]);
 
145
}
 
146
 
 
147
static inline void au_reset_hinotify(struct inode *inode, unsigned int flags)
 
148
{
 
149
        /* nothing */
 
150
}
 
151
 
 
152
static inline void au_hin_ignore(struct au_hinotify *hinotify, __u32 events)
 
153
{
 
154
        /* nothing */
 
155
}
 
156
 
 
157
static inline void au_hin_unignore(struct au_hinotify *hinotify, __u32 events)
 
158
{
 
159
        /* nothing */
 
160
}
 
161
 
 
162
static inline int au_inotify_init(void)
 
163
{
 
164
        return 0;
 
165
}
 
166
 
 
167
#define au_inotify_fin()        do {} while (0)
 
168
#endif /* CONFIG_AUFS_HINOTIFY */
 
169
 
 
170
/* ---------------------------------------------------------------------- */
 
171
 
 
172
/*
 
173
 * au_hdir_lock, au_hdir2_lock
 
174
 */
 
175
#define AuLockFunc(name, lsc) \
 
176
static inline \
 
177
void name##_lock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex) \
 
178
{ au_do_hdir_lock(h_dir, dir, bindex, AuLsc_I_##lsc); }
 
179
 
 
180
AuLockFunc(au_hdir, PARENT);
 
181
AuLockFunc(au_hdir2, PARENT2);
 
182
 
 
183
#undef AuLockFunc
 
184
 
 
185
/* ---------------------------------------------------------------------- */
 
186
 
 
187
#endif /* __KERNEL__ */
 
188
#endif /* __AUFS_HINODE_H__ */