1 // SPDX-License-Identifier: GPL-2.0
3 * Procfs support for lockd
5 * Copyright (c) 2014 Jeff Layton <jlayton@primarydata.com>
9 #include <linux/proc_fs.h>
10 #include <linux/module.h>
11 #include <linux/nsproxy.h>
12 #include <net/net_namespace.h>
18 * We only allow strings that start with 'Y', 'y', or '1'.
21 nlm_end_grace_write(struct file
*file
, const char __user
*buf
, size_t size
,
25 struct lockd_net
*ln
= net_generic(current
->nsproxy
->net_ns
,
31 data
= simple_transaction_get(file
, buf
, size
);
39 locks_end_grace(&ln
->lockd_manager
);
49 nlm_end_grace_read(struct file
*file
, char __user
*buf
, size_t size
,
52 struct lockd_net
*ln
= net_generic(current
->nsproxy
->net_ns
,
56 resp
[0] = list_empty(&ln
->lockd_manager
.list
) ? 'Y' : 'N';
60 return simple_read_from_buffer(buf
, size
, pos
, resp
, sizeof(resp
));
63 static const struct file_operations lockd_end_grace_operations
= {
64 .write
= nlm_end_grace_write
,
65 .read
= nlm_end_grace_read
,
66 .llseek
= default_llseek
,
67 .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
);