6

(SquashFS is a compressed filesystem - http://en.wikipedia.org/wiki/SquashFS)

I'm looking for a way to read a SquashFS filesystem from a program. So far, I've know about the in-kernel drivers for it, but I'm sure that a userspace library for it must exist somewhere. Any language would be fine, but C is preferred.

Just mounting the filesystem and using it that way is technically possible, but I'd rather avoid that route because the application I'm looking at would involve working with at least a few dozen archives at any given time.

Braiam
  • 1
  • 11
  • 47
  • 78
p-static
  • 529
  • 1
  • 4
  • 9

3 Answers3

6

There is a tool called unsquashfs which extracts the squashfs image akin to tar. It should be bundled with mksquashfs

Yann Ramin
  • 32,895
  • 3
  • 59
  • 82
  • As of 2023, `mksquashfs` and `unsquashfs` are both bundled in the `squashfs-tools` debian package. – Juergen Mar 24 '23 at 17:32
5

I just downloaded the code tarball from squashfs.sourceforce.net and there is no kernel code in there. Only userland code in C for mksquashfs and unsquashfs.

You could probably extract code from unsquashfs.

Nicolás
  • 7,423
  • 33
  • 35
1

mksquashfs and unsquashfs are packaged as "squashfs-tools" on my Red Hat system:

Name        : squashfs-tools
Group       : System Environment/Base
Size        : 160923
URL         : http://squashfs.sf.net
Summary     : squashfs utilities
Description :

Squashfs is a highly compressed read-only filesystem for Linux. This package contains the utilities for manipulating squashfs filesystems.

/sbin/mksquashfs
/usr/sbin/unsquashfs
/usr/share/doc/squashfs-tools-3.0
/usr/share/doc/squashfs-tools-3.0/ACKNOWLEDGEMENTS
/usr/share/doc/squashfs-tools-3.0/CHANGES
/usr/share/doc/squashfs-tools-3.0/COPYING
/usr/share/doc/squashfs-tools-3.0/PERFORMANCE.README
/usr/share/doc/squashfs-tools-3.0/README

Be warned that squashing and unsquashing are painfully slow. It takes several minutes for a script I wrote to unsquash, modify, and re-squash an 87M stage2.img file.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578