summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2020-09-12 09:05:06 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2020-09-12 09:05:06 +0200
commit4da8dff6d68a5c47549a8f833b7ee8afcbfebdac (patch)
tree95b98f0c68c841b50719b5c71dd322754a8160c1
parent7cdc0ae265ec6b29db242c91bdab1bd6412fc633 (diff)
src/dir.h: split the file in two, see src/dir_common.h
-rw-r--r--src/Makefile.am4
-rw-r--r--src/dir.h94
-rw-r--r--src/dir_common.h123
-rw-r--r--src/fat_dir.h1
4 files changed, 127 insertions, 95 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 5f0c86a..a9736d2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -44,7 +44,7 @@ fs_H = analyse.h bfs.h bsd.h btrfs.h cramfs.h exfat.h ext2.h ext2_common.h fat
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
-testdisk_SOURCES = $(base_C) $(base_H) $(fs_C) $(fs_H) $(testdisk_ncurses_C) $(testdisk_ncurses_H) dir.c dir.h exfat_dir.c exfat_dir.h ext2_dir.c ext2_dir.h ext2_inc.h fat_dir.c fat_dir.h ntfs_dir.c ntfs_dir.h ntfs_inc.h partgptw.c rfs_dir.c rfs_dir.h setdate.c setdate.h $(ICON_TESTDISK) next.c next.h
+testdisk_SOURCES = $(base_C) $(base_H) $(fs_C) $(fs_H) $(testdisk_ncurses_C) $(testdisk_ncurses_H) dir.c dir.h dir_common.h exfat_dir.c exfat_dir.h ext2_dir.c ext2_dir.h ext2_inc.h fat_dir.c fat_dir.h ntfs_dir.c ntfs_dir.h ntfs_inc.h partgptw.c rfs_dir.c rfs_dir.h setdate.c setdate.h $(ICON_TESTDISK) next.c next.h
file_C = filegen.c \
file_list.c \
@@ -389,7 +389,7 @@ file_H = ext2.h ext2_common.h filegen.h file_doc.h file_jpg.h file_gz.h file_s
photorec_C = photorec.c phcfg.c addpart.c chgarch.c dir.c exfatp.c ext2grp.c ext2_dir.c ext2p.c fat_dir.c fatp.c file_found.c geometry.c ntfs_dir.c ntfsp.c pdisksel.c poptions.c sessionp.c setdate.c dfxml.c
-photorec_H = photorec.h phcfg.h addpart.h chgarch.h dir.h exfatp.h ext2grp.h ext2p.h ext2_dir.h ext2_inc.h fat_dir.h fatp.h file_found.h geometry.h memmem.h ntfs_dir.h ntfsp.h ntfs_inc.h pdisksel.h poptions.h sessionp.h setdate.h dfxml.h
+photorec_H = photorec.h phcfg.h addpart.h chgarch.h dir_common.h dir.h exfatp.h ext2grp.h ext2p.h ext2_dir.h ext2_inc.h fat_dir.h fatp.h file_found.h geometry.h memmem.h ntfs_dir.h ntfsp.h ntfs_inc.h pdisksel.h poptions.h sessionp.h setdate.h dfxml.h
photorec_ncurses_C = addpartn.c askloc.c chgarchn.c chgtype.c chgtypen.c fat_cluster.c fat_unformat.c geometryn.c hiddenn.c intrfn.c nodisk.c parti386n.c partgptn.c partmacn.c partsunn.c partxboxn.c pbanner.c pblocksize.c pdiskseln.c pfree_whole.c phbf.c phbs.c phcli.c phnc.c phrecn.c ppartseln.c psearchn.c
photorec_ncurses_H = addpartn.h askloc.h chgarchn.h chgtype.h chgtypen.h fat_cluster.h fat_unformat.h geometryn.h hiddenn.h intrfn.h nodisk.h parti386n.h partgptn.h partmacn.h partsunn.h partxboxn.h pblocksize.h pdiskseln.h pfree_whole.h pnext.h phbf.h phbs.h phcli.h phnc.h phrecn.h ppartseln.h psearch.h psearchn.h photorec_check_header.h
diff --git a/src/dir.h b/src/dir.h
index 0a78ae4..ca67255 100644
--- a/src/dir.h
+++ b/src/dir.h
@@ -24,56 +24,7 @@
#ifdef __cplusplus
extern "C" {
#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#include "list.h"
-#define DIR_NAME_LEN 1024
-#define FLAG_LIST_DELETED 1
-#define FLAG_LIST_MASK12 2
-#define FLAG_LIST_MASK16 4
-#define FLAG_LIST_PATHNAME 8
-#define FLAG_LIST_ADS 16
-#define FLAG_LIST_SYSTEM 32
-/* capabilities */
-#define CAPA_LIST_DELETED 1
-#define CAPA_LIST_ADS 2
-
-typedef enum { DIR_PART_ENOIMP=-3, DIR_PART_ENOSYS=-2, DIR_PART_EIO=-1, DIR_PART_OK=0} dir_partition_t;
-typedef struct dir_data dir_data_t;
-typedef struct
-{
- struct td_list_head list;
- char *name;
- uint32_t st_ino;
- uint32_t st_mode;
- uint32_t st_uid;
- uint32_t st_gid;
- uint64_t st_size;
- time_t td_atime; /* time of last access */
- time_t td_mtime; /* time of last modification */
- time_t td_ctime; /* time of last status change */
- unsigned int status;
-} file_info_t;
-
-struct dir_data
-{
- void *display;
- char current_directory[DIR_NAME_LEN];
- unsigned long int current_inode;
- int verbose;
- unsigned int param;
- unsigned int capabilities;
- int(*get_dir)(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, const unsigned long int first_inode, file_info_t*list);
- int (*copy_file)(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, const file_info_t *file);
- void (*close)(dir_data_t *dir_data);
- char *local_dir;
- void *private_dir_data;
-};
-
-#define FILE_STATUS_DELETED 1
-#define FILE_STATUS_MARKED 2
-#define FILE_STATUS_ADS 4
+#include "dir_common.h"
/*@
@ requires \valid(datestr);
@@ -96,49 +47,6 @@ FILE *fopen_local(char **localfilename, const char *localroot, const char *filen
char *gen_local_filename(const char *filename);
char *mkdir_local(const char *localroot, const char *pathname);
void mkdir_local_for_file(const char *filename);
-
-#define LINUX_S_IFMT 00170000
-#define LINUX_S_IFSOCK 0140000
-#define LINUX_S_IFLNK 0120000
-#define LINUX_S_IFREG 0100000
-#define LINUX_S_IFBLK 0060000
-#define LINUX_S_IFDIR 0040000
-#define LINUX_S_IFCHR 0020000
-#define LINUX_S_IFIFO 0010000
-#define LINUX_S_ISUID 0004000
-#define LINUX_S_ISGID 0002000
-#define LINUX_S_ISVTX 0001000
-
-
-#define LINUX_S_IRWXU 00700
-#define LINUX_S_IRUSR 00400
-#define LINUX_S_IWUSR 00200
-#define LINUX_S_IXUSR 00100
-
-#define LINUX_S_IRWXG 00070
-#define LINUX_S_IRGRP 00040
-#define LINUX_S_IWGRP 00020
-#define LINUX_S_IXGRP 00010
-
-#define LINUX_S_IRWXO 00007
-#define LINUX_S_IROTH 00004
-#define LINUX_S_IWOTH 00002
-#define LINUX_S_IXOTH 00001
-
-#define LINUX_S_IRWXUGO (LINUX_S_IRWXU|LINUX_S_IRWXG|LINUX_S_IRWXO)
-#define LINUX_S_IALLUGO (LINUX_S_ISUID|LINUX_S_ISGID|LINUX_S_ISVTX|LINUX_S_IRWXUGO)
-#define LINUX_S_IRUGO (LINUX_S_IRUSR|LINUX_S_IRGRP|LINUX_S_IROTH)
-#define LINUX_S_IWUGO (LINUX_S_IWUSR|LINUX_S_IWGRP|LINUX_S_IWOTH)
-#define LINUX_S_IXUGO (LINUX_S_IXUSR|LINUX_S_IXGRP|LINUX_S_IXOTH)
-
-#define LINUX_S_ISLNK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK)
-#define LINUX_S_ISREG(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFREG)
-#define LINUX_S_ISDIR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)
-#define LINUX_S_ISCHR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR)
-#define LINUX_S_ISBLK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK)
-#define LINUX_S_ISFIFO(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO)
-#define LINUX_S_ISSOCK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK)
-
int filesort(const struct td_list_head *a, const struct td_list_head *b);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/dir_common.h b/src/dir_common.h
new file mode 100644
index 0000000..8463d67
--- /dev/null
+++ b/src/dir_common.h
@@ -0,0 +1,123 @@
+/*
+
+ File: dir_common.h
+
+ Copyright (C) 2020 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.
+
+ */
+#ifndef _DIR_COMMON_H
+#define _DIR_COMMON_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#include "list.h"
+#define DIR_NAME_LEN 1024
+#define FLAG_LIST_DELETED 1
+#define FLAG_LIST_MASK12 2
+#define FLAG_LIST_MASK16 4
+#define FLAG_LIST_PATHNAME 8
+#define FLAG_LIST_ADS 16
+#define FLAG_LIST_SYSTEM 32
+/* capabilities */
+#define CAPA_LIST_DELETED 1
+#define CAPA_LIST_ADS 2
+
+typedef enum { DIR_PART_ENOIMP=-3, DIR_PART_ENOSYS=-2, DIR_PART_EIO=-1, DIR_PART_OK=0} dir_partition_t;
+typedef struct dir_data dir_data_t;
+typedef struct
+{
+ struct td_list_head list;
+ char *name;
+ uint32_t st_ino;
+ uint32_t st_mode;
+ uint32_t st_uid;
+ uint32_t st_gid;
+ uint64_t st_size;
+ time_t td_atime; /* time of last access */
+ time_t td_mtime; /* time of last modification */
+ time_t td_ctime; /* time of last status change */
+ unsigned int status;
+} file_info_t;
+
+struct dir_data
+{
+ void *display;
+ char current_directory[DIR_NAME_LEN];
+ unsigned long int current_inode;
+ int verbose;
+ unsigned int param;
+ unsigned int capabilities;
+ int(*get_dir)(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, const unsigned long int first_inode, file_info_t*list);
+ int (*copy_file)(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, const file_info_t *file);
+ void (*close)(dir_data_t *dir_data);
+ char *local_dir;
+ void *private_dir_data;
+};
+
+#define FILE_STATUS_DELETED 1
+#define FILE_STATUS_MARKED 2
+#define FILE_STATUS_ADS 4
+
+#define LINUX_S_IFMT 00170000
+#define LINUX_S_IFSOCK 0140000
+#define LINUX_S_IFLNK 0120000
+#define LINUX_S_IFREG 0100000
+#define LINUX_S_IFBLK 0060000
+#define LINUX_S_IFDIR 0040000
+#define LINUX_S_IFCHR 0020000
+#define LINUX_S_IFIFO 0010000
+#define LINUX_S_ISUID 0004000
+#define LINUX_S_ISGID 0002000
+#define LINUX_S_ISVTX 0001000
+
+
+#define LINUX_S_IRWXU 00700
+#define LINUX_S_IRUSR 00400
+#define LINUX_S_IWUSR 00200
+#define LINUX_S_IXUSR 00100
+
+#define LINUX_S_IRWXG 00070
+#define LINUX_S_IRGRP 00040
+#define LINUX_S_IWGRP 00020
+#define LINUX_S_IXGRP 00010
+
+#define LINUX_S_IRWXO 00007
+#define LINUX_S_IROTH 00004
+#define LINUX_S_IWOTH 00002
+#define LINUX_S_IXOTH 00001
+
+#define LINUX_S_IRWXUGO (LINUX_S_IRWXU|LINUX_S_IRWXG|LINUX_S_IRWXO)
+#define LINUX_S_IALLUGO (LINUX_S_ISUID|LINUX_S_ISGID|LINUX_S_ISVTX|LINUX_S_IRWXUGO)
+#define LINUX_S_IRUGO (LINUX_S_IRUSR|LINUX_S_IRGRP|LINUX_S_IROTH)
+#define LINUX_S_IWUGO (LINUX_S_IWUSR|LINUX_S_IWGRP|LINUX_S_IWOTH)
+#define LINUX_S_IXUGO (LINUX_S_IXUSR|LINUX_S_IXGRP|LINUX_S_IXOTH)
+
+#define LINUX_S_ISLNK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK)
+#define LINUX_S_ISREG(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFREG)
+#define LINUX_S_ISDIR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)
+#define LINUX_S_ISCHR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR)
+#define LINUX_S_ISBLK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK)
+#define LINUX_S_ISFIFO(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO)
+#define LINUX_S_ISSOCK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK)
+
+#ifdef __cplusplus
+} /* closing brace for extern "C" */
+#endif
+#endif
diff --git a/src/fat_dir.h b/src/fat_dir.h
index 4988260..c6cd24b 100644
--- a/src/fat_dir.h
+++ b/src/fat_dir.h
@@ -22,6 +22,7 @@
#ifdef __cplusplus
extern "C" {
#endif
+#include "dir_common.h"
int dir_fat_aux(const unsigned char*buffer, const unsigned int size, const unsigned int param, file_info_t *dir_list);
dir_partition_t dir_partition_fat_init(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, const int verbose);