16 #include <linux/export.h>
17 #include <linux/slab.h>
18 #include <linux/list.h>
20 #include <linux/capability.h>
24 #include <linux/errno.h>
28 #include <asm/uaccess.h>
45 static inline int is_live(
void)
47 return !(list_empty(&dcookie_users));
52 static inline unsigned long dcookie_value(
struct dcookie_struct * dcs)
54 return (
unsigned long)dcs->
path.dentry;
58 static size_t dcookie_hash(
unsigned long dcookie)
71 list = dcookie_hashtable + dcookie_hash(dcookie);
75 if (dcookie_value(dcs) == dcookie) {
87 struct list_head * list = dcookie_hashtable + dcookie_hash(dcookie_value(dcs));
128 dcs = find_dcookie((
unsigned long)path->
dentry);
130 dcs = alloc_dcookie(path);
137 *cookie = dcookie_value(dcs);
150 unsigned long cookie = (
unsigned long)cookie64;
170 if (!(dcs = find_dcookie(cookie)))
191 if (pathlen <=
len) {
204 #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
205 asmlinkage long SyS_lookup_dcookie(
u64 cookie64,
long buf,
long len)
207 return SYSC_lookup_dcookie(cookie64, (
char __user *) buf, (
size_t) len);
212 static int dcookie_init(
void)
215 unsigned int i, hash_bits;
226 if (!dcookie_hashtable)
240 }
while ((hash_size >> hash_bits) != 0);
247 hash_size = 1
UL << hash_bits;
250 d = dcookie_hashtable;
279 static void dcookie_exit(
void)
287 for (i = 0; i < hash_size; ++
i) {
288 list = dcookie_hashtable +
i;
296 kfree(dcookie_hashtable);
315 if (!is_live() && dcookie_init())
318 list_add(&user->
next, &dcookie_users);