From: Eric Sandeen <sandeen@sandeen.net>
To: Eric Sandeen <sandeen@redhat.com>, xfs-oss <xfs@oss.sgi.com>
Subject: [PATCH 3/3] xfs_fsr: test for more potential failures in packfile()
Date: Fri, 06 Jun 2014 16:06:47 -0500 [thread overview]
Message-ID: <53922D67.2060906@sandeen.net> (raw)
In-Reply-To: <53922B49.1050005@redhat.com>
Test for lseek, ftruncate, and fsync failures in packfile()
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 8b191e6..48629fd 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -1325,7 +1325,11 @@ packfile(char *fname, char *tname, int fd,
fsrprintf(_("could not trunc tmp %s\n"),
tname);
}
- lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR);
+ if (lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR) < 0) {
+ fsrprintf(_("could not lseek in tmpfile: %s : %s\n"),
+ tname, strerror(errno));
+ goto out;
+ }
continue;
} else if (outmap[extent].bmv_length == 0) {
/* to catch holes at the beginning of the file */
@@ -1341,7 +1345,11 @@ packfile(char *fname, char *tname, int fd,
" %s\n"), tname);
goto out;
}
- lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR);
+ if (lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR) < 0) {
+ fsrprintf(_("could not lseek in tmpfile: %s : %s\n"),
+ tname, strerror(errno));
+ goto out;
+ }
}
} /* end of space allocation loop */
@@ -1365,8 +1373,16 @@ packfile(char *fname, char *tname, int fd,
for (extent = 0; extent < nextents; extent++) {
pos = outmap[extent].bmv_offset;
if (outmap[extent].bmv_block == -1) {
- lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR);
- lseek64(fd, outmap[extent].bmv_length, SEEK_CUR);
+ if (lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR) < 0) {
+ fsrprintf(_("could not lseek in tmpfile: %s : %s\n"),
+ tname, strerror(errno));
+ goto out;
+ }
+ if (lseek64(fd, outmap[extent].bmv_length, SEEK_CUR) < 0) {
+ fsrprintf(_("could not lseek in file: %s : %s\n"),
+ fname, strerror(errno));
+ goto out;
+ }
continue;
} else if (outmap[extent].bmv_length == 0) {
/* to catch holes at the beginning of the file */
@@ -1442,8 +1458,16 @@ packfile(char *fname, char *tname, int fd,
}
}
}
- ftruncate64(tfd, statp->bs_size);
- fsync(tfd);
+ if (ftruncate64(tfd, statp->bs_size) < 0) {
+ fsrprintf(_("could not truncate tmpfile: %s : %s\n"),
+ fname, strerror(errno));
+ goto out;
+ }
+ if (fsync(tfd) < 0) {
+ fsrprintf(_("could not fsync tmpfile: %s : %s\n"),
+ fname, strerror(errno));
+ goto out;
+ }
sx.sx_stat = *statp; /* struct copy */
sx.sx_version = XFS_SX_VERSION;
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-06-06 21:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-06 20:57 [PATCH 0/3] xfs_fsr robustification Eric Sandeen
2014-06-06 21:03 ` [PATCH 1/3] xfs_fsr: ensure the line we read from leftofffile is null terminated Eric Sandeen
2014-06-09 13:02 ` Brian Foster
2014-06-09 14:01 ` Eric Sandeen
2014-06-09 14:29 ` Mark Tinguely
2014-06-06 21:04 ` [PATCH 2/3] xfs_fsr: create a cleanup/return target in packfile() Eric Sandeen
2014-06-09 13:02 ` Brian Foster
2014-06-06 21:06 ` Eric Sandeen [this message]
2014-06-09 13:02 ` [PATCH 3/3] xfs_fsr: test for more potential failures " Brian Foster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53922D67.2060906@sandeen.net \
--to=sandeen@sandeen.net \
--cc=sandeen@redhat.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox