History log of /netbsd-current/usr.sbin/makefs/walk.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.40 08-May-2024 christos

Add an option to warn and error out for mtree missing entries.


# 1.39 24-Apr-2024 rillig

makefs: fix out-of-bounds fsnode count in fsnode_sort

Found by running './makefs img.dat cd9660'.

While here, apply more KNF.


# 1.38 24-Apr-2024 christos

use __func__


# 1.37 24-Apr-2024 christos

make a separate sorting function and KNF (thanks rillig)


# 1.36 23-Apr-2024 christos

pass lint, simplify


# 1.35 23-Apr-2024 christos

makefs: Fix symlink permission bits

Permission bits for symlinks are taken straight from `lstat()`. However, the
actual bits presented to the user are filesystem/kernel specific. For example,
Linux with ext2/3/4 will use 0777 for symlinks, whereas NetBSD/FFS will
show 0755. As far as `makefs` is in the loop, the target filesystem will likely
be FFS, so use 0755.


# 1.34 23-Apr-2024 christos

makefs: Sort directory contents by name (Jan-Benedict Glaw)

`makefs` inserts nodes into its internal data structures in the order as
returned by `readdir()` calls. As this is unpredictable, sort entries by
name before creating the target filesystem.

This is done by first converting the (per-directory) linked list into
a plain array, sort it, finally re-link the list. Special case for the
sorting function: The "." directory entry seems to be ment to be always
at the front, so always check that first.


# 1.33 28-Dec-2023 tsutsui

Use EXIT_SUCCESS and EXIT_FAILURE where appropriate per style guide.


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.32 09-Apr-2022 riastradh

makefs(8): Nix trailing whitespace.

Computed by machine, eyeballed by hand, so to speak.


# 1.31 06-Apr-2022 wiz

makefs: fix some typos


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.30 03-Apr-2021 simonb

Add a -L option to follow all symbolic links. Useful if you have symlinks
in a makefs directory tree but want to refer to the actual file.


Revision tags: netbsd-8-3-RELEASE netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.29 25-Nov-2015 christos

Provide a -T option to set timestamps to a consistent value for MKREPRO


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.28 03-Feb-2013 christos

add a replace flag so we can overlay exiting files when we merge directories.


# 1.27 28-Jan-2013 christos

- use emalloc and friends
- kill a bunch of global variables, more work to be done here
- homogenize option parsing. more work for cd9660
- use the new options parsing code to print an fs-specific usage


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5
# 1.26 19-Apr-2012 christos

branches: 1.26.2;
WARNS=5


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base
# 1.25 28-Jan-2012 christos

Patch from Jung-uk Kim (jkim at FreeBSD dot org) to allow contents of multiple
directories to be merged to the current image.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.24 28-Dec-2008 christos

branches: 1.24.8;
fix for 64 bit time_t and dev_t.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base netbsd-4-0-1-RELEASE wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-fixsa-newbase wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base netbsd-4-base
# 1.23 10-Oct-2006 dbj

implement -x by pruning fsnodes tree before building filesystem rather
than by skipping nodes while building filesystem


# 1.22 10-Oct-2006 dbj

add implementation of free_fsnodes() which unlinks a node
from the hierarchy and frees it and any of its children
use it to free memory before a normal exit, which helps diagnostics


# 1.21 10-Oct-2006 dbj

free specfile structure once it has been applied


# 1.20 10-Oct-2006 dbj

use new implementation of link_check which i
implemented for du.c revision 1.25 :

Use open address hashtable with multiplicative double hash probing
and exponential hashtable growth for tracking previously seen inodes.
This replaces the O(n^2) behavior of linkchk() with an implementation
that should be O(n*logn)


Revision tags: abandoned-netbsd-4-base
# 1.19 01-Feb-2006 dyoung

Stop duplicating the ISO9660 sources in sys/fs/cd9660/ for makefs(8).


# 1.18 19-Aug-2005 christos

64 bit inode changes


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.17 20-Jun-2004 jmc

Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944


# 1.16 31-May-2004 lukem

Use uint64_t instead of uint32_t to store a host inode when checking
for duplicate inodes, as Cygwin's stat(2) has a 64 bit st_ino.
Fix from Ian Lance Taylor in private email.


Revision tags: netbsd-2-0-base
# 1.15 19-Sep-2003 itojun

branches: 1.15.2;
realloc pedant


# 1.14 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.


# 1.13 09-May-2003 itojun

just for safety - use sizeof


# 1.12 29-Mar-2003 thorpej

Add a -x option which causes makefs(8) to exclude any file system node
not explicitly listed in the specfile.


# 1.11 27-Jan-2003 uwe

s/ulong/unsigned long/. ulong is for SysV compatibility, there's no
point in using it in our code. This change makes makefs(8) compile on
host systems without ulong.


Revision tags: fvdl_fs64_base
# 1.10 19-Oct-2002 provos

use readlink with bufsize - 1; approved thorpej.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.9 08-Feb-2002 lukem

branches: 1.9.2;
If an entry is in the specfile but not in the underlying file system, and it's
marked "optional", don't add it. (e.g, don't create a zero-length file).


# 1.8 31-Jan-2002 tv

Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.


# 1.7 23-Jan-2002 lukem

Merge create_fsinode() into create_fsnode(), so that a newly created
fsnode always has a valid inode member. Problem noted by Artem Belevich.


# 1.6 05-Dec-2001 lukem

rework `fsnode' into two components; `fsnode' contains the name and tree
information and a link to the appropriate fsinode, and `fsinode' contains
the inode information and a reference count. multiple fsnodes may point
to the same fsinode. this replaces the 'dup' pointer in the previous code.


# 1.5 02-Nov-2001 lukem

tweak copyright


# 1.4 29-Oct-2001 lukem

cast time_t values to long if printing as %ld to appease the sparc64 port


# 1.3 29-Oct-2001 lukem

- apply_specdir(): when adding a new symlink from the specfile, do the assert
check on the correct node
- apply_specentry(): if this node is a duplicate of another, apply the
changes to the `master' entry instead of this one.
- fix inotype() to DTRT
- comment out some debugging info that is too verbose


# 1.2 28-Oct-2001 lukem

add __RCSID()


# 1.1 26-Oct-2001 lukem

branches: 1.1.1;
Initial revision


# 1.39 24-Apr-2024 rillig

makefs: fix out-of-bounds fsnode count in fsnode_sort

Found by running './makefs img.dat cd9660'.

While here, apply more KNF.


# 1.38 24-Apr-2024 christos

use __func__


# 1.37 24-Apr-2024 christos

make a separate sorting function and KNF (thanks rillig)


# 1.36 23-Apr-2024 christos

pass lint, simplify


# 1.35 23-Apr-2024 christos

makefs: Fix symlink permission bits

Permission bits for symlinks are taken straight from `lstat()`. However, the
actual bits presented to the user are filesystem/kernel specific. For example,
Linux with ext2/3/4 will use 0777 for symlinks, whereas NetBSD/FFS will
show 0755. As far as `makefs` is in the loop, the target filesystem will likely
be FFS, so use 0755.


# 1.34 23-Apr-2024 christos

makefs: Sort directory contents by name (Jan-Benedict Glaw)

`makefs` inserts nodes into its internal data structures in the order as
returned by `readdir()` calls. As this is unpredictable, sort entries by
name before creating the target filesystem.

This is done by first converting the (per-directory) linked list into
a plain array, sort it, finally re-link the list. Special case for the
sorting function: The "." directory entry seems to be ment to be always
at the front, so always check that first.


# 1.33 28-Dec-2023 tsutsui

Use EXIT_SUCCESS and EXIT_FAILURE where appropriate per style guide.


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.32 09-Apr-2022 riastradh

makefs(8): Nix trailing whitespace.

Computed by machine, eyeballed by hand, so to speak.


# 1.31 06-Apr-2022 wiz

makefs: fix some typos


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.30 03-Apr-2021 simonb

Add a -L option to follow all symbolic links. Useful if you have symlinks
in a makefs directory tree but want to refer to the actual file.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.29 25-Nov-2015 christos

Provide a -T option to set timestamps to a consistent value for MKREPRO


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.28 03-Feb-2013 christos

add a replace flag so we can overlay exiting files when we merge directories.


# 1.27 28-Jan-2013 christos

- use emalloc and friends
- kill a bunch of global variables, more work to be done here
- homogenize option parsing. more work for cd9660
- use the new options parsing code to print an fs-specific usage


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5
# 1.26 19-Apr-2012 christos

branches: 1.26.2;
WARNS=5


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base
# 1.25 28-Jan-2012 christos

Patch from Jung-uk Kim (jkim at FreeBSD dot org) to allow contents of multiple
directories to be merged to the current image.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.24 28-Dec-2008 christos

branches: 1.24.8;
fix for 64 bit time_t and dev_t.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base netbsd-4-0-1-RELEASE wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-fixsa-newbase wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base netbsd-4-base
# 1.23 10-Oct-2006 dbj

implement -x by pruning fsnodes tree before building filesystem rather
than by skipping nodes while building filesystem


# 1.22 10-Oct-2006 dbj

add implementation of free_fsnodes() which unlinks a node
from the hierarchy and frees it and any of its children
use it to free memory before a normal exit, which helps diagnostics


# 1.21 10-Oct-2006 dbj

free specfile structure once it has been applied


# 1.20 10-Oct-2006 dbj

use new implementation of link_check which i
implemented for du.c revision 1.25 :

Use open address hashtable with multiplicative double hash probing
and exponential hashtable growth for tracking previously seen inodes.
This replaces the O(n^2) behavior of linkchk() with an implementation
that should be O(n*logn)


Revision tags: abandoned-netbsd-4-base
# 1.19 01-Feb-2006 dyoung

Stop duplicating the ISO9660 sources in sys/fs/cd9660/ for makefs(8).


# 1.18 19-Aug-2005 christos

64 bit inode changes


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.17 20-Jun-2004 jmc

Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944


# 1.16 31-May-2004 lukem

Use uint64_t instead of uint32_t to store a host inode when checking
for duplicate inodes, as Cygwin's stat(2) has a 64 bit st_ino.
Fix from Ian Lance Taylor in private email.


Revision tags: netbsd-2-0-base
# 1.15 19-Sep-2003 itojun

branches: 1.15.2;
realloc pedant


# 1.14 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.


# 1.13 09-May-2003 itojun

just for safety - use sizeof


# 1.12 29-Mar-2003 thorpej

Add a -x option which causes makefs(8) to exclude any file system node
not explicitly listed in the specfile.


# 1.11 27-Jan-2003 uwe

s/ulong/unsigned long/. ulong is for SysV compatibility, there's no
point in using it in our code. This change makes makefs(8) compile on
host systems without ulong.


Revision tags: fvdl_fs64_base
# 1.10 19-Oct-2002 provos

use readlink with bufsize - 1; approved thorpej.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.9 08-Feb-2002 lukem

branches: 1.9.2;
If an entry is in the specfile but not in the underlying file system, and it's
marked "optional", don't add it. (e.g, don't create a zero-length file).


# 1.8 31-Jan-2002 tv

Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.


# 1.7 23-Jan-2002 lukem

Merge create_fsinode() into create_fsnode(), so that a newly created
fsnode always has a valid inode member. Problem noted by Artem Belevich.


# 1.6 05-Dec-2001 lukem

rework `fsnode' into two components; `fsnode' contains the name and tree
information and a link to the appropriate fsinode, and `fsinode' contains
the inode information and a reference count. multiple fsnodes may point
to the same fsinode. this replaces the 'dup' pointer in the previous code.


# 1.5 02-Nov-2001 lukem

tweak copyright


# 1.4 29-Oct-2001 lukem

cast time_t values to long if printing as %ld to appease the sparc64 port


# 1.3 29-Oct-2001 lukem

- apply_specdir(): when adding a new symlink from the specfile, do the assert
check on the correct node
- apply_specentry(): if this node is a duplicate of another, apply the
changes to the `master' entry instead of this one.
- fix inotype() to DTRT
- comment out some debugging info that is too verbose


# 1.2 28-Oct-2001 lukem

add __RCSID()


# 1.1 26-Oct-2001 lukem

branches: 1.1.1;
Initial revision


# 1.33 28-Dec-2023 tsutsui

Use EXIT_SUCCESS and EXIT_FAILURE where appropriate per style guide.


Revision tags: netbsd-10-0-RC1 netbsd-10-base
# 1.32 09-Apr-2022 riastradh

makefs(8): Nix trailing whitespace.

Computed by machine, eyeballed by hand, so to speak.


# 1.31 06-Apr-2022 wiz

makefs: fix some typos


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.30 03-Apr-2021 simonb

Add a -L option to follow all symbolic links. Useful if you have symlinks
in a makefs directory tree but want to refer to the actual file.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.29 25-Nov-2015 christos

Provide a -T option to set timestamps to a consistent value for MKREPRO


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.28 03-Feb-2013 christos

add a replace flag so we can overlay exiting files when we merge directories.


# 1.27 28-Jan-2013 christos

- use emalloc and friends
- kill a bunch of global variables, more work to be done here
- homogenize option parsing. more work for cd9660
- use the new options parsing code to print an fs-specific usage


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5
# 1.26 19-Apr-2012 christos

branches: 1.26.2;
WARNS=5


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base
# 1.25 28-Jan-2012 christos

Patch from Jung-uk Kim (jkim at FreeBSD dot org) to allow contents of multiple
directories to be merged to the current image.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.24 28-Dec-2008 christos

branches: 1.24.8;
fix for 64 bit time_t and dev_t.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base netbsd-4-0-1-RELEASE wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-fixsa-newbase wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base netbsd-4-base
# 1.23 10-Oct-2006 dbj

implement -x by pruning fsnodes tree before building filesystem rather
than by skipping nodes while building filesystem


# 1.22 10-Oct-2006 dbj

add implementation of free_fsnodes() which unlinks a node
from the hierarchy and frees it and any of its children
use it to free memory before a normal exit, which helps diagnostics


# 1.21 10-Oct-2006 dbj

free specfile structure once it has been applied


# 1.20 10-Oct-2006 dbj

use new implementation of link_check which i
implemented for du.c revision 1.25 :

Use open address hashtable with multiplicative double hash probing
and exponential hashtable growth for tracking previously seen inodes.
This replaces the O(n^2) behavior of linkchk() with an implementation
that should be O(n*logn)


Revision tags: abandoned-netbsd-4-base
# 1.19 01-Feb-2006 dyoung

Stop duplicating the ISO9660 sources in sys/fs/cd9660/ for makefs(8).


# 1.18 19-Aug-2005 christos

64 bit inode changes


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.17 20-Jun-2004 jmc

Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944


# 1.16 31-May-2004 lukem

Use uint64_t instead of uint32_t to store a host inode when checking
for duplicate inodes, as Cygwin's stat(2) has a 64 bit st_ino.
Fix from Ian Lance Taylor in private email.


Revision tags: netbsd-2-0-base
# 1.15 19-Sep-2003 itojun

branches: 1.15.2;
realloc pedant


# 1.14 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.


# 1.13 09-May-2003 itojun

just for safety - use sizeof


# 1.12 29-Mar-2003 thorpej

Add a -x option which causes makefs(8) to exclude any file system node
not explicitly listed in the specfile.


# 1.11 27-Jan-2003 uwe

s/ulong/unsigned long/. ulong is for SysV compatibility, there's no
point in using it in our code. This change makes makefs(8) compile on
host systems without ulong.


Revision tags: fvdl_fs64_base
# 1.10 19-Oct-2002 provos

use readlink with bufsize - 1; approved thorpej.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.9 08-Feb-2002 lukem

branches: 1.9.2;
If an entry is in the specfile but not in the underlying file system, and it's
marked "optional", don't add it. (e.g, don't create a zero-length file).


# 1.8 31-Jan-2002 tv

Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.


# 1.7 23-Jan-2002 lukem

Merge create_fsinode() into create_fsnode(), so that a newly created
fsnode always has a valid inode member. Problem noted by Artem Belevich.


# 1.6 05-Dec-2001 lukem

rework `fsnode' into two components; `fsnode' contains the name and tree
information and a link to the appropriate fsinode, and `fsinode' contains
the inode information and a reference count. multiple fsnodes may point
to the same fsinode. this replaces the 'dup' pointer in the previous code.


# 1.5 02-Nov-2001 lukem

tweak copyright


# 1.4 29-Oct-2001 lukem

cast time_t values to long if printing as %ld to appease the sparc64 port


# 1.3 29-Oct-2001 lukem

- apply_specdir(): when adding a new symlink from the specfile, do the assert
check on the correct node
- apply_specentry(): if this node is a duplicate of another, apply the
changes to the `master' entry instead of this one.
- fix inotype() to DTRT
- comment out some debugging info that is too verbose


# 1.2 28-Oct-2001 lukem

add __RCSID()


# 1.1 26-Oct-2001 lukem

branches: 1.1.1;
Initial revision


# 1.32 09-Apr-2022 riastradh

makefs(8): Nix trailing whitespace.

Computed by machine, eyeballed by hand, so to speak.


# 1.31 06-Apr-2022 wiz

makefs: fix some typos


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.30 03-Apr-2021 simonb

Add a -L option to follow all symbolic links. Useful if you have symlinks
in a makefs directory tree but want to refer to the actual file.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.29 25-Nov-2015 christos

Provide a -T option to set timestamps to a consistent value for MKREPRO


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.28 03-Feb-2013 christos

add a replace flag so we can overlay exiting files when we merge directories.


# 1.27 28-Jan-2013 christos

- use emalloc and friends
- kill a bunch of global variables, more work to be done here
- homogenize option parsing. more work for cd9660
- use the new options parsing code to print an fs-specific usage


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5
# 1.26 19-Apr-2012 christos

branches: 1.26.2;
WARNS=5


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base
# 1.25 28-Jan-2012 christos

Patch from Jung-uk Kim (jkim at FreeBSD dot org) to allow contents of multiple
directories to be merged to the current image.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.24 28-Dec-2008 christos

branches: 1.24.8;
fix for 64 bit time_t and dev_t.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base netbsd-4-0-1-RELEASE wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-fixsa-newbase wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base netbsd-4-base
# 1.23 10-Oct-2006 dbj

implement -x by pruning fsnodes tree before building filesystem rather
than by skipping nodes while building filesystem


# 1.22 10-Oct-2006 dbj

add implementation of free_fsnodes() which unlinks a node
from the hierarchy and frees it and any of its children
use it to free memory before a normal exit, which helps diagnostics


# 1.21 10-Oct-2006 dbj

free specfile structure once it has been applied


# 1.20 10-Oct-2006 dbj

use new implementation of link_check which i
implemented for du.c revision 1.25 :

Use open address hashtable with multiplicative double hash probing
and exponential hashtable growth for tracking previously seen inodes.
This replaces the O(n^2) behavior of linkchk() with an implementation
that should be O(n*logn)


Revision tags: abandoned-netbsd-4-base
# 1.19 01-Feb-2006 dyoung

Stop duplicating the ISO9660 sources in sys/fs/cd9660/ for makefs(8).


# 1.18 19-Aug-2005 christos

64 bit inode changes


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.17 20-Jun-2004 jmc

Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944


# 1.16 31-May-2004 lukem

Use uint64_t instead of uint32_t to store a host inode when checking
for duplicate inodes, as Cygwin's stat(2) has a 64 bit st_ino.
Fix from Ian Lance Taylor in private email.


Revision tags: netbsd-2-0-base
# 1.15 19-Sep-2003 itojun

branches: 1.15.2;
realloc pedant


# 1.14 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.


# 1.13 09-May-2003 itojun

just for safety - use sizeof


# 1.12 29-Mar-2003 thorpej

Add a -x option which causes makefs(8) to exclude any file system node
not explicitly listed in the specfile.


# 1.11 27-Jan-2003 uwe

s/ulong/unsigned long/. ulong is for SysV compatibility, there's no
point in using it in our code. This change makes makefs(8) compile on
host systems without ulong.


Revision tags: fvdl_fs64_base
# 1.10 19-Oct-2002 provos

use readlink with bufsize - 1; approved thorpej.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.9 08-Feb-2002 lukem

branches: 1.9.2;
If an entry is in the specfile but not in the underlying file system, and it's
marked "optional", don't add it. (e.g, don't create a zero-length file).


# 1.8 31-Jan-2002 tv

Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.


# 1.7 23-Jan-2002 lukem

Merge create_fsinode() into create_fsnode(), so that a newly created
fsnode always has a valid inode member. Problem noted by Artem Belevich.


# 1.6 05-Dec-2001 lukem

rework `fsnode' into two components; `fsnode' contains the name and tree
information and a link to the appropriate fsinode, and `fsinode' contains
the inode information and a reference count. multiple fsnodes may point
to the same fsinode. this replaces the 'dup' pointer in the previous code.


# 1.5 02-Nov-2001 lukem

tweak copyright


# 1.4 29-Oct-2001 lukem

cast time_t values to long if printing as %ld to appease the sparc64 port


# 1.3 29-Oct-2001 lukem

- apply_specdir(): when adding a new symlink from the specfile, do the assert
check on the correct node
- apply_specentry(): if this node is a duplicate of another, apply the
changes to the `master' entry instead of this one.
- fix inotype() to DTRT
- comment out some debugging info that is too verbose


# 1.2 28-Oct-2001 lukem

add __RCSID()


# 1.1 26-Oct-2001 lukem

branches: 1.1.1;
Initial revision


# 1.31 06-Apr-2022 wiz

makefs: fix some typos


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.30 03-Apr-2021 simonb

Add a -L option to follow all symbolic links. Useful if you have symlinks
in a makefs directory tree but want to refer to the actual file.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.29 25-Nov-2015 christos

Provide a -T option to set timestamps to a consistent value for MKREPRO


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.28 03-Feb-2013 christos

add a replace flag so we can overlay exiting files when we merge directories.


# 1.27 28-Jan-2013 christos

- use emalloc and friends
- kill a bunch of global variables, more work to be done here
- homogenize option parsing. more work for cd9660
- use the new options parsing code to print an fs-specific usage


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5
# 1.26 19-Apr-2012 christos

branches: 1.26.2;
WARNS=5


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base
# 1.25 28-Jan-2012 christos

Patch from Jung-uk Kim (jkim at FreeBSD dot org) to allow contents of multiple
directories to be merged to the current image.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.24 28-Dec-2008 christos

branches: 1.24.8;
fix for 64 bit time_t and dev_t.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base netbsd-4-0-1-RELEASE wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-fixsa-newbase wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base netbsd-4-base
# 1.23 10-Oct-2006 dbj

implement -x by pruning fsnodes tree before building filesystem rather
than by skipping nodes while building filesystem


# 1.22 10-Oct-2006 dbj

add implementation of free_fsnodes() which unlinks a node
from the hierarchy and frees it and any of its children
use it to free memory before a normal exit, which helps diagnostics


# 1.21 10-Oct-2006 dbj

free specfile structure once it has been applied


# 1.20 10-Oct-2006 dbj

use new implementation of link_check which i
implemented for du.c revision 1.25 :

Use open address hashtable with multiplicative double hash probing
and exponential hashtable growth for tracking previously seen inodes.
This replaces the O(n^2) behavior of linkchk() with an implementation
that should be O(n*logn)


Revision tags: abandoned-netbsd-4-base
# 1.19 01-Feb-2006 dyoung

Stop duplicating the ISO9660 sources in sys/fs/cd9660/ for makefs(8).


# 1.18 19-Aug-2005 christos

64 bit inode changes


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.17 20-Jun-2004 jmc

Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944


# 1.16 31-May-2004 lukem

Use uint64_t instead of uint32_t to store a host inode when checking
for duplicate inodes, as Cygwin's stat(2) has a 64 bit st_ino.
Fix from Ian Lance Taylor in private email.


Revision tags: netbsd-2-0-base
# 1.15 19-Sep-2003 itojun

branches: 1.15.2;
realloc pedant


# 1.14 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.


# 1.13 09-May-2003 itojun

just for safety - use sizeof


# 1.12 29-Mar-2003 thorpej

Add a -x option which causes makefs(8) to exclude any file system node
not explicitly listed in the specfile.


# 1.11 27-Jan-2003 uwe

s/ulong/unsigned long/. ulong is for SysV compatibility, there's no
point in using it in our code. This change makes makefs(8) compile on
host systems without ulong.


Revision tags: fvdl_fs64_base
# 1.10 19-Oct-2002 provos

use readlink with bufsize - 1; approved thorpej.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.9 08-Feb-2002 lukem

branches: 1.9.2;
If an entry is in the specfile but not in the underlying file system, and it's
marked "optional", don't add it. (e.g, don't create a zero-length file).


# 1.8 31-Jan-2002 tv

Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.


# 1.7 23-Jan-2002 lukem

Merge create_fsinode() into create_fsnode(), so that a newly created
fsnode always has a valid inode member. Problem noted by Artem Belevich.


# 1.6 05-Dec-2001 lukem

rework `fsnode' into two components; `fsnode' contains the name and tree
information and a link to the appropriate fsinode, and `fsinode' contains
the inode information and a reference count. multiple fsnodes may point
to the same fsinode. this replaces the 'dup' pointer in the previous code.


# 1.5 02-Nov-2001 lukem

tweak copyright


# 1.4 29-Oct-2001 lukem

cast time_t values to long if printing as %ld to appease the sparc64 port


# 1.3 29-Oct-2001 lukem

- apply_specdir(): when adding a new symlink from the specfile, do the assert
check on the correct node
- apply_specentry(): if this node is a duplicate of another, apply the
changes to the `master' entry instead of this one.
- fix inotype() to DTRT
- comment out some debugging info that is too verbose


# 1.2 28-Oct-2001 lukem

add __RCSID()


# 1.1 26-Oct-2001 lukem

branches: 1.1.1;
Initial revision


# 1.30 03-Apr-2021 simonb

Add a -L option to follow all symbolic links. Useful if you have symlinks
in a makefs directory tree but want to refer to the actual file.


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.29 25-Nov-2015 christos

Provide a -T option to set timestamps to a consistent value for MKREPRO


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.28 03-Feb-2013 christos

add a replace flag so we can overlay exiting files when we merge directories.


# 1.27 28-Jan-2013 christos

- use emalloc and friends
- kill a bunch of global variables, more work to be done here
- homogenize option parsing. more work for cd9660
- use the new options parsing code to print an fs-specific usage


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5
# 1.26 19-Apr-2012 christos

branches: 1.26.2;
WARNS=5


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base
# 1.25 28-Jan-2012 christos

Patch from Jung-uk Kim (jkim at FreeBSD dot org) to allow contents of multiple
directories to be merged to the current image.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.24 28-Dec-2008 christos

branches: 1.24.8;
fix for 64 bit time_t and dev_t.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base netbsd-4-0-1-RELEASE wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-fixsa-newbase wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base netbsd-4-base
# 1.23 10-Oct-2006 dbj

implement -x by pruning fsnodes tree before building filesystem rather
than by skipping nodes while building filesystem


# 1.22 10-Oct-2006 dbj

add implementation of free_fsnodes() which unlinks a node
from the hierarchy and frees it and any of its children
use it to free memory before a normal exit, which helps diagnostics


# 1.21 10-Oct-2006 dbj

free specfile structure once it has been applied


# 1.20 10-Oct-2006 dbj

use new implementation of link_check which i
implemented for du.c revision 1.25 :

Use open address hashtable with multiplicative double hash probing
and exponential hashtable growth for tracking previously seen inodes.
This replaces the O(n^2) behavior of linkchk() with an implementation
that should be O(n*logn)


Revision tags: abandoned-netbsd-4-base
# 1.19 01-Feb-2006 dyoung

Stop duplicating the ISO9660 sources in sys/fs/cd9660/ for makefs(8).


# 1.18 19-Aug-2005 christos

64 bit inode changes


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.17 20-Jun-2004 jmc

Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944


# 1.16 31-May-2004 lukem

Use uint64_t instead of uint32_t to store a host inode when checking
for duplicate inodes, as Cygwin's stat(2) has a 64 bit st_ino.
Fix from Ian Lance Taylor in private email.


Revision tags: netbsd-2-0-base
# 1.15 19-Sep-2003 itojun

branches: 1.15.2;
realloc pedant


# 1.14 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.


# 1.13 09-May-2003 itojun

just for safety - use sizeof


# 1.12 29-Mar-2003 thorpej

Add a -x option which causes makefs(8) to exclude any file system node
not explicitly listed in the specfile.


# 1.11 27-Jan-2003 uwe

s/ulong/unsigned long/. ulong is for SysV compatibility, there's no
point in using it in our code. This change makes makefs(8) compile on
host systems without ulong.


Revision tags: fvdl_fs64_base
# 1.10 19-Oct-2002 provos

use readlink with bufsize - 1; approved thorpej.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.9 08-Feb-2002 lukem

branches: 1.9.2;
If an entry is in the specfile but not in the underlying file system, and it's
marked "optional", don't add it. (e.g, don't create a zero-length file).


# 1.8 31-Jan-2002 tv

Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.


# 1.7 23-Jan-2002 lukem

Merge create_fsinode() into create_fsnode(), so that a newly created
fsnode always has a valid inode member. Problem noted by Artem Belevich.


# 1.6 05-Dec-2001 lukem

rework `fsnode' into two components; `fsnode' contains the name and tree
information and a link to the appropriate fsinode, and `fsinode' contains
the inode information and a reference count. multiple fsnodes may point
to the same fsinode. this replaces the 'dup' pointer in the previous code.


# 1.5 02-Nov-2001 lukem

tweak copyright


# 1.4 29-Oct-2001 lukem

cast time_t values to long if printing as %ld to appease the sparc64 port


# 1.3 29-Oct-2001 lukem

- apply_specdir(): when adding a new symlink from the specfile, do the assert
check on the correct node
- apply_specentry(): if this node is a duplicate of another, apply the
changes to the `master' entry instead of this one.
- fix inotype() to DTRT
- comment out some debugging info that is too verbose


# 1.2 28-Oct-2001 lukem

add __RCSID()


# 1.1 26-Oct-2001 lukem

branches: 1.1.1;
Initial revision


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.29 25-Nov-2015 christos

Provide a -T option to set timestamps to a consistent value for MKREPRO


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.28 03-Feb-2013 christos

add a replace flag so we can overlay exiting files when we merge directories.


# 1.27 28-Jan-2013 christos

- use emalloc and friends
- kill a bunch of global variables, more work to be done here
- homogenize option parsing. more work for cd9660
- use the new options parsing code to print an fs-specific usage


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5
# 1.26 19-Apr-2012 christos

branches: 1.26.2;
WARNS=5


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base
# 1.25 28-Jan-2012 christos

Patch from Jung-uk Kim (jkim at FreeBSD dot org) to allow contents of multiple
directories to be merged to the current image.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.24 28-Dec-2008 christos

branches: 1.24.8;
fix for 64 bit time_t and dev_t.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base netbsd-4-0-1-RELEASE wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-fixsa-newbase wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base netbsd-4-base
# 1.23 10-Oct-2006 dbj

implement -x by pruning fsnodes tree before building filesystem rather
than by skipping nodes while building filesystem


# 1.22 10-Oct-2006 dbj

add implementation of free_fsnodes() which unlinks a node
from the hierarchy and frees it and any of its children
use it to free memory before a normal exit, which helps diagnostics


# 1.21 10-Oct-2006 dbj

free specfile structure once it has been applied


# 1.20 10-Oct-2006 dbj

use new implementation of link_check which i
implemented for du.c revision 1.25 :

Use open address hashtable with multiplicative double hash probing
and exponential hashtable growth for tracking previously seen inodes.
This replaces the O(n^2) behavior of linkchk() with an implementation
that should be O(n*logn)


Revision tags: abandoned-netbsd-4-base
# 1.19 01-Feb-2006 dyoung

Stop duplicating the ISO9660 sources in sys/fs/cd9660/ for makefs(8).


# 1.18 19-Aug-2005 christos

64 bit inode changes


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.17 20-Jun-2004 jmc

Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944


# 1.16 31-May-2004 lukem

Use uint64_t instead of uint32_t to store a host inode when checking
for duplicate inodes, as Cygwin's stat(2) has a 64 bit st_ino.
Fix from Ian Lance Taylor in private email.


Revision tags: netbsd-2-0-base
# 1.15 19-Sep-2003 itojun

branches: 1.15.2;
realloc pedant


# 1.14 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.


# 1.13 09-May-2003 itojun

just for safety - use sizeof


# 1.12 29-Mar-2003 thorpej

Add a -x option which causes makefs(8) to exclude any file system node
not explicitly listed in the specfile.


# 1.11 27-Jan-2003 uwe

s/ulong/unsigned long/. ulong is for SysV compatibility, there's no
point in using it in our code. This change makes makefs(8) compile on
host systems without ulong.


Revision tags: fvdl_fs64_base
# 1.10 19-Oct-2002 provos

use readlink with bufsize - 1; approved thorpej.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.9 08-Feb-2002 lukem

branches: 1.9.2;
If an entry is in the specfile but not in the underlying file system, and it's
marked "optional", don't add it. (e.g, don't create a zero-length file).


# 1.8 31-Jan-2002 tv

Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.


# 1.7 23-Jan-2002 lukem

Merge create_fsinode() into create_fsnode(), so that a newly created
fsnode always has a valid inode member. Problem noted by Artem Belevich.


# 1.6 05-Dec-2001 lukem

rework `fsnode' into two components; `fsnode' contains the name and tree
information and a link to the appropriate fsinode, and `fsinode' contains
the inode information and a reference count. multiple fsnodes may point
to the same fsinode. this replaces the 'dup' pointer in the previous code.


# 1.5 02-Nov-2001 lukem

tweak copyright


# 1.4 29-Oct-2001 lukem

cast time_t values to long if printing as %ld to appease the sparc64 port


# 1.3 29-Oct-2001 lukem

- apply_specdir(): when adding a new symlink from the specfile, do the assert
check on the correct node
- apply_specentry(): if this node is a duplicate of another, apply the
changes to the `master' entry instead of this one.
- fix inotype() to DTRT
- comment out some debugging info that is too verbose


# 1.2 28-Oct-2001 lukem

add __RCSID()


# 1.1 26-Oct-2001 lukem

branches: 1.1.1;
Initial revision