2 * Procfs support for lockd
4 * Copyright (c) 2014 Jeff Layton <jlayton@primarydata.com>
8 #include <linux/proc_fs.h>
9 #include <linux/module.h>
10 #include <linux/nsproxy.h>
11 #include <net/net_namespace.h>
17 * We only allow strings that start with 'Y', 'y', or '1'.
20 nlm_end_grace_write(struct file
*file
, const char __user
*buf
, size_t size
,
24 struct lockd_net
*ln
= net_generic(current
->nsproxy
->net_ns
,
30 data
= simple_transaction_get(file
, buf
, size
);
38 locks_end_grace(&ln
->lockd_manager
);
48 nlm_end_grace_read(struct file
*file
, char __user
*buf
, size_t size
,
51 struct lockd_net
*ln
= net_generic(current
->nsproxy
->net_ns
,
55 resp
[0] = list_empty(&ln
->lockd_manager
.list
) ? 'Y' : 'N';
59 return simple_read_from_buffer(buf
, size
, pos
, resp
, sizeof(resp
));
62 static const struct file_operations lockd_end_grace_operations
= {
63 .write
= nlm_end_grace_write
,
64 .read
= nlm_end_grace_read
,
65 .llseek
= default_llseek
,
66 .release
= simple_transaction_release
,
71 lockd_create_procfs(void)
73 struct proc_dir_entry
*entry
;
75 entry
= proc_mkdir("fs/lockd", NULL
);
78 entry
= proc_create("nlm_end_grace", S_IRUGO
|S_IWUSR
, entry
,
79 &lockd_end_grace_operations
);
81 remove_proc_entry("fs/lockd", NULL
);
88 lockd_remove_procfs(void)
90 remove_proc_entry("fs/lockd/nlm_end_grace", NULL
);
91 remove_proc_entry("fs/lockd", NULL
);