summaryrefslogtreecommitdiffstats
path: root/toolbox/rm.c
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2013-11-22 11:28:10 -0800
committerConley Owens <cco3@android.com>2013-11-22 13:44:43 -0800
commit66ed50af6870210ce013a5588a688434a5d48ee9 (patch)
treea879f3ea31083496d0efe491bc187b6e0ebada39 /toolbox/rm.c
parentdd2ac3de625e6c0328a0f70530d8ade0d2151bfc (diff)
parent536dea9d61a032e64bbe584a97463c6638ead009 (diff)
downloadsystem_core-66ed50af6870210ce013a5588a688434a5d48ee9.zip
system_core-66ed50af6870210ce013a5588a688434a5d48ee9.tar.gz
system_core-66ed50af6870210ce013a5588a688434a5d48ee9.tar.bz2
Merge commit '536dea9d61a032e64bbe584a97463c6638ead009' into HEAD
Change-Id: I5c469a4b738629d99d721cad7ded02d6c35f56d5
Diffstat (limited to 'toolbox/rm.c')
-rw-r--r--toolbox/rm.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/toolbox/rm.c b/toolbox/rm.c
index 3a24bec..957b586 100644
--- a/toolbox/rm.c
+++ b/toolbox/rm.c
@@ -45,8 +45,10 @@ static int unlink_recursive(const char* name, int flags)
continue;
sprintf(dn, "%s/%s", name, de->d_name);
if (unlink_recursive(dn, flags) < 0) {
- fail = 1;
- break;
+ if (!(flags & OPT_FORCE)) {
+ fail = 1;
+ break;
+ }
}
errno = 0;
}
@@ -71,6 +73,7 @@ int rm_main(int argc, char *argv[])
int ret;
int i, c;
int flags = 0;
+ int something_failed = 0;
if (argc < 2)
return usage();
@@ -103,17 +106,21 @@ int rm_main(int argc, char *argv[])
ret = unlink_recursive(argv[i], flags);
} else {
ret = unlink(argv[i]);
- if (errno == ENOENT && (flags & OPT_FORCE)) {
- return 0;
+ if (ret < 0 && errno == ENOENT && (flags & OPT_FORCE)) {
+ continue;
}
}
if (ret < 0) {
fprintf(stderr, "rm failed for %s, %s\n", argv[i], strerror(errno));
- return -1;
+ if (!(flags & OPT_FORCE)) {
+ return -1;
+ } else {
+ something_failed = 1;
+ }
}
}
- return 0;
+ return something_failed;
}