[minicoredumper] [PATCH 08/14] minicoredumper: Log errors for copy_link() and copy_file()

Mateusz Moscicki m.moscicki2 at partner.samsung.com
Tue May 21 14:52:44 CEST 2019


Change-Id: Id7eedf29e02911e3caf3e6a265149a44ea283219
---
 src/minicoredumper/corestripper.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/minicoredumper/corestripper.c b/src/minicoredumper/corestripper.c
index 27fe8c0..74141ce 100644
--- a/src/minicoredumper/corestripper.c
+++ b/src/minicoredumper/corestripper.c
@@ -336,8 +336,10 @@ static int copy_file(const char *dest, const char *src)
 	int i;
 
 	f_src = fopen(src, "r");
-	if (!f_src)
+	if (!f_src) {
+		info("Failed to open a file %s for reading: %m", src);
 		return -1;
+	}
 
 	if (fstat(fileno(f_src), &sb) != 0) {
 		fclose(f_src);
@@ -353,6 +355,7 @@ static int copy_file(const char *dest, const char *src)
 	f_dest = fopen(dest, "w");
 	if (!f_dest) {
 		fclose(f_src);
+		info("Failed to open a file %s for writing: %m", dest);
 		return -1;
 	}
 
@@ -2821,8 +2824,10 @@ static int copy_link(const char *dest, const char *src)
 	char *linkname;
 	int ret;
 
-	if (lstat(src, &sb) != 0)
+	if (lstat(src, &sb) != 0) {
+		info("Failed to lstat() for %s: %m", src);
 		return -1;
+	}
 
 	/* stat/lstat is screwy for /proc/.../cwd, so
 	 * fallback to stat if lstat provides no size */
@@ -2843,6 +2848,7 @@ static int copy_link(const char *dest, const char *src)
 	if (ret < 2) {
 		/* empty link? */
 		free(linkname);
+		info("Failed to readlink() for %s: %m", src);
 		return -1;
 	}
 	/* truncate when too long */
-- 
2.7.4




More information about the minicoredumper mailing list