2
* Copyright (C) 2005, 2006, 2007 Junjiro Okajima
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.
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.
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
19
/* $Id: hinode.h,v 1.7 2007/10/22 02:15:35 sfjro Exp $ */
21
#ifndef __AUFS_HINODE_H__
22
#define __AUFS_HINODE_H__
27
#include <linux/inotify.h>
28
#include <linux/version.h>
29
#include <linux/aufs_type.h>
34
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
36
struct inotify_watch {
41
/* ---------------------------------------------------------------------- */
43
struct aufs_hinotify {
44
#ifdef CONFIG_AUFS_HINOTIFY
45
struct inotify_watch hin_watch;
46
struct inode *hin_aufs_inode; /* no get/put */
48
/* an array of atomic_t X au_hin_nignore */
49
atomic_t hin_ignore[0];
54
struct inode *hi_inode;
56
#ifdef CONFIG_AUFS_HINOTIFY
57
struct aufs_hinotify *hi_notify;
60
/* reference to the copied-up whiteout with get/put */
61
struct dentry *hi_whdentry;
64
struct aufs_hin_ignore {
65
#ifdef CONFIG_AUFS_HINOTIFY
67
struct aufs_hinode *ign_hinode;
71
/* ---------------------------------------------------------------------- */
73
#ifdef CONFIG_AUFS_HINOTIFY
75
void au_hin_init(struct aufs_hinode *hinode, struct aufs_hinotify *val)
77
hinode->hi_notify = val;
82
int au_hin_alloc(struct aufs_hinode *hinode, struct inode *inode,
83
struct inode *h_inode);
84
void au_hin_free(struct aufs_hinode *hinode);
85
void au_do_hdir_lock(struct inode *h_dir, struct inode *dir,
86
aufs_bindex_t bindex, unsigned int lsc);
87
void hdir_unlock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex);
88
void hdir_lock_rename(struct dentry **h_parents, struct inode **dirs,
89
aufs_bindex_t bindex, int issamedir);
90
void hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
91
aufs_bindex_t bindex, int issamedir);
92
void au_reset_hinotify(struct inode *inode, unsigned int flags);
94
void au_hin_ignore(struct aufs_hinode *hinode, __u32 events);
95
void au_hin_unignore(struct aufs_hinode *hinode, __u32 events);
97
int __init au_inotify_init(void);
98
void au_inotify_fin(void);
101
void au_hin_init(struct aufs_hinode *hinode, struct aufs_hinotify *val)
107
int au_hin_alloc(struct aufs_hinode *hinode, struct inode *inode,
108
struct inode *h_inode)
113
static inline void au_hin_free(struct aufs_hinode *hinode)
118
static inline void au_do_hdir_lock(struct inode *h_dir, struct inode *dir,
119
aufs_bindex_t bindex, unsigned int lsc)
121
vfsub_i_lock_nested(h_dir, lsc);
125
void hdir_unlock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex)
127
vfsub_i_unlock(h_dir);
131
void hdir_lock_rename(struct dentry **h_parents, struct inode **dirs,
132
aufs_bindex_t bindex, int issamedir)
134
vfsub_lock_rename(h_parents[0], h_parents[1]);
138
void hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
139
aufs_bindex_t bindex, int issamedir)
141
vfsub_unlock_rename(h_parents[0], h_parents[1]);
144
static inline void au_reset_hinotify(struct inode *inode, unsigned int flags)
149
static inline __u32 au_notify_change_events(struct iattr *ia)
154
static inline void au_hin_ignore(struct aufs_hinotify *hinotify, __u32 events)
159
static inline void au_hin_unignore(struct aufs_hinotify *hinotify, __u32 events)
164
#define au_inotify_init() 0
165
#define au_inotify_fin() do {} while (0)
166
#endif /* CONFIG_AUFS_HINOTIFY */
168
/* ---------------------------------------------------------------------- */
171
* hgdir_lock, hdir_lock, hdir2_lock
173
#define LockFunc(name, lsc) \
175
void name##_lock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex) \
176
{ au_do_hdir_lock(h_dir, dir, bindex, AuLsc_I_##lsc); }
178
LockFunc(hdir, PARENT);
179
LockFunc(hdir2, PARENT2);
183
/* ---------------------------------------------------------------------- */
185
#endif /* __KERNEL__ */
186
#endif /* __AUFS_HINODE_H__ */