~ubuntu-branches/ubuntu/karmic/linux-mvl-dove/karmic-proposed

« back to all changes in this revision

Viewing changes to ubuntu/aufs/file.h

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bader
  • Date: 2010-03-10 22:24:12 UTC
  • mto: (15.1.2 karmic-security)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20100310222412-k86m3r53jw0je7x1
Tags: upstream-2.6.31
ImportĀ upstreamĀ versionĀ 2.6.31

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2005-2009 Junjiro R. 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
 
 * file operations
21
 
 */
22
 
 
23
 
#ifndef __AUFS_FILE_H__
24
 
#define __AUFS_FILE_H__
25
 
 
26
 
#ifdef __KERNEL__
27
 
 
28
 
#include <linux/fs.h>
29
 
#include <linux/poll.h>
30
 
#include <linux/aufs_type.h>
31
 
#include "rwsem.h"
32
 
 
33
 
struct au_branch;
34
 
struct au_hfile {
35
 
        struct file             *hf_file;
36
 
        struct au_branch        *hf_br;
37
 
};
38
 
 
39
 
struct au_vdir;
40
 
struct au_finfo {
41
 
        atomic_t                fi_generation;
42
 
 
43
 
        struct au_rwsem         fi_rwsem;
44
 
        struct au_hfile         *fi_hfile;
45
 
        aufs_bindex_t           fi_bstart, fi_bend;
46
 
 
47
 
        union {
48
 
                /* non-dir only */
49
 
                struct {
50
 
                        struct vm_operations_struct     *fi_h_vm_ops;
51
 
                        struct vm_operations_struct     *fi_vm_ops;
52
 
                };
53
 
 
54
 
                /* dir only */
55
 
                struct {
56
 
                        struct au_vdir          *fi_vdir_cache;
57
 
                        int                     fi_maintain_plink;
58
 
                };
59
 
        };
60
 
};
61
 
 
62
 
/* ---------------------------------------------------------------------- */
63
 
 
64
 
/* file.c */
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,
69
 
                       struct file *file);
70
 
int au_do_open(struct file *file, int (*open)(struct file *file, int flags));
71
 
int au_reopen_nondir(struct file *file);
72
 
struct au_pin;
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),
75
 
                          int wlock);
76
 
 
77
 
/* poll.c */
78
 
#ifdef CONFIG_AUFS_POLL
79
 
unsigned int aufs_poll(struct file *file, poll_table *wait);
80
 
#endif
81
 
 
82
 
/* f_op.c */
83
 
extern const struct file_operations aufs_file_fop;
84
 
int aufs_flush(struct file *file, fl_owner_t id);
85
 
 
86
 
/* finfo.c */
87
 
void au_hfput(struct au_hfile *hf, struct file *file);
88
 
void au_set_h_fptr(struct file *file, aufs_bindex_t bindex,
89
 
                   struct file *h_file);
90
 
 
91
 
void au_update_figen(struct file *file);
92
 
 
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);
96
 
 
97
 
/* ---------------------------------------------------------------------- */
98
 
 
99
 
static inline struct au_finfo *au_fi(struct file *file)
100
 
{
101
 
        return file->private_data;
102
 
}
103
 
 
104
 
/* ---------------------------------------------------------------------- */
105
 
 
106
 
/*
107
 
 * fi_read_lock, fi_write_lock,
108
 
 * fi_read_unlock, fi_write_unlock, fi_downgrade_lock
109
 
 */
110
 
AuSimpleRwsemFuncs(fi, struct file *f, &au_fi(f)->fi_rwsem);
111
 
 
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)
115
 
 
116
 
/* ---------------------------------------------------------------------- */
117
 
 
118
 
/* todo: hard/soft set? */
119
 
static inline aufs_bindex_t au_fbstart(struct file *file)
120
 
{
121
 
        FiMustAnyLock(file);
122
 
        return au_fi(file)->fi_bstart;
123
 
}
124
 
 
125
 
static inline aufs_bindex_t au_fbend(struct file *file)
126
 
{
127
 
        FiMustAnyLock(file);
128
 
        return au_fi(file)->fi_bend;
129
 
}
130
 
 
131
 
static inline struct au_vdir *au_fvdir_cache(struct file *file)
132
 
{
133
 
        FiMustAnyLock(file);
134
 
        return au_fi(file)->fi_vdir_cache;
135
 
}
136
 
 
137
 
static inline void au_set_fbstart(struct file *file, aufs_bindex_t bindex)
138
 
{
139
 
        FiMustWriteLock(file);
140
 
        au_fi(file)->fi_bstart = bindex;
141
 
}
142
 
 
143
 
static inline void au_set_fbend(struct file *file, aufs_bindex_t bindex)
144
 
{
145
 
        FiMustWriteLock(file);
146
 
        au_fi(file)->fi_bend = bindex;
147
 
}
148
 
 
149
 
static inline void au_set_fvdir_cache(struct file *file,
150
 
                                      struct au_vdir *vdir_cache)
151
 
{
152
 
        FiMustWriteLock(file);
153
 
        au_fi(file)->fi_vdir_cache = vdir_cache;
154
 
}
155
 
 
156
 
static inline struct file *au_h_fptr(struct file *file, aufs_bindex_t bindex)
157
 
{
158
 
        FiMustAnyLock(file);
159
 
        return au_fi(file)->fi_hfile[0 + bindex].hf_file;
160
 
}
161
 
 
162
 
/* todo: memory barrier? */
163
 
static inline unsigned int au_figen(struct file *f)
164
 
{
165
 
        return atomic_read(&au_fi(f)->fi_generation);
166
 
}
167
 
 
168
 
static inline int au_test_mmapped(struct file *f)
169
 
{
170
 
        FiMustAnyLock(f);
171
 
        return !!(au_fi(f)->fi_h_vm_ops);
172
 
}
173
 
 
174
 
#endif /* __KERNEL__ */
175
 
#endif /* __AUFS_FILE_H__ */