summaryrefslogtreecommitdiffstats
path: root/src/xfs.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2016-01-23 09:36:09 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2016-01-23 09:36:09 +0100
commiteb48734418f0ece6b1034e6f4514ef444632e891 (patch)
treee77310162da71bd585e01135b8854bde26d490fa /src/xfs.c
parent8cd58b321c68b84f1a08a49a4d30cd980ff35ab3 (diff)
Support XFS5
Diffstat (limited to 'src/xfs.c')
-rw-r--r--src/xfs.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/src/xfs.c b/src/xfs.c
index a5c2e87..07db3f9 100644
--- a/src/xfs.c
+++ b/src/xfs.c
@@ -38,8 +38,8 @@
#include "log.h"
#include "guid_cpy.h"
-static int set_xfs_info(const struct xfs_sb *sb, partition_t *partition);
-static int test_xfs(const disk_t *disk_car, const struct xfs_sb *sb, partition_t *partition, const int verbose);
+static void set_xfs_info(const struct xfs_sb *sb, partition_t *partition);
+static int test_xfs(const disk_t *disk_car, const struct xfs_sb *sb, const partition_t *partition, const int verbose);
int check_xfs(disk_t *disk_car,partition_t *partition,const int verbose)
{
@@ -59,7 +59,7 @@ int check_xfs(disk_t *disk_car,partition_t *partition,const int verbose)
return 0;
}
-static int test_xfs(const disk_t *disk_car, const struct xfs_sb *sb, partition_t *partition, const int verbose)
+static int test_xfs(const disk_t *disk_car, const struct xfs_sb *sb, const partition_t *partition, const int verbose)
{
if(sb->sb_magicnum!=be32(XFS_SB_MAGIC) ||
(uint16_t)be16(sb->sb_sectsize) != (1U << sb->sb_sectlog) ||
@@ -69,20 +69,13 @@ static int test_xfs(const disk_t *disk_car, const struct xfs_sb *sb, partition_t
switch(be16(sb->sb_versionnum) & XFS_SB_VERSION_NUMBITS)
{
case XFS_SB_VERSION_1:
- partition->upart_type = UP_XFS;
- break;
case XFS_SB_VERSION_2:
- partition->upart_type = UP_XFS2;
- break;
case XFS_SB_VERSION_3:
- partition->upart_type = UP_XFS3;
- break;
case XFS_SB_VERSION_4:
- partition->upart_type = UP_XFS4;
+ case XFS_SB_VERSION_5:
break;
default:
- log_error("Unknown XFS version %x\n",be16(sb->sb_versionnum)& XFS_SB_VERSION_NUMBITS);
- partition->upart_type = UP_XFS4;
+ log_error("Unknown XFS version 0x%x\n",be16(sb->sb_versionnum)& XFS_SB_VERSION_NUMBITS);
break;
}
if(verbose>0)
@@ -102,43 +95,52 @@ int recover_xfs(disk_t *disk_car, const struct xfs_sb *sb,partition_t *partition
dump_log(sb,DEFAULT_SECTOR_SIZE);
}
}
-
+ set_xfs_info(sb, partition);
partition->part_size = (uint64_t)be64(sb->sb_dblocks) * be32(sb->sb_blocksize);
partition->part_type_i386=P_LINUX;
partition->part_type_mac=PMAC_LINUX;
partition->part_type_sun=PSUN_LINUX;
partition->part_type_gpt=GPT_ENT_TYPE_LINUX_DATA;
- set_xfs_info(sb, partition);
guid_cpy(&partition->part_uuid, (const efi_guid_t *)&sb->sb_uuid);
return 0;
}
-static int set_xfs_info(const struct xfs_sb *sb, partition_t *partition)
+static void set_xfs_info(const struct xfs_sb *sb, partition_t *partition)
{
partition->blocksize=be32(sb->sb_blocksize);
partition->fsname[0]='\0';
partition->info[0]='\0';
- switch(partition->upart_type)
+ switch(be16(sb->sb_versionnum) & XFS_SB_VERSION_NUMBITS)
{
- case UP_XFS:
+ case XFS_SB_VERSION_1:
+ partition->upart_type = UP_XFS;
+ snprintf(partition->info, sizeof(partition->info),
+ "XFS <=6.1, blocksize=%u", partition->blocksize);
+ break;
+ case XFS_SB_VERSION_2:
+ partition->upart_type = UP_XFS2;
snprintf(partition->info, sizeof(partition->info),
- "XFS <=6.1 blocksize=%u", partition->blocksize);
+ "XFS 6.2 - attributes, blocksize=%u", partition->blocksize);
break;
- case UP_XFS2:
+ case XFS_SB_VERSION_3:
+ partition->upart_type = UP_XFS3;
snprintf(partition->info, sizeof(partition->info),
- "XFS 6.2 - attributes blocksize=%u", partition->blocksize);
+ "XFS 6.2 - new inode version, blocksize=%u", partition->blocksize);
break;
- case UP_XFS3:
+ case XFS_SB_VERSION_4:
+ partition->upart_type = UP_XFS4;
snprintf(partition->info, sizeof(partition->info),
- "XFS 6.2 - new inode version blocksize=%u", partition->blocksize);
+ "XFS 6.2+ - bitmap version, blocksize=%u", partition->blocksize);
break;
- case UP_XFS4:
+ case XFS_SB_VERSION_5:
+ partition->upart_type = UP_XFS5;
snprintf(partition->info, sizeof(partition->info),
- "XFS 6.2+ - bitmap version blocksize=%u", partition->blocksize);
+ "XFS CRC enabled, blocksize=%u", partition->blocksize);
break;
default:
- return 1;
+ snprintf(partition->info, sizeof(partition->info),
+ "XFS unknown version %u\n", be16(sb->sb_versionnum)& XFS_SB_VERSION_NUMBITS);
+ break;
}
set_part_name(partition,sb->sb_fname,12);
- return 0;
}