I am currently debugging the EXT4 loader, and using the GUI and selecting the file every time is fairly annoying. The simpler solution would be to have a Headless Analyzer invocation that imports the file system image and parses it.
The naive way of simply calling the Headless Analyzer with the arguments for the project location, name and
-import image.ext4 results in the following errors:
INFO No load spec found for import file: <redacted>.ext4 (AutoImporter.java:215) ERROR The AutoImporter could not successfully load <redacted>.ext4 with the provided import parameters. Please ensure that any specified processor/cspec arguments are compatible with the loader that is used during import and try again. (HeadlessAnalyzer.java:1651) ERROR REPORT: Import failed for file: <redacted>.ext4 (HeadlessAnalyzer.java:1688)
The documentation only covers handling specific binaries, so this doesn't seem like it is supported currently.
A workaround that does not work for my specific use case, but might suffice for others is to mount the image and then use the
-recursive argument for the Headless Analyzer.
A solution could be a script, which would call whatever is called after selecting a file via the
Open File System menu option. There doesn't seem to be one like this shipped with Ghidra yet, but maybe there is one written by the community somewhere.