dir.h 3.03 KB
Newer Older
J. R. Okajima's avatar
J. R. Okajima committed
1
2
/* SPDX-License-Identifier: GPL-2.0 */
/*
3
 * Copyright (C) 2005-2020 Junjiro R. Okajima
J. R. Okajima's avatar
J. R. Okajima committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 */

/*
 * directory operations
 */

#ifndef __AUFS_DIR_H__
#define __AUFS_DIR_H__

#ifdef __KERNEL__

#include <linux/fs.h>

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

19
20
21
22
23
24
25
26
27
/* need to be faster and smaller */

struct au_nhash {
	unsigned int		nh_num;
	struct hlist_head	*nh_head;
};

struct au_vdir_destr {
	unsigned char	len;
J. R. Okajima's avatar
J. R. Okajima committed
28
	unsigned char	name[];
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
} __packed;

struct au_vdir_dehstr {
	struct hlist_node	hash;
	struct au_vdir_destr	*str;
	struct rcu_head		rcu;
} ____cacheline_aligned_in_smp;

struct au_vdir_de {
	ino_t			de_ino;
	unsigned char		de_type;
	/* caution: packed */
	struct au_vdir_destr	de_str;
} __packed;

struct au_vdir_wh {
	struct hlist_node	wh_hash;
J. R. Okajima's avatar
J. R. Okajima committed
46
47
#ifdef CONFIG_AUFS_SHWH
	ino_t			wh_ino;
48
	aufs_bindex_t		wh_bindex;
J. R. Okajima's avatar
J. R. Okajima committed
49
50
51
52
	unsigned char		wh_type;
#else
	aufs_bindex_t		wh_bindex;
#endif
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
	/* caution: packed */
	struct au_vdir_destr	wh_str;
} __packed;

union au_vdir_deblk_p {
	unsigned char		*deblk;
	struct au_vdir_de	*de;
};

struct au_vdir {
	unsigned char	**vd_deblk;
	unsigned long	vd_nblk;
	struct {
		unsigned long		ul;
		union au_vdir_deblk_p	p;
	} vd_last;

	u64		vd_version;
	unsigned int	vd_deblk_sz;
	unsigned long	vd_jiffy;
	struct rcu_head	rcu;
} ____cacheline_aligned_in_smp;

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

J. R. Okajima's avatar
J. R. Okajima committed
78
/* dir.c */
J. R. Okajima's avatar
J. R. Okajima committed
79
extern const struct file_operations aufs_dir_fop;
J. R. Okajima's avatar
J. R. Okajima committed
80
81
void au_add_nlink(struct inode *dir, struct inode *h_dir);
void au_sub_nlink(struct inode *dir, struct inode *h_dir);
82
loff_t au_dir_size(struct file *file, struct dentry *dentry);
J. R. Okajima's avatar
J. R. Okajima committed
83
void au_dir_ts(struct inode *dir, aufs_bindex_t bsrc);
J. R. Okajima's avatar
J. R. Okajima committed
84
85
int au_test_empty_lower(struct dentry *dentry);
int au_test_empty(struct dentry *dentry, struct au_nhash *whlist);
J. R. Okajima's avatar
J. R. Okajima committed
86

87
/* vdir.c */
88
89
90
unsigned int au_rdhash_est(loff_t sz);
int au_nhash_alloc(struct au_nhash *nhash, unsigned int num_hash, gfp_t gfp);
void au_nhash_wh_free(struct au_nhash *whlist);
J. R. Okajima's avatar
J. R. Okajima committed
91
92
int au_nhash_test_longer_wh(struct au_nhash *whlist, aufs_bindex_t btgt,
			    int limit);
93
94
int au_nhash_test_known_wh(struct au_nhash *whlist, char *name, int nlen);
int au_nhash_append_wh(struct au_nhash *whlist, char *name, int nlen, ino_t ino,
J. R. Okajima's avatar
J. R. Okajima committed
95
96
		       unsigned int d_type, aufs_bindex_t bindex,
		       unsigned char shwh);
97
void au_vdir_free(struct au_vdir *vdir);
98
99
int au_vdir_init(struct file *file);
int au_vdir_fill_de(struct file *file, struct dir_context *ctx);
100

J. R. Okajima's avatar
J. R. Okajima committed
101
102
103
/* ioctl.c */
long aufs_ioctl_dir(struct file *file, unsigned int cmd, unsigned long arg);

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#ifdef CONFIG_AUFS_RDU
/* rdu.c */
long au_rdu_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
#ifdef CONFIG_COMPAT
long au_rdu_compat_ioctl(struct file *file, unsigned int cmd,
			 unsigned long arg);
#endif
#else
AuStub(long, au_rdu_ioctl, return -EINVAL, struct file *file,
       unsigned int cmd, unsigned long arg)
#ifdef CONFIG_COMPAT
AuStub(long, au_rdu_compat_ioctl, return -EINVAL, struct file *file,
       unsigned int cmd, unsigned long arg)
#endif
#endif

J. R. Okajima's avatar
J. R. Okajima committed
120
121
#endif /* __KERNEL__ */
#endif /* __AUFS_DIR_H__ */