actions: add a prune action - allow fine tuning of excluding

This adds the prune action.  This action is designed to do fine
grained tuning of the in-core directory structure after the exclude,
move and pseudo actions have been performed.

Unlike exclude which can be most usefully used to exclude based on
the evaluation of the file in question in isolation, prune can be
used to do exclusion based on the overall state of the filesystem
once exclusion has been done, rather than just the single file.

This is for two reasons:

1. At exclude time the filesystem is being scanned and files are being
   evaluated and excluded.  As the filesystem has not been fully scanned,
   it is impossible to make decisons based on the state of other files.

   For example, delete directory "xyz" if it has 10 or fewer entries.
   At the time directory "xyz" is evaluated by the exclude action, the
   number of files that will be eventully be in it after scanning and
   exclusion is unknown.

   Or another example delete file "abc" if file "../../x/y/xxx" doesn't
   exist in the filesystem.  Again, as the filesystem has not yet
   been fully scanned this may not known when file "abc" is evaluted
   by the exclude action.

2. Many of the complex context aware test options not only
   are meaningless at exclusion time, but their complexity
   means they rely on the in-core directory to be present.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: move symlink reading from create_inode() to dir_scan1()

Up till now Mksquashfs did not read the contents of symlinks at
directory scanning, but left this task to the final filesystem
creation when the symlink inode in the output squashfs filesystem
was created.

Now that we're adding action test operations that operate on symlinks,
this creates a problem.  We want the values of the symlink when
evaluating the symlink for existence, recursive evaluation via
readlink() etc.  Up till now when implementing these tests I have
chosen to read the symlink from the source filesystem on demand and
then discard the value.  The over-arching reason for this is because
symlinks can reference other symlinks, and because these tests were
previously designed to be evaluated at exclude action time when the
directory structure has not been fully scanned, we need to deal with
symlinks that have not yet been scanned.  In other words moving
symlimk reading to directory scan time is no help when evaluating
synlinks at exclude time because there is no guarantee that any
referenced symlinks have been read.  You have no option but to fall back
to reading symlinks from the source filesystem at symlink test
evaluation time.

But evaluating symlinks by reading from the source filesystem is fraught
with difficulties, not least the fact that the existence of the
symlink in the source filesystem is no guarantee that the symlink exists
in the output filesystem.  Additionally there is never any guarantee
that the source filesystem hasn't changed whilst evaluating it rendering
any checks meaningless.

The fix to this has been to decide evaluating symlinks at exclude time
when the directory stucture has not been fully scanned causes
insurmountable problems.  The solution to this has been to introduce
a new prune action, which is evaluated on the fully scanned
directory structure.  This alleviates all the aforementioned
problems.

So, now that the prune action has been implemented, this checkin
moves reading of symlinks to the dir scanning phase, so that the
snapshotted values are available for the symlink test operations.

An additional minor improvement is that failure to read the symlink
for some reason is discovered at dir scanning time allowing Mksquashfs
to ignore the symlink.  Previously because reading the symlink was
performed at filesystem creation time, failure to read meant a
dummy empty symlink had to be created.  This is because at
filesystem creation all the metadata for the filesystem has been
computed and partially written, and this includes the count
of the number of inodes.

This is called a "minor improvement" because in practice this
situation never occurs because due to the nature of symlinks if Mksquashfs
could stat it at dir scanning time, then it is guaranteed to
be able to read it at filesystem creation time, unless the symlink
has been deleted in the meantime.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
action: add code to check test is correct for action specified at parse time

In the future some test operations will not be useable with
the exclude action because the directory structure has not been fully
scanned.

Add code to flag each test, and check for this at parse time.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
action: update absolute test to use in-core directory structure

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: move creation of root directory dir_ent and inode structure

Move it to just after dir_scan1().  Future action test operations may
reference this in their operation, and so it needs to be present
when these test operations are evaluated.

Previously these structures were not referenced by code until after
dir_scan6() which is why they were created then.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
actions: rewrite exists() test operation

Rewrite exists() test operation to operate on the scanned in-core
directory structure.

This allows exists() to be rewritten, and to change it's behaviour to
be more straightforward.  It now tests to see if the symbolic link
exists in the output filesystem.  It also now follows any symbolic
links embedded in the pathname to ensure that the symbolic link
is fully dereferenceable to an existing entry, and that no
symlinks do not exist or are absolute.

In that way, it is believed the semantics of exists() are now more
obvious and are more intuitive.

The new implementation of exists() subsumes the previously separate
exists(), contained() and contained_followlink() test operations.

Previously, three separate test operations were needed, and they
were written in the way they were, due to limitations imposed due
to the fact they were operating on the source directory.  This is because
they were originally intended to be used with the exclude action where
the directory structure has not been fully scanned.

The introduction of the prune action allows these test operations to
be rewritten.  Which is, obviously, why the prune action was
introduced.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
actions: get rid of contained and contained_followlink

They are now subsumed in the rewritten exists function.

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