Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Sysctl 1.01 - A utility to read and manipulate the sysctl parameters |
| 3 | * |
Rob Landley | 8b1f11d | 2006-04-17 21:49:34 +0000 | [diff] [blame] | 4 | * Copyright 1999 George Staikos |
Bernhard Reutner-Fischer | cb44816 | 2006-04-12 07:35:12 +0000 | [diff] [blame] | 5 | * |
| 6 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 7 | * |
| 8 | * Changelog: |
| 9 | * v1.01: |
| 10 | * - added -p <preload> to preload values from a file |
| 11 | * v1.01.1 |
| 12 | * - busybox applet aware by <solar@gentoo.org> |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 13 | * |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 16 | #include "libbb.h" |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 17 | |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 18 | static int sysctl_read_setting(const char *setting); |
| 19 | static int sysctl_write_setting(const char *setting); |
| 20 | static int sysctl_display_all(const char *path); |
| 21 | static int sysctl_preload_file_and_exit(const char *filename); |
Denis Vlasenko | 58cc52a | 2008-10-15 08:22:55 +0000 | [diff] [blame] | 22 | static void sysctl_dots_to_slashes(char *name); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 23 | |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 24 | static const char ETC_SYSCTL_CONF[] ALIGN1 = "/etc/sysctl.conf"; |
| 25 | static const char PROC_SYS[] ALIGN1 = "/proc/sys/"; |
| 26 | enum { strlen_PROC_SYS = sizeof(PROC_SYS) - 1 }; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 27 | |
Denis Vlasenko | cfdb711 | 2008-10-15 08:29:17 +0000 | [diff] [blame] | 28 | static const char msg_unknown_key[] ALIGN1 = |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 29 | "error: '%s' is an unknown key"; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 30 | |
Glenn L McGrath | ab82154 | 2003-12-26 02:19:34 +0000 | [diff] [blame] | 31 | static void dwrite_str(int fd, const char *buf) |
| 32 | { |
| 33 | write(fd, buf, strlen(buf)); |
| 34 | } |
| 35 | |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 36 | enum { |
| 37 | FLAG_SHOW_KEYS = 1 << 0, |
| 38 | FLAG_SHOW_KEY_ERRORS = 1 << 1, |
| 39 | FLAG_TABLE_FORMAT = 1 << 2, /* not implemented */ |
| 40 | FLAG_SHOW_ALL = 1 << 3, |
| 41 | FLAG_PRELOAD_FILE = 1 << 4, |
| 42 | FLAG_WRITE = 1 << 5, |
| 43 | }; |
| 44 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 45 | int sysctl_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | a60f84e | 2008-07-05 09:18:54 +0000 | [diff] [blame] | 46 | int sysctl_main(int argc UNUSED_PARAM, char **argv) |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 47 | { |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 48 | int retval; |
| 49 | int opt; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 50 | |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 51 | opt = getopt32(argv, "+neAapw"); /* '+' - stop on first non-option */ |
| 52 | argv += optind; |
| 53 | opt ^= (FLAG_SHOW_KEYS | FLAG_SHOW_KEY_ERRORS); |
| 54 | option_mask32 ^= (FLAG_SHOW_KEYS | FLAG_SHOW_KEY_ERRORS); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 55 | |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 56 | if (opt & (FLAG_TABLE_FORMAT | FLAG_SHOW_ALL)) |
| 57 | return sysctl_display_all(PROC_SYS); |
| 58 | if (opt & FLAG_PRELOAD_FILE) |
| 59 | return sysctl_preload_file_and_exit(*argv ? *argv : ETC_SYSCTL_CONF); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 60 | |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 61 | retval = 0; |
| 62 | while (*argv) { |
| 63 | if (opt & FLAG_WRITE) |
| 64 | retval |= sysctl_write_setting(*argv); |
| 65 | else |
| 66 | retval |= sysctl_read_setting(*argv); |
| 67 | argv++; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 68 | } |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 69 | |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 70 | return retval; |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 71 | } /* end sysctl_main() */ |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 72 | |
Denis Vlasenko | 81944c9 | 2008-10-15 08:45:54 +0000 | [diff] [blame^] | 73 | /* Set sysctl's from a conf file. Format example: |
| 74 | * # Controls IP packet forwarding |
| 75 | * net.ipv4.ip_forward = 0 |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 76 | */ |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 77 | static int sysctl_preload_file_and_exit(const char *filename) |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 78 | { |
Denis Vlasenko | 4a717e0 | 2008-07-20 13:01:56 +0000 | [diff] [blame] | 79 | char *token[2]; |
| 80 | parser_t *parser; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 81 | |
Denis Vlasenko | 4a717e0 | 2008-07-20 13:01:56 +0000 | [diff] [blame] | 82 | parser = config_open(filename); |
Denis Vlasenko | 81944c9 | 2008-10-15 08:45:54 +0000 | [diff] [blame^] | 83 | // TODO: ';' is comment char too |
| 84 | while (config_read(parser, token, 2, 2, "# \t=", PARSE_NORMAL)) { |
Denis Vlasenko | 4a717e0 | 2008-07-20 13:01:56 +0000 | [diff] [blame] | 85 | #if 0 |
Denis Vlasenko | 81944c9 | 2008-10-15 08:45:54 +0000 | [diff] [blame^] | 86 | char *s = xasprintf("%s=%s", token[0], token[1]); |
| 87 | sysctl_write_setting(s); |
| 88 | free(s); |
| 89 | #else /* Save ~4 bytes by using parser internals */ |
| 90 | sprintf(parser->line, "%s=%s", token[0], token[1]); // must have room by definition |
| 91 | sysctl_write_setting(parser->line); |
Denis Vlasenko | 4a717e0 | 2008-07-20 13:01:56 +0000 | [diff] [blame] | 92 | #endif |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 93 | } |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 94 | if (ENABLE_FEATURE_CLEAN_UP) |
Denis Vlasenko | 4a717e0 | 2008-07-20 13:01:56 +0000 | [diff] [blame] | 95 | config_close(parser); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 96 | return 0; |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 97 | } /* end sysctl_preload_file_and_exit() */ |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 98 | |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 99 | static int sysctl_write_setting(const char *setting) |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 100 | { |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 101 | int retval; |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 102 | const char *name; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 103 | const char *value; |
| 104 | const char *equals; |
| 105 | char *tmpname, *outname, *cptr; |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 106 | int fd; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 107 | |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 108 | name = setting; |
| 109 | equals = strchr(setting, '='); |
| 110 | if (!equals) { |
Denis Vlasenko | cfdb711 | 2008-10-15 08:29:17 +0000 | [diff] [blame] | 111 | bb_error_msg("error: '%s' must be of the form name=value", setting); |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 112 | return EXIT_FAILURE; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 113 | } |
| 114 | |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 115 | value = equals + 1; /* point to the value in name=value */ |
| 116 | if (name == equals || !*value) { |
Denis Vlasenko | cfdb711 | 2008-10-15 08:29:17 +0000 | [diff] [blame] | 117 | bb_error_msg("error: malformed setting '%s'", setting); |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 118 | return EXIT_FAILURE; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 119 | } |
| 120 | |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 121 | tmpname = xasprintf("%s%.*s", PROC_SYS, (int)(equals - name), name); |
| 122 | outname = xstrdup(tmpname + strlen_PROC_SYS); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 123 | |
Denis Vlasenko | 58cc52a | 2008-10-15 08:22:55 +0000 | [diff] [blame] | 124 | sysctl_dots_to_slashes(tmpname); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 125 | |
| 126 | while ((cptr = strchr(outname, '/')) != NULL) |
| 127 | *cptr = '.'; |
| 128 | |
Denis Vlasenko | 50f7f44 | 2007-04-11 23:20:53 +0000 | [diff] [blame] | 129 | fd = open(tmpname, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
| 130 | if (fd < 0) { |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 131 | switch (errno) { |
| 132 | case ENOENT: |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 133 | if (option_mask32 & FLAG_SHOW_KEY_ERRORS) |
Denis Vlasenko | cfdb711 | 2008-10-15 08:29:17 +0000 | [diff] [blame] | 134 | bb_error_msg(msg_unknown_key, outname); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 135 | break; |
| 136 | default: |
Denis Vlasenko | cfdb711 | 2008-10-15 08:29:17 +0000 | [diff] [blame] | 137 | bb_perror_msg("error setting key '%s'", outname); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 138 | break; |
| 139 | } |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 140 | retval = EXIT_FAILURE; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 141 | } else { |
Glenn L McGrath | ab82154 | 2003-12-26 02:19:34 +0000 | [diff] [blame] | 142 | dwrite_str(fd, value); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 143 | close(fd); |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 144 | if (option_mask32 & FLAG_SHOW_KEYS) { |
| 145 | printf("%s = ", outname); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 146 | } |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 147 | puts(value); |
| 148 | retval = EXIT_SUCCESS; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 149 | } |
| 150 | |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 151 | free(tmpname); |
| 152 | free(outname); |
| 153 | return retval; |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 154 | } /* end sysctl_write_setting() */ |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 155 | |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 156 | static int sysctl_read_setting(const char *name) |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 157 | { |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 158 | int retval; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 159 | char *tmpname, *outname, *cptr; |
| 160 | char inbuf[1025]; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 161 | FILE *fp; |
| 162 | |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 163 | if (!*name) { |
| 164 | if (option_mask32 & FLAG_SHOW_KEY_ERRORS) |
Denis Vlasenko | cfdb711 | 2008-10-15 08:29:17 +0000 | [diff] [blame] | 165 | bb_error_msg(msg_unknown_key, name); |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 166 | return -1; |
| 167 | } |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 168 | |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 169 | tmpname = concat_path_file(PROC_SYS, name); |
| 170 | outname = xstrdup(tmpname + strlen_PROC_SYS); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 171 | |
Denis Vlasenko | 58cc52a | 2008-10-15 08:22:55 +0000 | [diff] [blame] | 172 | sysctl_dots_to_slashes(tmpname); |
| 173 | |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 174 | while ((cptr = strchr(outname, '/')) != NULL) |
| 175 | *cptr = '.'; |
| 176 | |
Denis Vlasenko | 5415c85 | 2008-07-21 23:05:26 +0000 | [diff] [blame] | 177 | fp = fopen_for_read(tmpname); |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 178 | if (fp == NULL) { |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 179 | switch (errno) { |
| 180 | case ENOENT: |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 181 | if (option_mask32 & FLAG_SHOW_KEY_ERRORS) |
Denis Vlasenko | cfdb711 | 2008-10-15 08:29:17 +0000 | [diff] [blame] | 182 | bb_error_msg(msg_unknown_key, outname); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 183 | break; |
| 184 | default: |
Denis Vlasenko | cfdb711 | 2008-10-15 08:29:17 +0000 | [diff] [blame] | 185 | bb_perror_msg("error reading key '%s'", outname); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 186 | break; |
| 187 | } |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 188 | retval = EXIT_FAILURE; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 189 | } else { |
| 190 | while (fgets(inbuf, sizeof(inbuf) - 1, fp)) { |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 191 | if (option_mask32 & FLAG_SHOW_KEYS) { |
| 192 | printf("%s = ", outname); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 193 | } |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 194 | fputs(inbuf, stdout); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 195 | } |
| 196 | fclose(fp); |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 197 | retval = EXIT_SUCCESS; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | free(tmpname); |
| 201 | free(outname); |
| 202 | return retval; |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 203 | } /* end sysctl_read_setting() */ |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 204 | |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 205 | static int sysctl_display_all(const char *path) |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 206 | { |
Denis Vlasenko | 81944c9 | 2008-10-15 08:45:54 +0000 | [diff] [blame^] | 207 | int retval = EXIT_SUCCESS; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 208 | DIR *dp; |
| 209 | struct dirent *de; |
| 210 | char *tmpdir; |
| 211 | struct stat ts; |
| 212 | |
Denis Vlasenko | 51742f4 | 2007-04-12 00:32:05 +0000 | [diff] [blame] | 213 | dp = opendir(path); |
| 214 | if (!dp) { |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 215 | return EXIT_FAILURE; |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 216 | } |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 217 | while ((de = readdir(dp)) != NULL) { |
| 218 | tmpdir = concat_subpath_file(path, de->d_name); |
| 219 | if (tmpdir == NULL) |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 220 | continue; /* . or .. */ |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 221 | if (stat(tmpdir, &ts) != 0) { |
| 222 | bb_perror_msg(tmpdir); |
| 223 | } else if (S_ISDIR(ts.st_mode)) { |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 224 | retval |= sysctl_display_all(tmpdir); |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 225 | } else { |
Denis Vlasenko | 64309f8 | 2007-11-29 06:40:28 +0000 | [diff] [blame] | 226 | retval |= sysctl_read_setting(tmpdir + strlen_PROC_SYS); |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 227 | } |
| 228 | free(tmpdir); |
| 229 | } /* end while */ |
| 230 | closedir(dp); |
Eric Andersen | b905028 | 2003-12-24 06:02:11 +0000 | [diff] [blame] | 231 | |
| 232 | return retval; |
Denis Vlasenko | 5a28a25 | 2007-10-29 19:22:13 +0000 | [diff] [blame] | 233 | } /* end sysctl_display_all() */ |
Denis Vlasenko | 58cc52a | 2008-10-15 08:22:55 +0000 | [diff] [blame] | 234 | |
| 235 | static void sysctl_dots_to_slashes(char *name) |
| 236 | { |
| 237 | char *cptr = name; |
| 238 | |
| 239 | /* Example from bug 3894: |
| 240 | * net.ipv4.conf.eth0.100.mc_forwarding -> |
| 241 | * net/ipv4/conf/eth0.100/mc_forwarding */ |
| 242 | while (*cptr != '\0') { |
| 243 | if (*cptr == '.') { |
| 244 | *cptr = '\0'; |
| 245 | if (access(name, F_OK) == 0) |
| 246 | *cptr = '/'; |
| 247 | else |
| 248 | *cptr = '.'; |
| 249 | } |
| 250 | cptr++; |
| 251 | } |
| 252 | } /* end sysctl_dots_to_slashes() */ |