@@ -640,6 +640,7 @@ libxfs_mount(
xfs_buf_t *bp;
xfs_sb_t *sbp;
int error;
+ int readflags = 0;
libxfs_buftarg_init(mp, dev, logdev, rtdev);
@@ -716,9 +717,13 @@ libxfs_mount(
if (dev == 0) /* maxtrres, we have no device so leave now */
return mp;
+ /* device size checks must pass unless we're a debugger. */
+ if (!(flags & LIBXFS_MOUNT_DEBUGGER))
+ readflags |= LIBXFS_READBUF_FAIL_EXIT;
+
bp = libxfs_readbuf(mp->m_dev,
d - XFS_FSS_TO_BB(mp, 1), XFS_FSS_TO_BB(mp, 1),
- !(flags & LIBXFS_MOUNT_DEBUGGER), NULL);
+ readflags, NULL);
if (!bp) {
fprintf(stderr, _("%s: data size check failed\n"), progname);
if (!(flags & LIBXFS_MOUNT_DEBUGGER))
@@ -733,7 +738,7 @@ libxfs_mount(
(!(bp = libxfs_readbuf(mp->m_logdev_targp,
d - XFS_FSB_TO_BB(mp, 1),
XFS_FSB_TO_BB(mp, 1),
- !(flags & LIBXFS_MOUNT_DEBUGGER), NULL))) ) {
+ readflags, NULL))) ) {
fprintf(stderr, _("%s: log size checks failed\n"),
progname);
if (!(flags & LIBXFS_MOUNT_DEBUGGER))
@@ -760,7 +765,7 @@ libxfs_mount(
if (sbp->sb_agcount > 1000000) {
bp = libxfs_readbuf(mp->m_dev,
XFS_AG_DADDR(mp, sbp->sb_agcount - 1, 0), 1,
- !(flags & LIBXFS_MOUNT_DEBUGGER), NULL);
+ readflags, NULL);
if (bp->b_error) {
fprintf(stderr, _("%s: read of AG %u failed\n"),
progname, sbp->sb_agcount);
@@ -124,6 +124,9 @@ extern struct cache_operations libxfs_bcache_operations;
#define LIBXFS_GETBUF_TRYLOCK (1 << 0)
+/* Exit on buffer read error */
+#define LIBXFS_READBUF_FAIL_EXIT (1 << 0)
+
#ifdef XFS_BUF_TRACING
#define libxfs_readbuf(dev, daddr, len, flags, ops) \
@@ -911,13 +911,13 @@ __read_buf(int fd, void *buf, int len, off64_t offset, int flags)
int error = errno;
fprintf(stderr, _("%s: read failed: %s\n"),
progname, strerror(error));
- if (flags & LIBXFS_EXIT_ON_FAILURE)
+ if (flags & LIBXFS_READBUF_FAIL_EXIT)
exit(1);
return -error;
} else if (sts != len) {
fprintf(stderr, _("%s: error - read only %d of %d bytes\n"),
progname, sts, len);
- if (flags & LIBXFS_EXIT_ON_FAILURE)
+ if (flags & LIBXFS_READBUF_FAIL_EXIT)
exit(1);
return -EIO;
}
@@ -3577,7 +3577,7 @@ rewrite_secondary_superblocks(
XFS_AGB_TO_DADDR(mp, mp->m_sb.sb_agcount - 1,
XFS_SB_DADDR),
XFS_FSS_TO_BB(mp, 1),
- LIBXFS_EXIT_ON_FAILURE, &xfs_sb_buf_ops);
+ LIBXFS_READBUF_FAIL_EXIT, &xfs_sb_buf_ops);
XFS_BUF_TO_SBP(buf)->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
@@ -3589,7 +3589,7 @@ rewrite_secondary_superblocks(
XFS_AGB_TO_DADDR(mp, (mp->m_sb.sb_agcount - 1) / 2,
XFS_SB_DADDR),
XFS_FSS_TO_BB(mp, 1),
- LIBXFS_EXIT_ON_FAILURE, &xfs_sb_buf_ops);
+ LIBXFS_READBUF_FAIL_EXIT, &xfs_sb_buf_ops);
XFS_BUF_TO_SBP(buf)->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
}