mksquashfs: move inode_number allocation and sorting into a new scan routine

Move inode_number allocation out of the first scan (dir_scan1), and
directory sorting out of the second scan (dir_scan2).

Move them into a new dir_scan3, and bump the existing dir_scan3 to
dir_scan4.

There are a couple of reasons for doing this:

1. It fixes the problem that inode_numbers were allocated in
   the order files were read from the source directories, which is often
   different to the order files appear in the final file system image
   after sorting (*)

2. Previously if a file was added in the first scan (i.e. not excluded),
   it was guaranteed to be present in the final file system image and
   to be at that place in the directory hierarchy, and so it made sense
   to allocate the inode number then (ignoring issue 1 above), but now with
   the empty action and the soon to be implemented move action,
   this no longer makes sense.

   2.1. a directories can be deleted by the empty action after the
       first scan (**)

   2.2. directories and files can be moved into different directories
        by the move action after the first scan, and inode numbers
        should be allocated based on where the files will be in the
        final file system image and not where they appeared in the
        source directories (another case of issue 1 above).

(*) this is an aesthetic issue rather than one of correctness (the
    previous allocation was correct, but perhaps not as nice aesthetically).

(**) putting the empty action in the first scan avoided the issue that
     inode_numbers were allocated in the first scan, but, it is broken.
     An empty directory in the first scan can be populated by pseudo files
     in the second scan, or by the move action.

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