commit: 5539ab9cf34f303b7e11c5989d8cde8f1ed57043
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 20 19:58:18 2018 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Dec 20 19:58:18 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5539ab9c
rm_rf_at: ensure return code makes sense
Don't blindly ignore errors, just run statements that should succeed and
register success.
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
libq/xmkdir.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libq/xmkdir.c b/libq/xmkdir.c
index aa93905..bc89fe0 100644
--- a/libq/xmkdir.c
+++ b/libq/xmkdir.c
@@ -49,6 +49,7 @@ rm_rf_at(int dfd, const char *path)
int subdfd;
DIR *dir;
struct dirent *de;
+ int ret = 0;
/* Cannot use O_PATH as we want to use fdopendir() */
subdfd = openat(dfd, path, O_RDONLY|O_CLOEXEC|O_NOFOLLOW);
@@ -73,17 +74,16 @@ rm_rf_at(int dfd, const char *path)
!(st.st_mode & S_IFDIR))
errp("could not unlink %s", de->d_name);
}
- rm_rf_at(subdfd, de->d_name);
- unlinkat(subdfd, de->d_name, AT_REMOVEDIR);
+ ret |= rm_rf_at(subdfd, de->d_name);
}
}
- unlinkat(dfd, path, AT_REMOVEDIR);
+ ret |= unlinkat(dfd, path, AT_REMOVEDIR);
/* this also does close(subdfd); */
closedir(dir);
- return 0;
+ return ret;
}
static int