From 14bf880bb2f3ab24b0337264b24c2a5a2f3ae53e Mon Sep 17 00:00:00 2001 From: Brian Carrier <carrier@sleuthkit.org> Date: Tue, 27 Oct 2009 21:25:12 +0000 Subject: [PATCH] Added sector size to IMG_INFO and file and volume systems use it instead of 512. Changed istat and mmls -b flags to -B. --- CHANGES.txt | 6 ++++++ man/blkcalc.1 | 4 +++- man/blkcat.1 | 4 +++- man/blkls.1 | 4 +++- man/blkstat.1 | 4 +++- man/ffind.1 | 4 +++- man/fls.1 | 4 +++- man/fsstat.1 | 4 +++- man/icat.1 | 4 +++- man/ifind.1 | 4 +++- man/ils.1 | 4 +++- man/img_cat.1 | 4 +++- man/img_stat.1 | 4 +++- man/istat.1 | 8 +++++--- man/jcat.1 | 4 +++- man/jls.1 | 4 +++- man/mmcat.1 | 4 +++- man/mmls.1 | 6 ++++-- man/mmstat.1 | 4 +++- samples/callback-style.cpp | 2 +- samples/posix-style.cpp | 2 +- tests/fs_attrlist_apis.cpp | 4 ++-- tests/fs_fname_apis.cpp | 6 +++--- tests/read_apis.cpp | 12 +++++------ tools/fstools/blkcalc.cpp | 21 ++++++++++++++++--- tools/fstools/blkcat.cpp | 23 ++++++++++++++++----- tools/fstools/blkls.cpp | 27 +++++++++++++++++------- tools/fstools/blkstat.cpp | 19 ++++++++++++++--- tools/fstools/ffind.cpp | 20 +++++++++++++++--- tools/fstools/fls.cpp | 23 +++++++++++++++++---- tools/fstools/fscheck.cpp | 21 +++++++++++++++---- tools/fstools/fsstat.cpp | 22 ++++++++++++++++---- tools/fstools/icat.cpp | 20 +++++++++++++++--- tools/fstools/ifind.cpp | 20 +++++++++++++++--- tools/fstools/ils.cpp | 28 ++++++++++++++++++------- tools/fstools/istat.cpp | 25 ++++++++++++++++------ tools/fstools/jcat.cpp | 21 +++++++++++++++---- tools/fstools/jls.cpp | 22 ++++++++++++++++---- tools/imgtools/img_cat.cpp | 24 ++++++++++++++++++---- tools/imgtools/img_stat.cpp | 24 ++++++++++++++++++---- tools/srchtools/sigfind.cpp | 2 +- tools/vstools/mmcat.cpp | 20 +++++++++++++++--- tools/vstools/mmls.cpp | 24 +++++++++++++++++----- tools/vstools/mmstat.cpp | 21 ++++++++++++++++--- tsk3/fs/ext2fs.c | 2 +- tsk3/fs/ext2fs_dent.c | 6 +++--- tsk3/fs/fatfs.c | 2 +- tsk3/fs/fatfs_dent.c | 4 ++-- tsk3/fs/ffs.c | 4 ++-- tsk3/fs/ffs_dent.c | 4 ++-- tsk3/fs/fs_attr.c | 13 ++++++------ tsk3/fs/fs_name.c | 10 ++++----- tsk3/fs/iso9660.c | 6 +++--- tsk3/fs/nofs_misc.c | 4 ++-- tsk3/fs/ntfs.c | 16 +++++++-------- tsk3/fs/ntfs_dent.c | 12 +++++------ tsk3/fs/rawfs.c | 2 +- tsk3/fs/swapfs.c | 2 +- tsk3/fs/tsk_ext2fs.h | 1 - tsk3/fs/tsk_fatfs.h | 3 --- tsk3/fs/tsk_ffs.h | 5 ----- tsk3/fs/tsk_ntfs.h | 1 - tsk3/img/aff.c | 5 ++++- tsk3/img/aff.h | 3 ++- tsk3/img/ewf.c | 7 ++++++- tsk3/img/ewf.h | 3 ++- tsk3/img/img_open.c | 41 ++++++++++++++++++++++--------------- tsk3/img/raw.c | 7 ++++++- tsk3/img/raw.h | 2 +- tsk3/img/split.c | 8 +++++++- tsk3/img/split.h | 3 ++- tsk3/img/tsk_img.h | 9 ++++---- tsk3/vs/bsd.c | 2 +- tsk3/vs/dos.c | 2 +- tsk3/vs/gpt.c | 2 +- tsk3/vs/mac.c | 2 +- tsk3/vs/sun.c | 2 +- 77 files changed, 530 insertions(+), 202 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ed9a7eb76..6b5d6fdf1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -101,6 +101,12 @@ in UFS/Ext2. 8/19/09: Bug Fix: Fixed part of 2840345 where extended DOS partitions in extended partitions were not marked as Meta. +10/27/09: Update: 'mmls -b' is now 'mmls -B'. Similarly with istat -b. + +10/27/09: Update: Added sector_size value to IMG_INFO and file and volume +systems now use it instead of assuming 512. Also added -b options to all +command line tools to allow user to specify the device sector size. + ---------------- VERSION 3.0.1 -------------- 11/11/08: Bug Fix: Fixed crashing bug in ifind on FAT file system. Bug: 2265927 diff --git a/man/blkcalc.1 b/man/blkcalc.1 index 795f7d83b..6281ea4d2 100644 --- a/man/blkcalc.1 +++ b/man/blkcalc.1 @@ -4,7 +4,7 @@ blkcalc \- Converts between unallocated disk unit numbers and regular disk unit numbers. .SH SYNOPSIS .B blkcalc -[-dsu unit_addr] [-vV] [-i imgtype] [-o imgoffset] [-f fstype] image [images] +[-dsu unit_addr] [-vV] [-i imgtype] [-o imgoffset] [-b dev_sector_size] [-f fstype] image [images] .SH DESCRIPTION .B blkcalc creates a disk unit number mapping between two images, one normal and @@ -53,6 +53,8 @@ If not given, autodetection methods are used. .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048) +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -v Verbose output to STDERR. .IP -V diff --git a/man/blkcat.1 b/man/blkcat.1 index 278c02256..969a6fb47 100644 --- a/man/blkcat.1 +++ b/man/blkcat.1 @@ -2,7 +2,7 @@ .SH NAME blkcat \- Display the contents of file system data unit in a disk image. .SH SYNOPSIS -.B blkcat [-ahswvV] [-f fstype] [-u unit_size] [-i imgtype] [-o imgoffset] image [images] unit_addr [num] +.B blkcat [-ahswvV] [-f fstype] [-u unit_size] [-i imgtype] [-o imgoffset] [-b dev_sector_size] image [images] unit_addr [num] .SH DESCRIPTION .B blkcat @@ -42,6 +42,8 @@ If not given, autodetection methods are used. .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -v Verbose output to stderr. .IP -V diff --git a/man/blkls.1 b/man/blkls.1 index 70fb6f801..25487e74b 100644 --- a/man/blkls.1 +++ b/man/blkls.1 @@ -9,7 +9,7 @@ blkls \- List or output file system data units. .B ] [-o .I imgoffset .B ] -.I image [images] [start-stop] +.I [-b dev_sector_size] image [images] [start-stop] .SH DESCRIPTION .B blkls @@ -45,6 +45,8 @@ If not given, autodetection methods are used. .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -l List the data information in time machine format. .IP -s diff --git a/man/blkstat.1 b/man/blkstat.1 index 39fc2cc27..dcf675730 100644 --- a/man/blkstat.1 +++ b/man/blkstat.1 @@ -4,7 +4,7 @@ blkstat \- Display details of a file system data unit (i.e. block or sector) .SH SYNOPSIS .B blkstat [-f .I fstype -.B ] [-i imgtype] [-o imgoffset] [-vV] +.B ] [-i imgtype] [-o imgoffset] [-b dev_sector_size] [-vV] .I image [images] addr .SH DESCRIPTION .B blkstat @@ -24,6 +24,8 @@ If not given, autodetection methods are used. .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -v Verbose output of debugging statements to stderr .IP -V diff --git a/man/ffind.1 b/man/ffind.1 index a230fcc71..02950bba0 100644 --- a/man/ffind.1 +++ b/man/ffind.1 @@ -2,7 +2,7 @@ .SH NAME ffind \- Finds the name of the file or directory using a given inode .SH SYNOPSIS -.B ffind [-aduvV] [-f fstype] [-i imgtype] [-o imgoffset] +.B ffind [-aduvV] [-f fstype] [-i imgtype] [-o imgoffset] [-b dev_sector_size] .I image inode .SH DESCRIPTION .B ffind @@ -36,6 +36,8 @@ If not given, autodetection methods are used. .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -v Verbose output to stderr. .IP -V diff --git a/man/fls.1 b/man/fls.1 index 99cc299c2..4b7db7c45 100644 --- a/man/fls.1 +++ b/man/fls.1 @@ -14,7 +14,7 @@ fls \- List file and directory names in a disk image. .I imgtype .B ] [-o .I imgoffset -.B ] +.B ] [-b dev_sector_size] .I image [images] .B [ .I inode @@ -68,6 +68,8 @@ If not given, autodetection methods are used. .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -u Display undeleted entries only .IP -v diff --git a/man/fsstat.1 b/man/fsstat.1 index 519896aa9..67518bfd7 100644 --- a/man/fsstat.1 +++ b/man/fsstat.1 @@ -4,7 +4,7 @@ fsstat \- Display general details of a file system .SH SYNOPSIS .B fsstat [-f .I fstype -.B ] [-i imgtype] [-o imgoffset] [-tvV] +.B ] [-i imgtype] [-o imgoffset] [-b dev_sector_size] [-tvV] .I image [images] .SH DESCRIPTION .B fsstat @@ -31,6 +31,8 @@ If not given, autodetection methods are used. .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -v Verbose output of debugging statements to stderr .IP -V diff --git a/man/icat.1 b/man/icat.1 index 0e03594fb..8321e7291 100644 --- a/man/icat.1 +++ b/man/icat.1 @@ -8,7 +8,7 @@ icat \- Output the contents of a file based on its inode number. .I imgtype .B ] [-o .I imgoffset -.B ] +.B ] [-b dev_sector_size] .I image [images] inode .SH DESCRIPTION .B icat @@ -36,6 +36,8 @@ If not given, autodetection methods are used. .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -v Enable verbose mode, output to stderr. .IP -V diff --git a/man/ifind.1 b/man/ifind.1 index 0f931500d..01dc7a323 100644 --- a/man/ifind.1 +++ b/man/ifind.1 @@ -4,7 +4,7 @@ ifind \- Find the meta-data structure that has allocated a given disk unit or file name. .SH SYNOPSIS .B ifind [-avVl] [-f fstype] [-d data_unit] -.B [-n file] [-p par_inode] [-z ZONE] [-i imgtype] [-o imgoffset] +.B [-n file] [-p par_inode] [-z ZONE] [-i imgtype] [-o imgoffset] [-b dev_sector_size] .I image [images] .SH DESCRIPTION .B ifind @@ -47,6 +47,8 @@ If not given, autodetection methods are used. .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -v Verbose output to stderr. .IP -V diff --git a/man/ils.1 b/man/ils.1 index e15886501..f193fbe4f 100644 --- a/man/ils.1 +++ b/man/ils.1 @@ -10,7 +10,7 @@ ils \- List inode information .I imgtype .B ] [-o .I imgoffset -.B ] +.B ] [-b dev_sector_size] .I image [images] [start-stop] .B ils [-aAlLvVzZ] [-f @@ -60,6 +60,8 @@ If not given, autodetection methods are used. .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP \fB-v\fR Turn on verbose mode, output to stderr. .IP \fB-V\fR diff --git a/man/img_cat.1 b/man/img_cat.1 index 2cfb03136..b74156387 100644 --- a/man/img_cat.1 +++ b/man/img_cat.1 @@ -2,7 +2,7 @@ .SH NAME img_cat \- Output contents of an image file. .SH SYNOPSIS -.B img_cat [-i imgtype] [-vV] +.B img_cat [-i imgtype] [-b dev_sector_size] [-vV] .I image [images] .SH DESCRIPTION .B img_cat @@ -14,6 +14,8 @@ the appropriate tool. .SH ARGUMENTS .IP "-i imgtype" Identify the type of image file, such as raw, split, or aff. Use '-i list' to list the supported types. If not given, autodetection methods are used. +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -v Verbose output of debugging statements to stderr .IP -V diff --git a/man/img_stat.1 b/man/img_stat.1 index 43f8cd8f7..b5588112b 100644 --- a/man/img_stat.1 +++ b/man/img_stat.1 @@ -2,7 +2,7 @@ .SH NAME img_stat \- Display details of an image file .SH SYNOPSIS -.B img_stat [-i imgtype] [-tvV] +.B img_stat [-i imgtype] [-b dev_sector_size] [-tvV] .I image [images] .SH DESCRIPTION .B img_stat @@ -13,6 +13,8 @@ and the byte range of each file will be given for split image formats. .SH ARGUMENTS .IP "-i imgtype" Identify the type of image file, such as raw or split. Use '-i list' to list the supported types. If not given, autodetection methods are used. +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP "-t" Print the image type only. .IP -v diff --git a/man/istat.1 b/man/istat.1 index 33536faf5..55654f78e 100644 --- a/man/istat.1 +++ b/man/istat.1 @@ -2,11 +2,11 @@ .SH NAME istat \- Display details of a meta-data structure (i.e. inode) .SH SYNOPSIS -.B istat [-b +.B istat [-B .I num .B ] [-f .I fstype -.B ] [-i imgtype] [-o imgoffset] [-vV] [-z +.B ] [-i imgtype] [-o imgoffset] [-b dev_sector_size] [-vV] [-z .I zone .B ] [-s .I seconds @@ -18,7 +18,7 @@ displays the uid, gid, mode, size, link number, modified , accessed, changed times, and all the disk units a structure has allocated. The options are as follows: -.IP "-b num" +.IP "-B num" Display the addresses of num disk units. Useful when the inode is unallocated with size 0, but still has block pointers. .IP "-f fstype" @@ -34,6 +34,8 @@ If not given, autodetection methods are used. .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -v Verbose output of debugging statements to stderr .IP -V diff --git a/man/jcat.1 b/man/jcat.1 index f115811cb..40eba3a1a 100644 --- a/man/jcat.1 +++ b/man/jcat.1 @@ -4,7 +4,7 @@ jcat \- Show the contents of a block in the file system journal. .SH SYNOPSIS .B jcat [-f .I fstype -.B ] [-vV] [-i imgtype] [-o imgoffset] +.B ] [-vV] [-i imgtype] [-o imgoffset] [-b dev_sector_size] .I image [images] .B ] [ .I inode @@ -26,6 +26,8 @@ Identify the type of image file, such as raw or split. Use '-i list' to list th .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -V Display version .IP -v diff --git a/man/jls.1 b/man/jls.1 index d3efe14c2..b56c940df 100644 --- a/man/jls.1 +++ b/man/jls.1 @@ -4,7 +4,7 @@ jls \- List the contents of a file system journal .SH SYNOPSIS .B jls [-f .I fstype -.B ] [-vV] [-i imgtype] [-o imgoffset] +.B ] [-vV] [-i imgtype] [-o imgoffset] [-b dev_sector_size] .I image [images] [inode] .SH DESCRIPTION @@ -23,6 +23,8 @@ Identify the type of image file, such as raw or split. Use '-i list' to list th .IP "-o imgoffset" The sector offset where the file system starts in the image. Non-512 byte sectors can be specified using '@' (32@2048). +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP -V Display version .IP -v diff --git a/man/mmcat.1 b/man/mmcat.1 index 40c4daacb..b257f3fc8 100644 --- a/man/mmcat.1 +++ b/man/mmcat.1 @@ -8,7 +8,7 @@ mmcat \- Output the contents of a partition to stdout .I offset .B ] [ -i .I imgtype -.B ] [-vV] +.B ] [-b dev_sector_size] [-vV] .I image [images] part_num .SH DESCRIPTION .B mmcat @@ -22,6 +22,8 @@ Specify the media management type. Use '-t list' to list the supported types. I Specify the offset into the image where the volume containing the partition system starts. The relative offset of the partition system will be added to this value. +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP "-i imgtype" Identify the type of image file, such as raw or split. If not given, autodetection methods are used. .IP -v diff --git a/man/mmls.1 b/man/mmls.1 index 321fe3769..e2f7915f1 100644 --- a/man/mmls.1 +++ b/man/mmls.1 @@ -8,7 +8,7 @@ mmls \- Display the partition layout of a volume system (partition tables) .I offset .B ] [ -i .I imgtype -.B ] [-brvV] [-aAmM] +.B ] [-b dev_sector_size] [-BrvV] [-aAmM] .I image [images] .SH DESCRIPTION .B mmls @@ -22,9 +22,11 @@ Specify the media management type. Use '-t list' to list the supported types. I Specify the offset into the image where the volume containing the partition system starts. The relative offset of the partition system will be added to this value. +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP "-i imgtype" Identify the type of image file, such as raw or split. If not given, autodetection methods are used. -.IP -b +.IP -B Include a column with the partition sizes in bytes .IP -r Recurse into DOS partitions and look for other partition tables. This setup frequently occurs when Unix is installed on x86 systems. diff --git a/man/mmstat.1 b/man/mmstat.1 index 98468fa34..97500d395 100644 --- a/man/mmstat.1 +++ b/man/mmstat.1 @@ -8,7 +8,7 @@ mmstat \- Display details about the volume system (partition tables) .I offset .B ] [ -i .I imgtype -.B ] [-vV] +.B ] [-b dev_sector_size] [-vV] .I image [images] .SH DESCRIPTION .B mmstat @@ -22,6 +22,8 @@ Specify the media management type. Use '-t list' to list the supported types. I Specify the offset into the image where the volume containing the partition system starts. The relative offset of the partition system will be added to this value. +.IP "-b dev_sector_size" +The size, in bytes, of the underlying device sectors. If not given, the value in the image format is used (if it exists) or 512-bytes is assumed. .IP "-i imgtype" Identify the type of image file, such as raw or split. If not given, autodetection methods are used. .IP -v diff --git a/samples/callback-style.cpp b/samples/callback-style.cpp index 4d1f9d5b4..a597c1d85 100644 --- a/samples/callback-style.cpp +++ b/samples/callback-style.cpp @@ -297,7 +297,7 @@ main(int argc, char **argv1) hdb_info = NULL; #endif - img_info = tsk_img_open_sing(argv[1], TSK_IMG_TYPE_DETECT); + img_info = tsk_img_open_sing(argv[1], TSK_IMG_TYPE_DETECT, 0); if (img_info == NULL) { fprintf(stderr, "Error opening file\n"); tsk_error_print(stderr); diff --git a/samples/posix-style.cpp b/samples/posix-style.cpp index 8063ebe21..a091951c4 100644 --- a/samples/posix-style.cpp +++ b/samples/posix-style.cpp @@ -329,7 +329,7 @@ main(int argc, char **argv1) // open the disk image img_info = tsk_img_open_sing((const TSK_TCHAR *) argv[1], - TSK_IMG_TYPE_DETECT); + TSK_IMG_TYPE_DETECT, 0); if (img_info == NULL) { fprintf(stderr, "Error opening file\n"); tsk_error_print(stderr); diff --git a/tests/fs_attrlist_apis.cpp b/tests/fs_attrlist_apis.cpp index c0084876f..e92ce1af0 100644 --- a/tests/fs_attrlist_apis.cpp +++ b/tests/fs_attrlist_apis.cpp @@ -199,7 +199,7 @@ test_fat12() char fname[512]; snprintf(fname, 512, "%s/fat12.dd", s_root); - if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0)) == NULL) { + if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0, 0)) == NULL) { fprintf(stderr, "Error opening %s image\n", tname); tsk_error_print(stderr); return 1; @@ -238,7 +238,7 @@ test_ntfs_fe() char fname[512]; snprintf(fname, 512, "%s/fe_test_1.img", s_root); - if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0)) == NULL) { + if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0, 0)) == NULL) { fprintf(stderr, "Error opening %s image\n", tname); tsk_error_print(stderr); return 1; diff --git a/tests/fs_fname_apis.cpp b/tests/fs_fname_apis.cpp index 169e10c98..4692f29fd 100644 --- a/tests/fs_fname_apis.cpp +++ b/tests/fs_fname_apis.cpp @@ -363,7 +363,7 @@ test_fat12() char fname[512]; snprintf(fname, 512, "%s/fat12.dd", s_root); - if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0)) == NULL) { + if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0, 0)) == NULL) { fprintf(stderr, "Error opening %s image\n", tname); tsk_error_print(stderr); return 1; @@ -401,7 +401,7 @@ test_ntfs_fe() char fname[512]; snprintf(fname, 512, "%s/fe_test_1.img", s_root); - if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0)) == NULL) { + if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0, 0)) == NULL) { fprintf(stderr, "Error opening %s image\n", tname); tsk_error_print(stderr); return 1; @@ -438,7 +438,7 @@ test_ntfs_comp() char fname[512]; snprintf(fname, 512, "%s/ntfs-comp-1.img", s_root); - if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0)) == NULL) { + if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0, 0)) == NULL) { fprintf(stderr, "Error opening %s image\n", tname); tsk_error_print(stderr); return 1; diff --git a/tests/read_apis.cpp b/tests/read_apis.cpp index aa4ea029a..22a9c4360 100644 --- a/tests/read_apis.cpp +++ b/tests/read_apis.cpp @@ -207,7 +207,7 @@ test_fat12() char fname[512]; snprintf(fname, 512, "%s/fat12.dd", s_root); - if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0)) == NULL) { + if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0, 0)) == NULL) { fprintf(stderr, "Error opening %s image\n", tname); tsk_error_print(stderr); tsk_error_reset(); @@ -246,7 +246,7 @@ test_fat_slack() ssize_t retval; snprintf(fname, 512, "%s/fat-img-kw.dd", s_root); - if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0)) == NULL) { + if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0, 0)) == NULL) { fprintf(stderr, "Error opening %s image\n", tname); tsk_error_print(stderr); tsk_error_reset(); @@ -340,7 +340,7 @@ test_fat_recover() ssize_t retval; snprintf(fname, 512, "%s/fe_test_1.img", s_root); - if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0)) == NULL) { + if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0, 0)) == NULL) { fprintf(stderr, "Error opening %s image\n", tname); tsk_error_print(stderr); tsk_error_reset(); @@ -480,7 +480,7 @@ test_ntfs_slack_ads() ssize_t retval; snprintf(fname, 512, "%s/ntfs-img-kw-1.dd", s_root); - if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0)) == NULL) { + if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0, 0)) == NULL) { fprintf(stderr, "Error opening %s image\n", tname); tsk_error_print(stderr); tsk_error_reset(); @@ -627,7 +627,7 @@ test_ntfs_fe() char fname[512]; snprintf(fname, 512, "%s/fe_test_1.img", s_root); - if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0)) == NULL) { + if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0, 0)) == NULL) { fprintf(stderr, "Error opening %s image\n", tname); tsk_error_print(stderr); tsk_error_reset(); @@ -665,7 +665,7 @@ test_ntfs_comp() char fname[512]; snprintf(fname, 512, "%s/ntfs-comp-1.img", s_root); - if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0)) == NULL) { + if ((img = tsk_img_open_sing(fname, (TSK_IMG_TYPE_ENUM) 0, 0)) == NULL) { fprintf(stderr, "Error opening %s image\n", tname); tsk_error_print(stderr); tsk_error_reset(); diff --git a/tools/fstools/blkcalc.cpp b/tools/fstools/blkcalc.cpp index 62397f3a3..e5d6df939 100644 --- a/tools/fstools/blkcalc.cpp +++ b/tools/fstools/blkcalc.cpp @@ -31,7 +31,7 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-dsu unit_addr] [-vV] [-f fstype] [-i imgtype] [-o imgoffset] image [images]\n"), + ("usage: %s [-dsu unit_addr] [-vV] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] image [images]\n"), progname); tsk_fprintf(stderr, "Slowly calculates the opposite block number\n"); tsk_fprintf(stderr, "\tOne of the following must be given:\n"); @@ -45,6 +45,8 @@ usage() "\t-f fstype: The file system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-o imgoffset: The offset of the file system in the image (in sectors)\n"); tsk_fprintf(stderr, "\t-v: verbose output to stderr\n"); @@ -72,6 +74,7 @@ main(int argc, char **argv1) TSK_DADDR_T count = 0; TSK_TCHAR **argv; + unsigned int ssize = 0; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -88,7 +91,7 @@ main(int argc, char **argv1) progname = argv[0]; setlocale(LC_ALL, ""); - while ((ch = GETOPT(argc, argv, _TSK_T("d:f:i:o:s:u:vV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("b:d:f:i:o:s:u:vV"))) > 0) { switch (ch) { case _TSK_T('?'): default: @@ -96,6 +99,17 @@ main(int argc, char **argv1) argv[OPTIND]); usage(); + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; + case _TSK_T('d'): type |= TSK_FS_BLKCALC_DD; count = TSTRTOULL(OPTARG, &cp, 0); @@ -188,7 +202,8 @@ main(int argc, char **argv1) if ((img = - tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype)) == NULL) { + tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype, + ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/fstools/blkcat.cpp b/tools/fstools/blkcat.cpp index 5c32152e7..b765c2de4 100644 --- a/tools/fstools/blkcat.cpp +++ b/tools/fstools/blkcat.cpp @@ -32,12 +32,14 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-ahsvVw] [-f fstype] [-i imgtype] [-o imgoffset] [-u usize] image [images] unit_addr [num]\n"), + ("usage: %s [-ahsvVw] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] [-u usize] image [images] unit_addr [num]\n"), progname); tsk_fprintf(stderr, "\t-a: displays in all ASCII \n"); tsk_fprintf(stderr, "\t-h: displays in hexdump-like fashion\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-o imgoffset: The offset of the file system in the image (in sectors)\n"); tsk_fprintf(stderr, @@ -74,6 +76,7 @@ main(int argc, char **argv1) char format = 0; extern int OPTIND; TSK_TCHAR **argv; + unsigned int ssize = 0; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -90,11 +93,21 @@ main(int argc, char **argv1) progname = argv[0]; setlocale(LC_ALL, ""); - while ((ch = GETOPT(argc, argv, _TSK_T("af:hi:o:su:vVw"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("ab:f:hi:o:su:vVw"))) > 0) { switch (ch) { case _TSK_T('a'): format |= TSK_FS_BLKCAT_ASCII; break; + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('f'): if (TSTRCMP(OPTARG, BLKLS_TYPE) == 0) { fstype = TSK_FS_TYPE_RAW; @@ -196,7 +209,7 @@ main(int argc, char **argv1) if (format & TSK_FS_BLKCAT_STAT) { if ((img = tsk_img_open(argc - OPTIND, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -222,7 +235,7 @@ main(int argc, char **argv1) if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -250,7 +263,7 @@ main(int argc, char **argv1) if ((img = tsk_img_open(argc - OPTIND - 2, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); diff --git a/tools/fstools/blkls.cpp b/tools/fstools/blkls.cpp index 19541b5c0..a4f5d0b90 100644 --- a/tools/fstools/blkls.cpp +++ b/tools/fstools/blkls.cpp @@ -35,7 +35,7 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-aAelvV] [-f fstype] [-i imgtype] [-o imgoffset] image [images] [start-stop]\n"), + ("usage: %s [-aAelvV] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] image [images] [start-stop]\n"), progname); tsk_fprintf(stderr, "\t-e: every block\n"); tsk_fprintf(stderr, @@ -46,6 +46,8 @@ usage() "\t-f fstype: File system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-o imgoffset: The offset of the file system in the image (in sectors)\n"); tsk_fprintf(stderr, @@ -82,6 +84,7 @@ main(int argc, char **argv1) char lclflags = TSK_FS_BLKLS_CAT, set_bounds = 1; TSK_TCHAR **argv; + unsigned int ssize = 0; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -97,7 +100,7 @@ main(int argc, char **argv1) progname = argv[0]; setlocale(LC_ALL, ""); - while ((ch = GETOPT(argc, argv, _TSK_T("aAef:i:lo:svV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("aAb:ef:i:lo:svV"))) > 0) { switch (ch) { case _TSK_T('?'): default: @@ -110,6 +113,16 @@ main(int argc, char **argv1) case _TSK_T('A'): flags |= TSK_FS_BLOCK_FLAG_UNALLOC; break; + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('e'): flags |= (TSK_FS_BLOCK_FLAG_ALLOC | TSK_FS_BLOCK_FLAG_UNALLOC); break; @@ -174,7 +187,7 @@ main(int argc, char **argv1) } /* There should be no other arguments */ - img = tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype); + img = tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype, ssize); if (img == NULL) { tsk_error_print(stderr); @@ -202,7 +215,7 @@ main(int argc, char **argv1) /* No dash in arg - therefore it is an image file name */ if ((img = tsk_img_open(argc - OPTIND, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -225,7 +238,7 @@ main(int argc, char **argv1) *dash = _TSK_T('-'); if ((img = tsk_img_open(argc - OPTIND, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -248,7 +261,7 @@ main(int argc, char **argv1) *dash = _TSK_T('-'); if ((img = tsk_img_open(argc - OPTIND, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -267,7 +280,7 @@ main(int argc, char **argv1) /* It was a block range, so do not include it in the open */ if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/fstools/blkstat.cpp b/tools/fstools/blkstat.cpp index 6d40163b1..4aef47dc7 100644 --- a/tools/fstools/blkstat.cpp +++ b/tools/fstools/blkstat.cpp @@ -24,12 +24,14 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-vV] [-f fstype] [-i imgtype] [-o imgoffset] image [images] addr\n"), + ("usage: %s [-vV] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] image [images] addr\n"), progname); tsk_fprintf(stderr, "\t-f fstype: File system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-o imgoffset: The offset of the file system in the image (in sectors)\n"); tsk_fprintf(stderr, "\t-v: Verbose output to stderr\n"); @@ -58,6 +60,7 @@ main(int argc, char **argv1) (TSK_FS_BLOCK_FLAG_UNALLOC | TSK_FS_BLOCK_FLAG_ALLOC | TSK_FS_BLOCK_FLAG_META | TSK_FS_BLOCK_FLAG_CONT); TSK_TCHAR **argv; + unsigned int ssize = 0; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -73,8 +76,18 @@ main(int argc, char **argv1) progname = argv[0]; setlocale(LC_ALL, ""); - while ((ch = GETOPT(argc, argv, _TSK_T("f:i:o:uvV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("b:f:i:o:uvV"))) > 0) { switch (ch) { + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('f'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_fs_type_print(stderr); @@ -134,7 +147,7 @@ main(int argc, char **argv1) /* open image */ if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/fstools/ffind.cpp b/tools/fstools/ffind.cpp index 3725cdb9c..e2fddacb3 100644 --- a/tools/fstools/ffind.cpp +++ b/tools/fstools/ffind.cpp @@ -28,7 +28,7 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-aduvV] [-f fstype] [-i imgtype] [-o imgoffset] image [images] inode\n"), + ("usage: %s [-aduvV] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] image [images] inode\n"), progname); tsk_fprintf(stderr, "\t-a: Find all occurrences\n"); tsk_fprintf(stderr, "\t-d: Find deleted entries ONLY\n"); @@ -37,6 +37,8 @@ usage() "\t-f fstype: Image file system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-o imgoffset: The offset of the file system in the image (in sectors)\n"); tsk_fprintf(stderr, "\t-v: Verbose output to stderr\n"); @@ -65,6 +67,8 @@ main(int argc, char **argv1) uint8_t ffind_flags = 0; TSK_INUM_T inode; TSK_TCHAR **argv; + unsigned int ssize = 0; + TSK_TCHAR *cp; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -80,11 +84,21 @@ main(int argc, char **argv1) progname = argv[0]; setlocale(LC_ALL, ""); - while ((ch = GETOPT(argc, argv, _TSK_T("adf:i:o:uvV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("ab:df:i:o:uvV"))) > 0) { switch (ch) { case _TSK_T('a'): ffind_flags |= TSK_FS_FFIND_ALL; break; + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('d'): dir_walk_flags |= TSK_FS_DIR_WALK_FLAG_UNALLOC; break; @@ -160,7 +174,7 @@ main(int argc, char **argv1) /* open image */ if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/fstools/fls.cpp b/tools/fstools/fls.cpp index 7e574566b..f5251ae30 100644 --- a/tools/fstools/fls.cpp +++ b/tools/fstools/fls.cpp @@ -30,7 +30,7 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-adDFlpruvV] [-f fstype] [-i imgtype] [-m dir/] [-o imgoffset] [-z ZONE] [-s seconds] image [images] [inode]\n"), + ("usage: %s [-adDFlpruvV] [-f fstype] [-i imgtype] [-b dev_sector_size] [-m dir/] [-o imgoffset] [-z ZONE] [-s seconds] image [images] [inode]\n"), progname); tsk_fprintf(stderr, "\tIf [inode] is not given, the root directory is used\n"); @@ -41,6 +41,8 @@ usage() tsk_fprintf(stderr, "\t-l: Display long version (like ls -l)\n"); tsk_fprintf(stderr, "\t-i imgtype: Format of image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-f fstype: File system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, @@ -80,6 +82,8 @@ main(int argc, char **argv1) int32_t sec_skew = 0; static TSK_TCHAR *macpre = NULL; TSK_TCHAR **argv; + unsigned int ssize = 0; + TSK_TCHAR *cp; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -97,7 +101,8 @@ main(int argc, char **argv1) fls_flags = TSK_FS_FLS_DIR | TSK_FS_FLS_FILE; - while ((ch = GETOPT(argc, argv, _TSK_T("adDf:Fi:m:lo:prs:uvVz:"))) > 0) { + while ((ch = + GETOPT(argc, argv, _TSK_T("ab:dDf:Fi:m:lo:prs:uvVz:"))) > 0) { switch (ch) { case _TSK_T('?'): default: @@ -107,6 +112,16 @@ main(int argc, char **argv1) case _TSK_T('a'): fls_flags |= TSK_FS_FLS_DOT; break; + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('d'): name_flags &= ~TSK_FS_NAME_FLAG_ALLOC; break; @@ -235,7 +250,7 @@ main(int argc, char **argv1) /* Not an inode at the end */ if ((img = tsk_img_open(argc - OPTIND, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -264,7 +279,7 @@ main(int argc, char **argv1) if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/fstools/fscheck.cpp b/tools/fstools/fscheck.cpp index a7f565c14..863074ce0 100644 --- a/tools/fstools/fscheck.cpp +++ b/tools/fstools/fscheck.cpp @@ -13,9 +13,11 @@ static void usage() { fprintf(stderr, - "usage: %s [-vV] [-f fstype] [-i imgtype] [-o imgoffset] image [images]\n", + "usage: %s [-vV] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] image [images]\n", progname); fprintf(stderr, "\t-i imgtype: The format of the image file\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); fprintf(stderr, "\t-o imgoffset: The offset of the file system in the image (in sectors)\n"); fprintf(stderr, "\t-v: verbose output to stderr\n"); @@ -40,6 +42,8 @@ main(int argc, char **argv) int ch; TSK_TCHAR **argv; + unsigned int ssize = 0; + TSK_TCHAR *cp; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -55,13 +59,22 @@ main(int argc, char **argv) progname = argv[0]; - while ((ch = GETOPT(argc, argv, "f:i:o:vV")) > 0) { + while ((ch = GETOPT(argc, argv, "b:f:i:o:vV")) > 0) { switch (ch) { case '?': default: fprintf(stderr, "Invalid argument: %s\n", argv[OPTIND]); usage(); - + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case 'f': if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_fs_type_print(stderr); @@ -113,7 +126,7 @@ main(int argc, char **argv) img = img_open(imgoff, argc - OPTIND, - (const char **) &argv[OPTIND], imgtype); + (const char **) &argv[OPTIND], imgtype, ssize); if (img == NULL) { tsk_error_print(stderr); exit(1); diff --git a/tools/fstools/fsstat.cpp b/tools/fstools/fsstat.cpp index 34ee42b98..eaa2d46e0 100644 --- a/tools/fstools/fsstat.cpp +++ b/tools/fstools/fsstat.cpp @@ -22,11 +22,13 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-tvV] [-f fstype] [-i imgtype] [-o imgoffset] image\n"), + ("usage: %s [-tvV] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] image\n"), progname); tsk_fprintf(stderr, "\t-t: display type only\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-f fstype: File system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, @@ -51,6 +53,8 @@ main(int argc, char **argv1) int ch; uint8_t type = 0; TSK_TCHAR **argv; + unsigned int ssize = 0; + TSK_TCHAR *cp; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -66,14 +70,23 @@ main(int argc, char **argv1) progname = argv[0]; setlocale(LC_ALL, ""); - while ((ch = GETOPT(argc, argv, _TSK_T("f:i:o:tvV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("b:f:i:o:tvV"))) > 0) { switch (ch) { case _TSK_T('?'): default: TFPRINTF(stderr, _TSK_T("Invalid argument: %s\n"), argv[OPTIND]); usage(); - + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('f'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_fs_type_print(stderr); @@ -128,7 +141,8 @@ main(int argc, char **argv1) } if ((img = - tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype)) == NULL) { + tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype, + ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/fstools/icat.cpp b/tools/fstools/icat.cpp index 9b400c907..c82d1199f 100644 --- a/tools/fstools/icat.cpp +++ b/tools/fstools/icat.cpp @@ -33,7 +33,7 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-hHsvV] [-f fstype] [-i imgtype] [-o imgoffset] image [images] inum[-typ[-id]]\n"), + ("usage: %s [-hHsvV] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] image [images] inum[-typ[-id]]\n"), progname); tsk_fprintf(stderr, "\t-h: Do not display holes in sparse files\n"); tsk_fprintf(stderr, "\t-r: Recover deleted file\n"); @@ -42,6 +42,8 @@ usage() tsk_fprintf(stderr, "\t-s: Display slack space at end of file\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-f fstype: File system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, @@ -71,6 +73,8 @@ main(int argc, char **argv1) int retval; int suppress_recover_error = 0; TSK_TCHAR **argv; + TSK_TCHAR *cp; + unsigned int ssize = 0; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -86,13 +90,23 @@ main(int argc, char **argv1) progname = argv[0]; setlocale(LC_ALL, ""); - while ((ch = GETOPT(argc, argv, _TSK_T("f:hi:o:rRsvV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("b:f:hi:o:rRsvV"))) > 0) { switch (ch) { case _TSK_T('?'): default: TFPRINTF(stderr, _TSK_T("Invalid argument: %s\n"), argv[OPTIND]); usage(); + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('f'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_fs_type_print(stderr); @@ -160,7 +174,7 @@ main(int argc, char **argv1) if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/fstools/ifind.cpp b/tools/fstools/ifind.cpp index ef40f7468..327550a4c 100644 --- a/tools/fstools/ifind.cpp +++ b/tools/fstools/ifind.cpp @@ -31,7 +31,7 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-alvV] [-f fstype] [-i imgtype] [-o imgoffset] [-d unit_addr] [-n file] [-p par_addr] [-z ZONE] image [images]\n"), + ("usage: %s [-alvV] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] [-d unit_addr] [-n file] [-p par_addr] [-z ZONE] image [images]\n"), progname); tsk_fprintf(stderr, "\t-a: find all inodes\n"); tsk_fprintf(stderr, @@ -43,6 +43,8 @@ usage() "\t-p par_addr: Find UNALLOCATED MFT entries given the parent's meta address (NTFS only)\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-f fstype: File system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, @@ -77,6 +79,7 @@ main(int argc, char **argv1) TSK_INUM_T parinode = 0; TSK_TCHAR *path = NULL; TSK_TCHAR **argv; + unsigned int ssize = 0; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -94,11 +97,21 @@ main(int argc, char **argv1) localflags = 0; - while ((ch = GETOPT(argc, argv, _TSK_T("ad:f:i:ln:o:p:vVz:"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("ab:d:f:i:ln:o:p:vVz:"))) > 0) { switch (ch) { case _TSK_T('a'): localflags |= TSK_FS_IFIND_ALL; break; + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('d'): if (type) { tsk_fprintf(stderr, @@ -218,7 +231,8 @@ main(int argc, char **argv1) if ((img = - tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype)) == NULL) { + tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype, + ssize)) == NULL) { tsk_error_print(stderr); if (path) free(path); diff --git a/tools/fstools/ils.cpp b/tools/fstools/ils.cpp index 7098a09de..6fbefb0db 100644 --- a/tools/fstools/ils.cpp +++ b/tools/fstools/ils.cpp @@ -34,7 +34,7 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-emOpvV] [-aAlLzZ] [-f fstype] [-i imgtype] [-o imgoffset] [-s seconds] image [images] [inum[-end]]\n"), + ("usage: %s [-emOpvV] [-aAlLzZ] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] [-s seconds] image [images] [inum[-end]]\n"), progname); tsk_fprintf(stderr, "\t-e: Display all inodes\n"); tsk_fprintf(stderr, "\t-m: Display output in the mactime format\n"); @@ -52,6 +52,8 @@ usage() tsk_fprintf(stderr, "\t-Z: Used inodes (ctime is not 0)\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-f fstype: File system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, @@ -83,6 +85,7 @@ main(int argc, char **argv1) TSK_TCHAR *image = NULL; int32_t sec_skew = 0; TSK_TCHAR **argv; + unsigned int ssize = 0; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -102,13 +105,24 @@ main(int argc, char **argv1) * Provide convenience options for the most commonly selected feature * combinations. */ - while ((ch = GETOPT(argc, argv, _TSK_T("aAef:i:lLmo:Oprs:vVzZ"))) > 0) { + while ((ch = + GETOPT(argc, argv, _TSK_T("aAb:ef:i:lLmo:Oprs:vVzZ"))) > 0) { switch (ch) { case _TSK_T('?'): default: TFPRINTF(stderr, _TSK_T("Invalid argument: %s\n"), argv[OPTIND]); usage(); + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('f'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_fs_type_print(stderr); @@ -213,7 +227,7 @@ main(int argc, char **argv1) image = argv[OPTIND]; if ((img = tsk_img_open(argc - OPTIND, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -231,7 +245,7 @@ main(int argc, char **argv1) image = argv[OPTIND]; if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -254,7 +268,7 @@ main(int argc, char **argv1) image = argv[OPTIND]; if ((img = tsk_img_open(argc - OPTIND, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -275,7 +289,7 @@ main(int argc, char **argv1) image = argv[OPTIND]; if ((img = tsk_img_open(argc - OPTIND, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -292,7 +306,7 @@ main(int argc, char **argv1) image = argv[OPTIND]; if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/fstools/istat.cpp b/tools/fstools/istat.cpp index 0b21b6aba..afef35438 100644 --- a/tools/fstools/istat.cpp +++ b/tools/fstools/istat.cpp @@ -30,16 +30,18 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-b num] [-f fstype] [-i imgtype] [-o imgoffset] [-z zone] [-s seconds] [-vV] image inum\n"), + ("usage: %s [-B num] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] [-z zone] [-s seconds] [-vV] image inum\n"), progname); tsk_fprintf(stderr, - "\t-b num: force the display of NUM address of block pointers\n"); + "\t-B num: force the display of NUM address of block pointers\n"); tsk_fprintf(stderr, "\t-z zone: time zone of original machine (i.e. EST5EDT or GMT)\n"); tsk_fprintf(stderr, "\t-s seconds: Time skew of original machine (in seconds)\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-f fstype: File system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, @@ -65,9 +67,10 @@ main(int argc, char **argv1) TSK_TCHAR *cp; int32_t sec_skew = 0; - /* When > 0 this is the number of blocks to print, used for -b arg */ + /* When > 0 this is the number of blocks to print, used for -B arg */ TSK_DADDR_T numblock = 0; TSK_TCHAR **argv; + unsigned int ssize = 0; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -83,14 +86,14 @@ main(int argc, char **argv1) progname = argv[0]; setlocale(LC_ALL, ""); - while ((ch = GETOPT(argc, argv, _TSK_T("b:f:i:o:s:vVz:"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("b:B:f:i:o:s:vVz:"))) > 0) { switch (ch) { case _TSK_T('?'): default: TFPRINTF(stderr, _TSK_T("Invalid argument: %s\n"), argv[OPTIND]); usage(); - case _TSK_T('b'): + case _TSK_T('B'): numblock = TSTRTOULL(OPTARG, &cp, 0); if (*cp || *cp == *OPTARG || numblock < 1) { TFPRINTF(stderr, @@ -100,6 +103,16 @@ main(int argc, char **argv1) usage(); } break; + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('f'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_fs_type_print(stderr); @@ -175,7 +188,7 @@ main(int argc, char **argv1) */ if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/fstools/jcat.cpp b/tools/fstools/jcat.cpp index eb7de4839..017c6af90 100644 --- a/tools/fstools/jcat.cpp +++ b/tools/fstools/jcat.cpp @@ -24,13 +24,15 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-f fstype] [-i imgtype] [-o imgoffset] [-vV] image [images] [inode] blk\n"), + ("usage: %s [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] [-vV] image [images] [inode] blk\n"), progname); tsk_fprintf(stderr, "\tblk: The journal block to view\n"); tsk_fprintf(stderr, "\tinode: The file system inode where the journal is located\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-f fstype: File system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, @@ -56,6 +58,7 @@ main(int argc, char **argv1) TSK_DADDR_T blk; TSK_TCHAR *cp; TSK_TCHAR **argv; + unsigned int ssize = 0; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -71,13 +74,23 @@ main(int argc, char **argv1) progname = argv[0]; setlocale(LC_ALL, ""); - while ((ch = GETOPT(argc, argv, _TSK_T("f:i:o:vV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("b:f:i:o:vV"))) > 0) { switch (ch) { case _TSK_T('?'): default: TFPRINTF(stderr, _TSK_T("Invalid argument: %s\n"), argv[OPTIND]); usage(); + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('f'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_fs_type_print(stderr); @@ -134,7 +147,7 @@ main(int argc, char **argv1) /* Not a number therefore an image */ if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -157,7 +170,7 @@ main(int argc, char **argv1) else { if ((img = tsk_img_open(argc - OPTIND - 2, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/fstools/jls.cpp b/tools/fstools/jls.cpp index 65b24040a..efd2bc8ec 100644 --- a/tools/fstools/jls.cpp +++ b/tools/fstools/jls.cpp @@ -20,10 +20,12 @@ usage() { TFPRINTF(stderr, _TSK_T - ("usage: %s [-f fstype] [-i imgtype] [-o imgoffset] [-vV] image [inode]\n"), + ("usage: %s [-f fstype] [-i imgtype] [-b dev_sector_size] [-o imgoffset] [-vV] image [inode]\n"), progname); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-f fstype: File system type (use '-f list' for supported types)\n"); tsk_fprintf(stderr, @@ -47,6 +49,8 @@ main(int argc, char **argv1) TSK_INUM_T inum; int ch; TSK_TCHAR **argv; + unsigned int ssize = 0; + TSK_TCHAR *cp; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -62,13 +66,23 @@ main(int argc, char **argv1) progname = argv[0]; setlocale(LC_ALL, ""); - while ((ch = GETOPT(argc, argv, _TSK_T("f:i:o:vV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("b:f:i:o:vV"))) > 0) { switch (ch) { case _TSK_T('?'): default: TFPRINTF(stderr, _TSK_T("Invalid argument: %s\n"), argv[OPTIND]); usage(); + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('f'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_fs_type_print(stderr); @@ -123,7 +137,7 @@ main(int argc, char **argv1) /* Not an inode at the end */ if ((img = tsk_img_open(argc - OPTIND, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } @@ -147,7 +161,7 @@ main(int argc, char **argv1) else { if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/imgtools/img_cat.cpp b/tools/imgtools/img_cat.cpp index 672e23c13..af5b838fe 100644 --- a/tools/imgtools/img_cat.cpp +++ b/tools/imgtools/img_cat.cpp @@ -19,10 +19,14 @@ static TSK_TCHAR *progname; static void usage() { - TFPRINTF(stderr, _TSK_T("usage: %s [-vV] [-i imgtype] image\n"), + TFPRINTF(stderr, + _TSK_T + ("usage: %s [-vV] [-i imgtype] [-b dev_sector_size] image\n"), progname); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use 'i list' for supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-v: verbose output to stderr\n"); tsk_fprintf(stderr, "\t-V: Print version\n"); @@ -39,6 +43,8 @@ main(int argc, char **argv1) TSK_OFF_T done; ssize_t cnt; TSK_TCHAR **argv; + unsigned int ssize = 0; + TSK_TCHAR *cp; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -53,14 +59,23 @@ main(int argc, char **argv1) progname = argv[0]; - while ((ch = GETOPT(argc, argv, _TSK_T("i:vV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("b:i:vV"))) > 0) { switch (ch) { case _TSK_T('?'): default: TFPRINTF(stderr, _TSK_T("Invalid argument: %s\n"), argv[OPTIND]); usage(); - + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('i'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_img_type_print(stderr); @@ -91,7 +106,8 @@ main(int argc, char **argv1) } if ((img = - tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype)) == NULL) { + tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype, + ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/imgtools/img_stat.cpp b/tools/imgtools/img_stat.cpp index 5cd9f8c36..11c79725d 100644 --- a/tools/imgtools/img_stat.cpp +++ b/tools/imgtools/img_stat.cpp @@ -15,11 +15,15 @@ static TSK_TCHAR *progname; static void usage() { - TFPRINTF(stderr, _TSK_T("usage: %s [-tvV] [-i imgtype] image\n"), + TFPRINTF(stderr, + _TSK_T + ("usage: %s [-tvV] [-i imgtype] [-b dev_sector_size] image\n"), progname); tsk_fprintf(stderr, "\t-t: display type only\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for list of supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-v: verbose output to stderr\n"); tsk_fprintf(stderr, "\t-V: Print version\n"); @@ -35,6 +39,8 @@ main(int argc, char **argv1) int ch; uint8_t type = 0; TSK_TCHAR **argv; + unsigned int ssize = 0; + TSK_TCHAR *cp; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -49,14 +55,23 @@ main(int argc, char **argv1) progname = argv[0]; - while ((ch = GETOPT(argc, argv, _TSK_T("i:tvV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("b:i:tvV"))) > 0) { switch (ch) { case _TSK_T('?'): default: TFPRINTF(stderr, _TSK_T("Invalid argument: %s\n"), argv[OPTIND]); usage(); - + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('i'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_img_type_print(stderr); @@ -91,7 +106,8 @@ main(int argc, char **argv1) } if ((img = - tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype)) == NULL) { + tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype, + ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/srchtools/sigfind.cpp b/tools/srchtools/sigfind.cpp index 53a025ba8..c7b67927b 100644 --- a/tools/srchtools/sigfind.cpp +++ b/tools/srchtools/sigfind.cpp @@ -272,7 +272,7 @@ main(int argc, char **argv) if ((img_info = tsk_img_open_utf8_sing(argv[optind], - TSK_IMG_TYPE_DETECT)) == NULL) { + TSK_IMG_TYPE_DETECT, 0)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/vstools/mmcat.cpp b/tools/vstools/mmcat.cpp index a34b5a010..7d9a300f4 100644 --- a/tools/vstools/mmcat.cpp +++ b/tools/vstools/mmcat.cpp @@ -18,12 +18,14 @@ usage() { TFPRINTF(stderr, _TSK_T - ("%s [-i imgtype] [-o imgoffset] [-vV] [-t vstype] image [images] part_num\n"), + ("%s [-i imgtype] [-b dev_sector_size] [-o imgoffset] [-vV] [-t vstype] image [images] part_num\n"), progname); tsk_fprintf(stderr, "\t-t vstype: The type of partition system (use '-t list' for list of supported types)\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for list of supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-o imgoffset: Offset to the start of the volume that contains the partition system (in sectors)\n"); tsk_fprintf(stderr, "\t-v: verbose output\n"); @@ -46,6 +48,8 @@ main(int argc, char **argv1) const TSK_VS_PART_INFO *vs_part; char *buf; TSK_TCHAR **argv; + unsigned int ssize = 0; + TSK_TCHAR *cp; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -61,8 +65,18 @@ main(int argc, char **argv1) progname = argv[0]; - while ((ch = GETOPT(argc, argv, _TSK_T("i:o:t:vV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("b:i:o:t:vV"))) > 0) { switch (ch) { + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('i'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_img_type_print(stderr); @@ -118,7 +132,7 @@ main(int argc, char **argv1) /* open the image */ if ((img = tsk_img_open(argc - OPTIND - 1, &argv[OPTIND], - imgtype)) == NULL) { + imgtype, ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tools/vstools/mmls.cpp b/tools/vstools/mmls.cpp index 2e42d5fc8..fb7621c7e 100644 --- a/tools/vstools/mmls.cpp +++ b/tools/vstools/mmls.cpp @@ -24,15 +24,17 @@ usage() { TFPRINTF(stderr, _TSK_T - ("%s [-i imgtype] [-o imgoffset] [-brvV] [-aAmM] [-t vstype] image [images]\n"), + ("%s [-i imgtype] [-b dev_sector_size] [-o imgoffset] [-BrvV] [-aAmM] [-t vstype] image [images]\n"), progname); tsk_fprintf(stderr, "\t-t vstype: The type of volume system (use '-t list' for list of supported types)\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for list supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-o imgoffset: Offset to the start of the volume that contains the partition system (in sectors)\n"); - tsk_fprintf(stderr, "\t-b: print the rounded length in bytes\n"); + tsk_fprintf(stderr, "\t-B: print the rounded length in bytes\n"); tsk_fprintf(stderr, "\t-r: recurse and look for other partition tables in partitions (DOS Only)\n"); tsk_fprintf(stderr, "\t-v: verbose output\n"); @@ -153,6 +155,8 @@ main(int argc, char **argv1) TSK_VS_TYPE_ENUM vstype = TSK_VS_TYPE_DETECT; uint8_t hide_meta = 0; TSK_TCHAR **argv; + unsigned int ssize = 0; + TSK_TCHAR *cp; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -168,7 +172,7 @@ main(int argc, char **argv1) progname = argv[0]; - while ((ch = GETOPT(argc, argv, _TSK_T("aAbi:mMo:rt:vV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("aAb:Bi:mMo:rt:vV"))) > 0) { switch (ch) { case _TSK_T('a'): flags |= TSK_VS_PART_FLAG_ALLOC; @@ -176,9 +180,19 @@ main(int argc, char **argv1) case _TSK_T('A'): flags |= TSK_VS_PART_FLAG_UNALLOC; break; - case _TSK_T('b'): + case _TSK_T('B'): print_bytes = 1; break; + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('i'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_img_type_print(stderr); @@ -251,7 +265,7 @@ main(int argc, char **argv1) } /* open the image */ - img = tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype); + img = tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype, ssize); if (img == NULL) { tsk_error_print(stderr); diff --git a/tools/vstools/mmstat.cpp b/tools/vstools/mmstat.cpp index e11857ae9..50ef70a46 100644 --- a/tools/vstools/mmstat.cpp +++ b/tools/vstools/mmstat.cpp @@ -19,12 +19,14 @@ usage() { TFPRINTF(stderr, _TSK_T - ("%s [-i imgtype] [-o imgoffset] [-vV] [-t vstype] image [images]\n"), + ("%s [-i imgtype] [-b dev_sector_size] [-o imgoffset] [-vV] [-t vstype] image [images]\n"), progname); tsk_fprintf(stderr, "\t-t vstype: The volume system type (use '-t list' for list of supported types)\n"); tsk_fprintf(stderr, "\t-i imgtype: The format of the image file (use '-i list' for list of supported types)\n"); + tsk_fprintf(stderr, + "\t-b dev_sector_size: The size (in bytes) of the device sectors\n"); tsk_fprintf(stderr, "\t-o imgoffset: Offset to the start of the volume that contains the partition system (in sectors)\n"); tsk_fprintf(stderr, "\t-v: verbose output\n"); @@ -49,6 +51,8 @@ main(int argc, char **argv1) TSK_OFF_T imgoff = 0; TSK_IMG_INFO *img; TSK_TCHAR **argv; + unsigned int ssize = 0; + TSK_TCHAR *cp; #ifdef TSK_WIN32 // On Windows, get the wide arguments (mingw doesn't support wmain) @@ -63,8 +67,18 @@ main(int argc, char **argv1) progname = argv[0]; - while ((ch = GETOPT(argc, argv, _TSK_T("i:o:t:vV"))) > 0) { + while ((ch = GETOPT(argc, argv, _TSK_T("b:i:o:t:vV"))) > 0) { switch (ch) { + case _TSK_T('b'): + ssize = (unsigned int) TSTRTOUL(OPTARG, &cp, 0); + if (*cp || *cp == *OPTARG || ssize < 1) { + TFPRINTF(stderr, + _TSK_T + ("invalid argument: sector size must be positive: %s\n"), + OPTARG); + usage(); + } + break; case _TSK_T('i'): if (TSTRCMP(OPTARG, _TSK_T("list")) == 0) { tsk_img_type_print(stderr); @@ -118,7 +132,8 @@ main(int argc, char **argv1) /* open the image */ if ((img = - tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype)) == NULL) { + tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype, + ssize)) == NULL) { tsk_error_print(stderr); exit(1); } diff --git a/tsk3/fs/ext2fs.c b/tsk3/fs/ext2fs.c index 2a341f5b6..4d8a69ea3 100644 --- a/tsk3/fs/ext2fs.c +++ b/tsk3/fs/ext2fs.c @@ -2149,7 +2149,7 @@ ext2fs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, /* * Calculate the block info */ - fs->dev_bsize = EXT2FS_DEV_BSIZE; + fs->dev_bsize = img_info->sector_size; fs->block_count = tsk_getu32(fs->endian, ext2fs->fs->s_blocks_count); fs->first_block = 0; fs->last_block_act = fs->last_block = fs->block_count - 1; diff --git a/tsk3/fs/ext2fs_dent.c b/tsk3/fs/ext2fs_dent.c index 8f847d931..5156ed4f5 100644 --- a/tsk3/fs/ext2fs_dent.c +++ b/tsk3/fs/ext2fs_dent.c @@ -338,9 +338,9 @@ ext2fs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, retval_tmp = ext2fs_dent_parse_block(ext2fs, fs_dir, - (fs_dir->fs_file-> - meta->flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, - &list_seen, dirptr, len); + (fs_dir->fs_file->meta-> + flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, &list_seen, + dirptr, len); if (retval_tmp == TSK_ERR) { retval_final = TSK_ERR; diff --git a/tsk3/fs/fatfs.c b/tsk3/fs/fatfs.c index 118ce5341..d3df72b61 100644 --- a/tsk3/fs/fatfs.c +++ b/tsk3/fs/fatfs.c @@ -1389,7 +1389,7 @@ fatfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, } } - fs->dev_bsize = FATFS_DEV_BSIZE; + fs->dev_bsize = img_info->sector_size; /* Calculate block sizes and layout info */ // sector size diff --git a/tsk3/fs/fatfs_dent.c b/tsk3/fs/fatfs_dent.c index a437b9b42..9ce3412ae 100644 --- a/tsk3/fs/fatfs_dent.c +++ b/tsk3/fs/fatfs_dent.c @@ -289,8 +289,8 @@ fatfs_dent_parse_buf(FATFS_INFO * fatfs, TSK_FS_DIR * a_fs_dir, char *buf, /* Convert the UTF16 to UTF8 */ UTF16 *name16 = - (UTF16 *) ((uintptr_t) & lfninfo.name[lfninfo. - start + 1]); + (UTF16 *) ((uintptr_t) & lfninfo. + name[lfninfo.start + 1]); UTF8 *name8 = (UTF8 *) fs_name->name; retVal = diff --git a/tsk3/fs/ffs.c b/tsk3/fs/ffs.c index 3887cfa42..5b6326e46 100644 --- a/tsk3/fs/ffs.c +++ b/tsk3/fs/ffs.c @@ -1947,7 +1947,7 @@ ffs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, TSK_FS_TYPE_ENUM ftype) fs->offset = offset; /* Both sbs are the same size */ - len = roundup(sizeof(ffs_sb1), FFS_DEV_BSIZE); + len = roundup(sizeof(ffs_sb1), img_info->sector_size); ffs->fs.sb1 = (ffs_sb1 *) tsk_malloc(len); if (ffs->fs.sb1 == NULL) { fs->tag = 0; @@ -2061,7 +2061,7 @@ ffs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, TSK_FS_TYPE_ENUM ftype) */ fs->first_block = 0; fs->last_block = fs->last_block_act = fs->block_count - 1; - fs->dev_bsize = FFS_DEV_BSIZE; + fs->dev_bsize = img_info->sector_size; // determine the last block we have in this image if ((TSK_DADDR_T) ((img_info->size - offset) / fs->block_size) < diff --git a/tsk3/fs/ffs_dent.c b/tsk3/fs/ffs_dent.c index 4c141ba3d..f0ec5d7f2 100644 --- a/tsk3/fs/ffs_dent.c +++ b/tsk3/fs/ffs_dent.c @@ -334,8 +334,8 @@ ffs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, retval_tmp = ffs_dent_parse_block(ffs, fs_dir, - (fs_dir->fs_file-> - meta->flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, + (fs_dir->fs_file->meta-> + flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, dirbuf + cidx * FFS_DIRBLKSIZ, len); if (retval_tmp == TSK_ERR) { diff --git a/tsk3/fs/fs_attr.c b/tsk3/fs/fs_attr.c index 58a73eab5..6d31ee8fd 100644 --- a/tsk3/fs/fs_attr.c +++ b/tsk3/fs/fs_attr.c @@ -786,8 +786,8 @@ tsk_fs_attr_walk_nonres(const TSK_FS_ATTR * fs_attr, /* If the address is too large then give an error */ if (addr + len_idx > fs->last_block) { - if (fs_attr->fs_file->meta-> - flags & TSK_FS_META_FLAG_UNALLOC) + if (fs_attr->fs_file-> + meta->flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; else tsk_errno = TSK_ERR_FS_BLK_NUM; @@ -1112,8 +1112,8 @@ tsk_fs_attr_read(const TSK_FS_ATTR * a_fs_attr, TSK_OFF_T a_offset, fprintf(stderr, "tsk_fs_attr_read_type: File %" PRIuINUM " has FILLER entry, using 0s\n", - (a_fs_attr->fs_file->meta) ? a_fs_attr->fs_file-> - meta->addr : 0); + (a_fs_attr->fs_file->meta) ? a_fs_attr-> + fs_file->meta->addr : 0); } // we return 0s for reads past the initsize (unless they want slack space) else if (((TSK_OFF_T) ((data_run_cur->offset + @@ -1125,8 +1125,9 @@ tsk_fs_attr_read(const TSK_FS_ATTR * a_fs_attr, TSK_OFF_T a_offset, fprintf(stderr, "tsk_fs_attr_read: Returning 0s for read past end of initsize (%" PRIuINUM ")\n", ((a_fs_attr->fs_file) - && (a_fs_attr->fs_file->meta)) ? a_fs_attr-> - fs_file->meta->addr : 0); + && (a_fs_attr->fs_file-> + meta)) ? a_fs_attr->fs_file->meta-> + addr : 0); } else { TSK_OFF_T fs_offset_b; diff --git a/tsk3/fs/fs_name.c b/tsk3/fs/fs_name.c index ea67c26db..09c7581d9 100644 --- a/tsk3/fs/fs_name.c +++ b/tsk3/fs/fs_name.c @@ -376,9 +376,8 @@ tsk_fs_name_print(FILE * hFile, const TSK_FS_FILE * fs_file, tsk_fprintf(hFile, "%s:\t", ((fs_file->meta) && (fs_file->meta->flags & TSK_FS_META_FLAG_ALLOC) - && (fs_file-> - name->flags & TSK_FS_NAME_FLAG_UNALLOC)) ? "(realloc)" : - ""); + && (fs_file->name-> + flags & TSK_FS_NAME_FLAG_UNALLOC)) ? "(realloc)" : ""); if ((print_path) && (a_path != NULL)) tsk_fprintf(hFile, "%s", a_path); @@ -517,9 +516,8 @@ tsk_fs_name_print_mac(FILE * hFile, const TSK_FS_FILE * fs_file, * allocated, then add realloc comment */ if (fs_file->name->flags & TSK_FS_NAME_FLAG_UNALLOC) tsk_fprintf(hFile, " (deleted%s)", ((fs_file->meta) - && (fs_file-> - meta->flags & TSK_FS_META_FLAG_ALLOC)) ? "-realloc" : - ""); + && (fs_file->meta-> + flags & TSK_FS_META_FLAG_ALLOC)) ? "-realloc" : ""); /* inode */ tsk_fprintf(hFile, "|%" PRIuINUM, fs_file->name->meta_addr); diff --git a/tsk3/fs/iso9660.c b/tsk3/fs/iso9660.c index 47b5d698b..1077be37b 100644 --- a/tsk3/fs/iso9660.c +++ b/tsk3/fs/iso9660.c @@ -456,8 +456,8 @@ iso9660_load_inodes_dir(TSK_FS_INFO * fs, TSK_OFF_T a_offs, int count, tsk_UTF16toUTF8(fs->endian, (const UTF16 **) &name16, (UTF16 *) & buf[b_offs + dentry->fi_len], &name8, - (UTF8 *) ((uintptr_t) & in_node-> - inode.fn[ISO9660_MAXNAMLEN_STD]), + (UTF8 *) ((uintptr_t) & in_node->inode. + fn[ISO9660_MAXNAMLEN_STD]), TSKlenientConversion); if (retVal != TSKconversionOK) { if (tsk_verbose) @@ -1965,7 +1965,7 @@ load_vol_desc(TSK_FS_INFO * fs) iso->pvd = NULL; iso->svd = NULL; fs->block_size = 0; - fs->dev_bsize = 512; + fs->dev_bsize = fs->img_info->sector_size; #if 0 b = (iso_bootrec *) tsk_malloc(sizeof(iso_bootrec)); diff --git a/tsk3/fs/nofs_misc.c b/tsk3/fs/nofs_misc.c index ad5a950c9..7a34d0a3a 100644 --- a/tsk3/fs/nofs_misc.c +++ b/tsk3/fs/nofs_misc.c @@ -58,8 +58,8 @@ tsk_fs_nofs_make_data_run(TSK_FS_FILE * a_fs_file) tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "Illegal analysis method for %s data ", - (a_fs_file->fs_info) ? tsk_fs_type_toname(a_fs_file-> - fs_info->ftype) : ""); + (a_fs_file->fs_info) ? tsk_fs_type_toname(a_fs_file->fs_info-> + ftype) : ""); return 1; } diff --git a/tsk3/fs/ntfs.c b/tsk3/fs/ntfs.c index b37292472..60fbdd752 100644 --- a/tsk3/fs/ntfs.c +++ b/tsk3/fs/ntfs.c @@ -1220,8 +1220,8 @@ ntfs_attr_walk_special(const TSK_FS_ATTR * fs_attr, if (fs_attr_run->addr != 0) { tsk_error_reset(); - if (fs_attr->fs_file-> - meta->flags & TSK_FS_META_FLAG_UNALLOC) + if (fs_attr->fs_file->meta-> + flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; else tsk_errno = TSK_ERR_FS_GENFS; @@ -1248,8 +1248,8 @@ ntfs_attr_walk_special(const TSK_FS_ATTR * fs_attr, if (addr > fs->last_block) { tsk_error_reset(); - if (fs_attr->fs_file-> - meta->flags & TSK_FS_META_FLAG_UNALLOC) + if (fs_attr->fs_file->meta-> + flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; else tsk_errno = TSK_ERR_FS_BLK_NUM; @@ -1289,8 +1289,8 @@ ntfs_attr_walk_special(const TSK_FS_ATTR * fs_attr, TSK_FS_BLOCK_FLAG_COMP; retval = is_clustalloc(ntfs, comp_unit[i]); if (retval == -1) { - if (fs_attr->fs_file-> - meta->flags & TSK_FS_META_FLAG_UNALLOC) + if (fs_attr->fs_file->meta-> + flags & TSK_FS_META_FLAG_UNALLOC) tsk_errno = TSK_ERR_FS_RECOVER; free(comp_unit); ntfs_uncompress_done(&comp); @@ -4328,7 +4328,7 @@ ntfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, ntfs->bmap_buf = NULL; /* Read the boot sector */ - len = roundup(sizeof(ntfs_sb), NTFS_DEV_BSIZE); + len = roundup(sizeof(ntfs_sb), img_info->sector_size); ntfs->fs = (ntfs_sb *) tsk_malloc(len); if (ntfs->fs == NULL) { fs->tag = 0; @@ -4418,7 +4418,7 @@ ntfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, fs->last_block = fs->last_block_act = fs->block_count - 1; fs->block_size = ntfs->csize_b; - fs->dev_bsize = NTFS_DEV_BSIZE; + fs->dev_bsize = img_info->sector_size; // determine the last block we have in this image if ((TSK_DADDR_T) ((img_info->size - offset) / fs->block_size) < diff --git a/tsk3/fs/ntfs_dent.c b/tsk3/fs/ntfs_dent.c index 78cce20b5..d6e74931a 100644 --- a/tsk3/fs/ntfs_dent.c +++ b/tsk3/fs/ntfs_dent.c @@ -991,8 +991,8 @@ ntfs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, /* process the list of index entries */ retval_tmp = ntfs_proc_idxentry(ntfs, fs_dir, - (fs_dir->fs_file-> - meta->flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, idxe, + (fs_dir->fs_file->meta-> + flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, idxe, list_len, tsk_getu32(a_fs->endian, idxelist->seqend_off) - tsk_getu32(a_fs->endian, idxelist->begin_off)); @@ -1056,8 +1056,8 @@ ntfs_dir_open_meta(TSK_FS_INFO * a_fs, TSK_FS_DIR ** a_fs_dir, /* process the list of index entries */ retval_tmp = ntfs_proc_idxentry(ntfs, fs_dir, - (fs_dir->fs_file-> - meta->flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, idxe, + (fs_dir->fs_file->meta-> + flags & TSK_FS_META_FLAG_UNALLOC) ? 1 : 0, idxe, list_len, tsk_getu32(a_fs->endian, idxelist->seqend_off) - tsk_getu32(a_fs->endian, idxelist->begin_off)); @@ -1368,8 +1368,8 @@ ntfs_find_file(TSK_FS_INFO * fs, TSK_INUM_T inode_toid, uint32_t type_toid, fs_file->name->meta_seq = 0; fs_file->name->flags = ((tsk_getu16(fs->endian, - ntfs-> - mft->flags) & NTFS_MFT_INUSE) ? TSK_FS_NAME_FLAG_ALLOC : + ntfs->mft-> + flags) & NTFS_MFT_INUSE) ? TSK_FS_NAME_FLAG_ALLOC : TSK_FS_NAME_FLAG_UNALLOC); memset(&dinfo, 0, sizeof(NTFS_DINFO)); diff --git a/tsk3/fs/rawfs.c b/tsk3/fs/rawfs.c index 77a1c90ad..156a89228 100644 --- a/tsk3/fs/rawfs.c +++ b/tsk3/fs/rawfs.c @@ -68,7 +68,7 @@ rawfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset) fs->first_block = 0; fs->last_block = fs->last_block_act = fs->block_count - 1; fs->block_size = 512; - fs->dev_bsize = 512; + fs->dev_bsize = img_info->sector_size; /* Pointer to functions */ fs->close = tsk_fs_nofs_close; diff --git a/tsk3/fs/swapfs.c b/tsk3/fs/swapfs.c index 0c9954c82..a2ea14c9c 100644 --- a/tsk3/fs/swapfs.c +++ b/tsk3/fs/swapfs.c @@ -66,7 +66,7 @@ swapfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset) fs->first_block = 0; fs->last_block = fs->last_block_act = fs->block_count - 1; fs->block_size = 4096; - fs->dev_bsize = 512; + fs->dev_bsize = img_info->sector_size; /* Pointers to functions */ fs->close = tsk_fs_nofs_close; diff --git a/tsk3/fs/tsk_ext2fs.h b/tsk3/fs/tsk_ext2fs.h index 929b91687..433424fea 100644 --- a/tsk3/fs/tsk_ext2fs.h +++ b/tsk3/fs/tsk_ext2fs.h @@ -37,7 +37,6 @@ extern "C" { #define EXT2FS_MAXPATHLEN 4096 #define EXT2FS_MIN_BLOCK_SIZE 1024 #define EXT2FS_MAX_BLOCK_SIZE 4096 -#define EXT2FS_DEV_BSIZE 512 #define EXT2FS_FILE_CONTENT_LEN ((EXT2FS_NDADDR + EXT2FS_NIADDR) * sizeof(TSK_DADDR_T)) /* diff --git a/tsk3/fs/tsk_fatfs.h b/tsk3/fs/tsk_fatfs.h index 73fb7e745..dcabe01b0 100644 --- a/tsk3/fs/tsk_fatfs.h +++ b/tsk3/fs/tsk_fatfs.h @@ -46,9 +46,6 @@ extern "C" { #define FATFS_FAT2NAME "$FAT2" - - -#define FATFS_DEV_BSIZE 512 #define FATFS_SBOFF 0 #define FATFS_FS_MAGIC 0xaa55 #define FATFS_MAXNAMLEN 256 diff --git a/tsk3/fs/tsk_ffs.h b/tsk3/fs/tsk_ffs.h index 60be5486e..7a176b80b 100644 --- a/tsk3/fs/tsk_ffs.h +++ b/tsk3/fs/tsk_ffs.h @@ -47,11 +47,6 @@ extern "C" { #define FFS_FILE_CONTENT_LEN ((FFS_NDADDR + FFS_NIADDR) * sizeof(TSK_DADDR_T)) - - -#define FFS_DEV_BSIZE 512 - - typedef struct { uint8_t dir_num[4]; uint8_t blk_free[4]; diff --git a/tsk3/fs/tsk_ntfs.h b/tsk3/fs/tsk_ntfs.h index 3ffcae401..a2f8b8488 100644 --- a/tsk3/fs/tsk_ntfs.h +++ b/tsk3/fs/tsk_ntfs.h @@ -29,7 +29,6 @@ extern "C" { //#define NTFS_FS_MAGIC 0x5346544E /* "NTFS" in little endian */ #define NTFS_FS_MAGIC 0xAA55 -#define NTFS_DEV_BSIZE 512 #define NTFS_MAXNAMLEN 256 #define NTFS_MAXNAMLEN_UTF8 4 * NTFS_MAXNAMLEN diff --git a/tsk3/img/aff.c b/tsk3/img/aff.c index 2f4b147d8..ffff038b9 100644 --- a/tsk3/img/aff.c +++ b/tsk3/img/aff.c @@ -221,7 +221,7 @@ aff_close(TSK_IMG_INFO * img_info) TSK_IMG_INFO * -aff_open(const char *const images[]) +aff_open(const char *const images[], unsigned int a_ssize) { IMG_AFF_INFO *aff_info; TSK_IMG_INFO *img_info; @@ -238,6 +238,9 @@ aff_open(const char *const images[]) img_info->close = aff_close; img_info->imgstat = aff_imgstat; + img_info->sector_size = 512; + if (a_ssize) + img_info->sector_size = a_ssize; type = af_identify_file_type(images[0], 1); if ((type == AF_IDENTIFY_ERR) || (type == AF_IDENTIFY_NOEXIST)) { diff --git a/tsk3/img/aff.h b/tsk3/img/aff.h index 172581c33..1ae7e1e03 100644 --- a/tsk3/img/aff.h +++ b/tsk3/img/aff.h @@ -19,7 +19,8 @@ #include <afflib/afflib.h> #include <afflib/afflib_i.h> -extern TSK_IMG_INFO *aff_open(const char *const images[]); +extern TSK_IMG_INFO *aff_open(const char *const images[], + unsigned int a_ssize); /** \internal * Stores AFF-specific data diff --git a/tsk3/img/ewf.c b/tsk3/img/ewf.c index a54fc140a..0233bddeb 100644 --- a/tsk3/img/ewf.c +++ b/tsk3/img/ewf.c @@ -124,7 +124,8 @@ img_file_header_signature_ncmp(const char *filename, TSK_IMG_INFO * -ewf_open(int num_img, const TSK_TCHAR * const images[]) +ewf_open(int num_img, const TSK_TCHAR * const images[], + unsigned int a_ssize) { IMG_EWF_INFO *ewf_info; TSK_IMG_INFO *img_info; @@ -218,6 +219,10 @@ ewf_open(int num_img, const TSK_TCHAR * const images[]) ewf_info->md5hash_isset = 1; } #endif + img_info->sector_size = 512; + if (a_ssize) + img_info->sector_size = a_ssize; + img_info->itype = TSK_IMG_TYPE_EWF_EWF; img_info->read = ewf_image_read; diff --git a/tsk3/img/ewf.h b/tsk3/img/ewf.h index 19dca3f4a..88b6b8d5a 100644 --- a/tsk3/img/ewf.h +++ b/tsk3/img/ewf.h @@ -30,7 +30,8 @@ extern "C" { #endif - extern TSK_IMG_INFO *ewf_open(int, const TSK_TCHAR * const images[]); + extern TSK_IMG_INFO *ewf_open(int, const TSK_TCHAR * const images[], + unsigned int a_ssize); typedef struct { TSK_IMG_INFO img_info; diff --git a/tsk3/img/img_open.c b/tsk3/img/img_open.c index 2188f365b..d4d78dca9 100644 --- a/tsk3/img/img_open.c +++ b/tsk3/img/img_open.c @@ -39,14 +39,16 @@ typedef int bool; * * @param a_image The path to the image file * @param type The disk image type (can be autodetection) + * @param a_ssize Size of device sector in bytes (or 0 for default) * * @return Pointer to TSK_IMG_INFO or NULL on error */ TSK_IMG_INFO * -tsk_img_open_sing(const TSK_TCHAR * a_image, TSK_IMG_TYPE_ENUM type) +tsk_img_open_sing(const TSK_TCHAR * a_image, TSK_IMG_TYPE_ENUM type, + unsigned int a_ssize) { const TSK_TCHAR *const a = a_image; - return tsk_img_open(1, &a, type); + return tsk_img_open(1, &a, type, a_ssize); } @@ -64,12 +66,14 @@ tsk_img_open_sing(const TSK_TCHAR * a_image, TSK_IMG_TYPE_ENUM type) * @param images The path to the image files (the number of files must * be equal to num_img and they must be in a sorted order) * @param type The disk image type (can be autodetection) + * @param a_ssize Size of device sector in bytes (or 0 for default) * * @return Pointer to TSK_IMG_INFO or NULL on error */ TSK_IMG_INFO * tsk_img_open(int num_img, - const TSK_TCHAR * const images[], TSK_IMG_TYPE_ENUM type) + const TSK_TCHAR * const images[], TSK_IMG_TYPE_ENUM type, + unsigned int a_ssize) { TSK_IMG_INFO *img_info = NULL; @@ -105,7 +109,7 @@ tsk_img_open(int num_img, /* Try the non-raw formats first */ #if HAVE_LIBAFFLIB - if ((img_info = aff_open(images)) != NULL) { + if ((img_info = aff_open(images, a_ssize)) != NULL) { /* we don't allow the "ANY" when autodetect is used because * we only want to detect the tested formats. */ if (img_info->itype == TSK_IMG_TYPE_AFF_ANY) { @@ -122,7 +126,7 @@ tsk_img_open(int num_img, #endif #if HAVE_LIBEWF - if ((img_info = ewf_open(num_img, images)) != NULL) { + if ((img_info = ewf_open(num_img, images, a_ssize)) != NULL) { if (set == NULL) { set = "EWF"; img_set = img_info; @@ -146,7 +150,7 @@ tsk_img_open(int num_img, /* We'll use the raw format */ if (num_img == 1) { - if ((img_info = raw_open(images[0])) != NULL) { + if ((img_info = raw_open(images[0], a_ssize)) != NULL) { return img_info; } else if (tsk_errno) { @@ -154,7 +158,7 @@ tsk_img_open(int num_img, } } else { - if ((img_info = split_open(num_img, images)) != NULL) { + if ((img_info = split_open(num_img, images, a_ssize)) != NULL) { return img_info; } else if (tsk_errno) { @@ -202,9 +206,9 @@ tsk_img_open(int num_img, /* If we have more than one image name, and raw was the only * type given, then use split */ if (num_img > 1) - img_info = split_open(num_img, images); + img_info = split_open(num_img, images, a_ssize); else - img_info = raw_open(images[0]); + img_info = raw_open(images[0], a_ssize); break; case TSK_IMG_TYPE_RAW_SPLIT: @@ -212,9 +216,9 @@ tsk_img_open(int num_img, /* If only one image file is given, and only one type was * given then use raw */ if (num_img == 1) - img_info = raw_open(images[0]); + img_info = raw_open(images[0], a_ssize); else - img_info = split_open(num_img, images); + img_info = split_open(num_img, images, a_ssize); break; #if HAVE_LIBAFFLIB @@ -222,13 +226,13 @@ tsk_img_open(int num_img, case TSK_IMG_TYPE_AFF_AFD: case TSK_IMG_TYPE_AFF_AFM: case TSK_IMG_TYPE_AFF_ANY: - img_info = aff_open(images); + img_info = aff_open(images, a_ssize); break; #endif #if HAVE_LIBEWF case TSK_IMG_TYPE_EWF_EWF: - img_info = ewf_open(num_img, images); + img_info = ewf_open(num_img, images, a_ssize); break; #endif @@ -252,14 +256,16 @@ tsk_img_open(int num_img, * * @param a_image The UTF-8 path to the image file * @param type The disk image type (can be autodetection) + * @param a_ssize Size of device sector in bytes (or 0 for default) * * @return Pointer to TSK_IMG_INFO or NULL on error */ TSK_IMG_INFO * -tsk_img_open_utf8_sing(const char *a_image, TSK_IMG_TYPE_ENUM type) +tsk_img_open_utf8_sing(const char *a_image, TSK_IMG_TYPE_ENUM type, + unsigned int a_ssize) { const char *const a = a_image; - return tsk_img_open_utf8(1, &a, type); + return tsk_img_open_utf8(1, &a, type, a_ssize); } @@ -273,12 +279,13 @@ tsk_img_open_utf8_sing(const char *a_image, TSK_IMG_TYPE_ENUM type) * @param images The path to the UTF-8 encoded image files (the number of files must * be equal to num_img and they must be in a sorted order) * @param type The disk image type (can be autodetection) + * @param a_ssize Size of device sector in bytes (or 0 for default) * * @return Pointer to TSK_IMG_INFO or NULL on error */ TSK_IMG_INFO * tsk_img_open_utf8(int num_img, const char *const images[], - TSK_IMG_TYPE_ENUM type) + TSK_IMG_TYPE_ENUM type, unsigned int a_ssize) { #ifdef TSK_WIN32 { @@ -339,7 +346,7 @@ tsk_img_open_utf8(int num_img, const char *const images[], return retval; } #else - return tsk_img_open(num_img, images, type); + return tsk_img_open(num_img, images, type, a_ssize); #endif } diff --git a/tsk3/img/raw.c b/tsk3/img/raw.c index d345087c3..91b134852 100644 --- a/tsk3/img/raw.c +++ b/tsk3/img/raw.c @@ -142,10 +142,11 @@ raw_close(TSK_IMG_INFO * img_info) * \internal * Open the file as a raw image. * @param image Path to disk image to open. + * @param a_ssize Size of device sector in bytes (or 0 for default) * @returns NULL on error. */ TSK_IMG_INFO * -raw_open(const TSK_TCHAR * image) +raw_open(const TSK_TCHAR * image, unsigned int a_ssize) { IMG_RAW_INFO *raw_info; TSK_IMG_INFO *img_info; @@ -163,6 +164,10 @@ raw_open(const TSK_TCHAR * image) img_info->close = raw_close; img_info->imgstat = raw_imgstat; + img_info->sector_size = 512; + if (a_ssize) + img_info->sector_size = a_ssize; + #if defined(TSK_WIN32) || defined(__CYGWIN__) if ((image[0] == _TSK_T('\\')) diff --git a/tsk3/img/raw.h b/tsk3/img/raw.h index 2b0c1f5a5..7d2512cc3 100644 --- a/tsk3/img/raw.h +++ b/tsk3/img/raw.h @@ -18,7 +18,7 @@ extern "C" { #endif - extern TSK_IMG_INFO *raw_open(const TSK_TCHAR *); + extern TSK_IMG_INFO *raw_open(const TSK_TCHAR *, unsigned int a_ssize); typedef struct { TSK_IMG_INFO img_info; diff --git a/tsk3/img/split.c b/tsk3/img/split.c index 10f68f0a2..d76942866 100644 --- a/tsk3/img/split.c +++ b/tsk3/img/split.c @@ -331,11 +331,13 @@ split_close(TSK_IMG_INFO * img_info) * * @param num_img Number of images in set * @param images List of disk image paths (in sorted order) + * @param a_ssize Size of device sector in bytes (or 0 for default) * * @return NULL on error */ TSK_IMG_INFO * -split_open(int num_img, const TSK_TCHAR * const images[]) +split_open(int num_img, const TSK_TCHAR * const images[], + unsigned int a_ssize) { IMG_SPLIT_INFO *split_info; TSK_IMG_INFO *img_info; @@ -352,6 +354,10 @@ split_open(int num_img, const TSK_TCHAR * const images[]) img_info->close = split_close; img_info->imgstat = split_imgstat; + img_info->sector_size = 512; + if (a_ssize) + img_info->sector_size = a_ssize; + /* Open the files */ if ((split_info->cptr = (int *) tsk_malloc(num_img * sizeof(int))) == NULL) { diff --git a/tsk3/img/split.h b/tsk3/img/split.h index 4ae25f0c7..e189af69e 100644 --- a/tsk3/img/split.h +++ b/tsk3/img/split.h @@ -18,7 +18,8 @@ extern "C" { #endif - extern TSK_IMG_INFO *split_open(int, const TSK_TCHAR * const images[]); + extern TSK_IMG_INFO *split_open(int, const TSK_TCHAR * const images[], + unsigned int a_ssize); #define SPLIT_CACHE 15 diff --git a/tsk3/img/tsk_img.h b/tsk3/img/tsk_img.h index 93c4948c5..2dee6bfbf 100644 --- a/tsk3/img/tsk_img.h +++ b/tsk3/img/tsk_img.h @@ -81,6 +81,7 @@ extern "C" { TSK_IMG_TYPE_ENUM itype; ///< Type of disk image format TSK_OFF_T size; ///< Total size of image in bytes + unsigned int sector_size; ///< sector size of device in bytes (typically 512) char cache[TSK_IMG_INFO_CACHE_NUM][TSK_IMG_INFO_CACHE_LEN]; ///< read cache TSK_OFF_T cache_off[TSK_IMG_INFO_CACHE_NUM]; ///< starting byte offset of corresponding cache entry @@ -94,13 +95,13 @@ extern "C" { // open and close functions extern TSK_IMG_INFO *tsk_img_open_sing(const TSK_TCHAR * a_image, - TSK_IMG_TYPE_ENUM type); + TSK_IMG_TYPE_ENUM type, unsigned int); extern TSK_IMG_INFO *tsk_img_open(int, - const TSK_TCHAR * const images[], TSK_IMG_TYPE_ENUM); + const TSK_TCHAR * const images[], TSK_IMG_TYPE_ENUM, unsigned int); extern TSK_IMG_INFO *tsk_img_open_utf8_sing(const char *a_image, - TSK_IMG_TYPE_ENUM type); + TSK_IMG_TYPE_ENUM type, unsigned int); extern TSK_IMG_INFO *tsk_img_open_utf8(int num_img, - const char *const images[], TSK_IMG_TYPE_ENUM type); + const char *const images[], TSK_IMG_TYPE_ENUM type, unsigned int); extern void tsk_img_close(TSK_IMG_INFO *); diff --git a/tsk3/vs/bsd.c b/tsk3/vs/bsd.c index dd67cd9ca..ef8c93ef9 100644 --- a/tsk3/vs/bsd.c +++ b/tsk3/vs/bsd.c @@ -220,7 +220,7 @@ tsk_vs_bsd_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset) vs->part_list = NULL; vs->part_count = 0; vs->endian = 0; - vs->block_size = 512; + vs->block_size = img_info->sector_size; /* Assign functions */ vs->close = bsd_close; diff --git a/tsk3/vs/dos.c b/tsk3/vs/dos.c index 4aa31b98e..b8253f287 100644 --- a/tsk3/vs/dos.c +++ b/tsk3/vs/dos.c @@ -1025,7 +1025,7 @@ tsk_vs_dos_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset, uint8_t test) vs->part_list = NULL; vs->part_count = 0; vs->endian = 0; - vs->block_size = 512; + vs->block_size = img_info->sector_size; /* Assign functions */ vs->close = dos_close; diff --git a/tsk3/vs/gpt.c b/tsk3/vs/gpt.c index 0cd87049a..606660bc7 100644 --- a/tsk3/vs/gpt.c +++ b/tsk3/vs/gpt.c @@ -256,7 +256,7 @@ tsk_vs_gpt_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset) vs->part_list = NULL; vs->part_count = 0; vs->endian = 0; - vs->block_size = 512; + vs->block_size = img_info->sector_size; /* Assign functions */ vs->close = gpt_close; diff --git a/tsk3/vs/mac.c b/tsk3/vs/mac.c index ea4909866..1819b2e8e 100644 --- a/tsk3/vs/mac.c +++ b/tsk3/vs/mac.c @@ -179,7 +179,7 @@ tsk_vs_mac_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset) vs->part_list = NULL; vs->part_count = 0; vs->endian = 0; - vs->block_size = 512; + vs->block_size = img_info->sector_size; /* Assign functions */ vs->close = mac_close; diff --git a/tsk3/vs/sun.c b/tsk3/vs/sun.c index ca3457c90..ef32ae70f 100644 --- a/tsk3/vs/sun.c +++ b/tsk3/vs/sun.c @@ -340,7 +340,7 @@ tsk_vs_sun_open(TSK_IMG_INFO * img_info, TSK_DADDR_T offset) vs->part_list = NULL; vs->part_count = 0; vs->endian = 0; - vs->block_size = 512; + vs->block_size = img_info->sector_size; /* Assign functions */ vs->close = sun_close; -- GitLab