1 --- procps-3.2.7/sysctl.c.kzak 2007-04-03 01:26:01.000000000 +0200
2 +++ procps-3.2.7/sysctl.c 2007-04-03 01:26:13.000000000 +0200
4 static const char ERR_PRELOAD_FILE[] = "error: unable to open preload file \"%s\"\n";
5 static const char WARN_BAD_LINE[] = "warning: %s(%d): invalid syntax, continuing...\n";
7 +/* Ignore deprecated sysctls
8 + * -- we use this list when we scan (DisplayAll) /proc/sys only. We don't use it
9 + * in case when user direcly uses deprecated key. It's better when user can read
10 + * an error message from kernel.
12 +struct sysctl_ignore {
19 +#define IGNORE_ENTRY(prefix, option) \
20 + { prefix, sizeof(prefix)-1, option, sizeof(option)-1 }
22 +static struct sysctl_ignore Ignore[] =
24 + IGNORE_ENTRY( "net.ipv6.neigh", "base_reachable_time" ),
25 + IGNORE_ENTRY( "net.ipv6.neigh", "retrans_time" )
28 +static bool IsIgnored(const char *name)
31 + int sz = strlen(name);
33 + for (i = 0; i < sizeof(Ignore)/sizeof(struct sysctl_ignore); i++) {
34 + struct sysctl_ignore *p = &Ignore[i];
36 + if (sz < (p->prefix_len + p->option_len))
39 + if (strncmp(name, p->prefix, p->prefix_len) == 0 &&
40 + strcmp(name + (sz - p->option_len), p->option) == 0)
46 static void slashdot(char *restrict p, char old, char new){
49 * Read a sysctl setting
52 -static int ReadSetting(const char *restrict const name) {
53 +static int ReadSetting(const char *restrict const name, bool useign) {
55 char *restrict tmpname;
56 char *restrict outname;
58 outname = strdup(name);
59 slashdot(outname,'/','.'); /* change / to . */
61 + if (useign && IsIgnored(outname)) {
67 if (stat(tmpname, &st)==0) {
68 if (st.st_mode & (S_IRUSR|S_IROTH|S_IRGRP))
69 fp = fopen(tmpname, "r");
74 - rc |= ReadSetting(tmpdir+strlen(PROC_PATH));
75 + rc |= ReadSetting(tmpdir+strlen(PROC_PATH), true);
80 if (WriteMode || index(*argv, '='))
81 ReturnCode = WriteSetting(*argv);
83 - ReturnCode = ReadSetting(*argv);
84 + ReturnCode = ReadSetting(*argv, false);