mirror of
https://github.com/Lekensteyn/lglaf.git
synced 2024-11-14 19:35:41 -05:00
dump-file.py: allow custom size
Files like /proc/kmsg are reported as zero size. It can be useful to assume a larger size to avoid empty output. Some devices are locked down and do not support all shell commands. If you know the size (or just want to try to read 1 byte), then you can avoid executing shell commands.
This commit is contained in:
parent
69ba8fb578
commit
39c9872ca0
1 changed files with 6 additions and 1 deletions
|
@ -79,6 +79,8 @@ def open_local_writable(path):
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--debug", action='store_true', help="Enable debug messages")
|
parser.add_argument("--debug", action='store_true', help="Enable debug messages")
|
||||||
|
parser.add_argument("--size", type=int,
|
||||||
|
help="Override file size (useful for files in /proc)")
|
||||||
parser.add_argument("file", help="File path on the device")
|
parser.add_argument("file", help="File path on the device")
|
||||||
parser.add_argument("output_file",
|
parser.add_argument("output_file",
|
||||||
help="Local output file (use '-' for stdout)")
|
help="Local output file (use '-' for stdout)")
|
||||||
|
@ -94,7 +96,10 @@ def main():
|
||||||
|
|
||||||
# Be careful: a too large read size will result in a hang while LAF
|
# Be careful: a too large read size will result in a hang while LAF
|
||||||
# tries to read more data, requiring a reset.
|
# tries to read more data, requiring a reset.
|
||||||
size = get_file_size(comm, args.file)
|
if args.size:
|
||||||
|
size = args.size
|
||||||
|
else:
|
||||||
|
size = get_file_size(comm, args.file)
|
||||||
if size > 0:
|
if size > 0:
|
||||||
_logger.debug("File size is %d", size)
|
_logger.debug("File size is %d", size)
|
||||||
with laf_open_ro(comm, args.file) as file_fd:
|
with laf_open_ro(comm, args.file) as file_fd:
|
||||||
|
|
Loading…
Reference in a new issue