diff options
Diffstat (limited to 'fs/zfs')
-rw-r--r-- | fs/zfs/zfs.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/fs/zfs/zfs.c b/fs/zfs/zfs.c index bfc11fa6676..113b428a938 100644 --- a/fs/zfs/zfs.c +++ b/fs/zfs/zfs.c @@ -17,6 +17,7 @@ #include <linux/time.h> #include <linux/ctype.h> #include <asm/byteorder.h> +#include <u-boot/zlib.h> #include "zfs_common.h" #include "div64.h" @@ -183,7 +184,8 @@ static int zlib_decompress(void *s, void *d, uint32_t slen, uint32_t dlen) { - if (zlib_decompress(s, d, slen, dlen) < 0) + uLongf z_dest_len = dlen; + if (uncompress(d, &z_dest_len, s, slen) != Z_OK) return ZFS_ERR_BAD_FS; return ZFS_ERR_NONE; } @@ -334,6 +336,12 @@ vdev_uberblock_compare(uberblock_t *ub1, uberblock_t *ub2) return 0; } +static inline int +is_supported_spa_version(uint64_t version) { + return version == FEATURES_SUPPORTED_SPA_VERSION || + (version > 0 && version <= SPA_VERSION); +} + /* * Three pieces of information are needed to verify an uberblock: the magic * number, the version number, and the checksum. @@ -355,14 +363,12 @@ uberblock_verify(uberblock_t *uber, int offset, struct zfs_data *data) return ZFS_ERR_BAD_FS; } - if (zfs_to_cpu64(uber->ub_magic, LITTLE_ENDIAN) == UBERBLOCK_MAGIC - && zfs_to_cpu64(uber->ub_version, LITTLE_ENDIAN) > 0 - && zfs_to_cpu64(uber->ub_version, LITTLE_ENDIAN) <= SPA_VERSION) + if (zfs_to_cpu64(uber->ub_magic, LITTLE_ENDIAN) == UBERBLOCK_MAGIC && + is_supported_spa_version(zfs_to_cpu64(uber->ub_version, LITTLE_ENDIAN))) endian = LITTLE_ENDIAN; - if (zfs_to_cpu64(uber->ub_magic, BIG_ENDIAN) == UBERBLOCK_MAGIC - && zfs_to_cpu64(uber->ub_version, BIG_ENDIAN) > 0 - && zfs_to_cpu64(uber->ub_version, BIG_ENDIAN) <= SPA_VERSION) + if (zfs_to_cpu64(uber->ub_magic, BIG_ENDIAN) == UBERBLOCK_MAGIC && + is_supported_spa_version(zfs_to_cpu64(uber->ub_version, BIG_ENDIAN))) endian = BIG_ENDIAN; if (endian == UNKNOWN_ENDIAN) { @@ -1788,7 +1794,7 @@ check_pool_label(struct zfs_data *data) return ZFS_ERR_BAD_FS; } - if (version > SPA_VERSION) { + if (!is_supported_spa_version(version)) { free(nvlist); printf("SPA version too new %llu > %llu\n", (unsigned long long) version, |