From c75dc0697c4244a27d2b69826ccd57a64fb5382f Mon Sep 17 00:00:00 2001 From: Konstantin Germanov Date: Wed, 29 Jun 2022 05:49:41 -0400 Subject: [PATCH] Add option dev_offset to ntfs-3g.probe --- src/ntfs-3g.probe.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ntfs-3g.probe.c b/src/ntfs-3g.probe.c index cb73aee4..05acec35 100644 --- a/src/ntfs-3g.probe.c +++ b/src/ntfs-3g.probe.c @@ -45,6 +45,7 @@ typedef enum { static struct options { probe_t probetype; char *device; + s64 dev_offset; } opts; static const char *EXEC_NAME = "ntfs-3g.probe"; @@ -55,13 +56,13 @@ static const char *usage_msg = "\n" "Copyright (C) 2007 Szabolcs Szakacsits\n" "\n" -"Usage: %s <--readonly|--readwrite> \n" +"Usage: %s <--readonly|--readwrite> <--dev_offset n> \n" "\n" "Example: ntfs-3g.probe --readwrite /dev/sda1\n" "\n" "%s"; -static int ntfs_open(const char *device) +static int ntfs_open(const char *device, const s64 dev_offset) { ntfs_volume *vol; unsigned long flags = 0; @@ -70,7 +71,7 @@ static int ntfs_open(const char *device) if (opts.probetype == PROBE_READONLY) flags |= NTFS_MNT_RDONLY; - vol = ntfs_mount(device, flags); + vol = ntfs_mount_ext(device, flags, dev_offset); if (!vol) ret = ntfs_volume_error(errno); @@ -89,11 +90,12 @@ static int parse_options(int argc, char *argv[]) { int c; - static const char *sopt = "-hrw"; + static const char *sopt = "-hrwo:"; static const struct option lopt[] = { { "readonly", no_argument, NULL, 'r' }, { "readwrite", no_argument, NULL, 'w' }, { "help", no_argument, NULL, 'h' }, + { "dev_offset", required_argument, NULL, 'o' }, { NULL, 0, NULL, 0 } }; @@ -125,6 +127,9 @@ static int parse_options(int argc, char *argv[]) case 'w': opts.probetype = PROBE_READWRITE; break; + case 'o': + opts.dev_offset = optarg ? strtoull(optarg, 0, 0) : 0; + break; default: ntfs_log_error("%s: Unknown option '%s'.\n", EXEC_NAME, argv[optind - 1]); @@ -156,7 +161,7 @@ int main(int argc, char *argv[]) exit(NTFS_VOLUME_SYNTAX_ERROR); } - err = ntfs_open(opts.device); + err = ntfs_open(opts.device, opts.dev_offset); free(opts.device); if (err)