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

Possible to make only certain files uncompressed on a squash archive? #24

Closed
i30817 opened this issue Jul 29, 2017 · 4 comments
Closed

Comments

@i30817
Copy link

i30817 commented Jul 29, 2017

I'm thinking of files which already have specialized compression, where further compression would just add latency, but which are 'logically' part of a set which go into a squash partition.

Can append do this, or am i better asking for a special knob to do this?

If not, I've often thought that the exclusion file can be extended control some settings per file (if extended beyond 'exclusion' ofc). This could be a usecase.

@plougher
Copy link
Owner

You may be glad to know this is a feature already supported in Mksquashfs. Sadly, for various reasons, I didn't document it in the last release of Squashfs-tools, and so it is a "hidden feature", available for use but not documented.

If you're aware of the "find" utility, then the following description and use-cases should be fairly obvious, as this feature can thought of as a mini-find within Mksquashfs.

Find evaluates a series of "tests" and if these return TRUE, executes an action.

So this command "find dir -type f -print" prints all the files within dir which are regular files.

If you know find, you'll also know there are a lot of tests which can be performed on files, wildcard name matching, filesize, type, etc., and these can be combined with logical operators (and, or, not) to build up more complex match expressions.

So what about Mksquashfs? This feature which I called (perhaps unsurprisingly) actions, evaluates a series of test operators and then performs an action, if they return TRUE.

One of the actions you'll be interested in is called "uncompressed", this tells Mksquashfs not to compress the files which the test operators return TRUE.

Like in find, there exists quite a number of test operators, and they can be combined with logical operators (&&. ||, !).

So this command

mksquashfs zzz zzz.sqsh -action "uncompressed@name(*.c)"

Will make all files which match the wildcard "*.c" uncompressed. It obviously works for any wildcard.

Likewise, there is a file-size test operator called unsurprisingly "filesize".

So

mksquashfs zzz zzz.sqsh -action "uncompressed@filesize(4096)"

will make all files exactly 4096 bytes in length uncompressed.

Like in find, you use
+n for greater than n,
-n for less than n,
n for exactly n.

So

mksquashfs zzz zzz.sqsh -action "uncompressed@filesize(-4096)

will match filesizes less than 4096.

Test operators can obviously be combined.

mksquashfs zzz zzz.sqsh -action "uncompressed@name(*.c) && filesize(-4096)"

will match on files with names "*.c" and are less than 4096 bytes in size.

There are a lot of other tests and actions. If you're interested, look at the end of action.c in the source code.

One day I may get around to documenting this.

@i30817
Copy link
Author

i30817 commented Jul 31, 2017

Thank you.

@nigels-com
Copy link

Good to know. Thanks!

@plougher
Copy link
Owner

Closing as this issue is already supported.

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

3 participants