2
* Copyright (C) 2005-2009 Junjiro R. 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
23
#ifndef __AUFS_FILE_H__
24
#define __AUFS_FILE_H__
29
#include <linux/poll.h>
30
#include <linux/aufs_type.h>
36
struct au_branch *hf_br;
41
atomic_t fi_generation;
43
struct au_rwsem fi_rwsem;
44
struct au_hfile *fi_hfile;
45
aufs_bindex_t fi_bstart, fi_bend;
50
struct vm_operations_struct *fi_h_vm_ops;
51
struct vm_operations_struct *fi_vm_ops;
52
struct mutex fi_vm_mtx;
57
struct au_vdir *fi_vdir_cache;
58
int fi_maintain_plink;
63
/* ---------------------------------------------------------------------- */
66
extern struct address_space_operations aufs_aop;
67
unsigned int au_file_roflags(unsigned int flags);
68
struct file *au_h_open(struct dentry *dentry, aufs_bindex_t bindex, int flags,
70
int au_do_open(struct file *file, int (*open)(struct file *file, int flags));
71
int au_reopen_nondir(struct file *file);
73
int au_ready_to_write(struct file *file, loff_t len, struct au_pin *pin);
74
int au_reval_and_lock_fdi(struct file *file, int (*reopen)(struct file *file),
78
#ifdef CONFIG_AUFS_POLL
79
unsigned int aufs_poll(struct file *file, poll_table *wait);
83
extern const struct file_operations aufs_file_fop;
84
int aufs_flush(struct file *file, fl_owner_t id);
87
void au_hfput(struct au_hfile *hf, struct file *file);
88
void au_set_h_fptr(struct file *file, aufs_bindex_t bindex,
91
void au_update_figen(struct file *file);
93
void au_finfo_fin(struct file *file);
94
int au_finfo_init(struct file *file);
95
int au_fi_realloc(struct au_finfo *finfo, int nbr);
98
long aufs_ioctl_nondir(struct file *file, unsigned int cmd, unsigned long arg);
100
/* ---------------------------------------------------------------------- */
102
static inline struct au_finfo *au_fi(struct file *file)
104
return file->private_data;
107
/* ---------------------------------------------------------------------- */
110
* fi_read_lock, fi_write_lock,
111
* fi_read_unlock, fi_write_unlock, fi_downgrade_lock
113
AuSimpleRwsemFuncs(fi, struct file *f, &au_fi(f)->fi_rwsem);
115
#define FiMustNoWaiters(f) AuRwMustNoWaiters(&au_fi(f)->fi_rwsem)
116
#define FiMustAnyLock(f) AuRwMustAnyLock(&au_fi(f)->fi_rwsem)
117
#define FiMustWriteLock(f) AuRwMustWriteLock(&au_fi(f)->fi_rwsem)
119
/* ---------------------------------------------------------------------- */
121
/* todo: hard/soft set? */
122
static inline aufs_bindex_t au_fbstart(struct file *file)
125
return au_fi(file)->fi_bstart;
128
static inline aufs_bindex_t au_fbend(struct file *file)
131
return au_fi(file)->fi_bend;
134
static inline struct au_vdir *au_fvdir_cache(struct file *file)
137
return au_fi(file)->fi_vdir_cache;
140
static inline void au_set_fbstart(struct file *file, aufs_bindex_t bindex)
142
FiMustWriteLock(file);
143
au_fi(file)->fi_bstart = bindex;
146
static inline void au_set_fbend(struct file *file, aufs_bindex_t bindex)
148
FiMustWriteLock(file);
149
au_fi(file)->fi_bend = bindex;
152
static inline void au_set_fvdir_cache(struct file *file,
153
struct au_vdir *vdir_cache)
155
FiMustWriteLock(file);
156
au_fi(file)->fi_vdir_cache = vdir_cache;
159
static inline struct file *au_h_fptr(struct file *file, aufs_bindex_t bindex)
162
return au_fi(file)->fi_hfile[0 + bindex].hf_file;
165
/* todo: memory barrier? */
166
static inline unsigned int au_figen(struct file *f)
168
return atomic_read(&au_fi(f)->fi_generation);
171
static inline int au_test_mmapped(struct file *f)
173
/* FiMustAnyLock(f); */
174
return !!(au_fi(f)->fi_h_vm_ops);
177
#endif /* __KERNEL__ */
178
#endif /* __AUFS_FILE_H__ */