mksquashfs: remove redundant global variable fragment_size

Fragment_data has a size field, use this instead.

Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
mksquashfs: pass fragment_data to write_fragment()

Pass fragment_data to write_fragment() rather than access global variable.

Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
mksquashfs: move fragment index allocation to fragment creation

Move allocation of the fragment index to when a new empty fragment
is obtained, rather than when the filled fragment is queued to the
fragment_deflate threads.

Doing this allows multiple fragments to be open, and being filled at
the same time, the choice of which fragment is to be used for a
particular file-tail depending on various attributes.

Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
mksquashfs: add action support

Add intial action support.  Currently, there's supported:

	- One action fragment()
	- One test name()

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: add exclude action

Add an additional action called exclude, which takes no parameters.
Any files which the expression returns TRUE will be excluded.

Curently, the only test operator is name(wildcard), which matches
on the file name (leaf name without preceeding pathname).  So, currently
the functionality is equivalent to non-anchored excludes i.e.

-action exclude=name(*.o)

is equivalent to

-e "... *.o".

Do we really want yet another exclude facility?   Well no if it
remains equivalent to just anchored excludes, but once all the
anticipated test operators are implemented then it becomes much more
powerful than the existing functionality.  Want to exclude based
on file age, size or ownership etc.?  That will be possible soon.

The cool thing is the action infrastructure is shared with all other actions,
and the exclude infrastructure is already there and "comes free", and so
the exclude action code is minimal about 20 lines!

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
squashfs: rationalise struct file_buffer

Convert some flags from int to char, and reorganise removing
padding, on 64-bit architectures the structure should be reduced
by 20 bytes from 112 to 92.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: Make no_fragments and always_use_fragments inode specific

This allows them to be changed by actions on
an inode specific basis.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
actions: add fragments and no-fragments actions

These actions allow users to over-ride the global behaviour on a per inode
basis.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
actions: add always_use_fragments and dont_always_use_fragments

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: move fragment flag setting code into is_fragment()

Move duplicate separate implementations of fragment flag setting code
in reader_read_file() and read_read_process() into single
is_fragment() function.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquasfs: handle empty files specially in deflator()

Add special case for empty files in the deflator thread, without
this they're handled differently depending on whether the sparse
files flag is set, the fragment flag is set, or whether they fall
through to be considered as a block to be compressed by the deflator
thread.  In all cases the end result is the same (an empty file is
handled specially in the write_file() routine irrespective of
whether it has been handled as a sparse file of zero bytes, a
fragment of zero bytes, or a data block of zero bytes in the
deflator thread), but it is messy that they're handled differently
depending on filesystem flags.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: Make noD and noF inode specific

This allows them to be changed by actions on
an inode specific basis.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
actions: add compressed and uncompressed actions

These actions allow users to over-ride the global behaviour on a per inode
basis.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
actions: add uid and gid actions

These actions allow users to over-ride the global behaviour on a per inode
basis.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
actions: add an action specific parse arguments function to framework

This is needed for any actions which need to check their arguments
for correctness at parse time, and/or need to process the arguments into
a more optimised format for evaluation, saving repeated processing
each time the arguments are used when the action is evaluated.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
action: move parsing of uid/gid into into new parse_uid_args() function

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
actions: add guid action

This is equivalent to specifying both the uid and gid actions, and
allows both to be changed more consisely than specifying two actions.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
actions: fix uncompressed action

Remove erroneous statement.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
actions: extend action framework to have action run functions

These are functions which are executed if the expression matches for
a file.  This allows the specialised eval actions functions to be
replaced by a generic function, with the action specific code moved
into the action run functions for each action as necessary.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
actions: add file types operated on to actions

Actions (apart from exclude actions) only operated on regular files,
this was wrong.  Actions now specify which file types are applicable.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>