/[packages]/cauldron/procps/current/SOURCES/procps-3.2.7-sysctl-ignore.patch
ViewVC logotype

Contents of /cauldron/procps/current/SOURCES/procps-3.2.7-sysctl-ignore.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 328 - (show annotations) (download)
Fri Jan 7 23:44:59 2011 UTC (13 years, 3 months ago) by tmb
File size: 2603 byte(s)
imported package procps
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
3 @@ -63,6 +63,44 @@
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";
6
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.
11 + */
12 +struct sysctl_ignore {
13 + const char *prefix;
14 + int prefix_len;
15 + const char *option;
16 + int option_len;
17 +};
18 +
19 +#define IGNORE_ENTRY(prefix, option) \
20 + { prefix, sizeof(prefix)-1, option, sizeof(option)-1 }
21 +
22 +static struct sysctl_ignore Ignore[] =
23 +{
24 + IGNORE_ENTRY( "net.ipv6.neigh", "base_reachable_time" ),
25 + IGNORE_ENTRY( "net.ipv6.neigh", "retrans_time" )
26 +};
27 +
28 +static bool IsIgnored(const char *name)
29 +{
30 + unsigned int i;
31 + int sz = strlen(name);
32 +
33 + for (i = 0; i < sizeof(Ignore)/sizeof(struct sysctl_ignore); i++) {
34 + struct sysctl_ignore *p = &Ignore[i];
35 +
36 + if (sz < (p->prefix_len + p->option_len))
37 + continue;
38 +
39 + if (strncmp(name, p->prefix, p->prefix_len) == 0 &&
40 + strcmp(name + (sz - p->option_len), p->option) == 0)
41 + return true;
42 + }
43 + return false;
44 +}
45
46 static void slashdot(char *restrict p, char old, char new){
47 p = strpbrk(p,"/.");
48 @@ -122,7 +160,7 @@
49 * Read a sysctl setting
50 *
51 */
52 -static int ReadSetting(const char *restrict const name) {
53 +static int ReadSetting(const char *restrict const name, bool useign) {
54 int rc = 0;
55 char *restrict tmpname;
56 char *restrict outname;
57 @@ -145,6 +183,12 @@
58 outname = strdup(name);
59 slashdot(outname,'/','.'); /* change / to . */
60
61 + if (useign && IsIgnored(outname)) {
62 + free(outname);
63 + free(tmpname);
64 + return rc;
65 + }
66 +
67 if (stat(tmpname, &st)==0) {
68 if (st.st_mode & (S_IRUSR|S_IROTH|S_IRGRP))
69 fp = fopen(tmpname, "r");
70 @@ -257,7 +301,7 @@
71 strcat(tmpdir, "/");
72 DisplayAll(tmpdir);
73 } else {
74 - rc |= ReadSetting(tmpdir+strlen(PROC_PATH));
75 + rc |= ReadSetting(tmpdir+strlen(PROC_PATH), true);
76 }
77 }
78 free(tmpdir);
79 @@ -519,7 +563,7 @@
80 if (WriteMode || index(*argv, '='))
81 ReturnCode = WriteSetting(*argv);
82 else
83 - ReturnCode = ReadSetting(*argv);
84 + ReturnCode = ReadSetting(*argv, false);
85 }
86 }
87
88

  ViewVC Help
Powered by ViewVC 1.1.30