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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
 * Copyright (C) 2005-2008 Junjiro Okajima
 *
 * This program, aufs is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

/*
 * lower (branch filesystem) inode and setting inotify
 *
 * $Id: hinode.h,v 1.8 2008/07/14 00:15:21 sfjro Exp $
 */

#ifndef __AUFS_HINODE_H__
#define __AUFS_HINODE_H__

#ifdef __KERNEL__

#include <linux/fs.h>
#include <linux/inotify.h>
#include <linux/aufs_type.h>
#include "super.h"
#include "vfsub.h"

/* ---------------------------------------------------------------------- */

struct au_hinotify {
#ifdef CONFIG_AUFS_HINOTIFY
	spinlock_t		hin_ignore_lock;
	struct list_head	hin_ignore_list;

	struct inotify_watch	hin_watch;
	struct inode		*hin_aufs_inode;	/* no get/put */
#endif
};

struct au_hinode {
	struct inode		*hi_inode;
	aufs_bindex_t		hi_id;
#ifdef CONFIG_AUFS_HINOTIFY
	struct au_hinotify	*hi_notify;
#endif

	/* reference to the copied-up whiteout with get/put */
	struct dentry		*hi_whdentry;
};

struct au_hin_ignore {
#ifdef CONFIG_AUFS_HINOTIFY
	struct list_head	ign_list;

	pid_t			ign_pid;
	__u32			ign_events, ign_handled;
	struct au_hinode	*ign_hinode;
#endif
};

/* ---------------------------------------------------------------------- */

#ifdef CONFIG_AUFS_HINOTIFY
/* inotify events */
static const __u32 AuInMask = (IN_MOVE | IN_DELETE | IN_CREATE
			       /* | IN_ACCESS */
			       | IN_MODIFY | IN_ATTRIB
			       /* | IN_DELETE_SELF | IN_MOVE_SELF */
	);

static inline
void au_hin_init(struct au_hinode *hinode, struct au_hinotify *val)
{
	hinode->hi_notify = val;
}

/* hinotify.c */
int au_hin_alloc(struct au_hinode *hinode, struct inode *inode,
		 struct inode *h_inode);
void au_hin_free(struct au_hinode *hinode);
void au_hin_ctl(struct au_hinode *hinode, const __u32 mask);
void au_reset_hinotify(struct inode *inode, unsigned int flags);

int __init au_inotify_init(void);
void au_inotify_fin(void);

static inline void au_hin_suspend(struct au_hinode *hinode)
{
	au_hin_ctl(hinode, 0);
}

static inline void au_hin_resume(struct au_hinode *hinode)
{
	au_hin_ctl(hinode, AuInMask);
}

#else

static inline
void au_hin_init(struct au_hinode *hinode, struct au_hinotify *val)
{
	/* empty */
}

static inline
int au_hin_alloc(struct au_hinode *hinode, struct inode *inode,
		 struct inode *h_inode)
{
	return -EOPNOTSUPP;
}

static inline void au_hin_free(struct au_hinode *hinode)
{
	/* nothing */
}

static inline void au_reset_hinotify(struct inode *inode, unsigned int flags)
{
	/* nothing */
}

static inline int au_inotify_init(void)
{
	return 0;
}

#define au_inotify_fin()	do {} while (0)

static inline void au_hin_suspend(struct au_hinode *hinode)
{
	/* empty */
}

static inline void au_hin_resume(struct au_hinode *hinode)
{
	/* empty */
}
#endif /* CONFIG_AUFS_HINOTIFY */

#if defined(CONFIG_AUFS_HINOTIFY) && defined(CONFIG_AUFS_DEBUG)
static inline void au_hin_list_del(struct list_head *e)
{
	list_del_init(e);
}

void au_dbg_hin_list(struct vfsub_args *vargs);
#else
static inline void au_hin_list_del(struct list_head *e)
{
	list_del(e);
}

static inline void au_dbg_hin_list(struct vfsub_args *vargs)
{
	/* empty */
}
#endif /* CONFIG_AUFS_DEBUG */

/* ---------------------------------------------------------------------- */

#endif /* __KERNEL__ */
#endif /* __AUFS_HINODE_H__ */