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

« back to all changes in this revision

Viewing changes to fs/aufs25/vfsub.h

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080506183550-0b6c974kkgc46oeh
Tags: 0+20080506-1
* New upstream release, supports Kernel 2.6.25 (Closes: #479717)
* Fix building with older Kernels (Closes: #475042)
* Update the patches 01, 04 and 07 to also patch fs/aufs25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2007-2008 Junjiro 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
 * sub-routines for VFS
 
21
 *
 
22
 * $Id: vfsub.h,v 1.2 2008/04/21 01:49:22 sfjro Exp $
 
23
 */
 
24
 
 
25
#ifndef __AUFS_VFSUB_H__
 
26
#define __AUFS_VFSUB_H__
 
27
 
 
28
#ifdef __KERNEL__
 
29
 
 
30
#include <linux/fs.h>
 
31
#include <linux/namei.h>
 
32
#include <linux/splice.h>
 
33
#include <linux/inotify.h>
 
34
 
 
35
/* ---------------------------------------------------------------------- */
 
36
 
 
37
/* vfsub flags */
 
38
#define Vfsub_DLGT              1               /* operation with delegation */
 
39
#define Vfsub_FORCE_UNLINK      (1 << 1)        /* force unlinking */
 
40
#define vfsub_ftest(flags, name)        ((flags) & Vfsub_##name)
 
41
#define vfsub_fset(flags, name)         { (flags) |= Vfsub_##name; }
 
42
#define vfsub_fclr(flags, name)         { (flags) &= ~Vfsub_##name; }
 
43
#ifndef CONFIG_AUFS_DLGT
 
44
#undef Vfsub_DLGT
 
45
#define Vfsub_DLGT      0
 
46
#endif
 
47
 
 
48
struct au_hin_ignore;
 
49
struct vfsub_args {
 
50
#ifdef CONFIG_AUFS_HINOTIFY
 
51
        /* inotify events to be ignored */
 
52
        int                     nignore;
 
53
        struct au_hin_ignore    *ignore;
 
54
#endif
 
55
 
 
56
        unsigned int            flags;
 
57
};
 
58
 
 
59
struct au_hinode;
 
60
#ifdef CONFIG_AUFS_HINOTIFY
 
61
static inline
 
62
void do_vfsub_args_reinit(struct vfsub_args *vargs, struct au_hin_ignore *ign)
 
63
{
 
64
        vargs->nignore = 0;
 
65
        vargs->ignore = ign;
 
66
}
 
67
 
 
68
static inline void vfsub_args_reinit(struct vfsub_args *vargs)
 
69
{
 
70
        vargs->nignore = 0;
 
71
}
 
72
 
 
73
__u32 vfsub_events_notify_change(struct iattr *ia);
 
74
void vfsub_ign_hinode(struct vfsub_args *vargs, __u32 events,
 
75
                      struct au_hinode *hinode);
 
76
void vfsub_ign_inode(struct vfsub_args *vargs, __u32 events,
 
77
                     struct inode *inode, struct inode *h_inode);
 
78
 
 
79
void vfsub_ignore(struct vfsub_args *vargs);
 
80
void vfsub_unignore(struct vfsub_args *vargs);
 
81
#else
 
82
static inline
 
83
void do_vfsub_args_reinit(struct vfsub_args *vargs, struct au_hin_ignore *ign)
 
84
{
 
85
        /* empty */
 
86
}
 
87
 
 
88
static inline void vfsub_args_reinit(struct vfsub_args *vargs)
 
89
{
 
90
        /* empty */
 
91
}
 
92
 
 
93
static inline __u32 vfsub_events_notify_change(struct iattr *ia)
 
94
{
 
95
        return 0;
 
96
}
 
97
 
 
98
static inline void vfsub_ign_hinode(struct vfsub_args *vargs, __u32 events,
 
99
                                    struct au_hinode *hinode)
 
100
{
 
101
        /* empty */
 
102
}
 
103
 
 
104
static inline void vfsub_ign_inode(struct vfsub_args *vargs, __u32 events,
 
105
                                   struct inode *inode, struct inode *h_inode)
 
106
{
 
107
        /* empty */
 
108
}
 
109
 
 
110
static inline void vfsub_ignore(struct vfsub_args *vargs)
 
111
{
 
112
        /* empty */
 
113
}
 
114
 
 
115
static inline void vfsub_unignore(struct vfsub_args *vargs)
 
116
{
 
117
        /* empty */
 
118
}
 
119
#endif /* CONFIG_AUFS_HINOTIFY */
 
120
 
 
121
void vfsub_args_init(struct vfsub_args *vargs, struct au_hin_ignore *ign,
 
122
                     int dlgt, int force_unlink);
 
123
 
 
124
/* ---------------------------------------------------------------------- */
 
125
 
 
126
/* inotify_inode_watched() is not exported */
 
127
static inline int au_test_inotify(struct inode *inode)
 
128
{
 
129
#ifdef CONFIG_INOTIFY
 
130
        return !list_empty(&inode->inotify_watches);
 
131
#endif
 
132
        return 0;
 
133
}
 
134
 
 
135
/* ---------------------------------------------------------------------- */
 
136
 
 
137
/* lock subclass for hidden inode */
 
138
/* default MAX_LOCKDEP_SUBCLASSES(8) is not enough */
 
139
// todo: reduce it
 
140
enum {
 
141
        AuLsc_I_Begin = I_MUTEX_QUOTA, /* 4 */
 
142
        AuLsc_I_PARENT,         /* hidden inode, parent first */
 
143
        AuLsc_I_CHILD,
 
144
        AuLsc_I_PARENT2,        /* copyup dirs */
 
145
        AuLsc_I_CHILD2,
 
146
        AuLsc_I_End
 
147
};
 
148
 
 
149
#define IMustLock(i)    MtxMustLock(&(i)->i_mutex)
 
150
 
 
151
static inline
 
152
struct dentry *vfsub_lock_rename(struct dentry *d1, struct dentry *d2)
 
153
{
 
154
        struct dentry *d;
 
155
 
 
156
        lockdep_off();
 
157
        d = lock_rename(d1, d2);
 
158
        lockdep_on();
 
159
        return d;
 
160
}
 
161
 
 
162
static inline void vfsub_unlock_rename(struct dentry *d1, struct dentry *d2)
 
163
{
 
164
        lockdep_off();
 
165
        unlock_rename(d1, d2);
 
166
        lockdep_on();
 
167
}
 
168
 
 
169
/* ---------------------------------------------------------------------- */
 
170
 
 
171
#ifdef CONFIG_AUFS_WORKAROUND_FUSE
 
172
/* br_fuse.c */
 
173
int au_update_fuse_h_inode(struct vfsmount *h_mnt, struct dentry *h_dentry);
 
174
#else
 
175
static inline
 
176
int au_update_fuse_h_inode(struct vfsmount *h_mnt, struct dentry *h_dentry)
 
177
{
 
178
        return 0;
 
179
}
 
180
#endif
 
181
 
 
182
#ifdef CONFIG_AUFS_BR_XFS
 
183
/* br_xfs.c */
 
184
dev_t au_h_rdev(struct inode *h_inode, struct vfsmount *h_mnt,
 
185
                struct dentry *h_dentry);
 
186
#else
 
187
static inline
 
188
dev_t au_h_rdev(struct inode *h_inode, struct vfsmount *h_mnt,
 
189
                struct dentry *h_dentry)
 
190
{
 
191
        return h_inode->i_rdev;
 
192
}
 
193
#endif
 
194
 
 
195
/* simple abstractions, for future use */
 
196
static inline
 
197
int do_vfsub_permission(struct inode *inode, int mask, struct nameidata *nd)
 
198
{
 
199
        LKTRTrace("i%lu, mask 0x%x, nd %d\n", inode->i_ino, mask, !!nd);
 
200
        IMustLock(inode);
 
201
        return permission(inode, mask, nd);
 
202
}
 
203
 
 
204
/* ---------------------------------------------------------------------- */
 
205
 
 
206
struct file *vfsub_filp_open(const char *path, int oflags, int mode);
 
207
int vfsub_path_lookup(const char *name, unsigned int flags,
 
208
                      struct nameidata *nd);
 
209
struct dentry *vfsub_lookup_one_len(const char *name, struct dentry *parent,
 
210
                                    int len);
 
211
 
 
212
#ifdef CONFIG_AUFS_LHASH_PATCH
 
213
struct dentry *vfsub__lookup_hash(struct qstr *name, struct dentry *parent,
 
214
                                  struct nameidata *nd);
 
215
#endif
 
216
 
 
217
/* ---------------------------------------------------------------------- */
 
218
 
 
219
int do_vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
 
220
                    struct nameidata *nd);
 
221
int do_vfsub_symlink(struct inode *dir, struct dentry *dentry,
 
222
                     const char *symname, int mode);
 
223
int do_vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode,
 
224
                   dev_t dev);
 
225
int do_vfsub_link(struct dentry *src_dentry, struct inode *dir,
 
226
                  struct dentry *dentry);
 
227
int do_vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
 
228
                    struct inode *dir, struct dentry *dentry);
 
229
int do_vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode);
 
230
int do_vfsub_rmdir(struct inode *dir, struct dentry *dentry);
 
231
int do_vfsub_unlink(struct inode *dir, struct dentry *dentry);
 
232
 
 
233
/* ---------------------------------------------------------------------- */
 
234
 
 
235
ssize_t do_vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
 
236
                        loff_t *ppos);
 
237
// kernel_read() ??
 
238
ssize_t do_vfsub_read_k(struct file *file, void *kbuf, size_t count,
 
239
                        loff_t *ppos);
 
240
ssize_t do_vfsub_write_u(struct file *file, const char __user *ubuf,
 
241
                         size_t count, loff_t *ppos);
 
242
ssize_t do_vfsub_write_k(struct file *file, void *kbuf, size_t count,
 
243
                         loff_t *ppos);
 
244
int do_vfsub_readdir(struct file *file, filldir_t filldir, void *arg);
 
245
 
 
246
/* ---------------------------------------------------------------------- */
 
247
 
 
248
#ifdef CONFIG_AUFS_SPLICE_PATCH
 
249
long do_vfsub_splice_to(struct file *in, loff_t *ppos,
 
250
                        struct pipe_inode_info *pipe, size_t len,
 
251
                        unsigned int flags);
 
252
long do_vfsub_splice_from(struct pipe_inode_info *pipe, struct file *out,
 
253
                          loff_t *ppos, size_t len, unsigned int flags);
 
254
#else
 
255
static inline
 
256
long do_vfsub_splice_to(struct file *in, loff_t *ppos,
 
257
                        struct pipe_inode_info *pipe, size_t len,
 
258
                        unsigned int flags)
 
259
{
 
260
        return -ENOSYS;
 
261
}
 
262
 
 
263
static inline
 
264
long do_vfsub_splice_from(struct pipe_inode_info *pipe, struct file *out,
 
265
                          loff_t *ppos, size_t len, unsigned int flags)
 
266
{
 
267
        return -ENOSYS;
 
268
}
 
269
#endif /* CONFIG_AUFS_SPLICE_PATCH */
 
270
 
 
271
/* ---------------------------------------------------------------------- */
 
272
 
 
273
static inline loff_t vfsub_llseek(struct file *file, loff_t offset, int origin)
 
274
{
 
275
        loff_t err;
 
276
 
 
277
        LKTRTrace("%.*s\n", AuDLNPair(file->f_dentry));
 
278
 
 
279
        lockdep_off();
 
280
        err = vfs_llseek(file, offset, origin);
 
281
        lockdep_on();
 
282
        return err;
 
283
}
 
284
 
 
285
static inline int do_vfsub_getattr(struct vfsmount *mnt, struct dentry *dentry,
 
286
                                   struct kstat *st)
 
287
{
 
288
        LKTRTrace("%.*s\n", AuDLNPair(dentry));
 
289
        return vfs_getattr(mnt, dentry, st);
 
290
}
 
291
 
 
292
/* ---------------------------------------------------------------------- */
 
293
 
 
294
#if defined(CONFIG_AUFS_HINOTIFY) || defined(CONFIG_AUFS_DLGT)
 
295
/* hin_or_dlgt.c */
 
296
int vfsub_permission(struct inode *inode, int mask, struct nameidata *nd,
 
297
                     int dlgt);
 
298
 
 
299
int vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
 
300
                 struct nameidata *nd, int dlgt);
 
301
int vfsub_symlink(struct inode *dir, struct dentry *dentry, const char *symname,
 
302
                  int mode, int dlgt);
 
303
int vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev,
 
304
                int dlgt);
 
305
int vfsub_link(struct dentry *src_dentry, struct inode *dir,
 
306
               struct dentry *dentry, int dlgt);
 
307
int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
 
308
                 struct inode *dir, struct dentry *dentry,
 
309
                 struct vfsub_args *vargs);
 
310
int vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode, int dlgt);
 
311
int vfsub_rmdir(struct inode *dir, struct dentry *dentry,
 
312
                struct vfsub_args *vargs);
 
313
 
 
314
ssize_t vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
 
315
                     loff_t *ppos, int dlgt);
 
316
ssize_t vfsub_read_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
 
317
                     int dlgt);
 
318
ssize_t vfsub_write_u(struct file *file, const char __user *ubuf, size_t count,
 
319
                      loff_t *ppos, struct vfsub_args *vargs);
 
320
ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
 
321
                      struct vfsub_args *vargs);
 
322
int vfsub_readdir(struct file *file, filldir_t filldir, void *arg, int dlgt);
 
323
long vfsub_splice_to(struct file *in, loff_t *ppos,
 
324
                     struct pipe_inode_info *pipe, size_t len,
 
325
                     unsigned int flags, int dlgt);
 
326
long vfsub_splice_from(struct pipe_inode_info *pipe, struct file *out,
 
327
                       loff_t *ppos, size_t len, unsigned int flags,
 
328
                       struct vfsub_args *vargs);
 
329
 
 
330
int vfsub_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *st,
 
331
                  int dlgt);
 
332
#else
 
333
 
 
334
static inline
 
335
int vfsub_permission(struct inode *inode, int mask, struct nameidata *nd,
 
336
                     int dlgt)
 
337
{
 
338
        return do_vfsub_permission(inode, mask, nd);
 
339
}
 
340
 
 
341
static inline
 
342
int vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
 
343
                 struct nameidata *nd, int dlgt)
 
344
{
 
345
        return do_vfsub_create(dir, dentry, mode, nd);
 
346
}
 
347
 
 
348
static inline
 
349
int vfsub_symlink(struct inode *dir, struct dentry *dentry, const char *symname,
 
350
                  int mode, int dlgt)
 
351
{
 
352
        return do_vfsub_symlink(dir, dentry, symname, mode);
 
353
}
 
354
 
 
355
static inline
 
356
int vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev,
 
357
                int dlgt)
 
358
{
 
359
        return do_vfsub_mknod(dir, dentry, mode, dev);
 
360
}
 
361
 
 
362
static inline
 
363
int vfsub_link(struct dentry *src_dentry, struct inode *dir,
 
364
               struct dentry *dentry, int dlgt)
 
365
{
 
366
        return do_vfsub_link(src_dentry, dir, dentry);
 
367
}
 
368
 
 
369
static inline
 
370
int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
 
371
                 struct inode *dir, struct dentry *dentry,
 
372
                 struct vfsub_args *vargs)
 
373
{
 
374
        int err;
 
375
 
 
376
        vfsub_ignore(vargs);
 
377
        err = do_vfsub_rename(src_dir, src_dentry, dir, dentry);
 
378
        if (unlikely(err))
 
379
                vfsub_unignore(vargs);
 
380
        return err;
 
381
}
 
382
 
 
383
static inline
 
384
int vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode, int dlgt)
 
385
{
 
386
        return do_vfsub_mkdir(dir, dentry, mode);
 
387
}
 
388
 
 
389
static inline
 
390
int vfsub_rmdir(struct inode *dir, struct dentry *dentry,
 
391
                struct vfsub_args *vargs)
 
392
{
 
393
        int err;
 
394
 
 
395
        vfsub_ignore(vargs);
 
396
        err = do_vfsub_rmdir(dir, dentry);
 
397
        if (unlikely(err))
 
398
                vfsub_unignore(vargs);
 
399
        return err;
 
400
}
 
401
 
 
402
static inline
 
403
ssize_t vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
 
404
                     loff_t *ppos, int dlgt)
 
405
{
 
406
        return do_vfsub_read_u(file, ubuf, count, ppos);
 
407
}
 
408
 
 
409
static inline
 
410
ssize_t vfsub_read_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
 
411
                     int dlgt)
 
412
{
 
413
        return do_vfsub_read_k(file, kbuf, count, ppos);
 
414
}
 
415
 
 
416
static inline
 
417
ssize_t vfsub_write_u(struct file *file, const char __user *ubuf, size_t count,
 
418
                      loff_t *ppos, struct vfsub_args *vargs)
 
419
{
 
420
        int err;
 
421
 
 
422
        vfsub_ignore(vargs);
 
423
        err = do_vfsub_write_u(file, ubuf, count, ppos);
 
424
        if (unlikely(err < 0))
 
425
                vfsub_unignore(vargs);
 
426
        return err;
 
427
}
 
428
 
 
429
static inline
 
430
ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
 
431
                      struct vfsub_args *vargs)
 
432
{
 
433
        int err;
 
434
 
 
435
        vfsub_ignore(vargs);
 
436
        err = do_vfsub_write_k(file, kbuf, count, ppos);
 
437
        if (unlikely(err < 0))
 
438
                vfsub_unignore(vargs);
 
439
        return err;
 
440
}
 
441
 
 
442
static inline
 
443
int vfsub_readdir(struct file *file, filldir_t filldir, void *arg, int dlgt)
 
444
{
 
445
        return do_vfsub_readdir(file, filldir, arg);
 
446
}
 
447
 
 
448
static inline
 
449
long vfsub_splice_to(struct file *in, loff_t *ppos,
 
450
                     struct pipe_inode_info *pipe, size_t len,
 
451
                     unsigned int flags, int dlgt)
 
452
{
 
453
        return do_vfsub_splice_to(in, ppos, pipe, len, flags);
 
454
}
 
455
 
 
456
static inline
 
457
long vfsub_splice_from(struct pipe_inode_info *pipe, struct file *out,
 
458
                       loff_t *ppos, size_t len, unsigned int flags,
 
459
                       struct vfsub_args *vargs)
 
460
{
 
461
        long err;
 
462
 
 
463
        vfsub_ignore(vargs);
 
464
        err = do_vfsub_splice_from(pipe, out, ppos, len, flags);
 
465
        if (unlikely(err < 0))
 
466
                vfsub_unignore(vargs);
 
467
        return err;
 
468
}
 
469
 
 
470
static inline
 
471
int vfsub_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *st,
 
472
                  int dlgt)
 
473
{
 
474
        return do_vfsub_getattr(mnt, dentry, st);
 
475
}
 
476
#endif /* CONFIG_AUFS_DLGT || CONFIG_AUFS_HINOTIFY */
 
477
 
 
478
/* ---------------------------------------------------------------------- */
 
479
 
 
480
int vfsub_sio_mkdir(struct inode *dir, struct dentry *dentry, int mode,
 
481
                    int dlgt);
 
482
int vfsub_sio_rmdir(struct inode *dir, struct dentry *dentry, int dlgt);
 
483
 
 
484
/* ---------------------------------------------------------------------- */
 
485
 
 
486
int vfsub_notify_change(struct dentry *dentry, struct iattr *ia,
 
487
                        struct vfsub_args *vargs);
 
488
int vfsub_unlink(struct inode *dir, struct dentry *dentry,
 
489
                 struct vfsub_args *vargs);
 
490
int vfsub_statfs(void *arg, struct kstatfs *buf, int dlgt);
 
491
 
 
492
#endif /* __KERNEL__ */
 
493
#endif /* __AUFS_VFSUB_H__ */