Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to use the library #132

Open
probonopd opened this issue Aug 13, 2024 · 2 comments
Open

Document how to use the library #132

probonopd opened this issue Aug 13, 2024 · 2 comments

Comments

@probonopd
Copy link

probonopd commented Aug 13, 2024

I am trying to write extract_diricon.c that does the following:

  • Extracts the file .DirIcon from a zstd compressed squashfs file (resolving symlinks inside the squashfs file)
  • The squashfs file starts at an offset of bytes, specified with -o

Example: ./extract_diricon -o 12345 my.squashfs should extract the file .DirIcon.

I figure I need to compile with gcc -o extract_diricon extract_diricon.c -I/usr/include/sqfs -L/usr/lib/x86_64-linux-gnu -lsquashfs.
But how would I have to code the above?

Thank you very much for your help.

(Use case: AppImage files contain a squashfs image that contains an icon, and I want to write a tiny helper to extract this icon, so that file managers can natively show the correct icons for AppImages.)

@AgentD
Copy link
Owner

AgentD commented Aug 19, 2024

Hi @probonopd ,

in the extras directory, there some are example programs. Specifically extract_one.c does recursive path resolution and unpacks a single file from an image.

As for the offset, currently you'd have to create a wrapper object around sqfs_file_t that applies it.

A "compiled" version of the Doxygen reference manual is currently hosted here: https://infraroot.at/projects/squashfs-tools-ng/doxydoc/index.html

I hope this helps.

@probonopd
Copy link
Author

probonopd commented Aug 25, 2024

Thanks for your hint @AgentD. Unfortunately I could not make the offset work yet.

In particular, the sqfs_file_t structure does not have a fd member that can be directly accessed (for seeking).

In case you could show me how to do this properly, I'd be super happy. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants