mksquashfs: optimise excluded() when dealing with non-anchored excludes

Non anchored excludes (specified with the "... name" syntax to exclude
files matching name in any directory) are implemented with the
"stickypath" path variable.  This is an exclude specification which
"sticks" as it is present in every directory.

This was previously implemented by adding the stickypath to each
new set of paths returned from the excluded() function, as obviously,
we want stickypath to be present in the next sub-directory.

However, this has the undesirable effect that the new paths variable
"new" is always returned holding at least one entry (the stickypath).
This partially breaks the original design intention of excluded() where
by putting the exclude specifications only in the directories where
they are applicable, for the majority of the time dir_scan1() will have
an empty set of paths to check for exclude matches, thus eliminating
the overhead of exclude matching.

Fix this by not implementing stickypaths as an entry added to the
new set of paths returned from excluded(), instead explictly match
against stickypath if it exists.  This slightly complicates
excluded() requiring a new helper function excluded_match() split out
of excluded(), but the benefit is the new variable in the majority
of cases now gets returned empty (NULL) for stickypaths which was the
original intention.

Also get rid of init_subdir() and instead initialise new in
add_subdir() when first called.  This not only eliminates code (so the
overall changes are 15 lines shorter than before despite the
addition of the new excluded_match() helper function) but it also
means "new" is never allocated in the event we don't get
any matches.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
1 file changed
tree: da7bd3f17bf5314f508d7cb50127e7bc3acc5dd0
  1. kernel/
  2. kernel-2.4/
  3. squashfs-tools/
  4. README