summaryrefslogtreecommitdiffstats
path: root/Dump.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-25 06:14:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-25 06:14:19 +0000
commit50f2ad8e92ef06e4dee6d7070049a96231d3a8ee (patch)
treeb7cda9c5caad5948899bf7d6551262d9d7d86d09 /Dump.c
parentAdding upstream version 4.3+20240412. (diff)
downloadmdadm-50f2ad8e92ef06e4dee6d7070049a96231d3a8ee.tar.xz
mdadm-50f2ad8e92ef06e4dee6d7070049a96231d3a8ee.zip
Adding upstream version 4.3+20240723.upstream/4.3+20240723
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'Dump.c')
-rw-r--r--Dump.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Dump.c b/Dump.c
index 736bcb6..81b9494 100644
--- a/Dump.c
+++ b/Dump.c
@@ -37,6 +37,7 @@ int Dump_metadata(char *dev, char *dir, struct context *c,
unsigned long long size;
DIR *dirp;
struct dirent *de;
+ int ret = 0;
if (stat(dir, &stb) != 0 ||
(S_IFMT & stb.st_mode) != S_IFDIR) {
@@ -112,9 +113,15 @@ int Dump_metadata(char *dev, char *dir, struct context *c,
}
if (c->verbose >= 0)
printf("%s saved as %s.\n", dev, fname);
- fstat(fd, &dstb);
- close(fd);
+
close(fl);
+ ret = fstat(fd, &dstb);
+ close(fd);
+ if (ret) {
+ unlink(fname);
+ free(fname);
+ return 1;
+ }
if ((dstb.st_mode & S_IFMT) != S_IFBLK) {
/* Not a block device, so cannot create links */
free(fname);