]> granicus.if.org Git - procps-ng/commitdiff
sysctl: enable pattern matching with path
authorSami Kerola <kerolasa@iki.fi>
Sun, 18 Dec 2011 15:24:36 +0000 (16:24 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 20 Dec 2011 16:30:55 +0000 (17:30 +0100)
Pattern matching support in `sysctl: implement --pattern option'
commit did not work when variable path was defined, for example

$ sysctl net.ipv4 -r arp.ignore

gave no output. Reason being was tht the pattern was matched agains
the specified argument and not the output variable list.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sysctl.c

index ee03ee903c1810ee171bfad39abbe57def944328..b4e0dea7c5b53fdba16310e54e1704bc484d13d1 100644 (file)
--- a/sysctl.c
+++ b/sysctl.c
@@ -164,11 +164,6 @@ static int ReadSetting(const char *restrict const name) {
    outname = xstrdup(name);
    slashdot(outname,'/','.'); /* change / to . */
 
-   if (pattern && !pattern_match(outname, pattern)){
-      free(outname);
-      return 0;
-   }
-
    /* used to open the file */
    tmpname = xmalloc(strlen(name)+strlen(PROC_PATH)+2);
    strcpy(tmpname, PROC_PATH);
@@ -198,6 +193,11 @@ static int ReadSetting(const char *restrict const name) {
       goto out;
    }
 
+   if (pattern && !pattern_match(outname, pattern)){
+      free(outname);
+      return 0;
+   }
+
    fp = fopen(tmpname, "r");
 
    if (!fp) {