testdisk/testdisk-6.11.3-ntfs-3g.patch

471 lines
16 KiB
Diff
Raw Permalink Normal View History

diff -ru testdisk-6.11/config.h.in testdisk-6.11.new/config.h.in
--- testdisk-6.11/config.h.in 2009-04-19 16:34:34.000000000 +0200
+++ testdisk-6.11.new/config.h.in 2011-04-16 09:00:00.000000000 +0200
@@ -33,16 +33,16 @@
/* Define to 1 if you have the <dal/file.h> header file. */
#undef HAVE_DAL_FILE_H
-/* Define to 1 if `block_size' is member of `dal_t'. */
+/* Define to 1 if `block_size' is a member of `dal_t'. */
#undef HAVE_DAL_T_BLOCK_SIZE
-/* Define to 1 if `entity' is member of `dal_t'. */
+/* Define to 1 if `entity' is a member of `dal_t'. */
#undef HAVE_DAL_T_ENTITY
-/* Define to 1 if `error' is member of `dal_t'. */
+/* Define to 1 if `error' is a member of `dal_t'. */
#undef HAVE_DAL_T_ERROR
-/* Define to 1 if `name' is member of `dal_t'. */
+/* Define to 1 if `name' is a member of `dal_t'. */
#undef HAVE_DAL_T_NAME
/* Define to 1 if you have the <ddk/ntddstor.h> header file. */
@@ -147,6 +147,9 @@
/* Define to 1 if you have the ntfs library (-lntfs). */
#undef HAVE_LIBNTFS
+/* Define to 1 if you have the ntfs3g library (-lntfs3g). */
+#undef HAVE_LIBNTFS3G
+
/* Define to 1 if you have the reiserfs library (-lreiserfs). */
#undef HAVE_LIBREISERFS
@@ -205,6 +208,12 @@
/* Define to 1 if you have the <ncurses/ncurses.h> header file. */
#undef HAVE_NCURSES_NCURSES_H
+/* Define to 1 if you have the <ntfs-3g/attrib.h> header file. */
+#undef HAVE_NTFS_3G_ATTRIB_H
+
+/* Define to 1 if you have the <ntfs-3g/volume.h> header file. */
+#undef HAVE_NTFS_3G_VOLUME_H
+
/* Define to 1 if you have the <ntfs/attrib.h> header file. */
#undef HAVE_NTFS_ATTRIB_H
@@ -316,22 +325,22 @@
/* Define to 1 if you have the `strtol' function. */
#undef HAVE_STRTOL
-/* Define to 1 if `dev' is member of `struct dal_ops'. */
+/* Define to 1 if `dev' is a member of `struct dal_ops'. */
#undef HAVE_STRUCT_DAL_OPS_DEV
-/* Define to 1 if `st_blksize' is member of `struct stat'. */
+/* Define to 1 if `st_blksize' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
-/* Define to 1 if `st_blocks' is member of `struct stat'. */
+/* Define to 1 if `st_blocks' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLOCKS
-/* Define to 1 if `st_rdev' is member of `struct stat'. */
+/* Define to 1 if `st_rdev' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_RDEV
-/* Define to 1 if `set_option' is member of `struct struct_io_manager'. */
+/* Define to 1 if `set_option' is a member of `struct struct_io_manager'. */
#undef HAVE_STRUCT_STRUCT_IO_MANAGER_SET_OPTION
-/* Define to 1 if `tm_gmtoff' is member of `struct tm'. */
+/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
#undef HAVE_STRUCT_TM_TM_GMTOFF
/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use
@@ -464,6 +473,9 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
/* Define to the version of this package. */
#undef PACKAGE_VERSION
diff -ru testdisk-6.11/configure.ac testdisk-6.11.new/configure.ac
--- testdisk-6.11/configure.ac 2009-04-19 16:31:43.000000000 +0200
+++ testdisk-6.11.new/configure.ac 2011-04-16 09:00:00.000000000 +0200
@@ -97,6 +97,20 @@
AS_HELP_STRING(--with-ntfs-includes=DIR,location of the ntfs includes files),
[CPPFLAGS="${CPPFLAGS} -I${withval}"])
+AC_ARG_WITH([ntfs3g],
+ AS_HELP_STRING(--without-ntfs3g,disabled use of the ntfs3g library (default is NO)),
+ [ use_ntfs3g="n" ])
+
+AC_ARG_WITH(ntfs3g-lib,
+ AS_HELP_STRING(--with-ntfs3g-lib=DIR,location of the ntfs3g library),
+ [ ntfs3g_lib_a="${withval}/libntfs-3g.a"
+ LDFLAGS="${LDFLAGS} -L${withval}"
+ ])
+
+AC_ARG_WITH(ntfs3g-includes,
+ AS_HELP_STRING(--with-ntfs3g-includes=DIR,location of the ntfs3g includes files),
+ [CPPFLAGS="${CPPFLAGS} -I${withval}"])
+
AC_ARG_WITH(dal-lib,
AS_HELP_STRING(--with-dal-lib=DIR,location of the dal library),
[ LDFLAGS="${LDFLAGS} -L${withval}" ])
@@ -378,6 +392,10 @@
use_ntfs=no
AC_MSG_WARN(Disable use of ntfs library))
+AC_CHECK_HEADERS([ntfs-3g/attrib.h ntfs-3g/volume.h],,
+ use_ntfs3g=no
+ AC_MSG_WARN(Disable use of ntfs3g library))
+
AC_CHECK_HEADERS([libcarvpath.h],,
use_carvpath=no
AC_MSG_WARN(Disable use of carvpath library))
@@ -516,6 +534,23 @@
AC_MSG_WARN(Use of jpeg library disabled)
fi
+if test -z "${use_ntfs3g}"; then
+ AC_CHECK_LIB(ntfs-3g,ntfs_device_mount,
+ [
+ AC_DEFINE([HAVE_LIBNTFS3G],1,[Define to 1 if you have the ntfs3g library (-lntfs3g).])
+ if test "${ntfs3g_lib_a}" = ""; then
+ LIBS="-lntfs-3g $LIBS"
+ else
+ LIBS="${ntfs3g_lib_a} $LIBS"
+ fi
+ use_ntfs=no
+ ],
+ AC_MSG_WARN(No ntfs-3g library detected)
+ )
+else
+ AC_MSG_WARN(Use of ntfs3g library disabled)
+fi
+
if test -z "${use_ntfs}"; then
AC_CHECK_LIB(ntfs,ntfs_device_mount,
[
diff -ru testdisk-6.11/src/ntfs_dir.c testdisk-6.11.new/src/ntfs_dir.c
--- testdisk-6.11/src/ntfs_dir.c 2009-04-13 16:45:08.000000000 +0200
+++ testdisk-6.11.new/src/ntfs_dir.c 2011-04-16 09:00:00.000000000 +0200
@@ -63,6 +63,10 @@
#include <ntfs/version.h>
#endif
#endif
+#ifdef HAVE_LIBNTFS3G
+#include <ntfs-3g/volume.h>
+#include <ntfs-3g/attrib.h>
+#endif
#include "common.h"
#include "intrf.h"
@@ -73,7 +77,7 @@
#include "ntfs_inc.h"
#include "log.h"
-#ifdef HAVE_LIBNTFS
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
#define MAX_PATH 1024
#define PATH_SEP '/'
#define NTFS_DT_DIR 4
@@ -99,7 +103,7 @@
void *dirent, ntfs_filldir_t filldir);
extern u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni,
const ntfschar *uname, const int uname_len);
-static time_t ntfs2utc (s64 ntfstime);
+static time_t td_ntfs2utc (s64 ntfstime);
static int ntfs_td_list_entry( struct ntfs_dir_struct *ls, const ntfschar *name,
const int name_len, const int name_type, const s64 pos,
const MFT_REF mref, const unsigned dt_type);
@@ -131,7 +135,7 @@
}
/**
- * ntfs2utc - Convert an NTFS time to Unix time
+ * td_ntfs2utc - Convert an NTFS time to Unix time
* @time: An NTFS time in 100ns units since 1601
*
* NTFS stores times as the number of 100ns intervals since January 1st 1601 at
@@ -139,7 +143,7 @@
*
* Return: n A Unix time (number of seconds since 1970)
*/
-static time_t ntfs2utc (s64 ntfstime)
+static time_t td_ntfs2utc (s64 ntfstime)
{
return (ntfstime - (NTFS_TIME_OFFSET)) / 10000000;
}
@@ -261,9 +265,9 @@
new_file->stat.st_blocks=(new_file->stat.st_size+new_file->stat.st_blksize-1)/new_file->stat.st_blksize;
}
#endif
- new_file->stat.st_atime=ntfs2utc(sle64_to_cpu(file_name_attr->last_access_time));
- new_file->stat.st_ctime=ntfs2utc(sle64_to_cpu(file_name_attr->creation_time));
- new_file->stat.st_mtime=ntfs2utc(sle64_to_cpu(file_name_attr->last_data_change_time));
+ new_file->stat.st_atime=td_ntfs2utc(sle64_to_cpu(file_name_attr->last_access_time));
+ new_file->stat.st_ctime=td_ntfs2utc(sle64_to_cpu(file_name_attr->creation_time));
+ new_file->stat.st_mtime=td_ntfs2utc(sle64_to_cpu(file_name_attr->last_data_change_time));
new_file->prev=ls->current_file;
new_file->next=NULL;
/* log_debug("fat: new file %s de=%p size=%u\n",new_file->name,de,de->size); */
@@ -500,7 +504,7 @@
int dir_partition_ntfs_init(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, const int verbose)
{
-#ifdef HAVE_LIBNTFS
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
struct ntfs_device *dev;
my_data_t *my_data=NULL;
ntfs_volume *vol=NULL;
@@ -582,6 +586,8 @@
#else
return "available";
#endif
+#elif defined(HAVE_LIBNTFS3G)
+ return "libntfs-3g";
#else
return "none";
#endif
diff -ru testdisk-6.11/src/ntfs_inc.h testdisk-6.11.new/src/ntfs_inc.h
--- testdisk-6.11/src/ntfs_inc.h 2008-08-08 21:50:28.000000000 +0200
+++ testdisk-6.11.new/src/ntfs_inc.h 2011-04-16 09:00:00.000000000 +0200
@@ -19,7 +19,7 @@
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifdef HAVE_LIBNTFS
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
struct ntfs_dir_struct {
file_data_t *dir_list;
file_data_t *current_file;
diff -ru testdisk-6.11/src/ntfs_io.c testdisk-6.11.new/src/ntfs_io.c
--- testdisk-6.11/src/ntfs_io.c 2009-01-29 16:20:45.000000000 +0100
+++ testdisk-6.11.new/src/ntfs_io.c 2011-04-16 09:00:00.000000000 +0200
@@ -26,7 +26,7 @@
#include <config.h>
#endif
-#ifdef HAVE_LIBNTFS
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
@@ -44,7 +44,12 @@
#include <sys/ioctl.h>
#endif
#include <stdarg.h>
+#ifdef HAVE_LIBNTFS
#include <ntfs/device.h>
+#endif
+#ifdef HAVE_LIBNTFS3G
+#include <ntfs-3g/device.h>
+#endif
#include <stdio.h>
#include "types.h"
#include "common.h"
@@ -117,6 +122,22 @@
return count;
}
+static s64 ntfs_device_testdisk_io_pread(struct ntfs_device *dev, void *buf,
+ s64 count, s64 offset)
+{
+ my_data_t *my_data=(my_data_t*)dev->d_private;
+ return my_data->disk_car->pread(my_data->disk_car, buf, count,
+ my_data->partition->part_offset + offset);
+}
+
+static s64 ntfs_device_testdisk_io_pwrite(struct ntfs_device *dev, const void *buf,
+ s64 count, s64 offset)
+{
+ my_data_t *my_data=(my_data_t*)dev->d_private;
+ return my_data->disk_car->pwrite(my_data->disk_car, buf, count,
+ my_data->partition->part_offset + offset);
+}
+
static int ntfs_device_testdisk_io_sync(struct ntfs_device *dev)
{
my_data_t *my_data=(my_data_t*)dev->d_private;
@@ -147,8 +168,8 @@
.seek = ntfs_device_testdisk_io_seek,
.read = ntfs_device_testdisk_io_read,
.write = ntfs_device_testdisk_io_write,
- .pread = NULL,
- .pwrite = NULL,
+ .pread = ntfs_device_testdisk_io_pread,
+ .pwrite = ntfs_device_testdisk_io_pwrite,
.sync = ntfs_device_testdisk_io_sync,
.stat = ntfs_device_testdisk_io_stat,
.ioctl = ntfs_device_testdisk_io_ioctl,
diff -ru testdisk-6.11/src/ntfsp.c testdisk-6.11.new/src/ntfsp.c
--- testdisk-6.11/src/ntfsp.c 2009-02-11 08:49:41.000000000 +0100
+++ testdisk-6.11.new/src/ntfsp.c 2011-04-16 09:00:00.000000000 +0200
@@ -39,6 +39,11 @@
#include "filegen.h"
#ifdef HAVE_LIBNTFS
#include <ntfs/attrib.h>
+#endif
+#ifdef HAVE_LIBNTFS3G
+#include <ntfs-3g/attrib.h>
+#endif
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
#include "ntfsp.h"
#endif
#include "intrf.h"
@@ -49,7 +54,7 @@
#include "log.h"
#include "log_part.h"
-#ifdef HAVE_LIBNTFS
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
#define SIZEOF_BUFFER ((const unsigned int)512)
unsigned int ntfs_remove_used_space(disk_t *disk_car,const partition_t *partition, alloc_data_t *list_search_space)
diff -ru testdisk-6.11/src/ntfs_udl.c testdisk-6.11.new/src/ntfs_udl.c
--- testdisk-6.11/src/ntfs_udl.c 2009-04-13 16:31:01.000000000 +0200
+++ testdisk-6.11.new/src/ntfs_udl.c 2011-04-16 09:00:00.000000000 +0200
@@ -85,6 +85,20 @@
#ifdef HAVE_NTFS_VERSION_H
#include <ntfs/version.h>
#endif
+#endif
+
+#ifdef HAVE_LIBNTFS3G
+#include <ntfs-3g/bootsect.h>
+#include <ntfs-3g/mft.h>
+#include <ntfs-3g/attrib.h>
+#include <ntfs-3g/layout.h>
+#include <ntfs-3g/inode.h>
+#include <ntfs-3g/device.h>
+#include <ntfs-3g/debug.h>
+#include <ntfs-3g/ntfstime.h>
+#endif
+
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
#ifdef HAVE_ICONV_H
#include <iconv.h>
#endif
@@ -150,6 +164,20 @@
char padding[4]; /* Unused: padding to 64 bit. */
};
+/**
+ * td_ntfs2utc - Convert an NTFS time to Unix time
+ * @time: An NTFS time in 100ns units since 1601
+ *
+ * NTFS stores times as the number of 100ns intervals since January 1st 1601 at
+ * 00:00 UTC. This system will not suffer from Y2K problems until ~57000AD.
+ *
+ * Return: n A Unix time (number of seconds since 1970)
+ */
+static time_t td_ntfs2utc (s64 ntfstime)
+{
+ return (ntfstime - (NTFS_TIME_OFFSET)) / 10000000;
+}
+
static const char *UNKNOWN = "unknown";
static struct options opts;
@@ -226,7 +254,7 @@
filename_attr = (FILE_NAME_ATTR*)((char*)attr30 + le16_to_cpu(attr30->value_offset));
/* if name is older than this dir -> can't determine */
- if (ntfs2utc(filename_attr->creation_time) > name->date_c) {
+ if (td_ntfs2utc(filename_attr->creation_time) > name->date_c) {
return NULL;
}
if (filename_attr->file_name_type != name->name_space) {
@@ -384,10 +412,10 @@
name->size_data = sle64_to_cpu(attr->data_size);
name->flags = attr->file_attributes;
- name->date_c = ntfs2utc(attr->creation_time);
- name->date_a = ntfs2utc(attr->last_data_change_time);
- name->date_m = ntfs2utc(attr->last_mft_change_time);
- name->date_r = ntfs2utc(attr->last_access_time);
+ name->date_c = td_ntfs2utc(attr->creation_time);
+ name->date_a = td_ntfs2utc(attr->last_data_change_time);
+ name->date_m = td_ntfs2utc(attr->last_mft_change_time);
+ name->date_r = td_ntfs2utc(attr->last_access_time);
if (ntfs_ucstombs(name->uname, name->uname_len, &name->name,
0) < 0) {
@@ -553,7 +581,7 @@
if (attr10) {
STANDARD_INFORMATION *si;
si = (STANDARD_INFORMATION *) ((char *) attr10 + le16_to_cpu(attr10->value_offset));
- file->date = ntfs2utc(si->last_data_change_time);
+ file->date = td_ntfs2utc(si->last_data_change_time);
}
if (attr20 || !attr10)
diff -ru testdisk-6.11/src/ntfs_utl.c testdisk-6.11.new/src/ntfs_utl.c
--- testdisk-6.11/src/ntfs_utl.c 2009-03-22 14:00:01.000000000 +0100
+++ testdisk-6.11.new/src/ntfs_utl.c 2011-04-16 09:00:00.000000000 +0200
@@ -26,7 +26,7 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#ifdef HAVE_LIBNTFS
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@@ -50,7 +50,13 @@
#include <stdarg.h>
#include "types.h"
+#ifdef HAVE_LIBNTFS
#include <ntfs/attrib.h>
+#endif
+#ifdef HAVE_LIBNTFS3G
+#include <ntfs-3g/attrib.h>
+#endif
+
#include "ntfs_utl.h"
#include "common.h"
#include "log.h"
diff -ru testdisk-6.11/src/ntfs_utl.h testdisk-6.11.new/src/ntfs_utl.h
--- testdisk-6.11/src/ntfs_utl.h 2009-01-06 01:21:50.000000000 +0100
+++ testdisk-6.11.new/src/ntfs_utl.h 2011-04-16 09:00:00.000000000 +0200
@@ -19,7 +19,7 @@
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifdef HAVE_LIBNTFS
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
#ifdef __cplusplus
extern "C" {
#endif
diff -ru testdisk-6.11/src/pfree_whole.c testdisk-6.11.new/src/pfree_whole.c
--- testdisk-6.11/src/pfree_whole.c 2008-08-25 20:23:02.000000000 +0200
+++ testdisk-6.11.new/src/pfree_whole.c 2011-04-16 09:00:00.000000000 +0200
@@ -55,7 +55,7 @@
{'W',"Whole","Extract files from whole partition"},
{0,NULL,NULL}
};
-#ifdef HAVE_LIBNTFS
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
static const struct MenuItem menuNTFS[]=
{
{'F',"Free", "Scan for file from NTFS unallocated space only"},
@@ -110,7 +110,7 @@
else if(partition->upart_type==UP_FAT32)
command = wmenuSelect_ext(window, 23, 8, 0, menuFAT32, 11,
options, MENU_VERT | MENU_VERT_WARN | MENU_BUTTON, &menu,NULL);
-#ifdef HAVE_LIBNTFS
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
else if(partition->upart_type==UP_NTFS)
command = wmenuSelect_ext(window, 23, 8, 0, menuNTFS, 11,
options, MENU_VERT | MENU_VERT_WARN | MENU_BUTTON, &menu,NULL);
diff -ru testdisk-6.11/src/photorec.c testdisk-6.11.new/src/photorec.c
--- testdisk-6.11/src/photorec.c 2009-04-13 21:56:51.000000000 +0200
+++ testdisk-6.11.new/src/photorec.c 2011-04-16 09:00:00.000000000 +0200
@@ -381,7 +381,7 @@
{
if(partition->upart_type==UP_FAT16 || partition->upart_type==UP_FAT32)
return fat_remove_used_space(disk_car, partition, list_search_space);
-#ifdef HAVE_LIBNTFS
+#if defined(HAVE_LIBNTFS) || defined(HAVE_LIBNTFS3G)
else if(partition->upart_type==UP_NTFS)
return ntfs_remove_used_space(disk_car, partition, list_search_space);
#endif