From 59953e10e6eda484525a50afd4ad41634bd21409 Mon Sep 17 00:00:00 2001 From: elicn Date: Tue, 24 May 2022 16:42:45 +0300 Subject: [PATCH] Better handling of rootfs default --- qiling/core.py | 7 ++----- qltool | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/qiling/core.py b/qiling/core.py index 2e7513c3..e8bf7f46 100644 --- a/qiling/core.py +++ b/qiling/core.py @@ -30,7 +30,7 @@ class Qiling(QlCoreHooks, QlCoreStructs): def __init__( self, argv: Sequence[str] = None, - rootfs: str = None, + rootfs: str = r'.', env: MutableMapping[AnyStr, AnyStr] = {}, code: bytes = None, ostype: Union[str, QL_OS] = None, @@ -100,10 +100,7 @@ class Qiling(QlCoreHooks, QlCoreStructs): ################ # rootfs setup # ################ - if rootfs is None: - rootfs = '.' - - elif not os.path.exists(rootfs): + if not os.path.exists(rootfs): raise QlErrorFileNotFound(f'Target rootfs not found: "{rootfs}"') self._rootfs = rootfs diff --git a/qltool b/qltool index 2ce8fa3c..861bbbae 100755 --- a/qltool +++ b/qltool @@ -187,7 +187,7 @@ if __name__ == '__main__': code_parser.add_argument('--thumb', action='store_true', help='specify thumb mode for ARM') code_parser.add_argument('--endian', choices=('little', 'big'), default='little', help='specify endianess for bi-endian archs') code_parser.add_argument('--os', required=True, choices=os_map) - code_parser.add_argument('--rootfs', help='emulated root filesystem, that is where all libraries reside') + code_parser.add_argument('--rootfs', default='.', help='emulated root filesystem, that is where all libraries reside') code_parser.add_argument('--format', choices=('asm', 'hex', 'bin'), default='bin', help='input file format') # set "examples" subcommand @@ -223,7 +223,7 @@ if __name__ == '__main__': handle_examples(parser) # ql file setup - if options.subcommand == 'run': + elif options.subcommand == 'run': ql = handle_run(options) # ql code setup