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
20
* sub-routines for VFS
23
#ifndef __AUFS_VFSUB_H__
24
#define __AUFS_VFSUB_H__
29
#include <linux/fs_stack.h>
31
/* ---------------------------------------------------------------------- */
33
/* lock subclass for lower inode */
34
/* default MAX_LOCKDEP_SUBCLASSES(8) is not enough */
35
/* reduce? gave up. */
37
AuLsc_I_Begin = I_MUTEX_QUOTA, /* 4 */
38
AuLsc_I_PARENT, /* lower inode, parent first */
39
AuLsc_I_PARENT2, /* copyup dirs */
40
AuLsc_I_PARENT3, /* copyup wh */
46
/* to debug easier, do not make them inlined functions */
47
#define MtxMustLock(mtx) AuDebugOn(!mutex_is_locked(mtx))
48
#define IMustLock(i) MtxMustLock(&(i)->i_mutex)
50
/* ---------------------------------------------------------------------- */
52
static inline void vfsub_copy_inode_size(struct inode *inode,
53
struct inode *h_inode)
55
spin_lock(&inode->i_lock);
56
fsstack_copy_inode_size(inode, h_inode);
57
spin_unlock(&inode->i_lock);
60
int vfsub_update_h_iattr(struct path *h_path, int *did);
61
struct file *vfsub_filp_open(const char *path, int oflags, int mode);
62
struct file *vfsub_dentry_open(struct path *path, int flags,
63
const struct cred *cred);
64
int vfsub_kern_path(const char *name, unsigned int flags, struct path *path);
65
struct dentry *vfsub_lookup_one_len(const char *name, struct dentry *parent,
67
struct dentry *vfsub_lookup_hash(struct nameidata *nd);
69
/* ---------------------------------------------------------------------- */
72
struct dentry *vfsub_lock_rename(struct dentry *d1, struct au_hinode *hdir1,
73
struct dentry *d2, struct au_hinode *hdir2);
74
void vfsub_unlock_rename(struct dentry *d1, struct au_hinode *hdir1,
75
struct dentry *d2, struct au_hinode *hdir2);
77
int vfsub_create(struct inode *dir, struct path *path, int mode);
78
int vfsub_symlink(struct inode *dir, struct path *path,
80
int vfsub_mknod(struct inode *dir, struct path *path, int mode, dev_t dev);
81
int vfsub_link(struct dentry *src_dentry, struct inode *dir,
83
int vfsub_rename(struct inode *src_hdir, struct dentry *src_dentry,
84
struct inode *hdir, struct path *path);
85
int vfsub_mkdir(struct inode *dir, struct path *path, int mode);
86
int vfsub_rmdir(struct inode *dir, struct path *path);
88
int vfsub_sio_mkdir(struct inode *dir, struct path *path, int mode);
89
int vfsub_sio_rmdir(struct inode *dir, struct path *path);
90
int vfsub_sio_notify_change(struct path *path, struct iattr *ia);
91
int vfsub_notify_change(struct path *path, struct iattr *ia);
92
int vfsub_unlink(struct inode *dir, struct path *path, int force);
94
/* ---------------------------------------------------------------------- */
96
ssize_t vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
98
ssize_t vfsub_read_k(struct file *file, void *kbuf, size_t count,
100
ssize_t vfsub_write_u(struct file *file, const char __user *ubuf, size_t count,
102
ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count,
104
int vfsub_readdir(struct file *file, filldir_t filldir, void *arg);
106
long vfsub_splice_to(struct file *in, loff_t *ppos,
107
struct pipe_inode_info *pipe, size_t len,
109
long vfsub_splice_from(struct pipe_inode_info *pipe, struct file *out,
110
loff_t *ppos, size_t len, unsigned int flags);
111
int vfsub_trunc(struct path *h_path, loff_t length, unsigned int attr,
112
struct file *h_file);
114
static inline void vfsub_file_accessed(struct file *h_file)
116
file_accessed(h_file);
117
vfsub_update_h_iattr(&h_file->f_path, /*did*/NULL); /*ignore*/
120
static inline void vfsub_touch_atime(struct vfsmount *h_mnt,
121
struct dentry *h_dentry)
123
struct path h_path = {
127
touch_atime(h_mnt, h_dentry);
128
vfsub_update_h_iattr(&h_path, /*did*/NULL); /*ignore*/
131
/* ---------------------------------------------------------------------- */
133
static inline loff_t vfsub_llseek(struct file *file, loff_t offset, int origin)
138
err = vfs_llseek(file, offset, origin);
143
/* ---------------------------------------------------------------------- */
145
/* dirty workaround for strict type of fmode_t */
151
static inline unsigned int vfsub_fmode_to_uint(fmode_t fm)
153
union vfsub_fmu u = {
157
BUILD_BUG_ON(sizeof(u.fm) != sizeof(u.ui));
162
static inline fmode_t vfsub_uint_to_fmode(unsigned int ui)
164
union vfsub_fmu u = {
171
#endif /* __KERNEL__ */
172
#endif /* __AUFS_VFSUB_H__ */