diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2018-12-17 13:46:01 +0100 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2019-03-01 16:38:16 +0100 |
commit | 86b76c6d43a3ea87c00235f2961d71002d4c4792 (patch) | |
tree | d3bd847e213ea1beb01fb3d56269bff8c880eafd | |
parent | 8687e9c639621e1de65297cb7d56335b2add7701 (diff) | |
download | genimage-86b76c6d43a3ea87c00235f2961d71002d4c4792.tar.gz genimage-86b76c6d43a3ea87c00235f2961d71002d4c4792.tar.xz |
genimage: only delete regular files and symlinks
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r-- | genimage.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -20,6 +20,7 @@ #include <string.h> #include <errno.h> #include <libgen.h> +#include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <dirent.h> @@ -231,7 +232,11 @@ static int image_generate(struct image *image) } if (ret) { - systemp(image, "rm -f \"%s\"", imageoutfile(image)); + struct stat s; + if (lstat(imageoutfile(image), &s) != 0 || + ((s.st_mode & S_IFMT) == S_IFREG) || + ((s.st_mode & S_IFMT) == S_IFLNK)) + systemp(image, "rm -f \"%s\"", imageoutfile(image)); return ret; } |