Skip to content

Commit

Permalink
[PATCH] inotify: move sysctl
Browse files Browse the repository at this point in the history
This moves the inotify sysctl knobs to "/proc/sys/fs/inotify" from
"/proc/sys/fs".  Also some related cleanup.

Signed-off-by: Robert Love <rml@novell.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Robert Love authored and Linus Torvalds committed Jul 13, 2005
1 parent 153f805 commit 0399cb0
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 50 deletions.
49 changes: 45 additions & 4 deletions fs/inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ static kmem_cache_t *event_cachep;

static struct vfsmount *inotify_mnt;

/* These are configurable via /proc/sys/inotify */
int inotify_max_user_devices;
/* these are configurable via /proc/sys/fs/inotify/ */
int inotify_max_user_instances;
int inotify_max_user_watches;
int inotify_max_queued_events;

Expand Down Expand Up @@ -125,6 +125,47 @@ struct inotify_watch {
u32 mask; /* event mask for this watch */
};

#ifdef CONFIG_SYSCTL

#include <linux/sysctl.h>

static int zero;

ctl_table inotify_table[] = {
{
.ctl_name = INOTIFY_MAX_USER_INSTANCES,
.procname = "max_user_instances",
.data = &inotify_max_user_instances,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec_minmax,
.strategy = &sysctl_intvec,
.extra1 = &zero,
},
{
.ctl_name = INOTIFY_MAX_USER_WATCHES,
.procname = "max_user_watches",
.data = &inotify_max_user_watches,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec_minmax,
.strategy = &sysctl_intvec,
.extra1 = &zero,
},
{
.ctl_name = INOTIFY_MAX_QUEUED_EVENTS,
.procname = "max_queued_events",
.data = &inotify_max_queued_events,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec_minmax,
.strategy = &sysctl_intvec,
.extra1 = &zero
},
{ .ctl_name = 0 }
};
#endif /* CONFIG_SYSCTL */

static inline void get_inotify_dev(struct inotify_device *dev)
{
atomic_inc(&dev->count);
Expand Down Expand Up @@ -842,7 +883,7 @@ asmlinkage long sys_inotify_init(void)

user = get_uid(current->user);

if (unlikely(atomic_read(&user->inotify_devs) >= inotify_max_user_devices)) {
if (unlikely(atomic_read(&user->inotify_devs) >= inotify_max_user_instances)) {
ret = -EMFILE;
goto out_err;
}
Expand Down Expand Up @@ -979,7 +1020,7 @@ static int __init inotify_init(void)
inotify_mnt = kern_mount(&inotify_fs_type);

inotify_max_queued_events = 8192;
inotify_max_user_devices = 128;
inotify_max_user_instances = 8;
inotify_max_user_watches = 8192;

atomic_set(&inotify_cookie, 0);
Expand Down
12 changes: 6 additions & 6 deletions include/linux/sysctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ enum
CTL_DEV=7, /* Devices */
CTL_BUS=8, /* Busses */
CTL_ABI=9, /* Binary emulation */
CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
CTL_INOTIFY=11 /* Inotify */
CTL_CPU=10 /* CPU stuff (speed scaling, etc) */
};

/* CTL_BUS names: */
Expand All @@ -71,12 +70,12 @@ enum
CTL_BUS_ISA=1 /* ISA */
};

/* CTL_INOTIFY names: */
/* /proc/sys/fs/inotify/ */
enum
{
INOTIFY_MAX_USER_DEVICES=1, /* max number of inotify device instances per user */
INOTIFY_MAX_USER_WATCHES=2, /* max number of inotify watches per user */
INOTIFY_MAX_QUEUED_EVENTS=3 /* Max number of queued events per inotify device instance */
INOTIFY_MAX_USER_INSTANCES=1, /* max instances per user */
INOTIFY_MAX_USER_WATCHES=2, /* max watches per user */
INOTIFY_MAX_QUEUED_EVENTS=3 /* max queued events per instance */
};

/* CTL_KERN names: */
Expand Down Expand Up @@ -685,6 +684,7 @@ enum
FS_XFS=17, /* struct: control xfs parameters */
FS_AIO_NR=18, /* current system-wide number of aio requests */
FS_AIO_MAX_NR=19, /* system-wide maximum number of aio requests */
FS_INOTIFY=20, /* inotify submenu */
};

/* /proc/sys/fs/quota/ */
Expand Down
51 changes: 11 additions & 40 deletions kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ extern int printk_ratelimit_jiffies;
extern int printk_ratelimit_burst;
extern int pid_max_min, pid_max_max;

#ifdef CONFIG_INOTIFY
extern int inotify_max_user_devices;
extern int inotify_max_user_watches;
extern int inotify_max_queued_events;
#endif

#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
int unknown_nmi_panic;
extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *,
Expand Down Expand Up @@ -152,6 +146,9 @@ extern ctl_table random_table[];
#ifdef CONFIG_UNIX98_PTYS
extern ctl_table pty_table[];
#endif
#ifdef CONFIG_INOTIFY
extern ctl_table inotify_table[];
#endif

#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
int sysctl_legacy_va_layout;
Expand Down Expand Up @@ -957,6 +954,14 @@ static ctl_table fs_table[] = {
.mode = 0644,
.proc_handler = &proc_dointvec,
},
#ifdef CONFIG_INOTIFY
{
.ctl_name = FS_INOTIFY,
.procname = "inotify",
.mode = 0555,
.child = inotify_table,
},
#endif
#endif
{
.ctl_name = KERN_SETUID_DUMPABLE,
Expand All @@ -966,40 +971,6 @@ static ctl_table fs_table[] = {
.mode = 0644,
.proc_handler = &proc_dointvec,
},
#ifdef CONFIG_INOTIFY
{
.ctl_name = INOTIFY_MAX_USER_DEVICES,
.procname = "max_user_devices",
.data = &inotify_max_user_devices,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec_minmax,
.strategy = &sysctl_intvec,
.extra1 = &zero,
},

{
.ctl_name = INOTIFY_MAX_USER_WATCHES,
.procname = "max_user_watches",
.data = &inotify_max_user_watches,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec_minmax,
.strategy = &sysctl_intvec,
.extra1 = &zero,
},

{
.ctl_name = INOTIFY_MAX_QUEUED_EVENTS,
.procname = "max_queued_events",
.data = &inotify_max_queued_events,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec_minmax,
.strategy = &sysctl_intvec,
.extra1 = &zero
},
#endif
{ .ctl_name = 0 }
};

Expand Down

0 comments on commit 0399cb0

Please sign in to comment.