hbl.h 1.58 KB
Newer Older
J. R. Okajima's avatar
J. R. Okajima committed
1
2
/* SPDX-License-Identifier: GPL-2.0 */
/*
3
 * Copyright (C) 2017-2020 Junjiro R. Okajima
4
5
6
7
8
9
10
11
12
13
14
15
16
 *
 * This program, aufs is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
J. R. Okajima's avatar
J. R. Okajima committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 */

/*
 * helpers for hlist_bl.h
 */

#ifndef __AUFS_HBL_H__
#define __AUFS_HBL_H__

#ifdef __KERNEL__

#include <linux/list_bl.h>

static inline void au_hbl_add(struct hlist_bl_node *node,
			      struct hlist_bl_head *hbl)
{
	hlist_bl_lock(hbl);
	hlist_bl_add_head(node, hbl);
	hlist_bl_unlock(hbl);
}

static inline void au_hbl_del(struct hlist_bl_node *node,
			      struct hlist_bl_head *hbl)
{
	hlist_bl_lock(hbl);
	hlist_bl_del(node);
	hlist_bl_unlock(hbl);
}

#define au_hbl_for_each(pos, head)					\
	for (pos = hlist_bl_first(head);				\
	     pos;							\
	     pos = pos->next)

static inline unsigned long au_hbl_count(struct hlist_bl_head *hbl)
{
	unsigned long cnt;
	struct hlist_bl_node *pos;

	cnt = 0;
	hlist_bl_lock(hbl);
	au_hbl_for_each(pos, hbl)
		cnt++;
	hlist_bl_unlock(hbl);
	return cnt;
}

#endif /* __KERNEL__ */
#endif /* __AUFS_HBL_H__ */