Add missing files

This commit is contained in:
Christophe Grenier 2010-01-24 13:09:21 +01:00
parent d1f3b2d095
commit 4f3a8bdd4d
4 changed files with 2921 additions and 0 deletions

2776
ChangeLog Normal file

File diff suppressed because it is too large Load diff

6
THANKS Normal file
View file

@ -0,0 +1,6 @@
TestDisk & PhotoRec are mainly written by Christophe GRENIER.
Many people further contributed to TestDisk, directly or indirectly, by
reporting problems, helping with the documentation, suggesting various
improvements, sending me gifts using my Amazon whish-list...
Thanks to the thousands of people who have provided support for the project!

83
src/exfat.c Normal file
View file

@ -0,0 +1,83 @@
/*
File: exfat.c
Copyright (C) 2009 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 "exfat.h"
static int test_EXFAT(const struct exfat_super_block *exfat_header, partition_t *partition);
#define EXFAT_SIZE 512
static int set_EXFAT_info(partition_t *partition)
{
partition->fsname[0]='\0';
strncpy(partition->info,"EXFAT",sizeof(partition->info));
return 0;
}
int check_EXFAT(disk_t *disk_car, partition_t *partition)
{
unsigned char *buffer=(unsigned char*)MALLOC(EXFAT_SIZE);
if(disk_car->pread(disk_car, buffer, EXFAT_SIZE, partition->part_offset) != EXFAT_SIZE)
{
free(buffer);
return 1;
}
if(test_EXFAT((struct exfat_super_block*)buffer, partition)!=0)
{
free(buffer);
return 1;
}
set_EXFAT_info(partition);
free(buffer);
return 0;
}
static int test_EXFAT(const struct exfat_super_block *exfat_header, partition_t *partition)
{
if(le16(exfat_header->signature)!=0xAA55)
return 1;
if(memcmp(exfat_header->oem_id, "EXFAT ", sizeof(exfat_header->oem_id))!=0)
return 1;
partition->upart_type=UP_EXFAT;
return 0;
}
int recover_EXFAT(const disk_t *disk, const struct exfat_super_block *exfat_header, partition_t *partition)
{
if(test_EXFAT(exfat_header, partition)!=0)
return 1;
set_EXFAT_info(partition);
partition->part_type_i386=P_EXFAT;
partition->part_type_gpt=GPT_ENT_TYPE_MS_BASIC_DATA;
partition->part_size=(uint64_t)le64(exfat_header->nr_sectors) * disk->sector_size;
return 0;
}

56
src/exfat.h Normal file
View file

@ -0,0 +1,56 @@
/*
file: swap.h
Copyright (C) 2009 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
struct exfat_super_block {
unsigned char jmp_boot[3]; /* boot strap short or near jump */
unsigned char oem_id[8]; /* oem-id */
unsigned char unused0; /* 0x00... */
uint32_t unused1[13];
uint64_t start_sector; /* 0x40 start sector of partition */
uint64_t nr_sectors; /* number of sectors of partition */
uint32_t fat_blocknr; /* 0x50 start blocknr of FAT */
uint32_t fat_block_counts; /* number of FAT blocks */
uint32_t clus_blocknr; /* start blocknr of cluster */
uint32_t total_clusters; /* number of total clusters */
uint32_t rootdir_clusnr; /* 0x60 start clusnr of rootdir */
uint32_t serial_number; /* volume serial number */
unsigned char xxxx01; /* ??? (0x00 or any value (?)) */
unsigned char xxxx02; /* ??? (0x01 or 0x00 (?)) */
uint16_t state; /* state of this volume */
unsigned char blocksize_bits; /* bits of block size */
unsigned char block_per_clus_bits; /* bits of blocks per cluster */
unsigned char xxxx03; /* ??? (0x01 or 0x00 (?)) */
unsigned char xxxx04; /* ??? (0x80 or any value (?)) */
unsigned char allocated_percent; /* 0x70 percentage of allocated space (?) */
unsigned char xxxx05[397]; /* ??? (0x00...) */
uint16_t signature; /* 0xaa55 */
} __attribute__ ((__packed__));
int check_EXFAT(disk_t *disk_car, partition_t *partition);
int recover_EXFAT(const disk_t *disk, const struct exfat_super_block *exfat_header, partition_t *partition);
#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif