If we do something crazy like:
# xfs_metadump /root/anaconda.cfg outfile
xfs_metadump will pass "-F" to xfs_db to carry on even in the face
of bad superblock magic. [1] Depending on what we gave as an input
file, we may very well fail quite badly:
> xfs_metadump: /root/anaconda.cfg is not a valid XFS filesystem (unexpected SB magic number 0x230a2320)
> Floating point exception
I don't think it's possible to harden every path through libxfs for
non-xfs filesystems as input. (Even if it's possible, I don't think it's
worth the effort).
So I propose making the "-F" optional; by default, xfs_metadump will
say no, this has bad magic, I'm stopping. If the admin really wants to
try to proceed, suggest that they can use "-F" and they can keep all the
broken pieces.
[1] behavior added in
7f98455 xfs_db: exit on invalid magic number
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
if (sbp->sb_magicnum != XFS_SB_MAGIC) {
fprintf(stderr, _("%s: %s is not a valid XFS filesystem (unexpected SB magic number 0x%08x)\n"),
progname, fsdevice, sbp->sb_magicnum);
- if (!force)
+ if (!force) {
+ fprintf(stderr, _("Use -F to force a read attempt.\n"));
exit(EXIT_FAILURE);
+ }
}
mp = libxfs_mount(&xmount, sbp, x.ddev, x.logdev, x.rtdev,
OPTS=" "
DBOPTS=" "
-USAGE="Usage: xfs_metadump [-efogwV] [-m max_extents] [-l logdev] source target"
+USAGE="Usage: xfs_metadump [-efFogwV] [-m max_extents] [-l logdev] source target"
while getopts "efgl:m:owV" c
do
w) OPTS=$OPTS"-w ";;
f) DBOPTS=$DBOPTS" -f";;
l) DBOPTS=$DBOPTS" -l "$OPTARG" ";;
+ F) DBOPTS=$DBOPTS" -F";;
V) xfs_db -p xfs_metadump -V
status=$?
exit $status
set -- extra $@
shift $OPTIND
case $# in
- 2) xfs_db$DBOPTS -F -i -p xfs_metadump -c "metadump$OPTS $2" $1
+ 2) xfs_db$DBOPTS -i -p xfs_metadump -c "metadump$OPTS $2" $1
status=$?
;;
*) echo $USAGE 1>&2
.SH SYNOPSIS
.B xfs_metadump
[
-.B \-efgow
+.B \-efFgow
] [
.B \-m
.I max_extents
been made into an ordinary file with
.BR xfs_copy (8).
.TP
+.B \-F
+Specifies that we want to continue even if the superblock magic is not correct.
+If the source is truly not an XFS filesystem, the resulting image will be useless,
+and xfs_metadump may crash.
+.TP
.B \-g
Shows dump progress. This is sent to stdout if the
.I target