summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c60
1 files changed, 55 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index 39ff0c9..5cde040 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,6 +27,8 @@
#include "scrounge.h"
#include "compat.h"
+#ifdef _WIN32
+
const char kPrintHelp[] = "\
usage: scrounge -l \n\
List all drive partition information. \n\
@@ -45,6 +47,28 @@ usage: scrounge [-d drive] [-m mftoffset] [-c clustersize] [-o outdir] start end
\n\
";
+#else /* Not WIN32 */
+
+const char kPrintHelp[] = "\
+usage: scrounge -l \n\
+ List all drive partition information. \n\
+ \n\
+usage: scrounge -s disk \n\
+ Search drive for NTFS partitions. \n\
+ \n\
+usage: scrounge [-m mftoffset] [-c clustersize] [-o outdir] disk start end \n\
+ Scrounge data from a partition \n\
+ -m Offset to mft (in sectors) \n\
+ -c Cluster size (in sectors, default of 8) \n\
+ -o Directory to put scrounged files in \n\
+ disk The raw disk partitios (ie: /dev/hda) \n\
+ start First sector of partition \n\
+ end Last sector of partition \n\
+ \n\
+";
+
+#endif
+
#define MODE_SCROUNGE 1
#define MODE_LIST 2
#define MODE_SEARCH 3
@@ -58,16 +82,22 @@ int main(int argc, char* argv[])
int temp = 0;
int mode = 0;
int raw = 0;
- int drive = 0;
partitioninfo pi;
char driveName[MAX_PATH];
+#ifdef _WIN32
+ int drive = 0;
+#endif
memset(&pi, 0, sizeof(pi));
/* TODO: We need to be able to autodetect the cluster size */
pi.cluster = 8;
+#ifdef _WIN32
while((ch = getopt(argc, argv, "c:d:hlm:o:s")) != -1)
+#else
+ while((ch = getopt(argc, argv, "c:hlm:o:s")) != -1)
+#endif
{
switch(ch)
{
@@ -86,6 +116,7 @@ int main(int argc, char* argv[])
}
break;
+#ifdef _WIN32
/* drive number */
case 'd':
{
@@ -98,6 +129,7 @@ int main(int argc, char* argv[])
drive = temp;
}
break;
+#endif
/* help mode */
case 'h':
@@ -156,6 +188,21 @@ int main(int argc, char* argv[])
argc -= optind;
argv += optind;
+#ifdef _WIN32
+ /* Under windows we format the drive number */
+ makeDriveName(driveName, drive);
+
+#else
+ /* Now when not under Windows, it's the drive name */
+ if(argc < 1)
+ errx(2, "must specify drive name");
+
+ driveName = argv[0];
+ argv++;
+ argc--;
+#endif
+
+
if(mode == MODE_SCROUNGE || mode == 0)
{
/* Get the sectors */
@@ -178,11 +225,10 @@ int main(int argc, char* argv[])
pi.end = temp;
- makeDriveName(driveName, drive);
-
- pi.device = open(driveName, _O_BINARY | _O_RDONLY);
+ /* Open the device */
+ pi.device = open(driveName, _O_BINARY | _O_RDONLY | OPEN_LARGE_OPTS);
if(pi.device == -1)
- err(1, "couldn't open drive");
+ err(1, "couldn't open drive: %s", driveName);
/* Use mft type search */
if(pi.mft != 0)
@@ -205,7 +251,11 @@ int main(int argc, char* argv[])
/* List partition and drive info */
if(mode == MODE_LIST)
+#ifdef _WIN32
scroungeList();
+#else
+ scroungeListDrive(driveName);
+#endif
/* Search for NTFS partitions */
if(mode == MODE_SEARCH)