aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--procps/sysctl.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/procps/sysctl.c b/procps/sysctl.c
index 42de374d2..2ef19c1be 100644
--- a/procps/sysctl.c
+++ b/procps/sysctl.c
@@ -205,19 +205,21 @@ static int sysctl_act_on_setting(char *setting)
205 205
206static int sysctl_act_recursive(const char *path) 206static int sysctl_act_recursive(const char *path)
207{ 207{
208 DIR *dirp;
209 struct stat buf; 208 struct stat buf;
210 struct dirent *entry;
211 char *next;
212 int retval = 0; 209 int retval = 0;
213 210
214 stat(path, &buf); 211 if (!(option_mask32 & FLAG_WRITE)
215 if (S_ISDIR(buf.st_mode) && !(option_mask32 & FLAG_WRITE)) { 212 && stat(path, &buf) == 0
213 && S_ISDIR(buf.st_mode)
214 ) {
215 struct dirent *entry;
216 DIR *dirp;
217
216 dirp = opendir(path); 218 dirp = opendir(path);
217 if (dirp == NULL) 219 if (dirp == NULL)
218 return -1; 220 return -1;
219 while ((entry = readdir(dirp)) != NULL) { 221 while ((entry = readdir(dirp)) != NULL) {
220 next = concat_subpath_file(path, entry->d_name); 222 char *next = concat_subpath_file(path, entry->d_name);
221 if (next == NULL) 223 if (next == NULL)
222 continue; /* d_name is "." or ".." */ 224 continue; /* d_name is "." or ".." */
223 /* if path was ".", drop "./" prefix: */ 225 /* if path was ".", drop "./" prefix: */
@@ -305,6 +307,8 @@ int sysctl_main(int argc UNUSED_PARAM, char **argv)
305 return sysctl_act_recursive("."); 307 return sysctl_act_recursive(".");
306 } 308 }
307 309
310//TODO: if(!argv[0]) bb_show_usage() ?
311
308 retval = 0; 312 retval = 0;
309 while (*argv) { 313 while (*argv) {
310 sysctl_dots_to_slashes(*argv); 314 sysctl_dots_to_slashes(*argv);