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.

1 Answer 1


The solution that I found that suffices for my current issue of debugging the EXT4 parser is is the following Ghidra Script, saved as ImportFS.java:

import ghidra.app.script.GhidraScript;
import ghidra.formats.gfilesystem.FSRL;
import ghidra.formats.gfilesystem.FileSystemRef;
import ghidra.formats.gfilesystem.FileSystemService;

import java.io.File;

public class ImportFS extends GhidraScript{

        protected void run()throws Exception{
                File filesystemImage = askFile("Choose Filesystem Container", "Select");
                FSRL fsrl = FSRL.fromString("file://" + filesystemImage.getAbsolutePath());
                FileSystemService fileSystemService = FileSystemService.getInstance();
                FileSystemRef ref = fileSystemService.probeFileForFilesystem(fsrl, monitor, null);

And invoking the Headless Analyzer with

analyzeHeadless /tmp temp_project -scriptPath /path/to/script/folder -readOnly -preScript ImportFS.java /path/to/file.img

askFile will not prompt for the file via a GUI when running in headless mode, so either /path/to/file.img has to be provided via the argument or a property file.

Further code would be needed for actually importing the file system tree after parsing, but this should be doable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.