summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2011-03-05 18:40:22 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2011-03-05 18:40:22 +0100
commitf2c0943a5a5d2de868a6cfefa8b2c7386b8c5393 (patch)
tree067af5958b2777c67cc7811390d04f0cdc2e0675
parent237b0d53ac0d638ccbd8671293b6695436bad32c (diff)
TestDisk: recover btrfs, a GPL-licensed copy-on-write file system for Linux.
-rw-r--r--configure.ac2
-rw-r--r--src/Makefile.am4
-rw-r--r--src/analyse.c21
-rw-r--r--src/analyse.h1
-rw-r--r--src/btrfs.c124
-rw-r--r--src/btrfs.h146
-rw-r--r--src/common.h48
-rw-r--r--src/partgpt.c56
-rw-r--r--src/parti386.c46
-rw-r--r--src/partmac.c27
-rw-r--r--src/partnone.c5
-rw-r--r--src/partsun.c39
12 files changed, 402 insertions, 117 deletions
diff --git a/configure.ac b/configure.ac
index 6c63c60..44cad85 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
AC_PREREQ(2.59)
AC_INIT([testdisk],[6.12-WIP],[grenier@cgsecurity.org])
sinclude(acx_pthread.m4)
-TESTDISKDATE="October 2010"
+TESTDISKDATE="March 2011"
AC_SUBST(TESTDISKDATE)
AC_DEFINE_UNQUOTED([TESTDISKDATE],"$TESTDISKDATE",[Date of release])
AC_CONFIG_AUX_DIR(config)
diff --git a/src/Makefile.am b/src/Makefile.am
index 38da0f5..d72e4de 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,8 +16,8 @@ EXTRA_PROGRAMS = photorecf
base_C = autoset.c common.c crc.c ewf.c fnctdsk.c hdaccess.c hdcache.c hdwin32.c hidden.c hpa_dco.c intrf.c iso.c log.c log_part.c misc.c msdos.c parti386.c partgpt.c parthumax.c partmac.c partsun.c partnone.c partxbox.c io_redir.c ntfs_io.c ntfs_utl.c partauto.c sudo.c unicode.c win32.c
base_H = alignio.h autoset.h common.h crc.h ewf.h fnctdsk.h hdaccess.h hdwin32.h hidden.h guid_cmp.h guid_cpy.h hdcache.h hpa_dco.h intrf.h iso.h iso9660.h lang.h log.h log_part.h misc.h types.h io_redir.h msdos.h ntfs_utl.h parti386.h partgpt.h parthumax.h partmac.h partsun.h partxbox.h partauto.h sudo.h unicode.h win32.h
-fs_C = analyse.c bfs.c bsd.c cramfs.c exfat.c fat.c fatx.c ext2.c jfs.c hfs.c hfsp.c hpfs.c luks.c lvm.c md.c netware.c ntfs.c rfs.c savehdr.c sun.c swap.c sysv.c ufs.c xfs.c zfs.c
-fs_H = analyse.h bfs.h bsd.h cramfs.h exfat.h fat.h fatx.h ext2.h jfs_superblock.h jfs.h hfs.h hfsp.h hpfs.h luks.h lvm.h md.h netware.h ntfs.h rfs.h savehdr.h sun.h swap.h sysv.h ufs.h xfs.h zfs.h
+fs_C = analyse.c bfs.c bsd.c btrfs.c cramfs.c exfat.c fat.c fatx.c ext2.c jfs.c hfs.c hfsp.c hpfs.c luks.c lvm.c md.c netware.c ntfs.c rfs.c savehdr.c sun.c swap.c sysv.c ufs.c xfs.c zfs.c
+fs_H = analyse.h bfs.h bsd.h btrfs.h cramfs.h exfat.h fat.h fatx.h ext2.h jfs_superblock.h jfs.h hfs.h hfsp.h hpfs.h luks.h lvm.h md.h netware.h ntfs.h rfs.h savehdr.h sun.h swap.h sysv.h ufs.h xfs.h zfs.h
testdisk_ncurses_C = addpart.c adv.c askloc.c chgtype.c chgtypen.c dimage.c dirn.c dirpart.c diskacc.c diskcapa.c edit.c ext2_sb.c ext2_sbn.c fat1x.c fat32.c fat_adv.c fat_cluster.c fatn.c geometry.c godmode.c hiddenn.c intrface.c intrfn.c nodisk.c ntfs_adv.c ntfs_fix.c ntfs_udl.c parti386n.c partgptn.c partmacn.c partsunn.c partxboxn.c tanalyse.c tbanner.c tdelete.c tdiskop.c tdisksel.c testdisk.c texfat.c thfs.c tload.c tlog.c tmbrcode.c tntfs.c toptions.c tpartwr.c
testdisk_ncurses_H = addpart.h adv.h askloc.h chgtype.h chgtypen.h dimage.h dirn.h dirpart.h diskacc.h diskcapa.h edit.h ext2_sb.h ext2_sbn.h fat1x.h fat32.h fat_adv.h fat_cluster.h fatn.h geometry.h godmode.h hiddenn.h intrface.h intrfn.h nodisk.h ntfs_udl.h partgptn.h parti386n.h partmacn.h partsunn.h partxboxn.h tanalyse.h tdelete.h tdiskop.h tdisksel.h texfat.h thfs.h tload.h tlog.h tmbrcode.h tntfs.h toptions.h tpartwr.h
diff --git a/src/analyse.c b/src/analyse.c
index 5aeae0b..b3c967d 100644
--- a/src/analyse.c
+++ b/src/analyse.c
@@ -2,7 +2,7 @@
File: analyse.c
- Copyright (C) 1998-2007 Christophe GRENIER <grenier@cgsecurity.org>
+ Copyright (C) 1998-2011 Christophe GRENIER <grenier@cgsecurity.org>
This software is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -32,6 +32,7 @@
#include "analyse.h"
#include "bfs.h"
#include "bsd.h"
+#include "btrfs.h"
#include "cramfs.h"
#include "exfat.h"
#include "ext2.h"
@@ -359,6 +360,7 @@ int search_type_128(unsigned char *buffer, disk_t *disk, partition_t *partition,
const struct reiserfs_super_block *rfs=(const struct reiserfs_super_block *)data;
const struct reiser4_master_sb *rfs4=(const struct reiser4_master_sb *)data;
const struct ufs_super_block *ufs=(const struct ufs_super_block *)data;
+ const struct btrfs_super_block *btrfs=(const struct btrfs_super_block*)data;
/* 64k offset */
/* Test ReiserFS */
if((memcmp(rfs->s_magic,"ReIs",4) == 0 ||
@@ -370,7 +372,24 @@ int search_type_128(unsigned char *buffer, disk_t *disk, partition_t *partition,
le32(ufs->fs_magic)==UFS2_MAGIC || be32(ufs->fs_magic)==UFS2_MAGIC) &&
recover_ufs(disk, ufs, partition, verbose, dump_ind)==0)
return 1;
+ if(memcmp(&btrfs->magic, BTRFS_MAGIC, 8)==0 &&
+ recover_btrfs(disk, btrfs, partition, verbose, dump_ind)==0)
+ return 1;
// if(recover_gfs2(disk,(buffer+0x400),partition,verbose,dump_ind)==0) return 1;
}
return 0;
}
+
+int check_linux(disk_t *disk, partition_t *partition, const int verbose)
+{
+ if(check_JFS(disk, partition)==0 ||
+ check_rfs(disk, partition, verbose)==0 ||
+ check_EXT2(disk, partition, verbose)==0 ||
+ check_cramfs(disk, partition, verbose)==0 ||
+ check_xfs(disk, partition, verbose)==0 ||
+ check_LUKS(disk, partition)==0 ||
+ check_btrfs(disk, partition, verbose)==0)
+ return 0;
+ return 1;
+}
+
diff --git a/src/analyse.h b/src/analyse.h
index a1b19a3..d0a95cc 100644
--- a/src/analyse.h
+++ b/src/analyse.h
@@ -34,6 +34,7 @@ int search_EXFAT_backup(unsigned char *buffer, disk_t *disk, partition_t *partit
int search_FAT_backup(unsigned char *buffer, disk_t *disk_car,partition_t *partition, const int verbose, const int dump_ind);
int search_HFS_backup(unsigned char *buffer, disk_t *disk_car,partition_t *partition, const int verbose, const int dump_ind);
int search_NTFS_backup(unsigned char *buffer, disk_t *disk_car,partition_t *partition, const int verbose, const int dump_ind);
+int check_linux(disk_t *disk, partition_t *partition, const int verbose);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/btrfs.c b/src/btrfs.c
new file mode 100644
index 0000000..d99b8f4
--- /dev/null
+++ b/src/btrfs.c
@@ -0,0 +1,124 @@
+/*
+
+ File: btrfs.c
+
+ Copyright (C) 2011 Christophe GRENIER <grenier@cgsecurity.org>
+
+ This software is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write the Free Software Foundation, Inc., 51
+ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include "types.h"
+#include "common.h"
+#include "btrfs.h"
+#include "fnctdsk.h"
+#include "log.h"
+#include "guid_cpy.h"
+
+static int set_btrfs_info(const struct btrfs_super_block *sb, partition_t *partition, const int verbose);
+static int test_btrfs(const struct btrfs_super_block *sb, partition_t *partition);
+
+int check_btrfs(disk_t *disk_car,partition_t *partition,const int verbose)
+{
+ unsigned char *buffer=(unsigned char*)MALLOC(BTRFS_SUPER_INFO_SIZE);
+ if(disk_car->pread(disk_car, buffer, BTRFS_SUPER_INFO_SIZE, partition->part_offset + BTRFS_SUPER_INFO_OFFSET) != BTRFS_SUPER_INFO_SIZE)
+ {
+ free(buffer);
+ return 1;
+ }
+ if(test_btrfs((struct btrfs_super_block*)buffer, partition)!=0)
+ {
+ free(buffer);
+ return 1;
+ }
+ set_btrfs_info((struct btrfs_super_block*)buffer, partition, verbose);
+ free(buffer);
+ return 0;
+}
+
+static int set_btrfs_info(const struct btrfs_super_block *sb, partition_t *partition, const int verbose)
+{
+ set_part_name(partition, sb->label, sizeof(partition->partname));
+ strncpy(partition->info,"btrfs",sizeof(partition->info));
+ if(le64(sb->bytenr)!=partition->part_offset + BTRFS_SUPER_INFO_OFFSET)
+ {
+ strcat(partition->info," Backup superblock");
+ }
+ /* last mounted => date */
+ return 0;
+}
+
+/*
+Primary superblock is at 1024 (SUPERBLOCK_OFFSET)
+Group 0 begin at s_first_data_block
+*/
+int recover_btrfs(disk_t *disk, const struct btrfs_super_block *sb, partition_t *partition, const int verbose, const int dump_ind)
+{
+ if(test_btrfs(sb, partition)!=0)
+ return 1;
+ if(dump_ind!=0)
+ {
+ if(partition!=NULL && disk!=NULL)
+ log_info("\nbtrfs magic value at %u/%u/%u\n",
+ offset2cylinder(disk,partition->part_offset),
+ offset2head(disk,partition->part_offset),
+ offset2sector(disk,partition->part_offset));
+ dump_log(sb, BTRFS_SUPER_INFO_SIZE);
+ }
+ if(partition==NULL)
+ return 0;
+ set_btrfs_info(sb, partition, verbose);
+ 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;
+ partition->part_size=(uint64_t)le64(sb->dev_item.total_bytes);
+ partition->blocksize=le32(sb->dev_item.sector_size);
+ guid_cpy(&partition->part_uuid, (const efi_guid_t *)&sb->fsid);
+ if(verbose>0)
+ {
+ log_info("\n");
+ }
+ partition->sborg_offset=BTRFS_SUPER_INFO_OFFSET;
+ partition->sb_size=BTRFS_SUPER_INFO_SIZE;
+ if(verbose>0)
+ {
+ if(disk==NULL)
+ log_info("recover_btrfs: part_size %lu\n", (long unsigned)(partition->part_size / le32(sb->dev_item.sector_size)));
+ else
+ log_info("recover_btrfs: part_size %lu\n", (long unsigned)(partition->part_size / disk->sector_size));
+ }
+ return 0;
+}
+
+static int test_btrfs(const struct btrfs_super_block *sb, partition_t *partition)
+{
+ if(memcmp(&sb->magic, BTRFS_MAGIC, 8)!=0)
+ return 1;
+ if(le32(sb->dev_item.sector_size)==0)
+ return 1;
+ partition->upart_type=UP_BTRFS;
+ return 0;
+}
diff --git a/src/btrfs.h b/src/btrfs.h
new file mode 100644
index 0000000..04af24f
--- /dev/null
+++ b/src/btrfs.h
@@ -0,0 +1,146 @@
+/*
+
+ File: btrfs.h
+
+ Copyright (C) 2011 Christophe GRENIER <grenier@cgsecurity.org>
+
+ This software is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write the Free Software Foundation, Inc., 51
+ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BTRFS_SUPER_INFO_OFFSET (64 * 1024)
+#define BTRFS_SUPER_INFO_SIZE 4096
+
+#define BTRFS_SUPER_MIRROR_MAX 3
+#define BTRFS_SUPER_MIRROR_SHIFT 12
+#define BTRFS_MAGIC "_BHRfS_M"
+
+#define BTRFS_FSID_SIZE 16
+
+/* 32 bytes in various csum fields */
+#define BTRFS_CSUM_SIZE 32
+/*
+ * this is a very generous portion of the super block, giving us
+ * room to translate 14 chunks with 3 stripes each.
+ */
+#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
+#define BTRFS_LABEL_SIZE 256
+
+/*
+ * Structure of the super block
+ * Check http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git;a=blob;f=ctree.h;hb=HEAD
+ * for an up-to-date version
+ * Fields are in low endian
+ */
+
+#define BTRFS_UUID_SIZE 16
+struct btrfs_dev_item {
+ /* the internal btrfs device id */
+ uint64_t devid;
+
+ /* size of the device */
+ uint64_t total_bytes;
+
+ /* bytes used */
+ uint64_t bytes_used;
+
+ /* optimal io alignment for this device */
+ uint32_t io_align;
+
+ /* optimal io width for this device */
+ uint32_t io_width;
+
+ /* minimal io size for this device */
+ uint32_t sector_size;
+
+ /* type and info about this device */
+ uint64_t type;
+
+ /* expected generation for this device */
+ uint64_t generation;
+
+ /*
+ * starting byte of this partition on the device,
+ * to allowr for stripe alignment in the future
+ */
+ uint64_t start_offset;
+
+ /* grouping information for allocation decisions */
+ uint32_t dev_group;
+
+ /* seek speed 0-100 where 100 is fastest */
+ uint8_t seek_speed;
+
+ /* bandwidth 0-100 where 100 is fastest */
+ uint8_t bandwidth;
+
+ /* btrfs generated uuid for this device */
+ uint8_t uuid[BTRFS_UUID_SIZE];
+
+ /* uuid of FS who owns this device */
+ uint8_t fsid[BTRFS_UUID_SIZE];
+} __attribute__ ((__packed__));
+
+struct btrfs_super_block {
+ uint8_t csum[BTRFS_CSUM_SIZE];
+ /* the first 3 fields must match struct btrfs_header */
+ uint8_t fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
+ uint64_t bytenr; /* this block number */
+ uint64_t flags;
+
+ /* allowed to be different from the btrfs_header from here own down */
+ uint64_t magic;
+ uint64_t generation;
+ uint64_t root;
+ uint64_t chunk_root;
+ uint64_t log_root;
+
+ /* this will help find the new super based on the log root */
+ uint64_t log_root_transid;
+ uint64_t total_bytes;
+ uint64_t bytes_used;
+ uint64_t root_dir_objectid;
+ uint64_t num_devices;
+ uint32_t sectorsize;
+ uint32_t nodesize;
+ uint32_t leafsize;
+ uint32_t stripesize;
+ uint32_t sys_chunk_array_size;
+ uint64_t chunk_root_generation;
+ uint64_t compat_flags;
+ uint64_t compat_ro_flags;
+ uint64_t incompat_flags;
+ uint16_t csum_type;
+ uint8_t root_level;
+ uint8_t chunk_root_level;
+ uint8_t log_root_level;
+ struct btrfs_dev_item dev_item;
+
+ char label[BTRFS_LABEL_SIZE];
+
+ /* future expansion */
+ uint64_t reserved[32];
+ uint8_t sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
+} __attribute__ ((__packed__));
+
+int check_btrfs(disk_t *disk_car,partition_t *partition,const int verbose);
+int recover_btrfs(disk_t *disk_car, const struct btrfs_super_block *sb,partition_t *partition,const int verbose, const int dump_ind);
+
+#ifdef __cplusplus
+} /* closing brace for extern "C" */
+#endif
diff --git a/src/common.h b/src/common.h
index f2bcb04..9088160 100644
--- a/src/common.h
+++ b/src/common.h
@@ -222,7 +222,51 @@ struct efi_guid_s
#define TESTDISK_O_READAHEAD_32K 010
#define TESTDISK_O_ALL 020
-enum upart_type { UP_UNK, UP_BEOS, UP_CRAMFS, UP_EXT2, UP_EXT3, UP_EXT4, UP_EXTENDED, UP_EXFAT, UP_FAT12, UP_FAT16, UP_FAT32, UP_FATX, UP_FREEBSD, UP_HFS, UP_HFSP, UP_HFSX, UP_HPFS, UP_ISO, UP_JFS, UP_LINSWAP, UP_LINSWAP2, UP_LUKS, UP_LVM, UP_LVM2, UP_MD, UP_MD1, UP_NETWARE, UP_NTFS, UP_OPENBSD, UP_OS2MB, UP_RFS, UP_RFS2, UP_RFS3, UP_RFS4, UP_SUN, UP_SYSV4, UP_UFS, UP_UFS2, UP_XFS, UP_XFS2, UP_XFS3, UP_XFS4, UP_ZFS};
+enum upart_type {
+ UP_UNK=0,
+ UP_BEOS=1,
+ UP_BTRFS=2,
+ UP_CRAMFS=3,
+ UP_EXFAT=4,
+ UP_EXT2=5,
+ UP_EXT3=6,
+ UP_EXT4=7,
+ UP_EXTENDED=8,
+ UP_FAT12=9,
+ UP_FAT16=0x0a,
+ UP_FAT32=0x0b,
+ UP_FATX,
+ UP_FREEBSD,
+ UP_HFS,
+ UP_HFSP,
+ UP_HFSX,
+ UP_HPFS,
+ UP_ISO,
+ UP_JFS,
+ UP_LINSWAP,
+ UP_LINSWAP2,
+ UP_LUKS,
+ UP_LVM,
+ UP_LVM2,
+ UP_MD,
+ UP_MD1,
+ UP_NETWARE,
+ UP_NTFS,
+ UP_OPENBSD,
+ UP_OS2MB,
+ UP_RFS,
+ UP_RFS2,
+ UP_RFS3,
+ UP_RFS4,
+ UP_SUN,
+ UP_SYSV4,
+ UP_UFS,
+ UP_UFS2,
+ UP_XFS,
+ UP_XFS2,
+ UP_XFS3,
+ UP_XFS4,
+ UP_ZFS};
typedef enum upart_type upart_type_t;
enum status_type { STATUS_DELETED, STATUS_PRIM, STATUS_PRIM_BOOT, STATUS_LOG, STATUS_EXT, STATUS_EXT_IN_EXT};
typedef enum status_type status_type_t;
@@ -245,7 +289,7 @@ typedef struct
unsigned long int cylinders;
unsigned int heads_per_cylinder;
unsigned int sectors_per_head;
-// unsigned int bytes_per_sector;
+ unsigned int bytes_per_sector; /* WARN: may be uninitialized */
} CHSgeometry_t;
struct CHS_struct
diff --git a/src/partgpt.c b/src/partgpt.c
index f6987bb..6073f0c 100644
--- a/src/partgpt.c
+++ b/src/partgpt.c
@@ -46,26 +46,25 @@
#include "fnctdsk.h"
#include "lang.h"
#include "intrf.h"
+#include "analyse.h"
#include "chgtype.h"
#include "partgpt.h"
#include "savehdr.h"
-#include "cramfs.h"
#include "exfat.h"
-#include "ext2.h"
#include "fat.h"
-#include "jfs_superblock.h"
-#include "jfs.h"
+#include "hfs.h"
+#include "hfsp.h"
+#include "lvm.h"
#include "ntfs.h"
-#include "rfs.h"
-#include "xfs.h"
#include "log.h"
#include "log_part.h"
+#include "md.h"
#include "guid_cmp.h"
#include "guid_cpy.h"
#include "unicode.h"
#include "crc.h"
-static int check_part_gpt(disk_t *disk_car, const int verbose,partition_t *partition,const int saveheader);
+static int check_part_gpt(disk_t *disk, const int verbose, partition_t *partition, const int saveheader);
static list_part_t *read_part_gpt(disk_t *disk_car, const int verbose, const int saveheader);
static list_part_t *init_part_order_gpt(const disk_t *disk_car, list_part_t *list_part);
static void set_next_status_gpt(const disk_t *disk_car, partition_t *partition);
@@ -429,7 +428,7 @@ static void init_structure_gpt(const disk_t *disk_car,list_part_t *list_part, co
part_free_list_only(new_list_part);
}
-static int check_part_gpt(disk_t *disk_car,const int verbose,partition_t *partition, const int saveheader)
+static int check_part_gpt(disk_t *disk, const int verbose,partition_t *partition, const int saveheader)
{
int ret=0;
unsigned int old_levels;
@@ -437,36 +436,47 @@ static int check_part_gpt(disk_t *disk_car,const int verbose,partition_t *partit
if(guid_cmp(partition->part_type_gpt, GPT_ENT_TYPE_MS_BASIC_DATA)==0 ||
guid_cmp(partition->part_type_gpt, GPT_ENT_TYPE_MS_RESERVED)==0)
{
- ret=check_FAT(disk_car,partition,verbose);
+ ret=check_FAT(disk,partition,verbose);
if(ret!=0)
- ret=check_EXFAT(disk_car, partition);
+ ret=check_EXFAT(disk, partition);
if(ret!=0)
- ret=check_NTFS(disk_car,partition,verbose,0);
+ ret=check_NTFS(disk,partition,verbose,0);
if(ret!=0)
- ret=check_JFS(disk_car, partition);
+ ret=check_linux(disk, partition, verbose);
if(ret!=0)
- ret=check_rfs(disk_car,partition,verbose);
+ screen_buffer_add("No FAT, NTFS, ext2, JFS, Reiser, cramfs or XFS marker\n");
+ }
+ else if(guid_cmp(partition->part_type_gpt, GPT_ENT_TYPE_LINUX_RAID)==0)
+ {
+ ret=check_MD(disk, partition, verbose);
if(ret!=0)
- ret=check_EXT2(disk_car,partition,verbose);
+ screen_buffer_add("Invalid RAID superblock\n");
+ }
+ else if(guid_cmp(partition->part_type_gpt, GPT_ENT_TYPE_LINUX_LVM)==0)
+ {
+ ret=check_LVM(disk, partition, verbose);
if(ret!=0)
- ret=check_cramfs(disk_car,partition,verbose);
+ ret=check_LVM2(disk, partition, verbose);
if(ret!=0)
- ret=check_xfs(disk_car,partition,verbose);
+ screen_buffer_add("No LVM or LVM2 structure\n");
+ }
+ else if(guid_cmp(partition->part_type_gpt, GPT_ENT_TYPE_MAC_HFS)==0)
+ {
+ ret=check_HFS(disk, partition, verbose);
if(ret!=0)
- {
- screen_buffer_add("No FAT, NTFS, EXT2, JFS, Reiser, cramfs or XFS marker\n");
- }
+ ret=check_HFSP(disk, partition, verbose);
+ if(ret!=0)
+ screen_buffer_add("No HFS or HFS+ structure\n");
}
- /* TODO: complete me */
log_set_levels(old_levels);
if(ret!=0)
{
log_error("check_part_gpt failed for partition\n");
- log_partition(disk_car, partition);
- aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
+ log_partition(disk, partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk,partition);
if(saveheader>0)
{
- save_header(disk_car,partition,verbose);
+ save_header(disk, partition, verbose);
}
}
return ret;
diff --git a/src/parti386.c b/src/parti386.c
index 7f0a98c..b63ab74 100644
--- a/src/parti386.c
+++ b/src/parti386.c
@@ -40,25 +40,19 @@
#include "intrf.h"
#include "chgtype.h"
#include "savehdr.h"
+#include "analyse.h"
#include "bfs.h"
#include "bsd.h"
-#include "cramfs.h"
#include "exfat.h"
-#include "ext2.h"
#include "fat.h"
#include "hfs.h"
#include "hfsp.h"
-#include "jfs_superblock.h"
-#include "jfs.h"
-#include "luks.h"
#include "lvm.h"
#include "md.h"
#include "netware.h"
#include "ntfs.h"
-#include "rfs.h"
#include "sun.h"
#include "swap.h"
-#include "xfs.h"
#include "log.h"
#include "parti386.h"
#include "partgpt.h"
@@ -1522,36 +1516,16 @@ static int check_part_i386(disk_t *disk_car,const int verbose,partition_t *parti
{ screen_buffer_add("Invalid BSD disklabel\n"); }
break;
case P_HFS:
- ret=check_HFS(disk_car,partition,verbose);
+ ret=check_HFS(disk_car, partition, verbose);
if(ret!=0)
- {
- ret=check_HFSP(disk_car,partition,verbose);
- }
+ ret=check_HFSP(disk_car, partition, verbose);
+ if(ret!=0)
+ screen_buffer_add("No HFS or HFS+ structure\n");
break;
case P_LINUX:
- ret=check_JFS(disk_car, partition);
- if(ret!=0)
- {
- ret=check_rfs(disk_car,partition,verbose);
- }
+ ret=check_linux(disk_car, partition, verbose);
if(ret!=0)
- {
- ret=check_EXT2(disk_car,partition,verbose);
- }
- if(ret!=0)
- {
- ret=check_cramfs(disk_car,partition,verbose);
- }
- if(ret!=0)
- {
- ret=check_xfs(disk_car,partition,verbose);
- }
- if(ret!=0)
- {
- ret=check_LUKS(disk_car,partition);
- }
- if(ret!=0)
- { screen_buffer_add("No EXT2, JFS, Reiser, cramfs or XFS marker\n"); }
+ screen_buffer_add("No ext2, JFS, Reiser, cramfs or XFS marker\n");
break;
case P_LINSWAP:
ret=check_Linux_SWAP(disk_car, partition);
@@ -1559,9 +1533,9 @@ static int check_part_i386(disk_t *disk_car,const int verbose,partition_t *parti
case P_LVM:
ret=check_LVM(disk_car,partition,verbose);
if(ret!=0)
- {
ret=check_LVM2(disk_car,partition,verbose);
- }
+ if(ret!=0)
+ screen_buffer_add("No LVM or LVM2 structure\n");
break;
case P_NETBSD:
ret=check_BSD(disk_car,partition,verbose,BSD_MAXPARTITIONS);
@@ -1582,7 +1556,7 @@ static int check_part_i386(disk_t *disk_car,const int verbose,partition_t *parti
case P_RAID:
ret=check_MD(disk_car,partition,verbose);
if(ret!=0)
- { screen_buffer_add("Invalid RAID superblock\n"); }
+ screen_buffer_add("Invalid RAID superblock\n");
break;
case P_SUN:
ret=check_sun_i386(disk_car,partition,verbose);
diff --git a/src/partmac.c b/src/partmac.c
index 23db660..d43cc2d 100644
--- a/src/partmac.c
+++ b/src/partmac.c
@@ -38,18 +38,13 @@
#include "fnctdsk.h"
#include "lang.h"
#include "intrf.h"
+#include "analyse.h"
#include "chgtype.h"
#include "partmac.h"
#include "savehdr.h"
-#include "cramfs.h"
-#include "ext2.h"
#include "fat.h"
#include "hfs.h"
#include "hfsp.h"
-#include "jfs_superblock.h"
-#include "jfs.h"
-#include "rfs.h"
-#include "xfs.h"
#include "log.h"
static int check_part_mac(disk_t *disk_car, const int verbose,partition_t *partition,const int saveheader);
@@ -363,25 +358,9 @@ static int check_part_mac(disk_t *disk_car,const int verbose,partition_t *partit
case PMAC_PRODOS:
break;
case PMAC_LINUX:
- ret=check_JFS(disk_car, partition);
+ ret=check_linux(disk_car, partition, verbose);
if(ret!=0)
- {
- ret=check_rfs(disk_car,partition,verbose);
- }
- if(ret!=0)
- {
- ret=check_EXT2(disk_car,partition,verbose);
- }
- if(ret!=0)
- {
- ret=check_cramfs(disk_car,partition,verbose);
- }
- if(ret!=0)
- {
- ret=check_xfs(disk_car,partition,verbose);
- }
- if(ret!=0)
- { screen_buffer_add("No EXT2, JFS, Reiser, cramfs or XFS marker\n"); }
+ screen_buffer_add("No ext2, JFS, Reiser, cramfs or XFS marker\n");
break;
case PMAC_HFS:
ret=check_HFSP(disk_car,partition,verbose);
diff --git a/src/partnone.c b/src/partnone.c
index 03a6024..37a1c4b 100644
--- a/src/partnone.c
+++ b/src/partnone.c
@@ -41,6 +41,7 @@
#include "intrf.h"
#include "bfs.h"
#include "bsd.h"
+#include "btrfs.h"
#include "cramfs.h"
#include "exfat.h"
#include "ext2.h"
@@ -81,6 +82,7 @@ static const char *get_partition_typename_none(const partition_t *partition);
static const struct systypes none_sys_types[] = {
{UP_BEOS, "BeFS"},
+ {UP_BTRFS, "btrfs"},
{UP_CRAMFS, "CramFS"},
{UP_EXT2, "ext2"},
{UP_EXT3, "ext3"},
@@ -318,6 +320,9 @@ static int check_part_none(disk_t *disk_car,const int verbose,partition_t *parti
case UP_BEOS:
ret=check_BeFS(disk_car,partition);
break;
+ case UP_BTRFS:
+ ret=check_btrfs(disk_car, partition, verbose);
+ break;
case UP_CRAMFS:
ret=check_cramfs(disk_car,partition,verbose);
break;
diff --git a/src/partsun.c b/src/partsun.c
index b6ddce5..5ce33df 100644
--- a/src/partsun.c
+++ b/src/partsun.c
@@ -38,21 +38,13 @@
#include "fnctdsk.h"
#include "lang.h"
#include "intrf.h"
+#include "analyse.h"
#include "chgtype.h"
#include "sun.h"
#include "swap.h"
-#include "bsd.h"
-#include "fat.h"
-#include "ntfs.h"
-#include "ext2.h"
-#include "rfs.h"
#include "lvm.h"
#include "md.h"
-#include "jfs_superblock.h"
-#include "jfs.h"
#include "savehdr.h"
-#include "cramfs.h"
-#include "xfs.h"
#include "ufs.h"
#include "log.h"
#include "partsun.h"
@@ -354,30 +346,21 @@ static int check_part_sun(disk_t *disk_car,const int verbose,partition_t *partit
ret=check_ufs(disk_car,partition,verbose);
break;
case PSUN_LINUX:
- ret=check_JFS(disk_car, partition);
+ ret=check_linux(disk_car, partition, verbose);
if(ret!=0)
- {
- ret=check_rfs(disk_car,partition,verbose);
- }
- if(ret!=0)
- {
- ret=check_EXT2(disk_car,partition,verbose);
- }
- if(ret!=0)
- {
- ret=check_cramfs(disk_car,partition,verbose);
- }
- if(ret!=0)
- {
- ret=check_xfs(disk_car,partition,verbose);
- }
- if(ret!=0)
- { screen_buffer_add("No EXT2, JFS, Reiser, cramfs or XFS marker\n"); }
+ screen_buffer_add("No EXT2, JFS, Reiser, cramfs or XFS marker\n");
break;
-
case PSUN_LINSWAP:
ret=check_Linux_SWAP(disk_car, partition);
break;
+ case PSUN_LVM:
+ ret=check_LVM(disk_car,partition,verbose);
+ if(ret!=0)
+ ret=check_LVM2(disk_car,partition,verbose);
+ break;
+ case PSUN_RAID:
+ ret=check_MD(disk_car,partition,verbose);
+ break;
default:
if(verbose>0)
{