mirror of https://github.com/vitalif/e2fsprogs
e2undo: add "-o offset" option to specify the filesystem offset
This is useful if the filesystem is located at an arbitrary offset instead of the beginning of a device or file. Signed-off-by: Marcus Huewe <suse-tux@gmx.de> Signed-off-by: Theodore Ts'o <tytso@mit.edu>debian
parent
abf70cdcc1
commit
6930537d52
|
@ -46,6 +46,11 @@ Display a usage message.
|
|||
.B \-n
|
||||
Dry-run; do not actually write blocks back to the filesystem.
|
||||
.TP
|
||||
.BI \-o " offset"
|
||||
Specify the filesystem's
|
||||
.I offset
|
||||
(in bytes) from the beginning of the device or file.
|
||||
.TP
|
||||
.B \-v
|
||||
Report which block we're currently replaying.
|
||||
.SH AUTHOR
|
||||
|
|
|
@ -292,6 +292,8 @@ int main(int argc, char *argv[])
|
|||
__u32 key_crc, blk_crc, hdr_crc;
|
||||
blk64_t lblk;
|
||||
ext2_filsys fs;
|
||||
__u64 offset;
|
||||
char opt_offset_string[40] = { 0 };
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
setlocale(LC_MESSAGES, "");
|
||||
|
@ -303,7 +305,7 @@ int main(int argc, char *argv[])
|
|||
add_error_table(&et_ext2_error_table);
|
||||
|
||||
prg_name = argv[0];
|
||||
while ((c = getopt(argc, argv, "fhnvz:")) != EOF) {
|
||||
while ((c = getopt(argc, argv, "fhno:vz:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'f':
|
||||
force = 1;
|
||||
|
@ -314,6 +316,16 @@ int main(int argc, char *argv[])
|
|||
case 'n':
|
||||
dry_run = 1;
|
||||
break;
|
||||
case 'o':
|
||||
offset = strtoull(optarg, &buf, 0);
|
||||
if (*buf) {
|
||||
com_err(prg_name, 0,
|
||||
_("illegal offset - %s"), optarg);
|
||||
exit(1);
|
||||
}
|
||||
/* used to indicate that an offset was specified */
|
||||
opt_offset_string[0] = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
|
@ -423,6 +435,17 @@ int main(int argc, char *argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
if (*opt_offset_string) {
|
||||
retval = snprintf(opt_offset_string, sizeof(opt_offset_string),
|
||||
"offset=%llu", offset);
|
||||
if (retval >= sizeof(opt_offset_string)) {
|
||||
/* should not happen... */
|
||||
com_err(prg_name, 0, _("specified offset is too large"));
|
||||
exit(1);
|
||||
}
|
||||
io_channel_set_options(channel, opt_offset_string);
|
||||
}
|
||||
|
||||
if (!force && check_filesystem(&undo_ctx, channel))
|
||||
exit(1);
|
||||
|
||||
|
|
Loading…
Reference in New Issue