mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-25 06:03:36 -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:
parent
088024b1de
commit
f1ecf06854
5 changed files with 108 additions and 0 deletions
|
|
@ -931,6 +931,7 @@ enum
|
|||
#ifdef __KERNEL__
|
||||
#include <linux/list.h>
|
||||
#include <linux/rcupdate.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
/* For the /proc/sys support */
|
||||
struct ctl_table;
|
||||
|
|
@ -1011,6 +1012,26 @@ extern int proc_do_large_bitmap(struct ctl_table *, int,
|
|||
* cover common cases.
|
||||
*/
|
||||
|
||||
/* Support for userspace poll() to watch for changes */
|
||||
struct ctl_table_poll {
|
||||
atomic_t event;
|
||||
wait_queue_head_t wait;
|
||||
};
|
||||
|
||||
static inline void *proc_sys_poll_event(struct ctl_table_poll *poll)
|
||||
{
|
||||
return (void *)(unsigned long)atomic_read(&poll->event);
|
||||
}
|
||||
|
||||
void proc_sys_poll_notify(struct ctl_table_poll *poll);
|
||||
|
||||
#define __CTL_TABLE_POLL_INITIALIZER(name) { \
|
||||
.event = ATOMIC_INIT(0), \
|
||||
.wait = __WAIT_QUEUE_HEAD_INITIALIZER(name.wait) }
|
||||
|
||||
#define DEFINE_CTL_TABLE_POLL(name) \
|
||||
struct ctl_table_poll name = __CTL_TABLE_POLL_INITIALIZER(name)
|
||||
|
||||
/* A sysctl table is an array of struct ctl_table: */
|
||||
struct ctl_table
|
||||
{
|
||||
|
|
@ -1021,6 +1042,7 @@ struct ctl_table
|
|||
struct ctl_table *child;
|
||||
struct ctl_table *parent; /* Automatically set */
|
||||
proc_handler *proc_handler; /* Callback for text formatting */
|
||||
struct ctl_table_poll *poll;
|
||||
void *extra1;
|
||||
void *extra2;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,6 +37,14 @@ struct new_utsname {
|
|||
#include <linux/nsproxy.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
enum uts_proc {
|
||||
UTS_PROC_OSTYPE,
|
||||
UTS_PROC_OSRELEASE,
|
||||
UTS_PROC_VERSION,
|
||||
UTS_PROC_HOSTNAME,
|
||||
UTS_PROC_DOMAINNAME,
|
||||
};
|
||||
|
||||
struct user_namespace;
|
||||
extern struct user_namespace init_user_ns;
|
||||
|
||||
|
|
@ -80,6 +88,14 @@ static inline struct uts_namespace *copy_utsname(unsigned long flags,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PROC_SYSCTL
|
||||
extern void uts_proc_notify(enum uts_proc proc);
|
||||
#else
|
||||
static inline void uts_proc_notify(enum uts_proc proc)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline struct new_utsname *utsname(void)
|
||||
{
|
||||
return ¤t->nsproxy->uts_ns->name;
|
||||
|
|
|
|||
Loading…
Reference in a new issue