aboutsummaryrefslogtreecommitdiff
path: root/coreutils/chmod.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/chmod.c')
-rw-r--r--coreutils/chmod.c13
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
68static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf, void* param, int depth) 68static 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 }