]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit - libxfs/init.c
libxfs: sanitize agcount on load
authorEric Sandeen <sandeen@sandeen.net>
Thu, 26 Jan 2017 02:02:43 +0000 (20:02 -0600)
committerEric Sandeen <sandeen@redhat.com>
Thu, 26 Jan 2017 02:02:43 +0000 (20:02 -0600)
commita547152d47909aba27336a1d1d42fccf96262476
tree67d55f16e8bb459e548dfe764eb9168062d17f0a
parent6954769314101dec2ae06efe8b41e8d433dec3fe
libxfs: sanitize agcount on load

Before we get into libxfs_initialize_perag and try to blindly
allocate a perag struct for every (possibly corrupted number of)
AGs, see if we can read the last one.  If not, assume it's corrupt,
and load only the first AG.

Do this only for an arbitrarily high-ish agcount, so that normal-ish
geometry on a possibly truncated file or device will still do
its best to make all readable AGs available.

Set xfs_db's exitcode to 1 if this happens.

Also teach metadump to detect this and exit appropriately if
truncated, as it resets exitcode to 0 for its own purposes internally.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/init.c
db/metadump.c
libxfs/init.c