aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archival/libunarchive/open_transformer.c7
-rw-r--r--libbb/recursive_action.c28
2 files changed, 24 insertions, 11 deletions
diff --git a/archival/libunarchive/open_transformer.c b/archival/libunarchive/open_transformer.c
index d0a2b7c36..86415c749 100644
--- a/archival/libunarchive/open_transformer.c
+++ b/archival/libunarchive/open_transformer.c
@@ -40,7 +40,8 @@ int open_transformer(int src_fd,
40 close(fd_pipe.wr); /* Send EOF */ 40 close(fd_pipe.wr); /* Send EOF */
41 close(src_fd); 41 close(src_fd);
42 } 42 }
43 exit(EXIT_SUCCESS); 43 /* must be _exit! bug was actually seen here */
44 _exit(EXIT_SUCCESS);
44#else 45#else
45 { 46 {
46 char *argv[4]; 47 char *argv[4];
@@ -60,5 +61,7 @@ int open_transformer(int src_fd,
60 /* parent process */ 61 /* parent process */
61 close(fd_pipe.wr); /* Don't want to write to the child */ 62 close(fd_pipe.wr); /* Don't want to write to the child */
62 63
63 return fd_pipe.rd; 64//TODO: get rid of return value (become void)?
65 xmove_fd(fd_pipe.rd, src_fd);
66 return src_fd;
64} 67}
diff --git a/libbb/recursive_action.c b/libbb/recursive_action.c
index 513aff315..fe9ba2ecc 100644
--- a/libbb/recursive_action.c
+++ b/libbb/recursive_action.c
@@ -34,9 +34,19 @@ static int true_action(const char *fileName ATTRIBUTE_UNUSED,
34 * recursive_action() return 0, but it doesn't stop directory traversal 34 * recursive_action() return 0, but it doesn't stop directory traversal
35 * (fileAction/dirAction will be called on each file). 35 * (fileAction/dirAction will be called on each file).
36 * 36 *
37 * if !depthFirst, dirAction return value of 0 (FALSE) or 2 (SKIP) 37 * If !ACTION_RECURSE, dirAction is called on the directory and its
38 * prevents recursion into that directory, instead 38 * return value is returned from recursive_action(). No recursion.
39 * recursive_action() returns 0 (if FALSE) or 1 (if SKIP). 39 *
40 * If ACTION_RECURSE, recursive_action() is called on each directory.
41 * If any one of these calls returns 0, current recursive_action() returns 0.
42 *
43 * If ACTION_DEPTHFIRST, dirAction is called after recurse.
44 * If it returns 0, the warning is printed and recursive_action() returns 0.
45 *
46 * If !ACTION_DEPTHFIRST, dirAction is called before we recurse.
47 * Return value of 0 (FALSE) or 2 (SKIP) prevents recursion
48 * into that directory, instead recursive_action() returns 0 (if FALSE)
49 * or 1 (if SKIP)
40 * 50 *
41 * followLinks=0/1 differs mainly in handling of links to dirs. 51 * followLinks=0/1 differs mainly in handling of links to dirs.
42 * 0: lstat(statbuf). Calls fileAction on link name even if points to dir. 52 * 0: lstat(statbuf). Calls fileAction on link name even if points to dir.
@@ -59,7 +69,8 @@ int recursive_action(const char *fileName,
59 if (!dirAction) dirAction = true_action; 69 if (!dirAction) dirAction = true_action;
60 70
61 status = ACTION_FOLLOWLINKS; /* hijack a variable for bitmask... */ 71 status = ACTION_FOLLOWLINKS; /* hijack a variable for bitmask... */
62 if (!depth) status = ACTION_FOLLOWLINKS | ACTION_FOLLOWLINKS_L0; 72 if (!depth)
73 status = ACTION_FOLLOWLINKS | ACTION_FOLLOWLINKS_L0;
63 status = ((flags & status) ? stat : lstat)(fileName, &statbuf); 74 status = ((flags & status) ? stat : lstat)(fileName, &statbuf);
64 if (status < 0) { 75 if (status < 0) {
65#ifdef DEBUG_RECURS_ACTION 76#ifdef DEBUG_RECURS_ACTION
@@ -105,8 +116,9 @@ int recursive_action(const char *fileName,
105 nextFile = concat_subpath_file(fileName, next->d_name); 116 nextFile = concat_subpath_file(fileName, next->d_name);
106 if (nextFile == NULL) 117 if (nextFile == NULL)
107 continue; 118 continue;
108 /* now descend into it (NB: ACTION_RECURSE is set in flags) */ 119 /* process every file (NB: ACTION_RECURSE is set in flags) */
109 if (!recursive_action(nextFile, flags, fileAction, dirAction, userData, depth+1)) 120 if (!recursive_action(nextFile, flags, fileAction, dirAction,
121 userData, depth + 1))
110 status = FALSE; 122 status = FALSE;
111 free(nextFile); 123 free(nextFile);
112 } 124 }
@@ -117,9 +129,7 @@ int recursive_action(const char *fileName,
117 goto done_nak_warn; 129 goto done_nak_warn;
118 } 130 }
119 131
120 if (!status) 132 return status;
121 return FALSE;
122 return TRUE;
123 133
124 done_nak_warn: 134 done_nak_warn:
125 bb_simple_perror_msg(fileName); 135 bb_simple_perror_msg(fileName);