开发者

Reading a SquashFS archive

(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 files开发者_开发技巧ystem 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.


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


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.


I've got some ruby code that'll do it: https://github.com/vasi/squash.rb

It's pretty rough, but it works fine. Maybe I'll turn it into a better-designed C library someday.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜