[PATCH 02/14] xfsprogs: refactor fsrall_cleanup in xfs_fsr
Eric Sandeen
sandeen at redhat.com
Tue Apr 8 18:24:52 CDT 2014
fsrall_cleanup leaked an fd in the non-timeout
case - but the logic was weird and tortured, refactor
it to make more sense and fix the fd leak as well.
Signed-off-by: Eric Sandeen <sandeen at redhat.com>
---
fsr/xfs_fsr.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 6b5d260..3818f02 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -647,14 +647,19 @@ fsrall_cleanup(int timeout)
int ret;
char buf[SMBUFSZ];
- /* record where we left off */
unlink(leftofffile);
- fd = open(leftofffile, O_WRONLY|O_CREAT|O_EXCL, 0644);
- if (fd == -1)
- fsrprintf(_("open(%s) failed: %s\n"),
- leftofffile, strerror(errno));
- else {
- if (timeout) {
+
+ if (timeout) {
+ fsrprintf(_("%s startpass %d, endpass %d, time %d seconds\n"),
+ progname, startpass, fs->npass,
+ time(0) - endtime + howlong);
+
+ /* record where we left off */
+ fd = open(leftofffile, O_WRONLY|O_CREAT|O_EXCL, 0644);
+ if (fd == -1) {
+ fsrprintf(_("open(%s) failed: %s\n"),
+ leftofffile, strerror(errno));
+ } else {
ret = sprintf(buf, "%s %d %llu\n", fs->dev,
fs->npass, (unsigned long long)leftoffino);
if (write(fd, buf, ret) < strlen(buf))
@@ -663,11 +668,6 @@ fsrall_cleanup(int timeout)
close(fd);
}
}
-
- if (timeout)
- fsrprintf(_("%s startpass %d, endpass %d, time %d seconds\n"),
- progname, startpass, fs->npass,
- time(0) - endtime + howlong);
}
/*
--
1.7.1
More information about the xfs
mailing list