-----------------------------------------------------------------

[*] Initial strace run with jchroot on the command ./usr/bin/jsonfilter to identify missing areas

[*] Emulating binary name: jsonfilter in strace mode to identify missing areas (with jchroot)
[*] Emulator used: qemu-mipsel-static
[*] Chroot environment used: jchroot
[*] Using root directory: /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract (1/1)
[*] Using CPU config: 

1 brk(NULL) = 0x004140d0
1 mmap2(NULL,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0) = 0x3ffc8000
1 uname(0x4071e6f0) = 0
1 access("/etc/ld.so.preload",R_OK) = -1 errno=2 (No such file or directory)
1 openat(AT_FDCWD,"/etc/ld.so.cache",O_RDONLY|O_CLOEXEC) = -1 errno=2 (No such file or directory)
1 openat(AT_FDCWD,"/lib/tls/libubox.so",O_RDONLY|O_CLOEXEC) = -1 errno=2 (No such file or directory)
1 stat64("/lib/tls",0x4071e328) = 0
1 openat(AT_FDCWD,"/lib/libubox.so",O_RDONLY|O_CLOEXEC) = 3
1 read(3,0x4071e474,512) = 512
1 prctl(46,8,1081205876,512,1073770496,0) = 0
1 fstat64(3,0x4071e338) = 0
1 mmap2(NULL,99696,PROT_EXEC|PROT_READ,MAP_PRIVATE|MAP_DENYWRITE,3,0) = 0x3ffaf000
1 mprotect(0x3ffb7000,61440,PROT_NONE) = 0
1 mmap2(0x3ffc6000,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_DENYWRITE|MAP_FIXED,3,0x7) = 0x3ffc6000
1 close(3) = 0
1 openat(AT_FDCWD,"/lib/tls/libjson-c.so.2",O_RDONLY|O_CLOEXEC) = -1 errno=2 (No such file or directory)
1 openat(AT_FDCWD,"/lib/libjson-c.so.2",O_RDONLY|O_CLOEXEC) = -1 errno=2 (No such file or directory)
1 openat(AT_FDCWD,"/usr/lib/tls/libjson-c.so.2",O_RDONLY|O_CLOEXEC) = -1 errno=2 (No such file or directory)
1 stat64("/usr/lib/tls",0x4071e310) = 0
1 openat(AT_FDCWD,"/usr/lib/libjson-c.so.2",O_RDONLY|O_CLOEXEC) = 3
1 read(3,0x4071e45c,512) = 512
1 prctl(46,8,1081205852,512,1073770496,0) = 0
1 fstat64(3,0x4071e320) = 0
1 mmap2(NULL,94800,PROT_EXEC|PROT_READ,MAP_PRIVATE|MAP_DENYWRITE,3,0) = 0x3ff97000
1 mprotect(0x3ff9e000,61440,PROT_NONE) = 0
1 mmap2(0x3ffad000,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_DENYWRITE|MAP_FIXED,3,0x6) = 0x3ffad000
1 close(3) = 0
1 openat(AT_FDCWD,"/lib/tls/libgcc_s.so.1",O_RDONLY|O_CLOEXEC) = 3
1 read(3,0x4071e444,512) = 512
1 prctl(46,9,1081205828,512,1073770496,0) = 0
1 fstat64(3,0x4071e308) = 0
1 mmap2(NULL,144160,PROT_EXEC|PROT_READ,MAP_PRIVATE|MAP_DENYWRITE,3,0) = 0x3ff73000
1 mprotect(0x3ff86000,61440,PROT_NONE) = 0
1 mmap2(0x3ff95000,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_DENYWRITE|MAP_FIXED,3,0x12) = 0x3ff95000
1 mprotect(0x4071e000,4096,PROT_EXEC|PROT_READ|PROT_WRITE|PROT_GROWSDOWN) = 0
1 close(3) = 0
1 openat(AT_FDCWD,"/lib/tls/libc.so.6",O_RDONLY|O_CLOEXEC) = 3
1 read(3,0x4071e42c,512) = 512
1 prctl(46,13,1081205804,512,1073770496,0) = 0
1 _llseek(3,0,792,0x4071e1e8,SEEK_SET) = 0
1 read(3,0x4071e218,32) = 32
1 fstat64(3,0x4071e2f0) = 0
1 mmap2(NULL,1630336,PROT_EXEC|PROT_READ,MAP_PRIVATE|MAP_DENYWRITE,3,0) = 0x3fde4000
1 mprotect(0x3ff5a000,61440,PROT_NONE) = 0
1 mmap2(0x3ff69000,28672,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_DENYWRITE|MAP_FIXED,3,0x175) = 0x3ff69000
1 mmap2(0x3ff70000,8320,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,-1,0) = 0x3ff70000
1 close(3) = 0
1 mmap2(NULL,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0) = 0x3fde2000
1 set_thread_area(0x3fde94a0) = 0
1 mprotect(0x3ff69000,16384,PROT_READ) = 0
1 mprotect(0x3ff95000,4096,PROT_READ) = 0
1 mprotect(0x3ffad000,4096,PROT_READ) = 0
1 mprotect(0x3ffc6000,4096,PROT_READ) = 0
1 mprotect(0x00413000,4096,PROT_READ) = 0
1 mprotect(0x3fffe000,4096,PROT_READ) = 0
1 fstat64(1,0x4071e730) = 0
1 brk(NULL) = 0x004140d0
1 brk(0x004350d0) = 0x004350d0
1 brk(0x00436000) = 0x00436000
1 write(1,0x414220,1508)== Usage ==

  # ./usr/bin/jsonfilter [-a] [-i <file> | -s "json..."] {-t <pattern> | -e <pattern>}
  -q		Quiet, no errors are printed
  -h, --help	Print this help
  -a		Implicitely treat input as array, useful for JSON logs
  -i path	Specify a JSON file to parse
  -s "json"	Specify a JSON string to parse
  -l limit	Specify max number of results to show
  -F separator	Specify a field separator when using export
  -t <pattern>	Print the type of values matched by pattern
  -e <pattern>	Print the values matched by pattern
  -e VAR=<pat>	Serialize matched value for shell "eval"

== Patterns ==

  Patterns are JsonPath: http://goessner.net/articles/JsonPath/
  This tool implements $, @, [], * and the union operator ','
  plus the usual expressions and literals.
  It does not support the recursive child search operator '..' or
  the '?()' and '()' filter expressions as those would require a
  complete JavaScript engine to support them.

== Examples ==

  Display the first IPv4 address on lan:
  # ifstatus lan | ./usr/bin/jsonfilter -e '@["ipv4-address"][0].address'

  Extract the release string from the board information:
  # ubus call system board | ./usr/bin/jsonfilter -e '@.release.description'

  Find all interfaces which are up:
  # ubus call network.interface dump | \
  	./usr/bin/jsonfilter -e '@.interface[@.up=true].interface'

  Export br-lan traffic counters for shell eval:
  # devstatus br-lan | ./usr/bin/jsonfilter -e 'RX=@.statistics.rx_bytes' \
	-e 'TX=@.statistics.tx_bytes'
 = 1508
1 exit_group(0)

[*] Identification of missing filesytem areas.
[*] Found missing area: /etc/ld.so.cache
[*] Trying to identify this missing file: ld.so.cache
[*] Missing file /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/etc/ld.so.cache
[*] Found missing area: /lib/libjson-c.so.2
[*] Trying to identify this missing file: libjson-c.so.2
[*] Possible matching file found: /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/usr/lib/libjson-c.so.2
[*] Copy file /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/usr/lib/libjson-c.so.2 to /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/lib/
[*] Found missing area: /lib/tls/libjson-c.so.2
[*] Trying to identify this missing file: libjson-c.so.2
[*] Possible matching file found: /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/lib/libjson-c.so.2
[*] Copy file /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/lib/libjson-c.so.2 to /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/lib/tls/
[*] Found missing area: /lib/tls/libubox.so
[*] Trying to identify this missing file: libubox.so
[*] Possible matching file found: /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/lib/libubox.so
[*] Copy file /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/lib/libubox.so to /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/lib/tls/
[*] Found missing area: /usr/lib/tls/libjson-c.so.2
[*] Trying to identify this missing file: libjson-c.so.2
[*] Possible matching file found: /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/lib/libjson-c.so.2
[*] Copy file /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/lib/libjson-c.so.2 to /logs/s115_usermode_emulator/firmware/unblob_extracted/firmware_extract/1568982-13971496.squashfs_v4_le_extract/usr/lib/tls/

-----------------------------------------------------------------