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:
Peter Wu 2017-12-01 03:46:44 +00:00
parent 69ba8fb578
commit 39c9872ca0

View file

@ -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,6 +96,9 @@ 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.
if args.size:
size = args.size
else:
size = get_file_size(comm, args.file) 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)