mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
sysctl: add support for poll()
Adding support for poll() in sysctl fs allows userspace to receive notifications of changes in sysctl entries. This adds a infrastructure to allow files in sysctl fs to be pollable and implements it for hostname and domainname. [akpm@linux-foundation.org: s/declare/define/ for definitions] Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi> Cc: Greg KH <gregkh@suse.de> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
088024b1de
commit
f1ecf06854
@@ -13,6 +13,7 @@
|
||||
#include <linux/uts.h>
|
||||
#include <linux/utsname.h>
|
||||
#include <linux/sysctl.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
static void *get_uts(ctl_table *table, int write)
|
||||
{
|
||||
@@ -51,12 +52,19 @@ static int proc_do_uts_string(ctl_table *table, int write,
|
||||
uts_table.data = get_uts(table, write);
|
||||
r = proc_dostring(&uts_table,write,buffer,lenp, ppos);
|
||||
put_uts(table, write, uts_table.data);
|
||||
|
||||
if (write)
|
||||
proc_sys_poll_notify(table->poll);
|
||||
|
||||
return r;
|
||||
}
|
||||
#else
|
||||
#define proc_do_uts_string NULL
|
||||
#endif
|
||||
|
||||
static DEFINE_CTL_TABLE_POLL(hostname_poll);
|
||||
static DEFINE_CTL_TABLE_POLL(domainname_poll);
|
||||
|
||||
static struct ctl_table uts_kern_table[] = {
|
||||
{
|
||||
.procname = "ostype",
|
||||
@@ -85,6 +93,7 @@ static struct ctl_table uts_kern_table[] = {
|
||||
.maxlen = sizeof(init_uts_ns.name.nodename),
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_do_uts_string,
|
||||
.poll = &hostname_poll,
|
||||
},
|
||||
{
|
||||
.procname = "domainname",
|
||||
@@ -92,6 +101,7 @@ static struct ctl_table uts_kern_table[] = {
|
||||
.maxlen = sizeof(init_uts_ns.name.domainname),
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_do_uts_string,
|
||||
.poll = &domainname_poll,
|
||||
},
|
||||
{}
|
||||
};
|
||||
@@ -105,6 +115,19 @@ static struct ctl_table uts_root_table[] = {
|
||||
{}
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PROC_SYSCTL
|
||||
/*
|
||||
* Notify userspace about a change in a certain entry of uts_kern_table,
|
||||
* identified by the parameter proc.
|
||||
*/
|
||||
void uts_proc_notify(enum uts_proc proc)
|
||||
{
|
||||
struct ctl_table *table = &uts_kern_table[proc];
|
||||
|
||||
proc_sys_poll_notify(table->poll);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int __init utsname_sysctl_init(void)
|
||||
{
|
||||
register_sysctl_table(uts_root_table);
|
||||
|
||||
Reference in New Issue
Block a user