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;
56
struct au_vdir *fi_vdir_cache;
57
int fi_maintain_plink;
62
/* ---------------------------------------------------------------------- */
65
extern struct address_space_operations aufs_aop;
66
void au_store_oflag(struct nameidata *nd, struct inode *inode);
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);
97
/* ---------------------------------------------------------------------- */
99
static inline struct au_finfo *au_fi(struct file *file)
101
return file->private_data;
104
/* ---------------------------------------------------------------------- */
107
* fi_read_lock, fi_write_lock,
108
* fi_read_unlock, fi_write_unlock, fi_downgrade_lock
110
AuSimpleRwsemFuncs(fi, struct file *f, &au_fi(f)->fi_rwsem);
112
#define FiMustNoWaiters(f) AuRwMustNoWaiters(&au_fi(f)->fi_rwsem)
113
#define FiMustAnyLock(f) AuRwMustAnyLock(&au_fi(f)->fi_rwsem)
114
#define FiMustWriteLock(f) AuRwMustWriteLock(&au_fi(f)->fi_rwsem)
116
/* ---------------------------------------------------------------------- */
118
/* todo: hard/soft set? */
119
static inline aufs_bindex_t au_fbstart(struct file *file)
122
return au_fi(file)->fi_bstart;
125
static inline aufs_bindex_t au_fbend(struct file *file)
128
return au_fi(file)->fi_bend;
131
static inline struct au_vdir *au_fvdir_cache(struct file *file)
134
return au_fi(file)->fi_vdir_cache;
137
static inline void au_set_fbstart(struct file *file, aufs_bindex_t bindex)
139
FiMustWriteLock(file);
140
au_fi(file)->fi_bstart = bindex;
143
static inline void au_set_fbend(struct file *file, aufs_bindex_t bindex)
145
FiMustWriteLock(file);
146
au_fi(file)->fi_bend = bindex;
149
static inline void au_set_fvdir_cache(struct file *file,
150
struct au_vdir *vdir_cache)
152
FiMustWriteLock(file);
153
au_fi(file)->fi_vdir_cache = vdir_cache;
156
static inline struct file *au_h_fptr(struct file *file, aufs_bindex_t bindex)
159
return au_fi(file)->fi_hfile[0 + bindex].hf_file;
162
/* todo: memory barrier? */
163
static inline unsigned int au_figen(struct file *f)
165
return atomic_read(&au_fi(f)->fi_generation);
168
static inline int au_test_mmapped(struct file *f)
171
return !!(au_fi(f)->fi_h_vm_ops);
174
#endif /* __KERNEL__ */
175
#endif /* __AUFS_FILE_H__ */