summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am4
-rw-r--r--src/analyse.c7
-rw-r--r--src/common.h1
-rw-r--r--src/partgpt.c3
-rw-r--r--src/partnone.c1
-rw-r--r--src/refs.c83
-rw-r--r--src/refs.h38
7 files changed, 134 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 0ac6731..ff00950 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,8 +17,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 list_sort.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 list.h list_sort.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 btrfs.c cramfs.c exfat.c fat.c fat_common.c fatx.c ext2.c ext2_common.c jfs.c gfs2.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 vmfs.c wbfs.c xfs.c zfs.c
-fs_H = analyse.h bfs.h bsd.h btrfs.h cramfs.h exfat.h fat.h fat_common.h fatx.h ext2.h ext2_common.h jfs_superblock.h jfs.h gfs2.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 vmfs.h wbfs.h xfs.h zfs.h
+fs_C = analyse.c bfs.c bsd.c btrfs.c cramfs.c exfat.c fat.c fat_common.c fatx.c ext2.c ext2_common.c jfs.c gfs2.c hfs.c hfsp.c hpfs.c luks.c lvm.c md.c netware.c ntfs.c refs.c rfs.c savehdr.c sun.c swap.c sysv.c ufs.c vmfs.c wbfs.c xfs.c zfs.c
+fs_H = analyse.h bfs.h bsd.h btrfs.h cramfs.h exfat.h fat.h fat_common.h fatx.h ext2.h ext2_common.h jfs_superblock.h jfs.h gfs2.h hfs.h hfsp.h hpfs.h luks.h lvm.h md.h netware.h ntfs.h refs.h rfs.h savehdr.h sun.h swap.h sysv.h ufs.h vmfs.h wbfs.h xfs.h zfs.h
testdisk_ncurses_C = addpart.c addpartn.c adv.c askloc.c chgarch.c chgarchn.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 geometryn.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 addpartn.h adv.h askloc.h chgarch.h chgarchn.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 geometryn.h godmode.h hiddenn.h intrface.h intrfn.h nodisk.h ntfs_fix.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 99d47aa..a8448d1 100644
--- a/src/analyse.c
+++ b/src/analyse.c
@@ -2,7 +2,7 @@
File: analyse.c
- Copyright (C) 1998-2011 Christophe GRENIER <grenier@cgsecurity.org>
+ Copyright (C) 1998-2015 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
@@ -49,6 +49,7 @@
#include "md.h"
#include "netware.h"
#include "ntfs.h"
+#include "refs.h"
#include "rfs.h"
#include "sun.h"
#include "swap.h"
@@ -145,6 +146,7 @@ int search_type_0(const unsigned char *buffer, disk_t *disk, partition_t *partit
const struct wbfs_head *wbfs=(const struct wbfs_head *)buffer;
const struct xfs_sb *xfs=(const struct xfs_sb *)buffer;
const union swap_header *swap_header=(const union swap_header *)buffer;
+ const struct ReFS_boot_sector *refs_header=(const struct ReFS_boot_sector *)buffer;
static const uint8_t LUKS_MAGIC[LUKS_MAGIC_L] = {'L','U','K','S', 0xba, 0xbe};
// assert(sizeof(union swap_header)<=8*DEFAULT_SECTOR_SIZE);
// assert(sizeof(pv_disk_t)<=8*DEFAULT_SECTOR_SIZE);
@@ -192,6 +194,9 @@ int search_type_0(const unsigned char *buffer, disk_t *disk, partition_t *partit
if(memcmp(luks->magic,LUKS_MAGIC,LUKS_MAGIC_L)==0 &&
recover_LUKS(disk, luks, partition, verbose, dump_ind)==0)
return 1;
+ if(refs_header->fsname==be32(0x52654653) &&
+ recover_ReFS(disk, refs_header, partition)==0)
+ return 1;
/* MD 1.1 */
if(le32(sb1->major_version)==1 &&
recover_MD(disk, (const struct mdp_superblock_s*)buffer, partition, verbose, dump_ind)==0)
diff --git a/src/common.h b/src/common.h
index 6441743..c2c684b 100644
--- a/src/common.h
+++ b/src/common.h
@@ -254,6 +254,7 @@ enum upart_type {
UP_NTFS,
UP_OPENBSD,
UP_OS2MB,
+ UP_ReFS,
UP_RFS,
UP_RFS2,
UP_RFS3,
diff --git a/src/partgpt.c b/src/partgpt.c
index 1b60c36..e21d620 100644
--- a/src/partgpt.c
+++ b/src/partgpt.c
@@ -56,6 +56,7 @@
#include "hfsp.h"
#include "lvm.h"
#include "ntfs.h"
+#include "refs.h"
#include "log.h"
#include "log_part.h"
#include "md.h"
@@ -460,6 +461,8 @@ static int check_part_gpt(disk_t *disk, const int verbose,partition_t *partition
if(ret!=0)
ret=check_NTFS(disk,partition,verbose,0);
if(ret!=0)
+ ret=check_ReFS(disk, partition);
+ if(ret!=0)
ret=check_linux(disk, partition, verbose);
if(ret!=0)
screen_buffer_add("No FAT, NTFS, ext2, JFS, Reiser, cramfs or XFS marker\n");
diff --git a/src/partnone.c b/src/partnone.c
index 2d07515..7e23f01 100644
--- a/src/partnone.c
+++ b/src/partnone.c
@@ -119,6 +119,7 @@ static const struct systypes none_sys_types[] = {
{UP_NTFS, "NTFS"},
{UP_OPENBSD, "OpenBSD"},
{UP_OS2MB, "OS2 Multiboot"},
+ {UP_ReFS, "ReFS"},
{UP_RFS, "ReiserFS 3.5"},
{UP_RFS2, "ReiserFS 3.6"},
{UP_RFS3, "ReiserFS 3.x"},
diff --git a/src/refs.c b/src/refs.c
new file mode 100644
index 0000000..58a6f7c
--- /dev/null
+++ b/src/refs.c
@@ -0,0 +1,83 @@
+/*
+
+ File: refs.c
+
+ Copyright (C) 2015 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
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include <stdio.h>
+#include "types.h"
+#include "common.h"
+#include "refs.h"
+
+static void set_ReFS_info(partition_t *partition, const struct ReFS_boot_sector *refs_header)
+{
+ partition->fsname[0]='\0';
+ partition->info[0]='\0';
+ snprintf(partition->info, sizeof(partition->info), "ReFS");
+}
+
+static int test_ReFS(const struct ReFS_boot_sector *refs_header, partition_t *partition)
+{
+ if(refs_header->fsname!=be32(0x52654653))
+ return 1;
+ if(refs_header->identifier!=be32(0x46535253))
+ return 1;
+ partition->upart_type=UP_ReFS;
+ return 0;
+}
+
+int check_ReFS(disk_t *disk, partition_t *partition)
+{
+ unsigned char *buffer=(unsigned char*)MALLOC(ReFS_BS_SIZE);
+ if(disk->pread(disk, buffer, ReFS_BS_SIZE, partition->part_offset) != ReFS_BS_SIZE)
+ {
+ free(buffer);
+ return 1;
+ }
+ if(test_ReFS((struct ReFS_boot_sector*)buffer, partition)!=0)
+ {
+ free(buffer);
+ return 1;
+ }
+ set_ReFS_info(partition, (struct ReFS_boot_sector*)buffer);
+ free(buffer);
+ return 0;
+}
+
+int recover_ReFS(const disk_t *disk, const struct ReFS_boot_sector *refs_header, partition_t *partition)
+{
+ if(test_ReFS(refs_header, partition)!=0)
+ return 1;
+ partition->sborg_offset=0;
+ partition->sb_size=0x200;
+ partition->part_type_i386=P_NTFS;
+ partition->part_type_gpt=GPT_ENT_TYPE_MS_BASIC_DATA;
+ partition->part_size=disk->sector_size;
+ set_ReFS_info(partition, refs_header);
+ return 0;
+}
diff --git a/src/refs.h b/src/refs.h
new file mode 100644
index 0000000..b7cabef
--- /dev/null
+++ b/src/refs.h
@@ -0,0 +1,38 @@
+/*
+ * File refs.h
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like. Any license provided herein, whether implied or
+ * otherwise, applies only to this software file. Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * 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.
+ *
+ */
+
+#define ReFS_BS_SIZE 0x200
+struct ReFS_boot_sector {
+ uint8_t ignored[3];
+ uint32_t fsname;
+ uint8_t mustBeZero[9];
+ uint32_t identifier;
+ uint16_t length;
+ uint16_t checksum;
+} __attribute__ ((gcc_struct, __packed__));
+
+int check_ReFS(disk_t *disk, partition_t *partition);
+int recover_ReFS(const disk_t *disk, const struct ReFS_boot_sector *refs_header, partition_t *partition);
+
+