vfsub.h 2.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2005-2019 Junjiro R. Okajima
 */

/*
 * sub-routines for VFS
 */

#ifndef __AUFS_VFSUB_H__
#define __AUFS_VFSUB_H__

#ifdef __KERNEL__

#include <linux/fs.h>
16
#include <linux/mount.h>
17
18
#include "debug.h"

J. R. Okajima's avatar
J. R. Okajima committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* ---------------------------------------------------------------------- */

/* lock subclass for lower inode */
/* default MAX_LOCKDEP_SUBCLASSES(8) is not enough */
/* reduce? gave up. */
enum {
	AuLsc_I_Begin = I_MUTEX_PARENT2, /* 5 */
	AuLsc_I_PARENT,		/* lower inode, parent first */
	AuLsc_I_PARENT2,	/* copyup dirs */
	AuLsc_I_PARENT3,	/* copyup wh */
	AuLsc_I_CHILD,
	AuLsc_I_CHILD2,
	AuLsc_I_End
};

34
35
36
37
/* to debug easier, do not make them inlined functions */
#define MtxMustLock(mtx)	AuDebugOn(!mutex_is_locked(mtx))
#define IMustLock(i)		AuDebugOn(!inode_is_locked(i))

J. R. Okajima's avatar
J. R. Okajima committed
38
39
40
41
/* ---------------------------------------------------------------------- */

struct file *vfsub_dentry_open(struct path *path, int flags);
struct file *vfsub_filp_open(const char *path, int oflags, int mode);
42
43
int vfsub_kern_path(const char *name, unsigned int flags, struct path *path);

J. R. Okajima's avatar
J. R. Okajima committed
44
45
46
struct dentry *vfsub_lookup_one_len(const char *name, struct dentry *parent,
				    int len);

J. R. Okajima's avatar
J. R. Okajima committed
47
48
49
50
51
52
static inline struct dentry *vfsub_lkup_one(struct qstr *name,
					    struct dentry *parent)
{
	return vfsub_lookup_one_len(name->name, parent, name->len);
}

J. R. Okajima's avatar
J. R. Okajima committed
53
54
/* ---------------------------------------------------------------------- */

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
static inline int vfsub_mnt_want_write(struct vfsmount *mnt)
{
	int err;

	lockdep_off();
	err = mnt_want_write(mnt);
	lockdep_on();
	return err;
}

static inline void vfsub_mnt_drop_write(struct vfsmount *mnt)
{
	lockdep_off();
	mnt_drop_write(mnt);
	lockdep_on();
}

/* ---------------------------------------------------------------------- */

74
75
int vfsub_create(struct inode *dir, struct path *path, int mode,
		 bool want_excl);
76
77
int vfsub_link(struct dentry *src_dentry, struct inode *dir,
	       struct path *path, struct inode **delegated_inode);
78
79
int vfsub_mkdir(struct inode *dir, struct path *path, int mode);
int vfsub_rmdir(struct inode *dir, struct path *path);
80
81
82

/* ---------------------------------------------------------------------- */

J. R. Okajima's avatar
J. R. Okajima committed
83
84
85
86
87
88
89
90
91
92
static inline loff_t vfsub_f_size_read(struct file *file)
{
	return i_size_read(file_inode(file));
}

/* ---------------------------------------------------------------------- */

int vfsub_unlink(struct inode *dir, struct path *path,
		 struct inode **delegated_inode, int force);

93
94
#endif /* __KERNEL__ */
#endif /* __AUFS_VFSUB_H__ */