diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-10-01 21:52:16 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-10-01 21:52:16 +0200 |
commit | 689d0650ab63425adaea26afe347015a204958ee (patch) | |
tree | 9c2e10b952cad6804359bc10ccc963ff138fc3d4 /coreutils/chmod.c | |
parent | 3c3928fc658bddacd4e540589868bc28a8e4ca0a (diff) | |
download | busybox-w32-689d0650ab63425adaea26afe347015a204958ee.tar.gz busybox-w32-689d0650ab63425adaea26afe347015a204958ee.tar.bz2 busybox-w32-689d0650ab63425adaea26afe347015a204958ee.zip |
libbb: shrink recursive_action() by reducing memory pressure
function old new delta
recursive_action1 - 316 +316
file_action_grep 161 164 +3
add_to_prg_cache_if_socket 202 205 +3
depmod_main 509 511 +2
writeFileToTarball 488 489 +1
parse_module 281 282 +1
fileAction 207 208 +1
act 189 190 +1
add_to_dirlist 65 64 -1
writeTarFile 196 194 -2
uuidcache_init 47 45 -2
uuidcache_check_device 109 107 -2
true_action 8 6 -2
run_parts_main 310 308 -2
netstat_main 534 532 -2
lsusb_main 29 27 -2
lspci_main 45 43 -2
initial_scan 138 136 -2
grep_main 845 843 -2
find_main 482 480 -2
config_file_action 437 435 -2
chmod_main 142 140 -2
dirAction 14 10 -4
diff_main 1544 1540 -4
chown_main 154 148 -6
skip_dir 136 129 -7
dir_act 191 184 -7
recursive_action 453 69 -384
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 7/20 up/down: 328/-439) Total: -111 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/chmod.c')
-rw-r--r-- | coreutils/chmod.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/coreutils/chmod.c b/coreutils/chmod.c index 27e9b6b86..d2988c490 100644 --- a/coreutils/chmod.c +++ b/coreutils/chmod.c | |||
@@ -65,12 +65,14 @@ | |||
65 | * symbolic links encountered during recursive directory traversals. | 65 | * symbolic links encountered during recursive directory traversals. |
66 | */ | 66 | */ |
67 | 67 | ||
68 | static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf, void* param, int depth) | 68 | static int FAST_FUNC fileAction(struct recursive_state *state, |
69 | const char *fileName, | ||
70 | struct stat *statbuf) | ||
69 | { | 71 | { |
70 | mode_t newmode; | 72 | mode_t newmode; |
71 | 73 | ||
72 | /* match coreutils behavior */ | 74 | /* match coreutils behavior */ |
73 | if (depth == 0) { | 75 | if (state->depth == 0) { |
74 | /* statbuf holds lstat result, but we need stat (follow link) */ | 76 | /* statbuf holds lstat result, but we need stat (follow link) */ |
75 | if (stat(fileName, statbuf)) | 77 | if (stat(fileName, statbuf)) |
76 | goto err; | 78 | goto err; |
@@ -79,9 +81,9 @@ static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf, void | |||
79 | return TRUE; | 81 | return TRUE; |
80 | } | 82 | } |
81 | 83 | ||
82 | newmode = bb_parse_mode((char *)param, statbuf->st_mode); | 84 | newmode = bb_parse_mode((char *)state->userData, statbuf->st_mode); |
83 | if (newmode == (mode_t)-1) | 85 | if (newmode == (mode_t)-1) |
84 | bb_error_msg_and_die("invalid mode '%s'", (char *)param); | 86 | bb_error_msg_and_die("invalid mode '%s'", (char *)state->userData); |
85 | 87 | ||
86 | if (chmod(fileName, newmode) == 0) { | 88 | if (chmod(fileName, newmode) == 0) { |
87 | if (OPT_VERBOSE | 89 | if (OPT_VERBOSE |
@@ -136,8 +138,7 @@ int chmod_main(int argc UNUSED_PARAM, char **argv) | |||
136 | OPT_RECURSE, // recurse | 138 | OPT_RECURSE, // recurse |
137 | fileAction, // file action | 139 | fileAction, // file action |
138 | fileAction, // dir action | 140 | fileAction, // dir action |
139 | smode, // user data | 141 | smode) // user data |
140 | 0) // depth | ||
141 | ) { | 142 | ) { |
142 | retval = EXIT_FAILURE; | 143 | retval = EXIT_FAILURE; |
143 | } | 144 | } |