summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/3.0-upgrade/Makefile6
-rw-r--r--tools/3.0-upgrade/README31
-rw-r--r--tools/3.0-upgrade/cvt-wtmp.c284
-rw-r--r--tools/KSE/ksetest/Makefile8
-rw-r--r--tools/KSE/ksetest/kse_asm.S157
-rw-r--r--tools/KSE/ksetest/kse_threads_test.c492
-rw-r--r--tools/KSE/ksetest/simplelock.h59
-rwxr-xr-xtools/LibraryReport/LibraryReport.tcl289
-rw-r--r--tools/README8
-rw-r--r--tools/build/make_check/Makefile95
-rw-r--r--tools/build/make_check/regress.sysvmatch.out1
-rw-r--r--tools/build/make_check/regress.variables.out1
-rw-r--r--tools/diag/README17
-rw-r--r--tools/diag/ac/README9
-rw-r--r--tools/diag/ac/cknames.pl97
-rw-r--r--tools/diag/ac/ent.sh58
-rw-r--r--tools/diag/dumpvfscache/Makefile11
-rw-r--r--tools/diag/dumpvfscache/README6
-rw-r--r--tools/diag/dumpvfscache/dumpvfscache.c137
-rwxr-xr-xtools/diag/httpd-error/httpd-error62
-rw-r--r--tools/diag/localeck/Makefile12
-rw-r--r--tools/diag/localeck/docheck.sh37
-rw-r--r--tools/diag/localeck/localeck.c72
-rw-r--r--tools/install.sh42
-rw-r--r--tools/make_libdeps.sh117
-rw-r--r--tools/regression/README28
-rw-r--r--tools/regression/ccd/layout/Makefile11
-rw-r--r--tools/regression/ccd/layout/a.c16
-rw-r--r--tools/regression/ccd/layout/b.c19
-rw-r--r--tools/regression/ccd/layout/ccd.sh61
-rw-r--r--tools/regression/ccd/layout/ccd0.sh39
-rw-r--r--tools/regression/ccd/layout/ref.128k_128k_128k_128k_0_010
-rw-r--r--tools/regression/ccd/layout/ref.128k_128k_128k_128k_0_410
-rw-r--r--tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_0246
-rw-r--r--tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_2246
-rw-r--r--tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_4966
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_128k_128k_0_010
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_128k_128k_0_410
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_0247
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_2246
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_4966
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_384k_128k_0_010
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_384k_128k_0_410
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_098
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_268
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_4966
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_0374
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_2248
-rw-r--r--tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_4966
-rw-r--r--tools/regression/fsx/Makefile7
-rw-r--r--tools/regression/fsx/fsx.c1121
-rw-r--r--tools/regression/geom/ConfCmp/ConfCmp.c377
-rw-r--r--tools/regression/geom/ConfCmp/Makefile34
-rw-r--r--tools/regression/geom/ConfCmp/a1.conf414
-rw-r--r--tools/regression/geom/ConfCmp/a1a.conf414
-rw-r--r--tools/regression/geom/ConfCmp/a1b.conf414
-rw-r--r--tools/regression/geom/ConfCmp/a1c.conf414
-rw-r--r--tools/regression/geom/ConfCmp/a1d.conf414
-rw-r--r--tools/regression/geom/ConfCmp/a2.conf207
-rw-r--r--tools/regression/geom/ConfCmp/a2a.conf207
-rw-r--r--tools/regression/geom/ConfCmp/a2b.conf207
-rw-r--r--tools/regression/geom/ConfCmp/a2c.conf206
-rw-r--r--tools/regression/geom/ConfCmp/a2d.conf211
-rw-r--r--tools/regression/geom/Data/disk.alpha.da0.xml33
-rw-r--r--tools/regression/geom/Data/disk.alpha2.da0.xml33
-rw-r--r--tools/regression/geom/Data/disk.apple.xml93
-rw-r--r--tools/regression/geom/Data/disk.beast.da0.xml33
-rw-r--r--tools/regression/geom/Data/disk.critter.ad0.xml178
-rw-r--r--tools/regression/geom/Data/disk.empty.flp.xml12
-rw-r--r--tools/regression/geom/Data/disk.far.ad0.xml51
-rw-r--r--tools/regression/geom/Data/disk.flat.da1.xml97
-rw-r--r--tools/regression/geom/Data/disk.kern.flp.xml51
-rw-r--r--tools/regression/geom/Data/disk.msdos.ext.xml534
-rw-r--r--tools/regression/geom/Data/disk.msdos.flp.xml51
-rw-r--r--tools/regression/geom/Data/disk.pc98.wdc0.xml75
-rw-r--r--tools/regression/geom/Data/disk.sun.da0.xml33
-rw-r--r--tools/regression/geom/Data/disk.sun.da1.xml33
-rw-r--r--tools/regression/geom/Data/disk.typo.ad0.xml219
-rw-r--r--tools/regression/geom/GLib/Makefile25
-rw-r--r--tools/regression/geom/Makefile19
-rw-r--r--tools/regression/geom/Test/Makefile12
-rw-r--r--tools/regression/geom/Test/Makefile.inc37
-rw-r--r--tools/regression/geom/Test/T000/Makefile2
-rw-r--r--tools/regression/geom/Test/T000/ref.conf18
-rw-r--r--tools/regression/geom/Test/T000/testprg.c66
-rw-r--r--tools/regression/geom/Test/T001/Makefile2
-rw-r--r--tools/regression/geom/Test/T001/ref.conf409
-rw-r--r--tools/regression/geom/Test/T001/testprg.c69
-rw-r--r--tools/regression/geom/Test/T002/Makefile2
-rw-r--r--tools/regression/geom/Test/T002/ref.conf105
-rw-r--r--tools/regression/geom/Test/T002/testprg.c69
-rw-r--r--tools/regression/geom/Test/T003/Makefile2
-rw-r--r--tools/regression/geom/Test/T003/ref.conf695
-rw-r--r--tools/regression/geom/Test/T003/testprg.c69
-rw-r--r--tools/regression/geom/Test/T004/Makefile2
-rw-r--r--tools/regression/geom/Test/T004/ref.conf298
-rw-r--r--tools/regression/geom/Test/T004/testprg.c69
-rw-r--r--tools/regression/geom/Test/T005/Makefile2
-rw-r--r--tools/regression/geom/Test/T005/ref.conf133
-rw-r--r--tools/regression/geom/Test/T005/testprg.c69
-rw-r--r--tools/regression/geom/Test/T006/Makefile2
-rw-r--r--tools/regression/geom/Test/T006/ref.conf40
-rw-r--r--tools/regression/geom/Test/T006/testprg.c69
-rw-r--r--tools/regression/geom/Test/T007/Makefile2
-rw-r--r--tools/regression/geom/Test/T007/ref.conf18
-rw-r--r--tools/regression/geom/Test/T007/testprg.c73
-rw-r--r--tools/regression/geom/Test/T008/Makefile2
-rw-r--r--tools/regression/geom/Test/T008/ref.conf18
-rw-r--r--tools/regression/geom/Test/T008/testprg.c75
-rw-r--r--tools/regression/geom/Test/T009/Makefile2
-rw-r--r--tools/regression/geom/Test/T009/ref.conf18
-rw-r--r--tools/regression/geom/Test/T009/testprg.c89
-rw-r--r--tools/regression/geom/Test/T010/Makefile2
-rw-r--r--tools/regression/geom/Test/T010/ref.conf38
-rw-r--r--tools/regression/geom/Test/T010/testprg.c78
-rw-r--r--tools/regression/geom/Test/T011/Makefile2
-rw-r--r--tools/regression/geom/Test/T011/ref.conf40
-rw-r--r--tools/regression/geom/Test/T011/testprg.c78
-rw-r--r--tools/regression/geom/Test/T012/Makefile2
-rw-r--r--tools/regression/geom/Test/T012/ref.conf359
-rw-r--r--tools/regression/geom/Test/T012/testprg.c73
-rw-r--r--tools/regression/geom/Test/T013/Makefile2
-rw-r--r--tools/regression/geom/Test/T013/ref.conf413
-rw-r--r--tools/regression/geom/Test/T013/testprg.c71
-rw-r--r--tools/regression/geom/Test/T014/Makefile2
-rw-r--r--tools/regression/geom/Test/T014/ref.conf230
-rw-r--r--tools/regression/geom/Test/T014/testprg.c72
-rw-r--r--tools/regression/geom/Test/T015/Makefile2
-rw-r--r--tools/regression/geom/Test/T015/ref.conf121
-rw-r--r--tools/regression/geom/Test/T015/testprg.c67
-rw-r--r--tools/regression/geom/geom.c196
-rw-r--r--tools/regression/geom/geom_kernsim.c288
-rw-r--r--tools/regression/geom/geom_sim.c185
-rw-r--r--tools/regression/geom/geom_sim.h176
-rw-r--r--tools/regression/geom/geom_simdev.c159
-rw-r--r--tools/regression/geom/geom_simdisk.c259
-rw-r--r--tools/regression/geom/geom_simdisk.h64
-rw-r--r--tools/regression/geom/geom_simdisk_xml.c244
-rw-r--r--tools/regression/ia64_unaligned/Makefile6
-rw-r--r--tools/regression/ia64_unaligned/unaligned.c131
-rw-r--r--tools/regression/lib/libc/gen/Makefile11
-rw-r--r--tools/regression/lib/libc/gen/test-fpclassify.c75
-rw-r--r--tools/regression/lib/libc/gen/test-wordexp.c174
-rw-r--r--tools/regression/lib/libc/locale/Makefile21
-rw-r--r--tools/regression/lib/libc/locale/test-btowc.c70
-rw-r--r--tools/regression/lib/libc/locale/test-mblen.c109
-rw-r--r--tools/regression/lib/libc/locale/test-mbrlen.c127
-rw-r--r--tools/regression/lib/libc/locale/test-mbrtowc.c150
-rw-r--r--tools/regression/lib/libc/locale/test-mbsrtowcs.c148
-rw-r--r--tools/regression/lib/libc/locale/test-mbstowcs.c110
-rw-r--r--tools/regression/lib/libc/locale/test-mbtowc.c119
-rw-r--r--tools/regression/lib/libc/locale/test-wcrtomb.c132
-rw-r--r--tools/regression/lib/libc/locale/test-wcsrtombs.c153
-rw-r--r--tools/regression/lib/libc/locale/test-wcstombs.c127
-rw-r--r--tools/regression/lib/libc/locale/test-wctomb.c109
-rw-r--r--tools/regression/lib/libc/stdio/Makefile11
-rw-r--r--tools/regression/lib/libc/stdio/test-perror.c105
-rw-r--r--tools/regression/lib/libc/string/Makefile11
-rw-r--r--tools/regression/lib/libc/string/test-strerror.c130
-rw-r--r--tools/regression/nfsmmap/Makefile3
-rw-r--r--tools/regression/nfsmmap/README20
-rw-r--r--tools/regression/nfsmmap/test1/Makefile25
-rw-r--r--tools/regression/nfsmmap/test1/test1.c46
-rw-r--r--tools/regression/nfsmmap/test1/test1.good.uu95
-rw-r--r--tools/regression/nfsmmap/test1/test1.zeros.uu95
-rw-r--r--tools/regression/nfsmmap/test2/Makefile25
-rw-r--r--tools/regression/nfsmmap/test2/test2.c44
-rw-r--r--tools/regression/nfsmmap/test2/test2.good.uu95
-rw-r--r--tools/regression/nfsmmap/test2/test2.zeros.uu95
-rw-r--r--tools/regression/p1003_1b/Makefile17
-rw-r--r--tools/regression/p1003_1b/README14
-rw-r--r--tools/regression/p1003_1b/fifo.c227
-rw-r--r--tools/regression/p1003_1b/main.c78
-rw-r--r--tools/regression/p1003_1b/memlock.c91
-rw-r--r--tools/regression/p1003_1b/p26.c65
-rw-r--r--tools/regression/p1003_1b/prutil.c61
-rw-r--r--tools/regression/p1003_1b/prutil.h14
-rw-r--r--tools/regression/p1003_1b/sched.c294
-rw-r--r--tools/regression/p1003_1b/yield.c197
-rw-r--r--tools/regression/security/access/Makefile9
-rw-r--r--tools/regression/security/access/testaccess.c360
-rw-r--r--tools/regression/security/proc_to_proc/Makefile12
-rw-r--r--tools/regression/security/proc_to_proc/README54
-rw-r--r--tools/regression/security/proc_to_proc/scenario.c431
-rw-r--r--tools/regression/security/proc_to_proc/scenario.h34
-rw-r--r--tools/regression/security/proc_to_proc/testuid.c65
-rw-r--r--tools/regression/sysvmsg/Makefile15
-rw-r--r--tools/regression/sysvmsg/README13
-rw-r--r--tools/regression/sysvmsg/msgtest.c347
-rw-r--r--tools/regression/sysvsem/Makefile15
-rw-r--r--tools/regression/sysvsem/README13
-rw-r--r--tools/regression/sysvsem/semtest.c348
-rw-r--r--tools/regression/sysvshm/Makefile15
-rw-r--r--tools/regression/sysvshm/README13
-rw-r--r--tools/regression/sysvshm/shmtest.c297
-rw-r--r--tools/regression/usr.bin/Makefile5
-rw-r--r--tools/regression/usr.bin/file2c/Makefile4
-rw-r--r--tools/regression/usr.bin/file2c/regress.inbin0 -> 2048 bytes
-rw-r--r--tools/regression/usr.bin/file2c/regress.out104
-rw-r--r--tools/regression/usr.bin/file2c/regress.sh7
-rw-r--r--tools/regression/usr.bin/join/Makefile4
-rw-r--r--tools/regression/usr.bin/join/regress.1.in4
-rw-r--r--tools/regression/usr.bin/join/regress.2.in4
-rw-r--r--tools/regression/usr.bin/join/regress.out5
-rw-r--r--tools/regression/usr.bin/join/regress.sh7
-rw-r--r--tools/regression/usr.bin/jot/Makefile4
-rw-r--r--tools/regression/usr.bin/jot/regress.out1
-rw-r--r--tools/regression/usr.bin/jot/regress.sh7
-rw-r--r--tools/regression/usr.bin/m4/Makefile4
-rw-r--r--tools/regression/usr.bin/m4/regress.changecom.in3
-rw-r--r--tools/regression/usr.bin/m4/regress.changecom.out3
-rw-r--r--tools/regression/usr.bin/m4/regress.gchangecom.out2
-rw-r--r--tools/regression/usr.bin/m4/regress.sh40
-rw-r--r--tools/regression/usr.bin/make/Makefile95
-rw-r--r--tools/regression/usr.bin/make/regress.sysvmatch.out1
-rw-r--r--tools/regression/usr.bin/make/regress.variables.out1
-rw-r--r--tools/regression/usr.bin/regress.m461
-rw-r--r--tools/regression/usr.bin/sed/Makefile4
-rw-r--r--tools/regression/usr.bin/sed/hanoi.sed103
-rw-r--r--tools/regression/usr.bin/sed/math.sed163
-rw-r--r--tools/regression/usr.bin/sed/multitest.t552
-rw-r--r--tools/regression/usr.bin/sed/regress.G.out8
-rw-r--r--tools/regression/usr.bin/sed/regress.P.out8
-rw-r--r--tools/regression/usr.bin/sed/regress.bcb.out4
-rw-r--r--tools/regression/usr.bin/sed/regress.in4
-rw-r--r--tools/regression/usr.bin/sed/regress.psl.out4
-rw-r--r--tools/regression/usr.bin/sed/regress.sh11
-rw-r--r--tools/regression/usr.bin/sed/regress.y.out1
-rw-r--r--tools/regression/usr.bin/sed/sed.test552
-rw-r--r--tools/regression/usr.bin/uudecode/Makefile4
-rw-r--r--tools/regression/usr.bin/uudecode/regress.base64.in88
-rw-r--r--tools/regression/usr.bin/uudecode/regress.outbin0 -> 4096 bytes
-rw-r--r--tools/regression/usr.bin/uudecode/regress.sh8
-rw-r--r--tools/regression/usr.bin/uudecode/regress.traditional.in95
-rw-r--r--tools/regression/usr.bin/uuencode/Makefile4
-rw-r--r--tools/regression/usr.bin/uuencode/regress.base64.out74
-rw-r--r--tools/regression/usr.bin/uuencode/regress.inbin0 -> 4096 bytes
-rw-r--r--tools/regression/usr.bin/uuencode/regress.sh11
-rw-r--r--tools/regression/usr.bin/uuencode/regress.traditional.out95
-rw-r--r--tools/regression/usr.bin/xargs/Makefile4
-rw-r--r--tools/regression/usr.bin/xargs/regress.I.out4
-rw-r--r--tools/regression/usr.bin/xargs/regress.J.out1
-rw-r--r--tools/regression/usr.bin/xargs/regress.L.out2
-rw-r--r--tools/regression/usr.bin/xargs/regress.R.out4
-rw-r--r--tools/regression/usr.bin/xargs/regress.in4
-rw-r--r--tools/regression/usr.bin/xargs/regress.normal.out1
-rw-r--r--tools/regression/usr.bin/xargs/regress.sh11
-rw-r--r--tools/test/README12
-rw-r--r--tools/test/devrandom/hammer.random23
-rw-r--r--tools/test/devrandom/hammer.urandom27
-rw-r--r--tools/test/devrandom/stat.16bit29
-rw-r--r--tools/test/devrandom/stat.8bit29
-rw-r--r--tools/test/malloc/Makefile15
-rw-r--r--tools/test/malloc/main.c57
-rw-r--r--tools/test/posixshm/README4
-rw-r--r--tools/test/posixshm/shm_test.c144
-rw-r--r--tools/tools/README38
-rw-r--r--tools/tools/backout_commit/backout_commit.rb350
-rw-r--r--tools/tools/commitsdb/make_commit_db105
-rw-r--r--tools/tools/commitsdb/query_commit_db93
-rw-r--r--tools/tools/crypto/Makefile17
-rw-r--r--tools/tools/crypto/README44
-rw-r--r--tools/tools/crypto/cryptokeytest.c224
-rw-r--r--tools/tools/crypto/cryptostats.c77
-rw-r--r--tools/tools/crypto/cryptotest.c424
-rw-r--r--tools/tools/editing/freebsd.el40
-rw-r--r--tools/tools/epfe/epfe.pl38
-rw-r--r--tools/tools/find-sb/Makefile5
-rw-r--r--tools/tools/find-sb/README18
-rw-r--r--tools/tools/find-sb/find-sb.c95
-rw-r--r--tools/tools/html-mv/html-mv59
-rw-r--r--tools/tools/ifinfo/Makefile7
-rw-r--r--tools/tools/ifinfo/ifinfo.c282
-rw-r--r--tools/tools/ifinfo/ifinfo.h38
-rw-r--r--tools/tools/ifinfo/rfc1650.c124
-rwxr-xr-xtools/tools/kdrv/KernelDriver1081
-rw-r--r--tools/tools/kdrv/sample.drvinfo44
-rw-r--r--tools/tools/kernelcruft/kernelcruft.sh43
-rw-r--r--tools/tools/kerninclude/kerninclude.sh303
-rw-r--r--tools/tools/kernxref/kernxref.sh154
-rwxr-xr-xtools/tools/mid/mid-build46
-rwxr-xr-xtools/tools/mid/mid-index83
-rwxr-xr-xtools/tools/mid/mid-master33
-rwxr-xr-xtools/tools/mid/mid-master-index21
-rw-r--r--tools/tools/mtxstat/mtxstat.pl130
-rw-r--r--tools/tools/pciid/mk_pci_vendors.pl241
-rw-r--r--tools/tools/portsinfo/portsinfo.sh84
-rw-r--r--tools/tools/prstats/prstats.pl357
-rw-r--r--tools/tools/scsi-defects/README5
-rwxr-xr-xtools/tools/scsi-defects/scsi-defects.pl94
-rw-r--r--tools/tools/tinderbox/Makefile8
-rw-r--r--tools/tools/tinderbox/tbmaster.pl264
-rw-r--r--tools/tools/tinderbox/tinderbox.pl441
-rwxr-xr-xtools/tools/upgrade/doupgrade.sh78
-rwxr-xr-xtools/tools/upgrade/getosreldate.sh8
-rwxr-xr-xtools/tools/upgrade/move_aout_libs.sh139
-rw-r--r--tools/tools/vop_table/README2
-rw-r--r--tools/tools/vop_table/vop_table.tcl213
-rw-r--r--tools/tools/whereintheworld/Makefile5
-rw-r--r--tools/tools/whereintheworld/whereintheworld.pl69
300 files changed, 34182 insertions, 0 deletions
diff --git a/tools/3.0-upgrade/Makefile b/tools/3.0-upgrade/Makefile
new file mode 100644
index 0000000..3c78cd4
--- /dev/null
+++ b/tools/3.0-upgrade/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+PROG= cvt-wtmp
+NOMAN= YES
+
+.include <bsd.prog.mk>
diff --git a/tools/3.0-upgrade/README b/tools/3.0-upgrade/README
new file mode 100644
index 0000000..42761ac
--- /dev/null
+++ b/tools/3.0-upgrade/README
@@ -0,0 +1,31 @@
+$FreeBSD$
+
+By 1996/12/04, the utmp element size has been changed, in order to
+allow for longer usernames. This change renders all existing wtmp
+files unusable. The cvt-wtmp utility is provided as an aid to convert
+your old wtmp files into the new format, so you don't lose the
+existing track record.
+
+The tool cannot handle gzip'ed wtmp backups, so unzip them first if
+you need. Then simply call it as:
+
+ ./cvt-wtmp /var/log/wtmp*
+
+The old wtmp files are being renamed to <file>.bak, so nothing will be
+lost even in case of a failure. If you are only about to test whether
+the tool will grok your files correctly, you can run it as:
+
+ ./cvt-wtmp -n /var/log/wtmp*
+
+The tool tries an ``educated guess'', based on the reasonability of
+the timestamp values in the wtmp file. If it fails to recognize the
+format of your wtmp, it normally bails out, or at least ignores
+garbage records. In this case, rename the .bak files to the original
+name, and try to force the conversion:
+
+ ./cvt-wtmp -f /var/log/wtmp.xxx
+
+Make sure to verify the result however!
+
+
+Dresden, Jan 2, 1996 Joerg <joerg@FreeBSD.org>
diff --git a/tools/3.0-upgrade/cvt-wtmp.c b/tools/3.0-upgrade/cvt-wtmp.c
new file mode 100644
index 0000000..c5d3b54
--- /dev/null
+++ b/tools/3.0-upgrade/cvt-wtmp.c
@@ -0,0 +1,284 @@
+/*
+ * Copyright (c) 1996 Joerg Wunsch
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ *
+ */
+
+/*
+ * Heuristics to convert old wtmp format to new one.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <utmp.h>
+
+
+#define OUT_NAMESIZE 8
+#define OUT_LINESIZE 8
+#define OUT_HOSTSIZE 16
+
+struct olastlog {
+ time_t ll_time;
+ char ll_line[OUT_LINESIZE];
+ char ll_host[OUT_HOSTSIZE];
+};
+
+struct outmp {
+ char ut_line[OUT_LINESIZE];
+ char ut_name[OUT_NAMESIZE];
+ char ut_host[OUT_HOSTSIZE];
+ long ut_time;
+};
+
+void usage(void);
+void convert(const char *, int, int);
+
+/*
+ * NB: We cannot convert lastlog yet, but we don't need either.
+ */
+
+void
+usage(void)
+{
+ errx(EX_USAGE, "usage: cvt-wtmp [-f] [-n] /var/log/wtmp*");
+}
+
+
+int
+main(int argc, char **argv)
+{
+ int errs, i, nflag, forceflag, rv;
+
+ errs = nflag = forceflag = 0;
+ while ((i = getopt(argc, argv, "fn")) != -1)
+ switch (i)
+ {
+ case 'f':
+ forceflag++;
+ break;
+
+ case 'n':
+ nflag++;
+ break;
+
+ default:
+ errs++;
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc <= 0 || errs)
+ usage();
+
+ for (;argc > 0; argc--, argv++)
+ convert(*argv, nflag, forceflag);
+
+ return 0;
+}
+
+void
+convert(const char *name, int nflag, int forceflag)
+{
+ struct stat sb;
+ struct timeval tv[2];
+ char xname[1024], yname[1024];
+ unsigned char buf[128]; /* large enough to hold one wtmp record */
+ int fd1, fd2;
+ size_t off, shouldbe;
+ int old, new;
+ time_t now, early, *t;
+ struct tm tm;
+ struct utmp u;
+ struct outmp *ou;
+ enum { OLD, NEW } which = OLD; /* what we're defaulting to */
+
+ if (stat(name, &sb) == -1)
+ {
+ warn("Cannot stat file \"%s\", continuing.", name);
+ return;
+ }
+
+ now = time(NULL);
+ /* some point in time very early, before 386BSD 0.0 */
+ tm.tm_sec = 0; tm.tm_min = 0; tm.tm_hour = 0;
+ tm.tm_mday = 1; tm.tm_mon = 2; tm.tm_year = 92;
+ tm.tm_isdst = 0;
+ early = mktime(&tm);
+
+ tv[0].tv_sec = sb.st_atimespec.tv_sec;
+ tv[0].tv_usec = sb.st_atimespec.tv_nsec / 1000;
+ tv[1].tv_sec = sb.st_mtimespec.tv_sec;
+ tv[1].tv_usec = sb.st_mtimespec.tv_nsec / 1000;
+
+ /* unzipping is handled best externally */
+ if (strlen(name) > 3 && memcmp(&name[strlen(name) - 3], ".gz", 3) == 0)
+ {
+ warnx("Cannot handle gzipped files, ignoring \"%s\".", name);
+ return;
+ }
+
+ (void) snprintf(xname, sizeof xname, "%s.new", name);
+ if (!nflag && (fd1 = open(xname, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1)
+ err(EX_CANTCREAT, "Can't create new wtmp file");
+
+ if ((fd2 = open(name, O_RDONLY, 0)) == -1)
+ err(EX_UNAVAILABLE, "input file magically disappeared, i'm confused");
+
+ old = new = 0; off = 0;
+ memset(buf, 0, sizeof buf);
+
+ while (read(fd2, &buf[off], sizeof(time_t)) == sizeof(time_t))
+ {
+ t = (time_t *)&buf[off];
+ off += sizeof(time_t);
+ if (off < sizeof(struct outmp))
+ /* go on */
+ continue;
+ if (*t < early || *t > now)
+ {
+ /* unreasonable, collect another entry */
+ if (off > sizeof buf)
+ {
+ if (!forceflag)
+ {
+ (void) unlink(xname);
+ errx(EX_UNAVAILABLE, "I can't seem to make sense out of file \"%s\",\n"
+ "Could have forced using -f.",
+ name);
+ }
+ else
+ {
+ warnx("Record # %d in file \"%s\" seems bogus\n"
+ "(time: %d, previous time: %d, now: %d),\n"
+ "continuing anyway.",
+ old + new + 1, name, *t, early, now);
+ if (which == NEW)
+ {
+ (void)lseek(fd2, sizeof(struct utmp) - sizeof buf, SEEK_CUR);
+ goto write_new;
+ }
+ else
+ {
+ (void)lseek(fd2, sizeof(struct outmp) - sizeof buf, SEEK_CUR);
+ goto write_old;
+ }
+ }
+ }
+ continue;
+ }
+ /* time is reasonable, we seem to have collected a full entry */
+ if (off == sizeof(struct utmp))
+ {
+ /* new wtmp record */
+ which = NEW;
+ write_new:
+ new++;
+ if (!nflag)
+ {
+ if (write(fd1, buf, sizeof(struct utmp)) != sizeof(struct utmp))
+ err(EX_IOERR, "writing file \"%s\"", xname);
+ }
+ }
+ else if (off == sizeof(struct outmp))
+ {
+ /* old fart */
+ which = OLD;
+ write_old:
+ old++;
+ if (!nflag)
+ {
+ ou = (struct outmp *)buf;
+ memset(&u, 0, sizeof u);
+ memcpy(&u.ut_line, ou->ut_line, OUT_LINESIZE);
+ memcpy(&u.ut_name, ou->ut_name, OUT_NAMESIZE);
+ memcpy(&u.ut_host, ou->ut_host, OUT_HOSTSIZE);
+ memcpy(&u.ut_time, &ou->ut_time, sizeof u.ut_time);
+ if (write(fd1, &u, sizeof(struct utmp)) != sizeof(struct utmp))
+ err(EX_IOERR, "writing file \"%s\"", xname);
+ }
+ }
+ else
+ {
+ if (!forceflag)
+ {
+ warnx("Illegal record in file \"%s\", ignoring.", name);
+ off = 0;
+ continue;
+ }
+ else
+ {
+ warnx("Illegal record in file \"%s\", considering it %s one.",
+ name, (which == OLD? "an old": "a new"));
+ shouldbe = (which == OLD? sizeof(struct outmp): sizeof(struct utmp));
+ if (off < shouldbe)
+ (void)read(fd2, &buf[off], shouldbe - off);
+ else
+ (void)lseek(fd2, shouldbe - off, SEEK_CUR);
+ if (which == OLD)
+ goto write_old;
+ else
+ goto write_new;
+ }
+ }
+ off = 0;
+ /*
+ * Since the wtmp file is in chronologically acsending order, we
+ * can move the `early' time as we go. Allow for one hour
+ * time-of-day adjustments.
+ */
+ early = *t - 3600;
+ memset(buf, 0, sizeof buf);
+ }
+ close(fd2);
+
+ printf("File \"%s\": %d old and %d new records found.\n",
+ name, old, new);
+
+ if (nflag)
+ return;
+
+ (void) close(fd1);
+ (void) snprintf(yname, sizeof yname, "%s.bak", name);
+
+ if (rename(name, yname) == -1)
+ err(EX_OSERR, "Cannot rename \"%s\" to \"%s\"", name, yname);
+
+ if (rename(xname, name) == -1)
+ err(EX_OSERR, "Cannot rename \"%s\" to \"%s\"", xname, name);
+
+ if (utimes(name, tv) == -1)
+ warn("Cannot adjust access and modification times for \"%s\"", name);
+}
+
diff --git a/tools/KSE/ksetest/Makefile b/tools/KSE/ksetest/Makefile
new file mode 100644
index 0000000..b5838f2
--- /dev/null
+++ b/tools/KSE/ksetest/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+PROG= ksetest
+NOMAN=
+CFLAGS+= -g -Wall
+SRCS= kse_asm.S kse_threads_test.c
+
+.include <bsd.prog.mk>
diff --git a/tools/KSE/ksetest/kse_asm.S b/tools/KSE/ksetest/kse_asm.S
new file mode 100644
index 0000000..20dc1db
--- /dev/null
+++ b/tools/KSE/ksetest/kse_asm.S
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2002 Jonathan Mini <mini@freebsd.org>.
+ * Copyright (c) 2001 Daniel Eischen <deischen@freebsd.org>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Neither the name of the author nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Where do we define these?
+ */
+#define MC_SIZE 640 /* sizeof mcontext_t */
+#define UC_MC_OFFSET 16 /* offset to mcontext from ucontext */
+#define UC_MC_LEN_OFFSET 96 /* offset to mc_len from mcontext */
+#define MC_LEN_OFFSET 80 /* offset to mc_len from mcontext */
+#define MC_FP_REGS_OFFSET 96 /* offset to FP regs from mcontext */
+#define MC_FP_CW_OFFSET 96 /* offset to FP control word */
+#define MC_OWNEDFP_OFFSET 88 /* offset to mc_ownedfp from mcontext */
+#define KM_STACK_SP_OFFSET 36 /* offset to km_stack.ss_sp */
+#define KM_STACK_SIZE_OFFSET 40 /* offset to km_stack.ss_sp */
+#define KM_FUNC_OFFSET 32 /* offset to km_func */
+
+/*
+ * int uts_to_thread(struct kse_thr_mailbox *tdp,
+ * struct kse_thr_mailbox **curthreadp);
+ *
+ * Does not return on success, returns -1 otherwise.
+ */
+ENTRY(uts_to_thread)
+ movl 4(%esp), %edx /* get address of kse_thr_mailbox */
+ /* .. ucontext_t is at offset 0 */
+ cmpl $0, %edx /* check for null pointer */
+ jne 1f
+ movl $-1, %eax
+ jmp 5f
+1: cmpl $MC_SIZE, UC_MC_LEN_OFFSET(%edx) /* is context valid? */
+ je 2f
+ movl $-1, %eax /* bzzzt, invalid context */
+ jmp 5f
+2: movl 8(%esp), %ecx /* get address of curthreadp */
+ movl %edx, %ebx /* save the pointer for later */
+ /*
+ * From here on, we don't touch the old stack.
+ */
+ addl $UC_MC_OFFSET, %edx /* add offset to mcontext */
+ movl 4(%edx), %gs
+ movl 8(%edx), %fs
+ movl 12(%edx), %es
+ movl 16(%edx), %ds
+ movl 76(%edx), %ss
+ movl 20(%edx), %edi
+ movl 24(%edx), %esi
+ movl 28(%edx), %ebp
+ movl 72(%edx), %esp /* switch to context defined stack */
+ subl $4, %esp /* leave space for the return address */
+ movl 60(%edx), %eax /* put return address at top of stack */
+ movl %eax, (%esp)
+ cmpl $0, MC_OWNEDFP_OFFSET(%edx) /* are FP regs valid? */
+ jz 3f
+ frstor MC_FP_REGS_OFFSET(%edx) /* restore FP regs */
+ jmp 4f
+3: fninit
+ fldcw MC_FP_CW_OFFSET(%edx)
+4: movl 48(%edx), %eax /* restore ax, bx, cx, dx */
+ pushl 68(%edx) /* flags on stack */
+ pushl 36(%edx) /* %ebx on stack */
+ pushl 44(%edx) /* %ecx on stack */
+ movl 40(%edx), %edx /* %edx */
+ /*
+ * all registers are now moved out of mailbox,
+ * it's safe to set current thread pointer
+ */
+ movl %ebx,(%ecx)
+ popl %ecx /* %ecx off stack */
+ pop %ebx /* %ebx off stack */
+ popf /* flags off stack */
+5: ret /* %eip off stack */
+
+/*
+ * int thread_to_uts(struct kse_thr_mailbox *tm, struct kse_mailbox *km);
+ *
+ * Does not return on success, returns -1 otherwise.
+ */
+ENTRY(thread_to_uts)
+ movl 4(%esp), %eax /* get address of context */
+ cmpl $0, %eax /* check for null pointer */
+ jne 1f
+ movl $-1, %eax
+ jmp 2f
+1: pushl %edx /* save value of edx */
+ movl %eax, %edx /* get address of context */
+ addl $UC_MC_OFFSET, %edx /* add offset to mcontext */
+ movl %gs, 4(%edx)
+ movl %fs, 8(%edx)
+ movl %es, 12(%edx)
+ movl %ds, 16(%edx)
+ movl %edi, 20(%edx)
+ movl %esi, 24(%edx)
+ movl %ebp, 28(%edx)
+ movl %ebx, 36(%edx)
+ movl $0, 48(%edx) /* store successful return in eax */
+ popl %eax /* get saved value of edx */
+ movl %eax, 40(%edx) /* save edx */
+ movl %ecx, 44(%edx)
+ movl (%esp), %eax /* get return address */
+ movl %eax, 60(%edx) /* save return address */
+ movl %ss, 76(%edx)
+ /*
+ * Don't save floating point registers here.
+ *
+ * This is an explicit call to get the current context, so
+ * the caller is done with the floating point registers.
+ * Contexts formed by involuntary switches, such as signal delivery,
+ * have floating point registers saved by the kernel.
+ */
+ fnstcw MC_FP_CW_OFFSET(%edx)
+ movl $0, MC_OWNEDFP_OFFSET(%edx) /* no FP */
+ pushfl /* get eflags */
+ popl %eax
+ movl %eax, 68(%edx) /* store eflags */
+ movl %esp, %eax /* setcontext pushes the return */
+ addl $4, %eax /* address onto the top of the */
+ movl %eax, 72(%edx) /* stack; account for this */
+ movl $MC_SIZE, MC_LEN_OFFSET(%edx) /* context is now valid */
+ movl 8(%esp), %edx /* get address of mailbox */
+ movl KM_STACK_SP_OFFSET(%edx), %eax /* get bottom of stack */
+ addl KM_STACK_SIZE_OFFSET(%edx), %eax /* add length */
+ movl %eax, %esp /* switch to the uts's stack */
+ pushl %edx /* push the address of the mailbox */
+ pushl KM_FUNC_OFFSET(%edx) /* .. the uts can return to itself */
+ pushl KM_FUNC_OFFSET(%edx) /* push the address of the uts func */
+2: ret
+
diff --git a/tools/KSE/ksetest/kse_threads_test.c b/tools/KSE/ksetest/kse_threads_test.c
new file mode 100644
index 0000000..3ab09f9
--- /dev/null
+++ b/tools/KSE/ksetest/kse_threads_test.c
@@ -0,0 +1,492 @@
+/*-
+ * Copyright (c) 2002 Jonathan Mini (mini@freebsd.org).
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/sysctl.h>
+#include <sys/kse.h>
+#include <sys/ucontext.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <time.h>
+#include <unistd.h>
+#include "simplelock.h"
+
+#undef TRACE_UTS
+//#define TRACE_KSE
+
+#ifdef TRACE_UTS
+#define UPFMT(fmt...) pfmt(#fmt)
+#define UPSTR(s) pstr(s)
+#define UPCHAR(c) pchar(c)
+#else
+#define UPFMT(fmt...) /* Nothing. */
+#define UPSTR(s) /* Nothing. */
+#define UPCHAR(c) /* Nothing. */
+#endif
+
+#define MAIN_STACK_SIZE (1024 * 1024)
+#define THREAD_STACK_SIZE (32 * 1024)
+
+struct uts_runq {
+ struct kse_thr_mailbox *head;
+ struct simplelock lock;
+};
+
+struct uts_data {
+ struct kse_mailbox mb;
+ struct uts_runq *runq;
+ struct kse_thr_mailbox *cur_thread;
+};
+
+static struct uts_runq runq1;
+static struct uts_data data1, data2;
+static struct uts_runq runq2;
+static struct uts_data data3, data4;
+static struct kse_thr_mailbox *aa;
+
+#ifdef TRACE_UTS
+static int progress = 0;
+#endif
+
+static void init_uts(struct uts_data *data, struct uts_runq *q);
+static void start_uts(struct uts_data *data, int newgrp);
+static void enter_uts(struct uts_data *);
+static void pchar(char c);
+static void pfmt(const char *fmt, ...);
+static void pstr(const char *s);
+static void runq_init(struct uts_runq *q);
+static void runq_insert(struct uts_runq *q, struct kse_thr_mailbox *tm);
+static struct kse_thr_mailbox *runq_remove(struct uts_runq *q);
+static struct kse_thr_mailbox *runq_remove_nolock(struct uts_runq *q);
+static void thread_start(struct uts_data *data, const void *func, int arg);
+static void uts(struct kse_mailbox *km);
+
+/* Functions implemented in assembly */
+extern int uts_to_thread(struct kse_thr_mailbox *tdp,
+ struct kse_thr_mailbox **curthreadp);
+extern int thread_to_uts(struct kse_thr_mailbox *tm,
+ struct kse_mailbox *km);
+
+static void
+nano(int len)
+{
+ struct timespec time_to_sleep;
+ struct timespec time_remaining;
+
+ time_to_sleep.tv_sec = 0;
+ time_to_sleep.tv_nsec = len * 10000;
+ nanosleep(&time_to_sleep, &time_remaining);
+}
+
+void
+aaaa(int c)
+{
+ for (;;) {
+ pchar(c);
+ nano(1);
+ }
+}
+
+static void
+foof(int sig)
+{
+ pfmt("\n[%d]\n", sig);
+// thread_start(aaaa, '0' + progress++);
+}
+
+static void
+newkse(int v)
+{
+ start_uts(&data4, 0);
+}
+
+#if 0
+void
+spin(int arg)
+{
+ for (;;) enter_uts(); sched_yield();
+}
+#endif
+/*
+ * Test Userland Thread Scheduler (UTS) suite for KSE.
+ */
+int
+main(void)
+{
+ int i;
+
+ runq_init(&runq1);
+ init_uts(&data1, &runq1);
+ init_uts(&data2, &runq1);
+ thread_start(&data1, aaaa, '+');
+ thread_start(&data1, aaaa, '-');
+ start_uts(&data1, 0);
+ start_uts(&data2, 0);
+
+// start second ksegrp
+ runq_init(&runq2);
+ init_uts(&data3, &runq2);
+ init_uts(&data4, &runq2);
+ thread_start(&data3, newkse, 0);
+ thread_start(&data3, aaaa, '*');
+ thread_start(&data3, aaaa, '.');
+ start_uts(&data3, 1);
+
+ for (i = 0;1;i++) {
+// if (i < 1000)
+// thread_start(aaaa, 'a' + (i % 26));
+ pchar('A' + (i % 26));
+ nano(5);
+ }
+ pstr("\n** main() exiting **\n");
+ return (EX_OK);
+}
+
+
+/*
+ * Enter the UTS from a thread.
+ */
+static void
+enter_uts(struct uts_data *data)
+{
+ struct kse_thr_mailbox *td;
+
+ /* XXX: We should atomically exchange these two. */
+ td = data->mb.km_curthread;
+ data->mb.km_curthread = NULL;
+
+ thread_to_uts(td, &data->mb);
+}
+
+/*
+ * Initialise threading.
+ */
+static void
+init_uts(struct uts_data *data, struct uts_runq *q)
+{
+ struct kse_thr_mailbox *tm;
+ int mib[2];
+ char *p;
+#if 0
+ size_t len;
+#endif
+
+ /*
+ * Create initial thread.
+ */
+ tm = (struct kse_thr_mailbox *)calloc(1, sizeof(struct kse_thr_mailbox));
+
+ /* Throw us into its context. */
+ getcontext(&tm->tm_context);
+
+ /* Find our stack. */
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_USRSTACK;
+#if 0
+ len = sizeof(p);
+ if (sysctl(mib, 2, &p, &len, NULL, 0) == -1)
+ pstr("sysctl(CTL_KER.KERN_USRSTACK) failed.\n");
+#endif
+ p = (char *)malloc(MAIN_STACK_SIZE) + MAIN_STACK_SIZE;
+ pfmt("main() : 0x%x\n", tm);
+ pfmt("eip -> 0x%x\n", tm->tm_context.uc_mcontext.mc_eip);
+ tm->tm_context.uc_stack.ss_sp = p - MAIN_STACK_SIZE;
+ tm->tm_context.uc_stack.ss_size = MAIN_STACK_SIZE;
+
+ /*
+ * Create KSE mailbox.
+ */
+ p = (char *)malloc(THREAD_STACK_SIZE);
+ bzero(&data->mb, sizeof(struct kse_mailbox));
+ data->mb.km_stack.ss_sp = p;
+ data->mb.km_stack.ss_size = THREAD_STACK_SIZE;
+ data->mb.km_func = (void *)uts;
+ data->mb.km_udata = data;
+ data->cur_thread = tm;
+ data->runq = q;
+ pfmt("uts() at : 0x%x\n", uts);
+ pfmt("uts stack at : 0x%x - 0x%x\n", p, p + THREAD_STACK_SIZE);
+}
+
+static void
+start_uts(struct uts_data *data, int newgrp)
+{
+ /*
+ * Start KSE scheduling.
+ */
+ pfmt("kse_create() -> %d\n", kse_create(&data->mb, newgrp));
+ data->mb.km_curthread = data->cur_thread;
+
+ /*
+ * Arrange to deliver signals via KSE.
+ */
+ signal(SIGURG, foof);
+}
+
+/*
+ * Write a single character to stdout, in a thread-safe manner.
+ */
+static void
+pchar(char c)
+{
+
+ write(STDOUT_FILENO, &c, 1);
+}
+
+/*
+ * Write formatted output to stdout, in a thread-safe manner.
+ *
+ * Recognises the following conversions:
+ * %c -> char
+ * %d -> signed int (base 10)
+ * %s -> string
+ * %u -> unsigned int (base 10)
+ * %x -> unsigned int (base 16)
+ */
+static void
+pfmt(const char *fmt, ...)
+{
+ static const char digits[16] = "0123456789abcdef";
+ va_list ap;
+ char buf[10];
+ char *s;
+ unsigned r, u;
+ int c, d;
+
+ va_start(ap, fmt);
+ while ((c = *fmt++)) {
+ if (c == '%') {
+ c = *fmt++;
+ switch (c) {
+ case 'c':
+ pchar(va_arg(ap, int));
+ continue;
+ case 's':
+ pstr(va_arg(ap, char *));
+ continue;
+ case 'd':
+ case 'u':
+ case 'x':
+ r = ((c == 'u') || (c == 'd')) ? 10 : 16;
+ if (c == 'd') {
+ d = va_arg(ap, unsigned);
+ if (d < 0) {
+ pchar('-');
+ u = (unsigned)(d * -1);
+ } else
+ u = (unsigned)d;
+ } else
+ u = va_arg(ap, unsigned);
+ s = buf;
+ do {
+ *s++ = digits[u % r];
+ } while (u /= r);
+ while (--s >= buf)
+ pchar(*s);
+ continue;
+ }
+ }
+ pchar(c);
+ }
+ va_end(ap);
+}
+
+static void
+pstr(const char *s)
+{
+
+ write(STDOUT_FILENO, s, strlen(s));
+}
+
+static void
+runq_init(struct uts_runq *q)
+{
+ q->head = NULL;
+ simplelock_init(&q->lock);
+}
+
+/*
+ * Insert a thread into the run queue.
+ */
+static void
+runq_insert(struct uts_runq *q, struct kse_thr_mailbox *tm)
+{
+ simplelock_lock(&q->lock);
+ tm->tm_next = q->head;
+ q->head = tm;
+ simplelock_unlock(&q->lock);
+}
+
+/*
+ * Select and remove a thread from the run queue.
+ */
+static struct kse_thr_mailbox *
+runq_remove(struct uts_runq *q)
+{
+ struct kse_thr_mailbox *tm;
+
+ simplelock_lock(&q->lock);
+ tm = runq_remove_nolock(q);
+ simplelock_unlock(&q->lock);
+ return tm;
+}
+
+static struct kse_thr_mailbox *
+runq_remove_nolock(struct uts_runq *q)
+{
+ struct kse_thr_mailbox *p, *p1;
+
+ if (q->head == NULL)
+ return (NULL);
+ p1 = NULL;
+ for (p = q->head; p->tm_next != NULL; p = p->tm_next)
+ p1 = p;
+ if (p1 == NULL)
+ q->head = NULL;
+ else
+ p1->tm_next = NULL;
+ return (p);
+}
+
+/*
+ * Userland thread scheduler.
+ */
+static void
+uts(struct kse_mailbox *km)
+{
+#ifdef TRACE_KSE
+ static struct uts_data *prev_data;
+#endif
+ struct kse_thr_mailbox *tm, *p;
+ struct uts_data *data;
+ int i;
+
+ UPSTR("\n--uts() start--\n");
+ UPFMT("mailbox -> %x\n", km);
+
+ /*
+ * Insert any processes back from being blocked
+ * in the kernel into the run queue.
+ */
+ data = km->km_udata;
+ p = km->km_completed;
+ km->km_completed = NULL;
+ UPFMT("km_completed -> 0x%x", p);
+#ifdef TRACE_KSE
+ if (data != prev_data) {
+ prev_data = data;
+ pfmt("uts data: 0x%x\n", data);
+ }
+#endif
+ while ((tm = p) != NULL) {
+ p = tm->tm_next;
+ UPFMT(" 0x%x", p);
+ runq_insert(data->runq, tm);
+ }
+ UPCHAR('\n');
+
+ simplelock_lock(&data->runq->lock);
+ /*
+ * Process any signals we've recieved (but only if we have
+ * somewhere to deliver them to).
+ */
+ if ((data->runq->head != NULL) && SIGNOTEMPTY(km->km_sigscaught)) {
+ for (i = 0;i < _SIG_MAXSIG;i++)
+ if (SIGISMEMBER(km->km_sigscaught, i)) {
+ signalcontext(&data->runq->head->tm_context,
+ i, foof);
+ break;
+ }
+ bzero(&km->km_sigscaught, sizeof(sigset_t));
+ }
+
+ /*
+ * Pull a thread off the run queue.
+ */
+ p = runq_remove_nolock(data->runq);
+ simplelock_unlock(&data->runq->lock);
+#if 0
+ if ((p == aa) && (progress > 0)) {
+ --progress;
+ signalcontext(&p->tm_context, 1, foof);
+ }
+#endif
+
+ /*
+ * Either schedule a thread, or idle if none ready to run.
+ */
+ if (p != NULL) {
+ UPFMT("\n-- uts() scheduling 0x%x--\n", p);
+ UPFMT("eip -> 0x%x progress -> %d\n",
+ p->tm_context.uc_mcontext.mc_eip, progress);
+ UPSTR("curthread set\n");
+ uts_to_thread(p, &km->km_curthread);
+ UPSTR("\n-- uts_to_thread() failed --\n");
+ }
+ kse_release(NULL);
+ pstr("** uts() exiting **\n");
+ exit(EX_SOFTWARE);
+}
+
+/*
+ * Start a thread.
+ */
+static struct kse_thr_mailbox *
+thread_create(const void *func, int arg)
+{
+ struct kse_thr_mailbox *tm;
+ char *p;
+
+ aa = tm = (struct kse_thr_mailbox *)calloc(1, sizeof(struct kse_thr_mailbox));
+ getcontext(&tm->tm_context);
+ p = (char *)malloc(THREAD_STACK_SIZE);
+ tm->tm_context.uc_stack.ss_sp = p;
+ tm->tm_context.uc_stack.ss_size = THREAD_STACK_SIZE;
+ makecontext(&tm->tm_context, func, 2, arg);
+ // setcontext(&tm->tm_context);
+ return tm;
+}
+
+static void
+thread_start(struct uts_data *data, const void *func, int arg)
+{
+ struct kse_thr_mailbox *tm;
+ struct kse_thr_mailbox *tm2;
+
+ tm = thread_create(func, arg);
+ tm2 = thread_create(enter_uts, (int)data);
+ tm->tm_context.uc_link = &tm2->tm_context;
+ runq_insert(data->runq, tm);
+ pfmt("thread_start() : 0x%x %x\n", tm, &tm->tm_context);
+}
diff --git a/tools/KSE/ksetest/simplelock.h b/tools/KSE/ksetest/simplelock.h
new file mode 100644
index 0000000..2dae6ab
--- /dev/null
+++ b/tools/KSE/ksetest/simplelock.h
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 2002 David Xu (davidxu@freebsd.org).
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SIMPLELOCK_H
+#define _SIMPLELOCK_H
+
+#include <machine/asmacros.h>
+#include <machine/atomic.h>
+
+struct simplelock {
+ int s_lock;
+};
+
+static inline void
+simplelock_init(struct simplelock *lock)
+{
+ lock->s_lock = 0;
+}
+
+static inline void
+simplelock_lock(struct simplelock *lock)
+{
+ while (!atomic_cmpset_int(&lock->s_lock, 0, 1))
+ ;
+}
+
+static inline void
+simplelock_unlock(struct simplelock *lock)
+{
+ atomic_store_rel_int(&lock->s_lock, 0);
+}
+
+#endif
+
diff --git a/tools/LibraryReport/LibraryReport.tcl b/tools/LibraryReport/LibraryReport.tcl
new file mode 100755
index 0000000..fbf6389
--- /dev/null
+++ b/tools/LibraryReport/LibraryReport.tcl
@@ -0,0 +1,289 @@
+#!/bin/sh
+# tcl magic \
+exec tclsh $0 $*
+################################################################################
+# Copyright (C) 1997
+# Michael Smith. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the author nor the names of any co-contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY Michael Smith AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL Michael Smith OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+################################################################################
+#
+# LibraryReport; produce a list of shared libraries on the system, and a list of
+# all executables that use them.
+#
+################################################################################
+#
+# Stage 1 looks for shared libraries; the output of 'ldconfig -r' is examined
+# for hints as to where to look for libraries (but not trusted as a complete
+# list).
+#
+# These libraries each get an entry in the global 'Libs()' array.
+#
+# Stage 2 walks the entire system directory heirachy looking for executable
+# files, applies 'ldd' to them and attempts to determine which libraries are
+# used. The path of the executable is then added to the 'Libs()' array
+# for each library used.
+#
+# Stage 3 reports on the day's findings.
+#
+################################################################################
+#
+# $FreeBSD$
+#
+
+#########################################################################################
+# findLibs
+#
+# Ask ldconfig where it thinks libraries are to be found. Go look for them, and
+# add an element to 'Libs' for everything that looks like a library.
+#
+proc findLibs {} {
+
+ global Libs stats verbose;
+
+ # Older ldconfigs return a junk value when asked for a report
+ if {[catch {set liblist [exec ldconfig -r]} err]} { # get ldconfig output
+ puts stderr "ldconfig returned nonzero, persevering.";
+ set liblist $err; # there's junk in this
+ }
+
+ # remove hintsfile name, convert to list
+ set liblist [lrange [split $liblist "\n"] 1 end];
+
+ set libdirs ""; # no directories yet
+ foreach line $liblist {
+ # parse ldconfig output
+ if {[scan $line "%s => %s" junk libname] == 2} {
+ # find directory name
+ set libdir [file dirname $libname];
+ # have we got this one already?
+ if {[lsearch -exact $libdirs $libdir] == -1} {
+ lappend libdirs $libdir;
+ }
+ } else {
+ puts stderr "Unparseable ldconfig output line :";
+ puts stderr $line;
+ }
+ }
+
+ # libdirs is now a list of directories that we might find libraries in
+ foreach dir $libdirs {
+ # get the names of anything that looks like a library
+ set libnames [glob -nocomplain "$dir/lib*.so.*"]
+ foreach lib $libnames {
+ set type [file type $lib]; # what is it?
+ switch $type {
+ file { # looks like a library
+ # may have already been referenced by a symlink
+ if {![info exists Libs($lib)]} {
+ set Libs($lib) ""; # add it to our list
+ if {$verbose} {puts "+ $lib";}
+ }
+ }
+ link { # symlink; probably to another library
+ # If the readlink fails, the symlink is stale
+ if {[catch {set ldest [file readlink $lib]}]} {
+ puts stderr "Symbolic link points to nothing : $lib";
+ } else {
+ # may have already been referenced by another symlink
+ if {![info exists Libs($lib)]} {
+ set Libs($lib) ""; # add it to our list
+ if {$verbose} {puts "+ $lib";}
+ }
+ # list the symlink as a consumer of this library
+ lappend Libs($ldest) "($lib)";
+ if {$verbose} {puts "-> $ldest";}
+ }
+ }
+ }
+ }
+ }
+ set stats(libs) [llength [array names Libs]];
+}
+
+################################################################################
+# findLibUsers
+#
+# Look in the directory (dir) for executables. If we find any, call
+# examineExecutable to see if it uses any shared libraries. Call ourselves
+# on any directories we find.
+#
+# Note that the use of "*" as a glob pattern means we miss directories and
+# executables starting with '.'. This is a Feature.
+#
+proc findLibUsers {dir} {
+
+ global stats verbose;
+
+ if {[catch {
+ set ents [glob -nocomplain "$dir/*"];
+ } msg]} {
+ if {$msg == ""} {
+ set msg "permission denied";
+ }
+ puts stderr "Can't search under '$dir' : $msg";
+ return ;
+ }
+
+ if {$verbose} {puts "===>> $dir";}
+ incr stats(dirs);
+
+ # files?
+ foreach f $ents {
+ # executable?
+ if {[file executable $f]} {
+ # really a file?
+ if {[file isfile $f]} {
+ incr stats(files);
+ examineExecutable $f;
+ }
+ }
+ }
+ # subdirs?
+ foreach f $ents {
+ # maybe a directory with more files?
+ # don't use 'file isdirectory' because that follows symlinks
+ if {[catch {set type [file type $f]}]} {
+ continue ; # may not be able to stat
+ }
+ if {$type == "directory"} {
+ findLibUsers $f;
+ }
+ }
+}
+
+################################################################################
+# examineExecutable
+#
+# Look at (fname) and see if ldd thinks it references any shared libraries.
+# If it does, update Libs with the information.
+#
+proc examineExecutable {fname} {
+
+ global Libs stats verbose;
+
+ # ask Mr. Ldd.
+ if {[catch {set result [exec ldd $fname]} msg]} {
+ return ; # not dynamic
+ }
+
+ if {$verbose} {puts -nonewline "$fname : ";}
+ incr stats(execs);
+
+ # For a non-shared executable, we get a single-line error message.
+ # For a shared executable, we get a heading line, so in either case
+ # we can discard the first line and any subsequent lines are libraries
+ # that are required.
+ set llist [lrange [split $result "\n"] 1 end];
+ set uses "";
+
+ foreach line $llist {
+ if {[scan $line "%s => %s %s" junk1 lib junk2] == 3} {
+ if {$lib == "not"} { # "not found" error
+ set mlname [string range $junk1 2 end];
+ puts stderr "$fname : library '$mlname' not known.";
+ } else {
+ lappend Libs($lib) $fname;
+ lappend uses $lib;
+ }
+ } else {
+ puts stderr "Unparseable ldd output line :";
+ puts stderr $line;
+ }
+ }
+ if {$verbose} {puts "$uses";}
+}
+
+################################################################################
+# emitLibDetails
+#
+# Emit a listing of libraries and the executables that use them.
+#
+proc emitLibDetails {} {
+
+ global Libs;
+
+ # divide into used/unused
+ set used "";
+ set unused "";
+ foreach lib [array names Libs] {
+ if {$Libs($lib) == ""} {
+ lappend unused $lib;
+ } else {
+ lappend used $lib;
+ }
+ }
+
+ # emit used list
+ puts "== Current Shared Libraries ==================================================";
+ foreach lib [lsort $used] {
+ # sort executable names
+ set users [lsort $Libs($lib)];
+ puts [format "%-30s %s" $lib $users];
+ }
+ # emit unused
+ puts "== Stale Shared Libraries ====================================================";
+ foreach lib [lsort $unused] {
+ # sort executable names
+ set users [lsort $Libs($lib)];
+ puts [format "%-30s %s" $lib $users];
+ }
+}
+
+################################################################################
+# Run the whole shebang
+#
+proc main {} {
+
+ global stats verbose argv;
+
+ set verbose 0;
+ foreach arg $argv {
+ switch -- $arg {
+ -v {
+ set verbose 1;
+ }
+ default {
+ puts stderr "Unknown option '$arg'.";
+ exit ;
+ }
+ }
+ }
+
+ set stats(libs) 0;
+ set stats(dirs) 0;
+ set stats(files) 0;
+ set stats(execs) 0
+
+ findLibs;
+ findLibUsers "/";
+ emitLibDetails;
+
+ puts [format "Searched %d directories, %d executables (%d dynamic) for %d libraries." \
+ $stats(dirs) $stats(files) $stats(execs) $stats(libs)];
+}
+
+################################################################################
+main;
diff --git a/tools/README b/tools/README
new file mode 100644
index 0000000..99ec8e9
--- /dev/null
+++ b/tools/README
@@ -0,0 +1,8 @@
+$FreeBSD$
+
+This directory tree contains tools used for the maintenance and
+testing of FreeBSD. There is no toplevel Makefile structure since
+these tools are not meant to be built as part of the standard system,
+though there may be individual Makefiles in some of the subdirs.
+
+Please read the README files in the subdirs for further information.
diff --git a/tools/build/make_check/Makefile b/tools/build/make_check/Makefile
new file mode 100644
index 0000000..0ae687e
--- /dev/null
+++ b/tools/build/make_check/Makefile
@@ -0,0 +1,95 @@
+# $FreeBSD$
+
+# Test for broken LHS expansion.
+# This *must* cause make(1) to detect a recursive variable, and fail as such.
+.if make(lhs_expn)
+FOO= ${BAR}
+BAR${NIL}= ${FOO}
+FOO${BAR}= ${FOO}
+.endif
+
+DATA1= helllo
+DATA2:= ${DATA1}
+DATA3= ${DATA2:S/ll/rr/g}
+DATA4:= ${DATA2:S/ll/rr/g}
+DATA2?= allo
+DATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g}
+DATA2= yello
+DATA1:= ${DATA5:S/l/r/g}
+NIL=
+
+all:
+ @echo "Running test variables"
+ @echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \
+ diff -u ${.CURDIR}/regress.variables.out - || ${MAKE} failure
+ @echo "PASS: Test variables detected no regression, output matches."
+ @echo "Running test targets"
+ @${MAKE} double 2>/dev/null || ${MAKE} failure
+ @echo "PASS: Test targets detected no regression."
+ @echo "Running test sysvmatch"
+ @${MAKE} sysvmatch || ${MAKE} failure
+ @echo "PASS: Test sysvmatch detected no regression."
+ @echo "Running test lhs_expn"
+ @! ${MAKE} lhs_expn && true || ${MAKE} failure
+ @echo "PASS: Test lhs_expn detected no regression."
+ @echo "Running test notdef"
+ @${MAKE} notdef || ${MAKE} failure
+ @echo "PASS: Test notdef detected no regression."
+ @echo "Running test modifiers"
+ @${MAKE} modifiers || ${MAKE} failure
+ @echo "PASS: Test modifiers detected no regression."
+ @echo "Running test funny_targets"
+ @${MAKE} funny_targets || ${MAKE} failure
+ @echo "PASS: Test funny_targets detected no regression."
+
+.if make(double)
+# Doubly-defined targets. make(1) will warn, but use the "right" one. If it
+# switches to using the "non-right" one, it breaks things worse than a little
+# regression test.
+double:
+ @true
+
+double:
+ @false
+.endif
+
+.if make(sysvmatch)
+# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst.
+sysvmatch:
+ @echo EMPTY ${NIL:=foo} LHS | \
+ diff -u ${.CURDIR}/regress.sysvmatch.out - || false
+.endif
+
+# A bogus target for the lhs_expn test; If this is reached, then the make(1)
+# program has not errored out because of the recursion caused by not expanding
+# the left-hand-side's embedded variables above.
+lhs_expn:
+ @true
+
+.if make(notdef)
+# make(1) claims to only evaluate a conditional as far as is necessary
+# to determine its value; that was not always the case.
+.undef notdef
+notdef:
+.if defined(notdef) && ${notdef:U}
+.endif
+.endif
+
+.if make(modifiers)
+# See if make(1) supports the C modifier.
+modifiers:
+ @if ${MAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \
+ grep -q "Unknown modifier 'C'"; then \
+ false; \
+ fi
+.endif
+
+.if make(funny_targets)
+funny_targets: colons::target exclamation!target
+colons::target:
+exclamation!target:
+.endif
+
+failure:
+ @echo "FAIL: Test failed: regression detected. See above."
+ @false
diff --git a/tools/build/make_check/regress.sysvmatch.out b/tools/build/make_check/regress.sysvmatch.out
new file mode 100644
index 0000000..759859e
--- /dev/null
+++ b/tools/build/make_check/regress.sysvmatch.out
@@ -0,0 +1 @@
+EMPTY LHS
diff --git a/tools/build/make_check/regress.variables.out b/tools/build/make_check/regress.variables.out
new file mode 100644
index 0000000..83528d5
--- /dev/null
+++ b/tools/build/make_check/regress.variables.out
@@ -0,0 +1 @@
+1:heiiro herrro 2:yello 3:yerro 4:herrlo 5:heiilo herrlo
diff --git a/tools/diag/README b/tools/diag/README
new file mode 100644
index 0000000..8147943
--- /dev/null
+++ b/tools/diag/README
@@ -0,0 +1,17 @@
+$FreeBSD$
+
+This directory is for diagnostic programs.
+
+A diagnostic program is one that will inform you that something is wrong
+somewhere, for instance by traversing a kernel-structure and verifying
+the integrity.
+
+Please make a subdir per program, and add a brief description to this file.
+
+ac Various scripts that checks of style/content correctness of
+ committers lists in doc/ area.
+dumpvfscache program that can be used to examine the contents of the vfs
+ name cache.
+httpd-error check for Web files which does not exists on your host
+localeck check for invalid/incomplete locales
+
diff --git a/tools/diag/ac/README b/tools/diag/ac/README
new file mode 100644
index 0000000..48c1cad
--- /dev/null
+++ b/tools/diag/ac/README
@@ -0,0 +1,9 @@
+Various scripts that checks of style/content correctness of
+committers lists in doc/ area.
+
+ac check if the contributors article is in sync with the
+ committers list
+ent.sh check for ordering/content problems in .ent files (authors.ent,
+ teams.ent, etc)
+
+$FreeBSD$
diff --git a/tools/diag/ac/cknames.pl b/tools/diag/ac/cknames.pl
new file mode 100644
index 0000000..4363f65
--- /dev/null
+++ b/tools/diag/ac/cknames.pl
@@ -0,0 +1,97 @@
+#!/usr/bin/perl -w
+#
+# Copyright (c) 2002 Alexey Zelkin <phantom@FreeBSD.org>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# cknames.pl -- this scripts checks for integrity of person lists
+# between authors.ent, CVSROOT/access and passwd database
+# at freefall.freebsd.org
+#
+# NOTE: This script is supposed to run at freefall.freebsd.org *only*
+#
+# $FreeBSD$
+#
+
+$debug = 0;
+$accessfile = "CVSROOT/access";
+$authorsfile = "doc/en_US.ISO8859-1/share/sgml/authors.ent";
+
+$cvsroot = $ENV{'CVSROOT'};
+$cvsroot = "/home/ncvs" if !$cvsroot;
+$cvs = "cvs -R -d $cvsroot co -p";
+
+open(PASSWD, 'ypcat passwd |') || die "open passwd data: $!\n";
+while (<PASSWD>) {
+ ($login,undef) = split(/:/);
+ $login =~ s/_//g; # remove _ from usernames since this
+ # character is not allowed in docbook entities
+ print "passwd user: $login\n" if $debug;
+ $users{$login} = 1;
+}
+close PASSWD;
+
+print "$cvs $accessfile\n";
+open (ACCESS, "$cvs $accessfile |") || die "checkout $accessfile: $!\n";
+while (<ACCESS>) {
+ chomp;
+ next if /^#/;
+ ($accuser, undef) = split /\s/;
+ $accuser =~ s/_//g;
+ print "access user: $accuser\n" if $debug;
+ $access{$accuser} = 1;
+}
+close ACCESS;
+
+open (AUTHORS, "$cvs $authorsfile |") || die "checkout $authorsfile: $!\n";
+while (<AUTHORS>) {
+ $author = $1 if /ENTITY a\.([^ ]+)/;
+ next if !$author;
+ print "authors entity: $author\n" if $debug;
+ $authors{$author} = 1;
+ $author = "";
+}
+close AUTHORS;
+
+print "\n";
+print "People listed in CVSROOT/access, but have no account\n";
+print "----------------------------------------------------\n";
+foreach (keys %access) {
+ print "$_\n" if (!defined $users{$_});
+}
+
+print "\n";
+print "People listed in autors.ent, not have no account\n";
+print "------------------------------------------------\n";
+foreach (keys %authors) {
+ print "$_\n" if (!defined $users{$_});
+}
+
+print "\n";
+print "People listed in CVSROOT/access, but not listed in authors.ent\n";
+print "--------------------------------------------------------------\n";
+foreach (keys %access) {
+ print "$_\n" if (!defined $authors{$_});
+}
+
+print "\n";
diff --git a/tools/diag/ac/ent.sh b/tools/diag/ac/ent.sh
new file mode 100644
index 0000000..83d5005
--- /dev/null
+++ b/tools/diag/ac/ent.sh
@@ -0,0 +1,58 @@
+#!/bin/sh -x
+# Copyright (c) 2002 Alexey Zelkin <phantom@FreeBSD.org>
+#
+# ent.sh -- this script checks {authors,teams}.ent files for correctness
+#
+# $FreeBSD$
+
+: ${CVSROOT=/home/ncvs}
+prefix=doc/en_US.ISO8859-1/share/sgml
+cvs='cvs -Q co -p'
+diff='diff -u'
+tmp=${TMPDIR-/tmp}/_entities
+
+ckfile() {
+
+ckf=$1
+
+$cvs $prefix/$ckf 2>/dev/null |
+ grep ENTITY |
+ awk '{ print $2 }' > $tmp.entsrc
+sort -u $tmp.entsrc > $tmp.entsrc2
+$diff $tmp.entsrc $tmp.entsrc2 > $ckf.order
+
+$cvs $prefix/$ckf 2>/dev/null |
+ perl -ne 'print "$1 -- $2\n" if /ENTITY ([^ ]+).*<email>(.*)<\/email>/' |
+ grep -vi freebsd.org > $ckf.addr
+
+}
+
+ckresults() {
+
+ckf=$1
+
+if [ -s $ckf.order ]; then
+ echo "Ordering check for $ckf failed. See $ckf.ordering file for details."
+else
+ rm -f $ckf.order
+ echo "Ordering check for $ckf is Ok. "
+fi
+
+if [ -s $ckf.addr ]; then
+ echo "Email addresses for $ckf failed. See $ckf.addr file for details."
+else
+ rm -f $ckf.addr
+ echo "Email addresses check for $ckf is Ok. "
+fi
+
+}
+
+ckfile "authors.ent"
+ckfile "teams.ent"
+
+echo
+
+ckresults "authors.ent"
+ckresults "teams.ent"
+
+rm -f $tmp.entsrc $tmp.entsrc2
diff --git a/tools/diag/dumpvfscache/Makefile b/tools/diag/dumpvfscache/Makefile
new file mode 100644
index 0000000..a9299ce
--- /dev/null
+++ b/tools/diag/dumpvfscache/Makefile
@@ -0,0 +1,11 @@
+
+PROG= dumpvfscache
+
+LDADD= -lkvm -lmd
+
+NOMAN= 1
+
+test: ${PROG}
+ ./${PROG} > a
+
+.include <bsd.prog.mk>
diff --git a/tools/diag/dumpvfscache/README b/tools/diag/dumpvfscache/README
new file mode 100644
index 0000000..2a1c57c
--- /dev/null
+++ b/tools/diag/dumpvfscache/README
@@ -0,0 +1,6 @@
+This is a little C-program that can be used to examine the contents of
+the vfs name cache. It's very likely to loop and crash if you use it
+on an active system.
+
+ Poul-Henning Kamp
+ 4 sep 1997
diff --git a/tools/diag/dumpvfscache/dumpvfscache.c b/tools/diag/dumpvfscache/dumpvfscache.c
new file mode 100644
index 0000000..3f5eb57
--- /dev/null
+++ b/tools/diag/dumpvfscache/dumpvfscache.c
@@ -0,0 +1,137 @@
+/* $FreeBSD$ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <kvm.h>
+#include <nlist.h>
+#include <sysexits.h>
+#include <sys/uio.h>
+#include <sys/namei.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/time.h>
+#include <sys/vnode.h>
+/*----------------------------------*/
+static u_int crc16_table[16] = {
+ 0x0000, 0xCC01, 0xD801, 0x1400,
+ 0xF001, 0x3C00, 0x2800, 0xE401,
+ 0xA001, 0x6C00, 0x7800, 0xB401,
+ 0x5000, 0x9C01, 0x8801, 0x4400
+};
+
+/* XXX Taken from sys/kern/vfs_cache.c */
+struct namecache {
+ LIST_ENTRY(namecache) nc_hash;
+ LIST_ENTRY(namecache) nc_src;
+ TAILQ_ENTRY(namecache) nc_dst;
+ struct vnode *nc_dvp;
+ struct vnode *nc_vp;
+ u_char nc_flag;
+ u_char nc_nlen;
+ char nc_name[0];
+};
+
+static u_short
+wlpsacrc(u_char *buf, u_int len)
+{
+ u_short crc = 0;
+ int i, r1;
+
+ for (i = 0; i < len; i++, buf++) {
+ /* lower 4 bits */
+ r1 = crc16_table[crc & 0xF];
+ crc = (crc >> 4) & 0x0FFF;
+ crc = crc ^ r1 ^ crc16_table[*buf & 0xF];
+
+ /* upper 4 bits */
+ r1 = crc16_table[crc & 0xF];
+ crc = (crc >> 4) & 0x0FFF;
+ crc = crc ^ r1 ^ crc16_table[(*buf >> 4) & 0xF];
+ }
+ return(crc);
+}
+
+/*----------------------------------*/
+struct nlist nl[] = {
+ { "_nchash", 0},
+ { "_nchashtbl", 0},
+ { 0, 0 },
+};
+
+int histo[2047];
+int histn[2047];
+int *newbucket;
+
+int
+main(int argc, char **argv)
+{
+ int nchash, i, j, k, kn;
+ int nb, p1, p2;
+ u_long p;
+ LIST_HEAD(nchashhead, namecache) *nchashtbl;
+ struct namecache *nc;
+ struct vnode vn;
+
+ kvm_t *kvm = kvm_open(NULL, NULL, NULL, O_RDONLY, argv[0]);
+ if (kvm == NULL)
+ return(EX_OSERR);
+
+ printf("kvm: %p\n", kvm);
+ printf("kvm_nlist: %d\n", kvm_nlist(kvm, nl));
+ kvm_read(kvm, nl[0].n_value, &nchash, sizeof nchash);
+ nchash++;
+ nchashtbl = malloc(nchash * sizeof *nchashtbl);
+ nc = malloc(sizeof *nc + NAME_MAX);
+ newbucket = malloc(nchash * sizeof (int));
+ memset(newbucket, 0, nchash * sizeof (int));
+ kvm_read(kvm, nl[1].n_value, &p, sizeof p);
+ kvm_read(kvm, p, nchashtbl, nchash * sizeof *nchashtbl);
+ for (i=0; i < nchash; i++) {
+#if 0
+ printf("%d\n", i);
+#endif
+ nb=0;
+ p = (u_long)LIST_FIRST(nchashtbl+i);
+ while (p) {
+ nb++;
+ kvm_read(kvm, p, nc, sizeof *nc + NAME_MAX);
+ kvm_read(kvm, (u_long)nc->nc_dvp, &vn, sizeof vn);
+ nc->nc_name[nc->nc_nlen] = '\0';
+ for (j=k=kn=0;nc->nc_name[j];j++) {
+ k+= nc->nc_name[j];
+ kn <<= 1;
+ kn+= nc->nc_name[j];
+ }
+ /*
+ kn = k;
+ */
+ kn = wlpsacrc(nc->nc_name,nc->nc_nlen);
+
+ /* kn += (u_long)vn.v_data >> 8; */
+ /* kn += (u_long)nc->nc_dvp >> 7; */
+ kn += vn.v_id;
+ kn &= (nchash - 1);
+ newbucket[kn]++;
+#if 1
+ printf("%4d dvp %08x hash %08x vp %08x id %08x name <%s>\n",
+ i,nc->nc_dvp, k, nc->nc_vp, vn.v_id, nc->nc_name);
+#endif
+ p = (u_long)LIST_NEXT(nc, nc_hash);
+ }
+ histo[nb]++;
+ }
+ for (i=0; i < nchash; i++) {
+ histn[newbucket[i]]++;
+ }
+ p1=p2 = 0;
+ for (i=0;i<30;i++) {
+ p1 += histo[i] * i;
+ p2 += histn[i] * i;
+ if (histo[i] || histn[i])
+ printf("H%02d %4d %4d / %4d %4d\n",i,histo[i], p1 , histn[i], p2);
+ }
+
+ return (0);
+}
+
diff --git a/tools/diag/httpd-error/httpd-error b/tools/diag/httpd-error/httpd-error
new file mode 100755
index 0000000..a7f35be
--- /dev/null
+++ b/tools/diag/httpd-error/httpd-error
@@ -0,0 +1,62 @@
+#!/bin/sh
+# Copyright (c) 1998 by Wolfram Schneider <wosch@FreeBSD.org>, Berlin.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+#
+# httpd-error - check for Web files which do not exist on your host
+#
+# $FreeBSD$
+
+mode=${1}
+
+case "$mode" in
+ -host)
+ grep 'File does not exist$' |
+ awk '{print $11}' |
+ sort | uniq -c | sort -nr | perl -npe 's/,$//'
+ ;;
+ -filehits)
+ grep 'File does not exist$' |
+ awk '{print $8}' |
+ sort | uniq -c | sort -nr
+ ;;
+ -user)
+ grep 'File does not exist$' |
+ awk '{print $8}' |
+ sort | uniq -c | sort -k 2
+ ;;
+ -userhits)
+ grep 'File does not exist$' |
+ awk '{print $8}' | sort |
+ perl -npe 's#/home/([^/]+)/public_html.*#/~$1/#;
+ s#/usr/local/www/data/.*#/usr/local/www/data/#' |
+ uniq -c | sort -nr
+ ;;
+
+ *) echo "usage $0 {-host|-filehits|-user|-userhits} < error.log" >&2
+ exit 1
+ ;;
+esac
+
+
diff --git a/tools/diag/localeck/Makefile b/tools/diag/localeck/Makefile
new file mode 100644
index 0000000..2136e30
--- /dev/null
+++ b/tools/diag/localeck/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+PROG= localeck
+NOMAN= noman
+WARNS?= 4
+
+LOCALEDIR?= /usr/share/locale
+
+test: ${PROG}
+ sh docheck.sh ${LOCALEDIR}
+
+.include <bsd.prog.mk>
diff --git a/tools/diag/localeck/docheck.sh b/tools/diag/localeck/docheck.sh
new file mode 100644
index 0000000..7f47851
--- /dev/null
+++ b/tools/diag/localeck/docheck.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Validate all locales installed in specified directory
+# (by default check system locales)
+#
+# $FreeBSD$
+#
+
+LOCALEDIR=/usr/share/locale
+
+if [ "$1" != "" ]; then
+ LOCALEDIR=$1
+fi
+
+if [ ! -x ./localeck ]; then
+ echo "ERROR: build test program first."
+ exit 1
+fi
+
+PATH_LOCALE=$LOCALEDIR
+LOCALES=0
+ERRORS=0
+
+echo "Validating locales in $LOCALEDIR"
+echo
+
+for i in `ls -1 $LOCALEDIR`
+do
+ LOCALES=$(($LOCALES + 1))
+ ./localeck $i || ERRORS=$(($ERRORS + 1))
+done
+
+echo
+echo "Validation test complete"
+echo "$LOCALES locales were checked"
+echo "$ERRORS invalid locales were found"
+
diff --git a/tools/diag/localeck/localeck.c b/tools/diag/localeck/localeck.c
new file mode 100644
index 0000000..4ce7e45
--- /dev/null
+++ b/tools/diag/localeck/localeck.c
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 2002 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+ * Try setlocale() for locale with given name.
+ */
+
+struct locdef {
+ int catid;
+ const char *catname;
+} locales[_LC_LAST] = {
+ { LC_ALL, "LC_ALL" },
+ { LC_COLLATE, "LC_COLLATE" },
+ { LC_CTYPE, "LC_CTYPE" },
+ { LC_MONETARY, "LC_MONETARY" },
+ { LC_NUMERIC, "LC_NUMERIC" },
+ { LC_TIME, "LC_TIME" },
+ { LC_MESSAGES, "LC_MESSAGES" }
+};
+
+int
+main(int argc, char *argv[])
+{
+ int i, result;
+ const char *localename;
+
+ if (argc != 2) {
+ (void)fprintf(stderr, "usage: localeck <locale_name>\n");
+ exit(1);
+ }
+
+ localename = argv[1];
+ result = 0;
+
+ for (i = 0; i < _LC_LAST; i++) {
+ if (setlocale(locales[i].catid, localename) == NULL) {
+ printf("setlocale(%s, %s) failed\n", locales[i].catname,
+ localename);
+ result++;
+ }
+ }
+ return (result);
+}
diff --git a/tools/install.sh b/tools/install.sh
new file mode 100644
index 0000000..c578dda
--- /dev/null
+++ b/tools/install.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+#
+# Copyright (c) 1999 Marcel Moolenaar
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer
+# in this position and unchanged.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+
+# parse install's options and ignore them completely.
+# XXX - not all options are recognised.
+while [ ! -z $1 ]; do
+ case $1 in
+ -b | -C | -c | -M | -p | -S | -s) shift;;
+ -B | -f | -g | -m | -o) shift; shift;;
+ *) break;
+ esac
+done
+
+# the remaining arguments are assumed to be files/dirs only.
+exec install -p $*
diff --git a/tools/make_libdeps.sh b/tools/make_libdeps.sh
new file mode 100644
index 0000000..39e170f
--- /dev/null
+++ b/tools/make_libdeps.sh
@@ -0,0 +1,117 @@
+#!/bin/sh -e
+#
+# Copyright (c) 2002 Ruslan Ermilov, The FreeBSD Project
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+export PATH=/usr/bin
+
+FS=': ' # internal field separator
+LIBDEPENDS=./_libdeps # intermediate output file
+USRSRC=${1:-/usr/src} # source root
+LIBS="
+ lib
+ gnu/lib
+ kerberosIV/lib
+ kerberos5/lib
+ secure/lib
+ usr.bin/lex/lib
+ usr.sbin/pcvt/keycap
+" # where to scan for libraries
+
+# This sed(1) filter is used to convert -lfoo to path/to/libfoo.
+#
+SED_FILTER="
+sed -E
+ -e's; ;! ;g'
+ -e's;$;!;'
+ -e's;-lm!;lib/msun;g'
+ -e's;-l(supc\+\+)!;gnu/lib/lib\1;g'
+ -e's;-l(krb)!;kerberosIV/lib/lib\1;g'
+ -e's;-l(asn1|gssapi|krb5|roken)!;kerberos5/lib/lib\1;g'
+ -e's;-l(crypto|ssh)!;secure/lib/lib\1;g'
+ -e's;-l([^!]+)!;lib/lib\1;g'
+"
+
+# Generate interdependencies between libraries.
+#
+genlibdepends()
+{
+ (
+ cd ${USRSRC}
+ find ${LIBS} -mindepth 1 -name Makefile |
+ xargs grep -l 'bsd\.lib\.mk' |
+ while read makefile; do
+ libdir=$(dirname ${makefile})
+ deps=$(
+ cd ${libdir}
+ make -V LDADD
+ )
+ if [ "${deps}" ]; then
+ echo ${libdir}"${FS}"$(
+ echo ${deps} |
+ eval ${SED_FILTER}
+ )
+ fi
+ done
+ )
+}
+
+main()
+{
+ if [ ! -f ${LIBDEPENDS} ]; then
+ genlibdepends >${LIBDEPENDS}
+ fi
+
+ prebuild_libs=$(
+ awk -F"${FS}" '{ print $2 }' ${LIBDEPENDS} |rs 0 1 |sort -u
+ )
+ echo "Libraries with dependents:"
+ echo
+ echo ${prebuild_libs} |
+ rs 0 1
+ echo
+
+ echo "List of interdependencies:"
+ echo
+ for lib in ${prebuild_libs}; do
+ grep "^${lib}${FS}" ${LIBDEPENDS} || true
+ done |
+ awk -F"${FS}" '{
+ if ($2 in dependents)
+ dependents[$2]=dependents[$2]" "$1
+ else
+ dependents[$2]=$1
+ }
+ END {
+ for (lib in dependents)
+ print dependents[lib]": " lib
+ }' |
+ sort
+
+ exit 0
+}
+
+main
diff --git a/tools/regression/README b/tools/regression/README
new file mode 100644
index 0000000..40595ec
--- /dev/null
+++ b/tools/regression/README
@@ -0,0 +1,28 @@
+$FreeBSD$
+
+This directory is for regression test programs.
+
+A regression test program is one that will exercise a particular bit of the
+system to check that we have not reintroduced an old bug.
+
+Tests that are for parts of the base system should go into a directory here
+which is the same as their path relative to src/, for example the uuencode(1)
+utility resides in src/usr.bin/uuencode so its regression test resides in
+src/tools/regression/usr.bin/uuencode.
+
+Base system regression tests should prefix their test results with 'PASS' or
+'FAIL' accordingly, to make checking for failed tests easier. For now the
+tests are very free-form, and it's up to you to do that. Eventually, it
+should be a part of the regression test framework.
+
+Please make a subdir per other regression test, and add a brief description to
+this file.
+
+geom Some tests and an out-of-kernel simulator for the GEOM code
+ia64_unaligned Tests unaligned reads on the IA64
+nfsmmap Some tests to exercise some tricky cases in NFS and mmap
+p1003_1b Exercise 1003.1B scheduler
+fsx General filesystem exerciser
+sysvmsg SysV IPC Message Queue Regression Utility
+sysvsem SysV IPC Semaphore Regression Utility
+sysvshm SysV IPC Shared Memory Regression Utility
diff --git a/tools/regression/ccd/layout/Makefile b/tools/regression/ccd/layout/Makefile
new file mode 100644
index 0000000..1e6b4df
--- /dev/null
+++ b/tools/regression/ccd/layout/Makefile
@@ -0,0 +1,11 @@
+#
+# $FreeBSD$
+#
+# Regression test for ccd's layout.
+#
+
+test:
+ sh ccd0.sh
+
+clean:
+ rm -f a b _.*
diff --git a/tools/regression/ccd/layout/a.c b/tools/regression/ccd/layout/a.c
new file mode 100644
index 0000000..33eea10
--- /dev/null
+++ b/tools/regression/ccd/layout/a.c
@@ -0,0 +1,16 @@
+/* $FreeBSD$ */
+#include <unistd.h>
+
+static uint32_t buf[512/4];
+main()
+{
+ u_int u = 0;
+
+ while (1) {
+ buf[0] = u++;
+
+ if (512 != write(1, buf, sizeof buf))
+ break;
+ }
+ exit (0);
+}
diff --git a/tools/regression/ccd/layout/b.c b/tools/regression/ccd/layout/b.c
new file mode 100644
index 0000000..5b4ae8e
--- /dev/null
+++ b/tools/regression/ccd/layout/b.c
@@ -0,0 +1,19 @@
+/* $FreeBSD$ */
+
+#include <unistd.h>
+#include <fcntl.h>
+
+static uint32_t buf[512/4];
+main()
+{
+ u_int u = 0;
+
+ while (1) {
+
+ if (512 != read(0, buf, sizeof buf))
+ break;
+
+ printf("%u %u\n", u++, buf[0]);
+ }
+ exit (0);
+}
diff --git a/tools/regression/ccd/layout/ccd.sh b/tools/regression/ccd/layout/ccd.sh
new file mode 100644
index 0000000..08d385a
--- /dev/null
+++ b/tools/regression/ccd/layout/ccd.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+# $FreeBSD$
+
+set -e
+
+if mount | grep ccd3 ; then
+ echo "ccd3 seems to be mounted"
+ exit 1
+fi
+
+(
+ccdconfig -u ccd3 || true
+mdconfig -d -u 90 || true
+mdconfig -d -u 91 || true
+mdconfig -d -u 92 || true
+mdconfig -d -u 93 || true
+) > /dev/null 2>&1
+
+mdconfig -a -t malloc -s $1 -u 90
+mdconfig -a -t malloc -s $2 -u 91
+mdconfig -a -t malloc -s $3 -u 92
+mdconfig -a -t malloc -s $4 -u 93
+
+ccdconfig -v ccd3 $5 $6 /dev/md90 /dev/md91 /dev/md92 /dev/md93
+./a > /dev/ccd3c
+
+md5 < /dev/md90
+md5 < /dev/md91
+md5 < /dev/md92
+md5 < /dev/md93
+
+(
+./b < /dev/md90 | sed -e 1,16d -e 's/^/md90 /'
+./b < /dev/md91 | sed -e 1,16d -e 's/^/md91 /'
+./b < /dev/md92 | sed -e 1,16d -e 's/^/md92 /'
+./b < /dev/md93 | sed -e 1,16d -e 's/^/md93 /'
+) | sort +2n | awk '
+ {
+ if ($1 != l1) {
+ if (l1 != "") {
+ if (l1 == "md90") printf ""
+ if (l1 == "md91") printf " "
+ if (l1 == "md92") printf " "
+ if (l1 == "md93") printf " "
+ print l3,l2,l
+ }
+ l1 = $1
+ l2 = $2
+ l3 = $3
+ l = 0;
+ }
+ l++;
+ }
+END {
+ if (l1 == "md90") printf ""
+ if (l1 == "md91") printf " "
+ if (l1 == "md92") printf " "
+ if (l1 == "md93") printf " "
+ print l3,l2,l
+ }
+'
diff --git a/tools/regression/ccd/layout/ccd0.sh b/tools/regression/ccd/layout/ccd0.sh
new file mode 100644
index 0000000..0f71b18
--- /dev/null
+++ b/tools/regression/ccd/layout/ccd0.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# $FreeBSD$
+
+set -e
+
+make a
+make b
+foo() {
+ f="${1}_${2}_${3}_${4}_${5}_${6}"
+ echo $f
+ sh ccd.sh $1 $2 $3 $4 $5 $6 > _.$f
+ if [ -f ref.$f ] ; then
+ diff -u -I '$FreeBSD' ref.$f _.$f
+ fi
+}
+
+foo 128k 128k 128k 128k 0 0
+foo 128k 128k 128k 128k 0 4
+foo 128k 128k 128k 128k 4 0
+foo 128k 128k 128k 128k 4 2
+foo 128k 128k 128k 128k 4 4
+
+foo 256k 128k 128k 128k 0 0
+foo 256k 128k 128k 128k 0 4
+foo 256k 128k 128k 128k 4 0
+foo 256k 128k 128k 128k 4 2
+foo 256k 128k 128k 128k 4 4
+
+foo 256k 128k 384k 128k 0 0
+foo 256k 128k 384k 128k 0 4
+foo 256k 128k 384k 128k 4 0
+foo 256k 128k 384k 128k 4 2
+foo 256k 128k 384k 128k 4 4
+
+foo 256k 128k 384k 128k 16 0
+foo 256k 128k 384k 128k 16 4
+foo 256k 128k 384k 128k 16 0
+foo 256k 128k 384k 128k 16 2
+foo 256k 128k 384k 128k 16 4
diff --git a/tools/regression/ccd/layout/ref.128k_128k_128k_128k_0_0 b/tools/regression/ccd/layout/ref.128k_128k_128k_128k_0_0
new file mode 100644
index 0000000..470f2dc
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.128k_128k_128k_128k_0_0
@@ -0,0 +1,10 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 960 blocks concatenated
+76089c8ed2249882ae0bb260dcb4a913
+4cc57a9dd953d032ae7e07edaef31203
+476dc065c9ba15e4610975fe57d2d46e
+569cb47720caaf9543c26737195e6f67
+0 16 240
+ 240 16 240
+ 480 16 240
+ 720 16 240
diff --git a/tools/regression/ccd/layout/ref.128k_128k_128k_128k_0_4 b/tools/regression/ccd/layout/ref.128k_128k_128k_128k_0_4
new file mode 100644
index 0000000..470f2dc
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.128k_128k_128k_128k_0_4
@@ -0,0 +1,10 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 960 blocks concatenated
+76089c8ed2249882ae0bb260dcb4a913
+4cc57a9dd953d032ae7e07edaef31203
+476dc065c9ba15e4610975fe57d2d46e
+569cb47720caaf9543c26737195e6f67
+0 16 240
+ 240 16 240
+ 480 16 240
+ 720 16 240
diff --git a/tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_0 b/tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_0
new file mode 100644
index 0000000..593c413
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_0
@@ -0,0 +1,246 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 960 blocks interleaved at 4 blocks
+c3019ef8e08259f8748931f225e5cebf
+ddef760dcef4784565cfe7d76e5aa3ce
+1bb551ae77e015eb5186e7630fde16c4
+be4d327cb8085aa69a446f15b42521c7
+0 16 4
+ 4 16 4
+ 8 16 4
+ 12 16 4
+16 20 4
+ 20 20 4
+ 24 20 4
+ 28 20 4
+32 24 4
+ 36 24 4
+ 40 24 4
+ 44 24 4
+48 28 4
+ 52 28 4
+ 56 28 4
+ 60 28 4
+64 32 4
+ 68 32 4
+ 72 32 4
+ 76 32 4
+80 36 4
+ 84 36 4
+ 88 36 4
+ 92 36 4
+96 40 4
+ 100 40 4
+ 104 40 4
+ 108 40 4
+112 44 4
+ 116 44 4
+ 120 44 4
+ 124 44 4
+128 48 4
+ 132 48 4
+ 136 48 4
+ 140 48 4
+144 52 4
+ 148 52 4
+ 152 52 4
+ 156 52 4
+160 56 4
+ 164 56 4
+ 168 56 4
+ 172 56 4
+176 60 4
+ 180 60 4
+ 184 60 4
+ 188 60 4
+192 64 4
+ 196 64 4
+ 200 64 4
+ 204 64 4
+208 68 4
+ 212 68 4
+ 216 68 4
+ 220 68 4
+224 72 4
+ 228 72 4
+ 232 72 4
+ 236 72 4
+240 76 4
+ 244 76 4
+ 248 76 4
+ 252 76 4
+256 80 4
+ 260 80 4
+ 264 80 4
+ 268 80 4
+272 84 4
+ 276 84 4
+ 280 84 4
+ 284 84 4
+288 88 4
+ 292 88 4
+ 296 88 4
+ 300 88 4
+304 92 4
+ 308 92 4
+ 312 92 4
+ 316 92 4
+320 96 4
+ 324 96 4
+ 328 96 4
+ 332 96 4
+336 100 4
+ 340 100 4
+ 344 100 4
+ 348 100 4
+352 104 4
+ 356 104 4
+ 360 104 4
+ 364 104 4
+368 108 4
+ 372 108 4
+ 376 108 4
+ 380 108 4
+384 112 4
+ 388 112 4
+ 392 112 4
+ 396 112 4
+400 116 4
+ 404 116 4
+ 408 116 4
+ 412 116 4
+416 120 4
+ 420 120 4
+ 424 120 4
+ 428 120 4
+432 124 4
+ 436 124 4
+ 440 124 4
+ 444 124 4
+448 128 4
+ 452 128 4
+ 456 128 4
+ 460 128 4
+464 132 4
+ 468 132 4
+ 472 132 4
+ 476 132 4
+480 136 4
+ 484 136 4
+ 488 136 4
+ 492 136 4
+496 140 4
+ 500 140 4
+ 504 140 4
+ 508 140 4
+512 144 4
+ 516 144 4
+ 520 144 4
+ 524 144 4
+528 148 4
+ 532 148 4
+ 536 148 4
+ 540 148 4
+544 152 4
+ 548 152 4
+ 552 152 4
+ 556 152 4
+560 156 4
+ 564 156 4
+ 568 156 4
+ 572 156 4
+576 160 4
+ 580 160 4
+ 584 160 4
+ 588 160 4
+592 164 4
+ 596 164 4
+ 600 164 4
+ 604 164 4
+608 168 4
+ 612 168 4
+ 616 168 4
+ 620 168 4
+624 172 4
+ 628 172 4
+ 632 172 4
+ 636 172 4
+640 176 4
+ 644 176 4
+ 648 176 4
+ 652 176 4
+656 180 4
+ 660 180 4
+ 664 180 4
+ 668 180 4
+672 184 4
+ 676 184 4
+ 680 184 4
+ 684 184 4
+688 188 4
+ 692 188 4
+ 696 188 4
+ 700 188 4
+704 192 4
+ 708 192 4
+ 712 192 4
+ 716 192 4
+720 196 4
+ 724 196 4
+ 728 196 4
+ 732 196 4
+736 200 4
+ 740 200 4
+ 744 200 4
+ 748 200 4
+752 204 4
+ 756 204 4
+ 760 204 4
+ 764 204 4
+768 208 4
+ 772 208 4
+ 776 208 4
+ 780 208 4
+784 212 4
+ 788 212 4
+ 792 212 4
+ 796 212 4
+800 216 4
+ 804 216 4
+ 808 216 4
+ 812 216 4
+816 220 4
+ 820 220 4
+ 824 220 4
+ 828 220 4
+832 224 4
+ 836 224 4
+ 840 224 4
+ 844 224 4
+848 228 4
+ 852 228 4
+ 856 228 4
+ 860 228 4
+864 232 4
+ 868 232 4
+ 872 232 4
+ 876 232 4
+880 236 4
+ 884 236 4
+ 888 236 4
+ 892 236 4
+896 240 4
+ 900 240 4
+ 904 240 4
+ 908 240 4
+912 244 4
+ 916 244 4
+ 920 244 4
+ 924 244 4
+928 248 4
+ 932 248 4
+ 936 248 4
+ 940 248 4
+944 252 4
+ 948 252 4
+ 952 252 4
+ 956 252 4
diff --git a/tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_2 b/tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_2
new file mode 100644
index 0000000..593c413
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_2
@@ -0,0 +1,246 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 960 blocks interleaved at 4 blocks
+c3019ef8e08259f8748931f225e5cebf
+ddef760dcef4784565cfe7d76e5aa3ce
+1bb551ae77e015eb5186e7630fde16c4
+be4d327cb8085aa69a446f15b42521c7
+0 16 4
+ 4 16 4
+ 8 16 4
+ 12 16 4
+16 20 4
+ 20 20 4
+ 24 20 4
+ 28 20 4
+32 24 4
+ 36 24 4
+ 40 24 4
+ 44 24 4
+48 28 4
+ 52 28 4
+ 56 28 4
+ 60 28 4
+64 32 4
+ 68 32 4
+ 72 32 4
+ 76 32 4
+80 36 4
+ 84 36 4
+ 88 36 4
+ 92 36 4
+96 40 4
+ 100 40 4
+ 104 40 4
+ 108 40 4
+112 44 4
+ 116 44 4
+ 120 44 4
+ 124 44 4
+128 48 4
+ 132 48 4
+ 136 48 4
+ 140 48 4
+144 52 4
+ 148 52 4
+ 152 52 4
+ 156 52 4
+160 56 4
+ 164 56 4
+ 168 56 4
+ 172 56 4
+176 60 4
+ 180 60 4
+ 184 60 4
+ 188 60 4
+192 64 4
+ 196 64 4
+ 200 64 4
+ 204 64 4
+208 68 4
+ 212 68 4
+ 216 68 4
+ 220 68 4
+224 72 4
+ 228 72 4
+ 232 72 4
+ 236 72 4
+240 76 4
+ 244 76 4
+ 248 76 4
+ 252 76 4
+256 80 4
+ 260 80 4
+ 264 80 4
+ 268 80 4
+272 84 4
+ 276 84 4
+ 280 84 4
+ 284 84 4
+288 88 4
+ 292 88 4
+ 296 88 4
+ 300 88 4
+304 92 4
+ 308 92 4
+ 312 92 4
+ 316 92 4
+320 96 4
+ 324 96 4
+ 328 96 4
+ 332 96 4
+336 100 4
+ 340 100 4
+ 344 100 4
+ 348 100 4
+352 104 4
+ 356 104 4
+ 360 104 4
+ 364 104 4
+368 108 4
+ 372 108 4
+ 376 108 4
+ 380 108 4
+384 112 4
+ 388 112 4
+ 392 112 4
+ 396 112 4
+400 116 4
+ 404 116 4
+ 408 116 4
+ 412 116 4
+416 120 4
+ 420 120 4
+ 424 120 4
+ 428 120 4
+432 124 4
+ 436 124 4
+ 440 124 4
+ 444 124 4
+448 128 4
+ 452 128 4
+ 456 128 4
+ 460 128 4
+464 132 4
+ 468 132 4
+ 472 132 4
+ 476 132 4
+480 136 4
+ 484 136 4
+ 488 136 4
+ 492 136 4
+496 140 4
+ 500 140 4
+ 504 140 4
+ 508 140 4
+512 144 4
+ 516 144 4
+ 520 144 4
+ 524 144 4
+528 148 4
+ 532 148 4
+ 536 148 4
+ 540 148 4
+544 152 4
+ 548 152 4
+ 552 152 4
+ 556 152 4
+560 156 4
+ 564 156 4
+ 568 156 4
+ 572 156 4
+576 160 4
+ 580 160 4
+ 584 160 4
+ 588 160 4
+592 164 4
+ 596 164 4
+ 600 164 4
+ 604 164 4
+608 168 4
+ 612 168 4
+ 616 168 4
+ 620 168 4
+624 172 4
+ 628 172 4
+ 632 172 4
+ 636 172 4
+640 176 4
+ 644 176 4
+ 648 176 4
+ 652 176 4
+656 180 4
+ 660 180 4
+ 664 180 4
+ 668 180 4
+672 184 4
+ 676 184 4
+ 680 184 4
+ 684 184 4
+688 188 4
+ 692 188 4
+ 696 188 4
+ 700 188 4
+704 192 4
+ 708 192 4
+ 712 192 4
+ 716 192 4
+720 196 4
+ 724 196 4
+ 728 196 4
+ 732 196 4
+736 200 4
+ 740 200 4
+ 744 200 4
+ 748 200 4
+752 204 4
+ 756 204 4
+ 760 204 4
+ 764 204 4
+768 208 4
+ 772 208 4
+ 776 208 4
+ 780 208 4
+784 212 4
+ 788 212 4
+ 792 212 4
+ 796 212 4
+800 216 4
+ 804 216 4
+ 808 216 4
+ 812 216 4
+816 220 4
+ 820 220 4
+ 824 220 4
+ 828 220 4
+832 224 4
+ 836 224 4
+ 840 224 4
+ 844 224 4
+848 228 4
+ 852 228 4
+ 856 228 4
+ 860 228 4
+864 232 4
+ 868 232 4
+ 872 232 4
+ 876 232 4
+880 236 4
+ 884 236 4
+ 888 236 4
+ 892 236 4
+896 240 4
+ 900 240 4
+ 904 240 4
+ 908 240 4
+912 244 4
+ 916 244 4
+ 920 244 4
+ 924 244 4
+928 248 4
+ 932 248 4
+ 936 248 4
+ 940 248 4
+944 252 4
+ 948 252 4
+ 952 252 4
+ 956 252 4
diff --git a/tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_4 b/tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_4
new file mode 100644
index 0000000..9f8aebc
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.128k_128k_128k_128k_4_4
@@ -0,0 +1,966 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 480 blocks interleaved at 4 blocks
+a77c5edd8917abb32dc165750f1af781
+8db0b90ec1fa54feca98ad8fd292b07c
+a77c5edd8917abb32dc165750f1af781
+8db0b90ec1fa54feca98ad8fd292b07c
+0 16 1
+ 0 16 1
+1 17 1
+ 1 17 1
+2 18 1
+ 2 18 1
+3 19 1
+ 3 19 1
+ 4 16 1
+ 4 16 1
+ 5 17 1
+ 5 17 1
+ 6 18 1
+ 6 18 1
+ 7 19 1
+ 7 19 1
+8 20 1
+ 8 20 1
+9 21 1
+ 9 21 1
+10 22 1
+ 10 22 1
+11 23 1
+ 11 23 1
+ 12 20 1
+ 12 20 1
+ 13 21 1
+ 13 21 1
+ 14 22 1
+ 14 22 1
+ 15 23 1
+ 15 23 1
+16 24 1
+ 16 24 1
+17 25 1
+ 17 25 1
+18 26 1
+ 18 26 1
+19 27 1
+ 19 27 1
+ 20 24 1
+ 20 24 1
+ 21 25 1
+ 21 25 1
+ 22 26 1
+ 22 26 1
+ 23 27 1
+ 23 27 1
+24 28 1
+ 24 28 1
+25 29 1
+ 25 29 1
+26 30 1
+ 26 30 1
+27 31 1
+ 27 31 1
+ 28 28 1
+ 28 28 1
+ 29 29 1
+ 29 29 1
+ 30 30 1
+ 30 30 1
+ 31 31 1
+ 31 31 1
+32 32 1
+ 32 32 1
+33 33 1
+ 33 33 1
+34 34 1
+ 34 34 1
+35 35 1
+ 35 35 1
+ 36 32 1
+ 36 32 1
+ 37 33 1
+ 37 33 1
+ 38 34 1
+ 38 34 1
+ 39 35 1
+ 39 35 1
+40 36 1
+ 40 36 1
+41 37 1
+ 41 37 1
+42 38 1
+ 42 38 1
+43 39 1
+ 43 39 1
+ 44 36 1
+ 44 36 1
+ 45 37 1
+ 45 37 1
+ 46 38 1
+ 46 38 1
+ 47 39 1
+ 47 39 1
+48 40 1
+ 48 40 1
+49 41 1
+ 49 41 1
+50 42 1
+ 50 42 1
+51 43 1
+ 51 43 1
+ 52 40 1
+ 52 40 1
+ 53 41 1
+ 53 41 1
+ 54 42 1
+ 54 42 1
+ 55 43 1
+ 55 43 1
+56 44 1
+ 56 44 1
+57 45 1
+ 57 45 1
+58 46 1
+ 58 46 1
+59 47 1
+ 59 47 1
+ 60 44 1
+ 60 44 1
+ 61 45 1
+ 61 45 1
+ 62 46 1
+ 62 46 1
+ 63 47 1
+ 63 47 1
+64 48 1
+ 64 48 1
+65 49 1
+ 65 49 1
+66 50 1
+ 66 50 1
+67 51 1
+ 67 51 1
+ 68 48 1
+ 68 48 1
+ 69 49 1
+ 69 49 1
+ 70 50 1
+ 70 50 1
+ 71 51 1
+ 71 51 1
+72 52 1
+ 72 52 1
+73 53 1
+ 73 53 1
+74 54 1
+ 74 54 1
+75 55 1
+ 75 55 1
+ 76 52 1
+ 76 52 1
+ 77 53 1
+ 77 53 1
+ 78 54 1
+ 78 54 1
+ 79 55 1
+ 79 55 1
+80 56 1
+ 80 56 1
+81 57 1
+ 81 57 1
+82 58 1
+ 82 58 1
+83 59 1
+ 83 59 1
+ 84 56 1
+ 84 56 1
+ 85 57 1
+ 85 57 1
+ 86 58 1
+ 86 58 1
+ 87 59 1
+ 87 59 1
+88 60 1
+ 88 60 1
+89 61 1
+ 89 61 1
+90 62 1
+ 90 62 1
+91 63 1
+ 91 63 1
+ 92 60 1
+ 92 60 1
+ 93 61 1
+ 93 61 1
+ 94 62 1
+ 94 62 1
+ 95 63 1
+ 95 63 1
+96 64 1
+ 96 64 1
+97 65 1
+ 97 65 1
+98 66 1
+ 98 66 1
+99 67 1
+ 99 67 1
+ 100 64 1
+ 100 64 1
+ 101 65 1
+ 101 65 1
+ 102 66 1
+ 102 66 1
+ 103 67 1
+ 103 67 1
+104 68 1
+ 104 68 1
+105 69 1
+ 105 69 1
+106 70 1
+ 106 70 1
+107 71 1
+ 107 71 1
+ 108 68 1
+ 108 68 1
+ 109 69 1
+ 109 69 1
+ 110 70 1
+ 110 70 1
+ 111 71 1
+ 111 71 1
+112 72 1
+ 112 72 1
+113 73 1
+ 113 73 1
+114 74 1
+ 114 74 1
+115 75 1
+ 115 75 1
+ 116 72 1
+ 116 72 1
+ 117 73 1
+ 117 73 1
+ 118 74 1
+ 118 74 1
+ 119 75 1
+ 119 75 1
+120 76 1
+ 120 76 1
+121 77 1
+ 121 77 1
+122 78 1
+ 122 78 1
+123 79 1
+ 123 79 1
+ 124 76 1
+ 124 76 1
+ 125 77 1
+ 125 77 1
+ 126 78 1
+ 126 78 1
+ 127 79 1
+ 127 79 1
+128 80 1
+ 128 80 1
+129 81 1
+ 129 81 1
+130 82 1
+ 130 82 1
+131 83 1
+ 131 83 1
+ 132 80 1
+ 132 80 1
+ 133 81 1
+ 133 81 1
+ 134 82 1
+ 134 82 1
+ 135 83 1
+ 135 83 1
+136 84 1
+ 136 84 1
+137 85 1
+ 137 85 1
+138 86 1
+ 138 86 1
+139 87 1
+ 139 87 1
+ 140 84 1
+ 140 84 1
+ 141 85 1
+ 141 85 1
+ 142 86 1
+ 142 86 1
+ 143 87 1
+ 143 87 1
+144 88 1
+ 144 88 1
+145 89 1
+ 145 89 1
+146 90 1
+ 146 90 1
+147 91 1
+ 147 91 1
+ 148 88 1
+ 148 88 1
+ 149 89 1
+ 149 89 1
+ 150 90 1
+ 150 90 1
+ 151 91 1
+ 151 91 1
+152 92 1
+ 152 92 1
+153 93 1
+ 153 93 1
+154 94 1
+ 154 94 1
+155 95 1
+ 155 95 1
+ 156 92 1
+ 156 92 1
+ 157 93 1
+ 157 93 1
+ 158 94 1
+ 158 94 1
+ 159 95 1
+ 159 95 1
+160 96 1
+ 160 96 1
+161 97 1
+ 161 97 1
+162 98 1
+ 162 98 1
+163 99 1
+ 163 99 1
+ 164 96 1
+ 164 96 1
+ 165 97 1
+ 165 97 1
+ 166 98 1
+ 166 98 1
+ 167 99 1
+ 167 99 1
+168 100 1
+ 168 100 1
+169 101 1
+ 169 101 1
+170 102 1
+ 170 102 1
+171 103 1
+ 171 103 1
+ 172 100 1
+ 172 100 1
+ 173 101 1
+ 173 101 1
+ 174 102 1
+ 174 102 1
+ 175 103 1
+ 175 103 1
+176 104 1
+ 176 104 1
+177 105 1
+ 177 105 1
+178 106 1
+ 178 106 1
+179 107 1
+ 179 107 1
+ 180 104 1
+ 180 104 1
+ 181 105 1
+ 181 105 1
+ 182 106 1
+ 182 106 1
+ 183 107 1
+ 183 107 1
+184 108 1
+ 184 108 1
+185 109 1
+ 185 109 1
+186 110 1
+ 186 110 1
+187 111 1
+ 187 111 1
+ 188 108 1
+ 188 108 1
+ 189 109 1
+ 189 109 1
+ 190 110 1
+ 190 110 1
+ 191 111 1
+ 191 111 1
+192 112 1
+ 192 112 1
+193 113 1
+ 193 113 1
+194 114 1
+ 194 114 1
+195 115 1
+ 195 115 1
+ 196 112 1
+ 196 112 1
+ 197 113 1
+ 197 113 1
+ 198 114 1
+ 198 114 1
+ 199 115 1
+ 199 115 1
+200 116 1
+ 200 116 1
+201 117 1
+ 201 117 1
+202 118 1
+ 202 118 1
+203 119 1
+ 203 119 1
+ 204 116 1
+ 204 116 1
+ 205 117 1
+ 205 117 1
+ 206 118 1
+ 206 118 1
+ 207 119 1
+ 207 119 1
+208 120 1
+ 208 120 1
+209 121 1
+ 209 121 1
+210 122 1
+ 210 122 1
+211 123 1
+ 211 123 1
+ 212 120 1
+ 212 120 1
+ 213 121 1
+ 213 121 1
+ 214 122 1
+ 214 122 1
+ 215 123 1
+ 215 123 1
+216 124 1
+ 216 124 1
+217 125 1
+ 217 125 1
+218 126 1
+ 218 126 1
+219 127 1
+ 219 127 1
+ 220 124 1
+ 220 124 1
+ 221 125 1
+ 221 125 1
+ 222 126 1
+ 222 126 1
+ 223 127 1
+ 223 127 1
+224 128 1
+ 224 128 1
+225 129 1
+ 225 129 1
+226 130 1
+ 226 130 1
+227 131 1
+ 227 131 1
+ 228 128 1
+ 228 128 1
+ 229 129 1
+ 229 129 1
+ 230 130 1
+ 230 130 1
+ 231 131 1
+ 231 131 1
+232 132 1
+ 232 132 1
+233 133 1
+ 233 133 1
+234 134 1
+ 234 134 1
+235 135 1
+ 235 135 1
+ 236 132 1
+ 236 132 1
+ 237 133 1
+ 237 133 1
+ 238 134 1
+ 238 134 1
+ 239 135 1
+ 239 135 1
+240 136 1
+ 240 136 1
+241 137 1
+ 241 137 1
+242 138 1
+ 242 138 1
+243 139 1
+ 243 139 1
+ 244 136 1
+ 244 136 1
+ 245 137 1
+ 245 137 1
+ 246 138 1
+ 246 138 1
+ 247 139 1
+ 247 139 1
+248 140 1
+ 248 140 1
+249 141 1
+ 249 141 1
+250 142 1
+ 250 142 1
+251 143 1
+ 251 143 1
+ 252 140 1
+ 252 140 1
+ 253 141 1
+ 253 141 1
+ 254 142 1
+ 254 142 1
+ 255 143 1
+ 255 143 1
+256 144 1
+ 256 144 1
+257 145 1
+ 257 145 1
+258 146 1
+ 258 146 1
+259 147 1
+ 259 147 1
+ 260 144 1
+ 260 144 1
+ 261 145 1
+ 261 145 1
+ 262 146 1
+ 262 146 1
+ 263 147 1
+ 263 147 1
+264 148 1
+ 264 148 1
+265 149 1
+ 265 149 1
+266 150 1
+ 266 150 1
+267 151 1
+ 267 151 1
+ 268 148 1
+ 268 148 1
+ 269 149 1
+ 269 149 1
+ 270 150 1
+ 270 150 1
+ 271 151 1
+ 271 151 1
+272 152 1
+ 272 152 1
+273 153 1
+ 273 153 1
+274 154 1
+ 274 154 1
+275 155 1
+ 275 155 1
+ 276 152 1
+ 276 152 1
+ 277 153 1
+ 277 153 1
+ 278 154 1
+ 278 154 1
+ 279 155 1
+ 279 155 1
+280 156 1
+ 280 156 1
+281 157 1
+ 281 157 1
+282 158 1
+ 282 158 1
+283 159 1
+ 283 159 1
+ 284 156 1
+ 284 156 1
+ 285 157 1
+ 285 157 1
+ 286 158 1
+ 286 158 1
+ 287 159 1
+ 287 159 1
+288 160 1
+ 288 160 1
+289 161 1
+ 289 161 1
+290 162 1
+ 290 162 1
+291 163 1
+ 291 163 1
+ 292 160 1
+ 292 160 1
+ 293 161 1
+ 293 161 1
+ 294 162 1
+ 294 162 1
+ 295 163 1
+ 295 163 1
+296 164 1
+ 296 164 1
+297 165 1
+ 297 165 1
+298 166 1
+ 298 166 1
+299 167 1
+ 299 167 1
+ 300 164 1
+ 300 164 1
+ 301 165 1
+ 301 165 1
+ 302 166 1
+ 302 166 1
+ 303 167 1
+ 303 167 1
+304 168 1
+ 304 168 1
+305 169 1
+ 305 169 1
+306 170 1
+ 306 170 1
+307 171 1
+ 307 171 1
+ 308 168 1
+ 308 168 1
+ 309 169 1
+ 309 169 1
+ 310 170 1
+ 310 170 1
+ 311 171 1
+ 311 171 1
+312 172 1
+ 312 172 1
+313 173 1
+ 313 173 1
+314 174 1
+ 314 174 1
+315 175 1
+ 315 175 1
+ 316 172 1
+ 316 172 1
+ 317 173 1
+ 317 173 1
+ 318 174 1
+ 318 174 1
+ 319 175 1
+ 319 175 1
+320 176 1
+ 320 176 1
+321 177 1
+ 321 177 1
+322 178 1
+ 322 178 1
+323 179 1
+ 323 179 1
+ 324 176 1
+ 324 176 1
+ 325 177 1
+ 325 177 1
+ 326 178 1
+ 326 178 1
+ 327 179 1
+ 327 179 1
+328 180 1
+ 328 180 1
+329 181 1
+ 329 181 1
+330 182 1
+ 330 182 1
+331 183 1
+ 331 183 1
+ 332 180 1
+ 332 180 1
+ 333 181 1
+ 333 181 1
+ 334 182 1
+ 334 182 1
+ 335 183 1
+ 335 183 1
+336 184 1
+ 336 184 1
+337 185 1
+ 337 185 1
+338 186 1
+ 338 186 1
+339 187 1
+ 339 187 1
+ 340 184 1
+ 340 184 1
+ 341 185 1
+ 341 185 1
+ 342 186 1
+ 342 186 1
+ 343 187 1
+ 343 187 1
+344 188 1
+ 344 188 1
+345 189 1
+ 345 189 1
+346 190 1
+ 346 190 1
+347 191 1
+ 347 191 1
+ 348 188 1
+ 348 188 1
+ 349 189 1
+ 349 189 1
+ 350 190 1
+ 350 190 1
+ 351 191 1
+ 351 191 1
+352 192 1
+ 352 192 1
+353 193 1
+ 353 193 1
+354 194 1
+ 354 194 1
+355 195 1
+ 355 195 1
+ 356 192 1
+ 356 192 1
+ 357 193 1
+ 357 193 1
+ 358 194 1
+ 358 194 1
+ 359 195 1
+ 359 195 1
+360 196 1
+ 360 196 1
+361 197 1
+ 361 197 1
+362 198 1
+ 362 198 1
+363 199 1
+ 363 199 1
+ 364 196 1
+ 364 196 1
+ 365 197 1
+ 365 197 1
+ 366 198 1
+ 366 198 1
+ 367 199 1
+ 367 199 1
+368 200 1
+ 368 200 1
+369 201 1
+ 369 201 1
+370 202 1
+ 370 202 1
+371 203 1
+ 371 203 1
+ 372 200 1
+ 372 200 1
+ 373 201 1
+ 373 201 1
+ 374 202 1
+ 374 202 1
+ 375 203 1
+ 375 203 1
+376 204 1
+ 376 204 1
+377 205 1
+ 377 205 1
+378 206 1
+ 378 206 1
+379 207 1
+ 379 207 1
+ 380 204 1
+ 380 204 1
+ 381 205 1
+ 381 205 1
+ 382 206 1
+ 382 206 1
+ 383 207 1
+ 383 207 1
+384 208 1
+ 384 208 1
+385 209 1
+ 385 209 1
+386 210 1
+ 386 210 1
+387 211 1
+ 387 211 1
+ 388 208 1
+ 388 208 1
+ 389 209 1
+ 389 209 1
+ 390 210 1
+ 390 210 1
+ 391 211 1
+ 391 211 1
+392 212 1
+ 392 212 1
+393 213 1
+ 393 213 1
+394 214 1
+ 394 214 1
+395 215 1
+ 395 215 1
+ 396 212 1
+ 396 212 1
+ 397 213 1
+ 397 213 1
+ 398 214 1
+ 398 214 1
+ 399 215 1
+ 399 215 1
+400 216 1
+ 400 216 1
+401 217 1
+ 401 217 1
+402 218 1
+ 402 218 1
+403 219 1
+ 403 219 1
+ 404 216 1
+ 404 216 1
+ 405 217 1
+ 405 217 1
+ 406 218 1
+ 406 218 1
+ 407 219 1
+ 407 219 1
+408 220 1
+ 408 220 1
+409 221 1
+ 409 221 1
+410 222 1
+ 410 222 1
+411 223 1
+ 411 223 1
+ 412 220 1
+ 412 220 1
+ 413 221 1
+ 413 221 1
+ 414 222 1
+ 414 222 1
+ 415 223 1
+ 415 223 1
+416 224 1
+ 416 224 1
+417 225 1
+ 417 225 1
+418 226 1
+ 418 226 1
+419 227 1
+ 419 227 1
+ 420 224 1
+ 420 224 1
+ 421 225 1
+ 421 225 1
+ 422 226 1
+ 422 226 1
+ 423 227 1
+ 423 227 1
+424 228 1
+ 424 228 1
+425 229 1
+ 425 229 1
+426 230 1
+ 426 230 1
+427 231 1
+ 427 231 1
+ 428 228 1
+ 428 228 1
+ 429 229 1
+ 429 229 1
+ 430 230 1
+ 430 230 1
+ 431 231 1
+ 431 231 1
+432 232 1
+ 432 232 1
+433 233 1
+ 433 233 1
+434 234 1
+ 434 234 1
+435 235 1
+ 435 235 1
+ 436 232 1
+ 436 232 1
+ 437 233 1
+ 437 233 1
+ 438 234 1
+ 438 234 1
+ 439 235 1
+ 439 235 1
+440 236 1
+ 440 236 1
+441 237 1
+ 441 237 1
+442 238 1
+ 442 238 1
+443 239 1
+ 443 239 1
+ 444 236 1
+ 444 236 1
+ 445 237 1
+ 445 237 1
+ 446 238 1
+ 446 238 1
+ 447 239 1
+ 447 239 1
+448 240 1
+ 448 240 1
+449 241 1
+ 449 241 1
+450 242 1
+ 450 242 1
+451 243 1
+ 451 243 1
+ 452 240 1
+ 452 240 1
+ 453 241 1
+ 453 241 1
+ 454 242 1
+ 454 242 1
+ 455 243 1
+ 455 243 1
+456 244 1
+ 456 244 1
+457 245 1
+ 457 245 1
+458 246 1
+ 458 246 1
+459 247 1
+ 459 247 1
+ 460 244 1
+ 460 244 1
+ 461 245 1
+ 461 245 1
+ 462 246 1
+ 462 246 1
+ 463 247 1
+ 463 247 1
+464 248 1
+ 464 248 1
+465 249 1
+ 465 249 1
+466 250 1
+ 466 250 1
+467 251 1
+ 467 251 1
+ 468 248 1
+ 468 248 1
+ 469 249 1
+ 469 249 1
+ 470 250 1
+ 470 250 1
+ 471 251 1
+ 471 251 1
+472 252 1
+ 472 252 1
+473 253 1
+ 473 253 1
+474 254 1
+ 474 254 1
+475 255 1
+ 475 255 1
+ 476 252 1
+ 476 252 1
+ 477 253 1
+ 477 253 1
+ 478 254 1
+ 478 254 1
+ 479 255 1
+ 479 255 1
diff --git a/tools/regression/ccd/layout/ref.256k_128k_128k_128k_0_0 b/tools/regression/ccd/layout/ref.256k_128k_128k_128k_0_0
new file mode 100644
index 0000000..44a2818
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_128k_128k_0_0
@@ -0,0 +1,10 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 1216 blocks concatenated
+50ca80e7defff2928b09d9e6c22d14ff
+a5f4fb6b17d948b83b8685b3adfe0926
+a294e6900769b0a1cd744d01d5a5508d
+14fe8b94bacd1cf53ea587bbac2b74e4
+0 16 496
+ 496 16 240
+ 736 16 240
+ 976 16 240
diff --git a/tools/regression/ccd/layout/ref.256k_128k_128k_128k_0_4 b/tools/regression/ccd/layout/ref.256k_128k_128k_128k_0_4
new file mode 100644
index 0000000..44a2818
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_128k_128k_0_4
@@ -0,0 +1,10 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 1216 blocks concatenated
+50ca80e7defff2928b09d9e6c22d14ff
+a5f4fb6b17d948b83b8685b3adfe0926
+a294e6900769b0a1cd744d01d5a5508d
+14fe8b94bacd1cf53ea587bbac2b74e4
+0 16 496
+ 496 16 240
+ 736 16 240
+ 976 16 240
diff --git a/tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_0 b/tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_0
new file mode 100644
index 0000000..6fc421a
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_0
@@ -0,0 +1,247 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 1216 blocks interleaved at 4 blocks
+85853375739fe031c97c20e6226aae0e
+ddef760dcef4784565cfe7d76e5aa3ce
+1bb551ae77e015eb5186e7630fde16c4
+be4d327cb8085aa69a446f15b42521c7
+0 16 4
+ 4 16 4
+ 8 16 4
+ 12 16 4
+16 20 4
+ 20 20 4
+ 24 20 4
+ 28 20 4
+32 24 4
+ 36 24 4
+ 40 24 4
+ 44 24 4
+48 28 4
+ 52 28 4
+ 56 28 4
+ 60 28 4
+64 32 4
+ 68 32 4
+ 72 32 4
+ 76 32 4
+80 36 4
+ 84 36 4
+ 88 36 4
+ 92 36 4
+96 40 4
+ 100 40 4
+ 104 40 4
+ 108 40 4
+112 44 4
+ 116 44 4
+ 120 44 4
+ 124 44 4
+128 48 4
+ 132 48 4
+ 136 48 4
+ 140 48 4
+144 52 4
+ 148 52 4
+ 152 52 4
+ 156 52 4
+160 56 4
+ 164 56 4
+ 168 56 4
+ 172 56 4
+176 60 4
+ 180 60 4
+ 184 60 4
+ 188 60 4
+192 64 4
+ 196 64 4
+ 200 64 4
+ 204 64 4
+208 68 4
+ 212 68 4
+ 216 68 4
+ 220 68 4
+224 72 4
+ 228 72 4
+ 232 72 4
+ 236 72 4
+240 76 4
+ 244 76 4
+ 248 76 4
+ 252 76 4
+256 80 4
+ 260 80 4
+ 264 80 4
+ 268 80 4
+272 84 4
+ 276 84 4
+ 280 84 4
+ 284 84 4
+288 88 4
+ 292 88 4
+ 296 88 4
+ 300 88 4
+304 92 4
+ 308 92 4
+ 312 92 4
+ 316 92 4
+320 96 4
+ 324 96 4
+ 328 96 4
+ 332 96 4
+336 100 4
+ 340 100 4
+ 344 100 4
+ 348 100 4
+352 104 4
+ 356 104 4
+ 360 104 4
+ 364 104 4
+368 108 4
+ 372 108 4
+ 376 108 4
+ 380 108 4
+384 112 4
+ 388 112 4
+ 392 112 4
+ 396 112 4
+400 116 4
+ 404 116 4
+ 408 116 4
+ 412 116 4
+416 120 4
+ 420 120 4
+ 424 120 4
+ 428 120 4
+432 124 4
+ 436 124 4
+ 440 124 4
+ 444 124 4
+448 128 4
+ 452 128 4
+ 456 128 4
+ 460 128 4
+464 132 4
+ 468 132 4
+ 472 132 4
+ 476 132 4
+480 136 4
+ 484 136 4
+ 488 136 4
+ 492 136 4
+496 140 4
+ 500 140 4
+ 504 140 4
+ 508 140 4
+512 144 4
+ 516 144 4
+ 520 144 4
+ 524 144 4
+528 148 4
+ 532 148 4
+ 536 148 4
+ 540 148 4
+544 152 4
+ 548 152 4
+ 552 152 4
+ 556 152 4
+560 156 4
+ 564 156 4
+ 568 156 4
+ 572 156 4
+576 160 4
+ 580 160 4
+ 584 160 4
+ 588 160 4
+592 164 4
+ 596 164 4
+ 600 164 4
+ 604 164 4
+608 168 4
+ 612 168 4
+ 616 168 4
+ 620 168 4
+624 172 4
+ 628 172 4
+ 632 172 4
+ 636 172 4
+640 176 4
+ 644 176 4
+ 648 176 4
+ 652 176 4
+656 180 4
+ 660 180 4
+ 664 180 4
+ 668 180 4
+672 184 4
+ 676 184 4
+ 680 184 4
+ 684 184 4
+688 188 4
+ 692 188 4
+ 696 188 4
+ 700 188 4
+704 192 4
+ 708 192 4
+ 712 192 4
+ 716 192 4
+720 196 4
+ 724 196 4
+ 728 196 4
+ 732 196 4
+736 200 4
+ 740 200 4
+ 744 200 4
+ 748 200 4
+752 204 4
+ 756 204 4
+ 760 204 4
+ 764 204 4
+768 208 4
+ 772 208 4
+ 776 208 4
+ 780 208 4
+784 212 4
+ 788 212 4
+ 792 212 4
+ 796 212 4
+800 216 4
+ 804 216 4
+ 808 216 4
+ 812 216 4
+816 220 4
+ 820 220 4
+ 824 220 4
+ 828 220 4
+832 224 4
+ 836 224 4
+ 840 224 4
+ 844 224 4
+848 228 4
+ 852 228 4
+ 856 228 4
+ 860 228 4
+864 232 4
+ 868 232 4
+ 872 232 4
+ 876 232 4
+880 236 4
+ 884 236 4
+ 888 236 4
+ 892 236 4
+896 240 4
+ 900 240 4
+ 904 240 4
+ 908 240 4
+912 244 4
+ 916 244 4
+ 920 244 4
+ 924 244 4
+928 248 4
+ 932 248 4
+ 936 248 4
+ 940 248 4
+944 252 4
+ 948 252 4
+ 952 252 4
+ 956 252 4
+960 256 256
diff --git a/tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_2 b/tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_2
new file mode 100644
index 0000000..53cfc79
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_2
@@ -0,0 +1,246 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 960 blocks interleaved at 4 blocks
+c7d32c7a0aacde7259cac3ab214bda77
+ddef760dcef4784565cfe7d76e5aa3ce
+1bb551ae77e015eb5186e7630fde16c4
+be4d327cb8085aa69a446f15b42521c7
+0 16 260
+ 4 16 4
+ 8 16 4
+ 12 16 4
+16 20 4
+ 20 20 4
+ 24 20 4
+ 28 20 4
+32 24 4
+ 36 24 4
+ 40 24 4
+ 44 24 4
+48 28 4
+ 52 28 4
+ 56 28 4
+ 60 28 4
+64 32 4
+ 68 32 4
+ 72 32 4
+ 76 32 4
+80 36 4
+ 84 36 4
+ 88 36 4
+ 92 36 4
+96 40 4
+ 100 40 4
+ 104 40 4
+ 108 40 4
+112 44 4
+ 116 44 4
+ 120 44 4
+ 124 44 4
+128 48 4
+ 132 48 4
+ 136 48 4
+ 140 48 4
+144 52 4
+ 148 52 4
+ 152 52 4
+ 156 52 4
+160 56 4
+ 164 56 4
+ 168 56 4
+ 172 56 4
+176 60 4
+ 180 60 4
+ 184 60 4
+ 188 60 4
+192 64 4
+ 196 64 4
+ 200 64 4
+ 204 64 4
+208 68 4
+ 212 68 4
+ 216 68 4
+ 220 68 4
+224 72 4
+ 228 72 4
+ 232 72 4
+ 236 72 4
+240 76 4
+ 244 76 4
+ 248 76 4
+ 252 76 4
+256 80 4
+ 260 80 4
+ 264 80 4
+ 268 80 4
+272 84 4
+ 276 84 4
+ 280 84 4
+ 284 84 4
+288 88 4
+ 292 88 4
+ 296 88 4
+ 300 88 4
+304 92 4
+ 308 92 4
+ 312 92 4
+ 316 92 4
+320 96 4
+ 324 96 4
+ 328 96 4
+ 332 96 4
+336 100 4
+ 340 100 4
+ 344 100 4
+ 348 100 4
+352 104 4
+ 356 104 4
+ 360 104 4
+ 364 104 4
+368 108 4
+ 372 108 4
+ 376 108 4
+ 380 108 4
+384 112 4
+ 388 112 4
+ 392 112 4
+ 396 112 4
+400 116 4
+ 404 116 4
+ 408 116 4
+ 412 116 4
+416 120 4
+ 420 120 4
+ 424 120 4
+ 428 120 4
+432 124 4
+ 436 124 4
+ 440 124 4
+ 444 124 4
+448 128 4
+ 452 128 4
+ 456 128 4
+ 460 128 4
+464 132 4
+ 468 132 4
+ 472 132 4
+ 476 132 4
+480 136 4
+ 484 136 4
+ 488 136 4
+ 492 136 4
+496 140 4
+ 500 140 4
+ 504 140 4
+ 508 140 4
+512 144 4
+ 516 144 4
+ 520 144 4
+ 524 144 4
+528 148 4
+ 532 148 4
+ 536 148 4
+ 540 148 4
+544 152 4
+ 548 152 4
+ 552 152 4
+ 556 152 4
+560 156 4
+ 564 156 4
+ 568 156 4
+ 572 156 4
+576 160 4
+ 580 160 4
+ 584 160 4
+ 588 160 4
+592 164 4
+ 596 164 4
+ 600 164 4
+ 604 164 4
+608 168 4
+ 612 168 4
+ 616 168 4
+ 620 168 4
+624 172 4
+ 628 172 4
+ 632 172 4
+ 636 172 4
+640 176 4
+ 644 176 4
+ 648 176 4
+ 652 176 4
+656 180 4
+ 660 180 4
+ 664 180 4
+ 668 180 4
+672 184 4
+ 676 184 4
+ 680 184 4
+ 684 184 4
+688 188 4
+ 692 188 4
+ 696 188 4
+ 700 188 4
+704 192 4
+ 708 192 4
+ 712 192 4
+ 716 192 4
+720 196 4
+ 724 196 4
+ 728 196 4
+ 732 196 4
+736 200 4
+ 740 200 4
+ 744 200 4
+ 748 200 4
+752 204 4
+ 756 204 4
+ 760 204 4
+ 764 204 4
+768 208 4
+ 772 208 4
+ 776 208 4
+ 780 208 4
+784 212 4
+ 788 212 4
+ 792 212 4
+ 796 212 4
+800 216 4
+ 804 216 4
+ 808 216 4
+ 812 216 4
+816 220 4
+ 820 220 4
+ 824 220 4
+ 828 220 4
+832 224 4
+ 836 224 4
+ 840 224 4
+ 844 224 4
+848 228 4
+ 852 228 4
+ 856 228 4
+ 860 228 4
+864 232 4
+ 868 232 4
+ 872 232 4
+ 876 232 4
+880 236 4
+ 884 236 4
+ 888 236 4
+ 892 236 4
+896 240 4
+ 900 240 4
+ 904 240 4
+ 908 240 4
+912 244 4
+ 916 244 4
+ 920 244 4
+ 924 244 4
+928 248 4
+ 932 248 4
+ 936 248 4
+ 940 248 4
+944 252 4
+ 948 252 4
+ 952 252 4
+ 956 252 4
diff --git a/tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_4 b/tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_4
new file mode 100644
index 0000000..ba42742
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_128k_128k_4_4
@@ -0,0 +1,966 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 480 blocks interleaved at 4 blocks
+ab2274c3b7241753a015c243417c0c29
+8db0b90ec1fa54feca98ad8fd292b07c
+a77c5edd8917abb32dc165750f1af781
+8db0b90ec1fa54feca98ad8fd292b07c
+0 16 257
+ 0 16 1
+1 17 1
+ 1 17 1
+2 18 1
+ 2 18 1
+3 19 1
+ 3 19 1
+ 4 16 1
+ 4 16 1
+ 5 17 1
+ 5 17 1
+ 6 18 1
+ 6 18 1
+ 7 19 1
+ 7 19 1
+8 20 1
+ 8 20 1
+9 21 1
+ 9 21 1
+10 22 1
+ 10 22 1
+11 23 1
+ 11 23 1
+ 12 20 1
+ 12 20 1
+ 13 21 1
+ 13 21 1
+ 14 22 1
+ 14 22 1
+ 15 23 1
+ 15 23 1
+16 24 1
+ 16 24 1
+17 25 1
+ 17 25 1
+18 26 1
+ 18 26 1
+19 27 1
+ 19 27 1
+ 20 24 1
+ 20 24 1
+ 21 25 1
+ 21 25 1
+ 22 26 1
+ 22 26 1
+ 23 27 1
+ 23 27 1
+24 28 1
+ 24 28 1
+25 29 1
+ 25 29 1
+26 30 1
+ 26 30 1
+27 31 1
+ 27 31 1
+ 28 28 1
+ 28 28 1
+ 29 29 1
+ 29 29 1
+ 30 30 1
+ 30 30 1
+ 31 31 1
+ 31 31 1
+32 32 1
+ 32 32 1
+33 33 1
+ 33 33 1
+34 34 1
+ 34 34 1
+35 35 1
+ 35 35 1
+ 36 32 1
+ 36 32 1
+ 37 33 1
+ 37 33 1
+ 38 34 1
+ 38 34 1
+ 39 35 1
+ 39 35 1
+40 36 1
+ 40 36 1
+41 37 1
+ 41 37 1
+42 38 1
+ 42 38 1
+43 39 1
+ 43 39 1
+ 44 36 1
+ 44 36 1
+ 45 37 1
+ 45 37 1
+ 46 38 1
+ 46 38 1
+ 47 39 1
+ 47 39 1
+48 40 1
+ 48 40 1
+49 41 1
+ 49 41 1
+50 42 1
+ 50 42 1
+51 43 1
+ 51 43 1
+ 52 40 1
+ 52 40 1
+ 53 41 1
+ 53 41 1
+ 54 42 1
+ 54 42 1
+ 55 43 1
+ 55 43 1
+56 44 1
+ 56 44 1
+57 45 1
+ 57 45 1
+58 46 1
+ 58 46 1
+59 47 1
+ 59 47 1
+ 60 44 1
+ 60 44 1
+ 61 45 1
+ 61 45 1
+ 62 46 1
+ 62 46 1
+ 63 47 1
+ 63 47 1
+64 48 1
+ 64 48 1
+65 49 1
+ 65 49 1
+66 50 1
+ 66 50 1
+67 51 1
+ 67 51 1
+ 68 48 1
+ 68 48 1
+ 69 49 1
+ 69 49 1
+ 70 50 1
+ 70 50 1
+ 71 51 1
+ 71 51 1
+72 52 1
+ 72 52 1
+73 53 1
+ 73 53 1
+74 54 1
+ 74 54 1
+75 55 1
+ 75 55 1
+ 76 52 1
+ 76 52 1
+ 77 53 1
+ 77 53 1
+ 78 54 1
+ 78 54 1
+ 79 55 1
+ 79 55 1
+80 56 1
+ 80 56 1
+81 57 1
+ 81 57 1
+82 58 1
+ 82 58 1
+83 59 1
+ 83 59 1
+ 84 56 1
+ 84 56 1
+ 85 57 1
+ 85 57 1
+ 86 58 1
+ 86 58 1
+ 87 59 1
+ 87 59 1
+88 60 1
+ 88 60 1
+89 61 1
+ 89 61 1
+90 62 1
+ 90 62 1
+91 63 1
+ 91 63 1
+ 92 60 1
+ 92 60 1
+ 93 61 1
+ 93 61 1
+ 94 62 1
+ 94 62 1
+ 95 63 1
+ 95 63 1
+96 64 1
+ 96 64 1
+97 65 1
+ 97 65 1
+98 66 1
+ 98 66 1
+99 67 1
+ 99 67 1
+ 100 64 1
+ 100 64 1
+ 101 65 1
+ 101 65 1
+ 102 66 1
+ 102 66 1
+ 103 67 1
+ 103 67 1
+104 68 1
+ 104 68 1
+105 69 1
+ 105 69 1
+106 70 1
+ 106 70 1
+107 71 1
+ 107 71 1
+ 108 68 1
+ 108 68 1
+ 109 69 1
+ 109 69 1
+ 110 70 1
+ 110 70 1
+ 111 71 1
+ 111 71 1
+112 72 1
+ 112 72 1
+113 73 1
+ 113 73 1
+114 74 1
+ 114 74 1
+115 75 1
+ 115 75 1
+ 116 72 1
+ 116 72 1
+ 117 73 1
+ 117 73 1
+ 118 74 1
+ 118 74 1
+ 119 75 1
+ 119 75 1
+120 76 1
+ 120 76 1
+121 77 1
+ 121 77 1
+122 78 1
+ 122 78 1
+123 79 1
+ 123 79 1
+ 124 76 1
+ 124 76 1
+ 125 77 1
+ 125 77 1
+ 126 78 1
+ 126 78 1
+ 127 79 1
+ 127 79 1
+128 80 1
+ 128 80 1
+129 81 1
+ 129 81 1
+130 82 1
+ 130 82 1
+131 83 1
+ 131 83 1
+ 132 80 1
+ 132 80 1
+ 133 81 1
+ 133 81 1
+ 134 82 1
+ 134 82 1
+ 135 83 1
+ 135 83 1
+136 84 1
+ 136 84 1
+137 85 1
+ 137 85 1
+138 86 1
+ 138 86 1
+139 87 1
+ 139 87 1
+ 140 84 1
+ 140 84 1
+ 141 85 1
+ 141 85 1
+ 142 86 1
+ 142 86 1
+ 143 87 1
+ 143 87 1
+144 88 1
+ 144 88 1
+145 89 1
+ 145 89 1
+146 90 1
+ 146 90 1
+147 91 1
+ 147 91 1
+ 148 88 1
+ 148 88 1
+ 149 89 1
+ 149 89 1
+ 150 90 1
+ 150 90 1
+ 151 91 1
+ 151 91 1
+152 92 1
+ 152 92 1
+153 93 1
+ 153 93 1
+154 94 1
+ 154 94 1
+155 95 1
+ 155 95 1
+ 156 92 1
+ 156 92 1
+ 157 93 1
+ 157 93 1
+ 158 94 1
+ 158 94 1
+ 159 95 1
+ 159 95 1
+160 96 1
+ 160 96 1
+161 97 1
+ 161 97 1
+162 98 1
+ 162 98 1
+163 99 1
+ 163 99 1
+ 164 96 1
+ 164 96 1
+ 165 97 1
+ 165 97 1
+ 166 98 1
+ 166 98 1
+ 167 99 1
+ 167 99 1
+168 100 1
+ 168 100 1
+169 101 1
+ 169 101 1
+170 102 1
+ 170 102 1
+171 103 1
+ 171 103 1
+ 172 100 1
+ 172 100 1
+ 173 101 1
+ 173 101 1
+ 174 102 1
+ 174 102 1
+ 175 103 1
+ 175 103 1
+176 104 1
+ 176 104 1
+177 105 1
+ 177 105 1
+178 106 1
+ 178 106 1
+179 107 1
+ 179 107 1
+ 180 104 1
+ 180 104 1
+ 181 105 1
+ 181 105 1
+ 182 106 1
+ 182 106 1
+ 183 107 1
+ 183 107 1
+184 108 1
+ 184 108 1
+185 109 1
+ 185 109 1
+186 110 1
+ 186 110 1
+187 111 1
+ 187 111 1
+ 188 108 1
+ 188 108 1
+ 189 109 1
+ 189 109 1
+ 190 110 1
+ 190 110 1
+ 191 111 1
+ 191 111 1
+192 112 1
+ 192 112 1
+193 113 1
+ 193 113 1
+194 114 1
+ 194 114 1
+195 115 1
+ 195 115 1
+ 196 112 1
+ 196 112 1
+ 197 113 1
+ 197 113 1
+ 198 114 1
+ 198 114 1
+ 199 115 1
+ 199 115 1
+200 116 1
+ 200 116 1
+201 117 1
+ 201 117 1
+202 118 1
+ 202 118 1
+203 119 1
+ 203 119 1
+ 204 116 1
+ 204 116 1
+ 205 117 1
+ 205 117 1
+ 206 118 1
+ 206 118 1
+ 207 119 1
+ 207 119 1
+208 120 1
+ 208 120 1
+209 121 1
+ 209 121 1
+210 122 1
+ 210 122 1
+211 123 1
+ 211 123 1
+ 212 120 1
+ 212 120 1
+ 213 121 1
+ 213 121 1
+ 214 122 1
+ 214 122 1
+ 215 123 1
+ 215 123 1
+216 124 1
+ 216 124 1
+217 125 1
+ 217 125 1
+218 126 1
+ 218 126 1
+219 127 1
+ 219 127 1
+ 220 124 1
+ 220 124 1
+ 221 125 1
+ 221 125 1
+ 222 126 1
+ 222 126 1
+ 223 127 1
+ 223 127 1
+224 128 1
+ 224 128 1
+225 129 1
+ 225 129 1
+226 130 1
+ 226 130 1
+227 131 1
+ 227 131 1
+ 228 128 1
+ 228 128 1
+ 229 129 1
+ 229 129 1
+ 230 130 1
+ 230 130 1
+ 231 131 1
+ 231 131 1
+232 132 1
+ 232 132 1
+233 133 1
+ 233 133 1
+234 134 1
+ 234 134 1
+235 135 1
+ 235 135 1
+ 236 132 1
+ 236 132 1
+ 237 133 1
+ 237 133 1
+ 238 134 1
+ 238 134 1
+ 239 135 1
+ 239 135 1
+240 136 1
+ 240 136 1
+241 137 1
+ 241 137 1
+242 138 1
+ 242 138 1
+243 139 1
+ 243 139 1
+ 244 136 1
+ 244 136 1
+ 245 137 1
+ 245 137 1
+ 246 138 1
+ 246 138 1
+ 247 139 1
+ 247 139 1
+248 140 1
+ 248 140 1
+249 141 1
+ 249 141 1
+250 142 1
+ 250 142 1
+251 143 1
+ 251 143 1
+ 252 140 1
+ 252 140 1
+ 253 141 1
+ 253 141 1
+ 254 142 1
+ 254 142 1
+ 255 143 1
+ 255 143 1
+256 144 1
+ 256 144 1
+257 145 1
+ 257 145 1
+258 146 1
+ 258 146 1
+259 147 1
+ 259 147 1
+ 260 144 1
+ 260 144 1
+ 261 145 1
+ 261 145 1
+ 262 146 1
+ 262 146 1
+ 263 147 1
+ 263 147 1
+264 148 1
+ 264 148 1
+265 149 1
+ 265 149 1
+266 150 1
+ 266 150 1
+267 151 1
+ 267 151 1
+ 268 148 1
+ 268 148 1
+ 269 149 1
+ 269 149 1
+ 270 150 1
+ 270 150 1
+ 271 151 1
+ 271 151 1
+272 152 1
+ 272 152 1
+273 153 1
+ 273 153 1
+274 154 1
+ 274 154 1
+275 155 1
+ 275 155 1
+ 276 152 1
+ 276 152 1
+ 277 153 1
+ 277 153 1
+ 278 154 1
+ 278 154 1
+ 279 155 1
+ 279 155 1
+280 156 1
+ 280 156 1
+281 157 1
+ 281 157 1
+282 158 1
+ 282 158 1
+283 159 1
+ 283 159 1
+ 284 156 1
+ 284 156 1
+ 285 157 1
+ 285 157 1
+ 286 158 1
+ 286 158 1
+ 287 159 1
+ 287 159 1
+288 160 1
+ 288 160 1
+289 161 1
+ 289 161 1
+290 162 1
+ 290 162 1
+291 163 1
+ 291 163 1
+ 292 160 1
+ 292 160 1
+ 293 161 1
+ 293 161 1
+ 294 162 1
+ 294 162 1
+ 295 163 1
+ 295 163 1
+296 164 1
+ 296 164 1
+297 165 1
+ 297 165 1
+298 166 1
+ 298 166 1
+299 167 1
+ 299 167 1
+ 300 164 1
+ 300 164 1
+ 301 165 1
+ 301 165 1
+ 302 166 1
+ 302 166 1
+ 303 167 1
+ 303 167 1
+304 168 1
+ 304 168 1
+305 169 1
+ 305 169 1
+306 170 1
+ 306 170 1
+307 171 1
+ 307 171 1
+ 308 168 1
+ 308 168 1
+ 309 169 1
+ 309 169 1
+ 310 170 1
+ 310 170 1
+ 311 171 1
+ 311 171 1
+312 172 1
+ 312 172 1
+313 173 1
+ 313 173 1
+314 174 1
+ 314 174 1
+315 175 1
+ 315 175 1
+ 316 172 1
+ 316 172 1
+ 317 173 1
+ 317 173 1
+ 318 174 1
+ 318 174 1
+ 319 175 1
+ 319 175 1
+320 176 1
+ 320 176 1
+321 177 1
+ 321 177 1
+322 178 1
+ 322 178 1
+323 179 1
+ 323 179 1
+ 324 176 1
+ 324 176 1
+ 325 177 1
+ 325 177 1
+ 326 178 1
+ 326 178 1
+ 327 179 1
+ 327 179 1
+328 180 1
+ 328 180 1
+329 181 1
+ 329 181 1
+330 182 1
+ 330 182 1
+331 183 1
+ 331 183 1
+ 332 180 1
+ 332 180 1
+ 333 181 1
+ 333 181 1
+ 334 182 1
+ 334 182 1
+ 335 183 1
+ 335 183 1
+336 184 1
+ 336 184 1
+337 185 1
+ 337 185 1
+338 186 1
+ 338 186 1
+339 187 1
+ 339 187 1
+ 340 184 1
+ 340 184 1
+ 341 185 1
+ 341 185 1
+ 342 186 1
+ 342 186 1
+ 343 187 1
+ 343 187 1
+344 188 1
+ 344 188 1
+345 189 1
+ 345 189 1
+346 190 1
+ 346 190 1
+347 191 1
+ 347 191 1
+ 348 188 1
+ 348 188 1
+ 349 189 1
+ 349 189 1
+ 350 190 1
+ 350 190 1
+ 351 191 1
+ 351 191 1
+352 192 1
+ 352 192 1
+353 193 1
+ 353 193 1
+354 194 1
+ 354 194 1
+355 195 1
+ 355 195 1
+ 356 192 1
+ 356 192 1
+ 357 193 1
+ 357 193 1
+ 358 194 1
+ 358 194 1
+ 359 195 1
+ 359 195 1
+360 196 1
+ 360 196 1
+361 197 1
+ 361 197 1
+362 198 1
+ 362 198 1
+363 199 1
+ 363 199 1
+ 364 196 1
+ 364 196 1
+ 365 197 1
+ 365 197 1
+ 366 198 1
+ 366 198 1
+ 367 199 1
+ 367 199 1
+368 200 1
+ 368 200 1
+369 201 1
+ 369 201 1
+370 202 1
+ 370 202 1
+371 203 1
+ 371 203 1
+ 372 200 1
+ 372 200 1
+ 373 201 1
+ 373 201 1
+ 374 202 1
+ 374 202 1
+ 375 203 1
+ 375 203 1
+376 204 1
+ 376 204 1
+377 205 1
+ 377 205 1
+378 206 1
+ 378 206 1
+379 207 1
+ 379 207 1
+ 380 204 1
+ 380 204 1
+ 381 205 1
+ 381 205 1
+ 382 206 1
+ 382 206 1
+ 383 207 1
+ 383 207 1
+384 208 1
+ 384 208 1
+385 209 1
+ 385 209 1
+386 210 1
+ 386 210 1
+387 211 1
+ 387 211 1
+ 388 208 1
+ 388 208 1
+ 389 209 1
+ 389 209 1
+ 390 210 1
+ 390 210 1
+ 391 211 1
+ 391 211 1
+392 212 1
+ 392 212 1
+393 213 1
+ 393 213 1
+394 214 1
+ 394 214 1
+395 215 1
+ 395 215 1
+ 396 212 1
+ 396 212 1
+ 397 213 1
+ 397 213 1
+ 398 214 1
+ 398 214 1
+ 399 215 1
+ 399 215 1
+400 216 1
+ 400 216 1
+401 217 1
+ 401 217 1
+402 218 1
+ 402 218 1
+403 219 1
+ 403 219 1
+ 404 216 1
+ 404 216 1
+ 405 217 1
+ 405 217 1
+ 406 218 1
+ 406 218 1
+ 407 219 1
+ 407 219 1
+408 220 1
+ 408 220 1
+409 221 1
+ 409 221 1
+410 222 1
+ 410 222 1
+411 223 1
+ 411 223 1
+ 412 220 1
+ 412 220 1
+ 413 221 1
+ 413 221 1
+ 414 222 1
+ 414 222 1
+ 415 223 1
+ 415 223 1
+416 224 1
+ 416 224 1
+417 225 1
+ 417 225 1
+418 226 1
+ 418 226 1
+419 227 1
+ 419 227 1
+ 420 224 1
+ 420 224 1
+ 421 225 1
+ 421 225 1
+ 422 226 1
+ 422 226 1
+ 423 227 1
+ 423 227 1
+424 228 1
+ 424 228 1
+425 229 1
+ 425 229 1
+426 230 1
+ 426 230 1
+427 231 1
+ 427 231 1
+ 428 228 1
+ 428 228 1
+ 429 229 1
+ 429 229 1
+ 430 230 1
+ 430 230 1
+ 431 231 1
+ 431 231 1
+432 232 1
+ 432 232 1
+433 233 1
+ 433 233 1
+434 234 1
+ 434 234 1
+435 235 1
+ 435 235 1
+ 436 232 1
+ 436 232 1
+ 437 233 1
+ 437 233 1
+ 438 234 1
+ 438 234 1
+ 439 235 1
+ 439 235 1
+440 236 1
+ 440 236 1
+441 237 1
+ 441 237 1
+442 238 1
+ 442 238 1
+443 239 1
+ 443 239 1
+ 444 236 1
+ 444 236 1
+ 445 237 1
+ 445 237 1
+ 446 238 1
+ 446 238 1
+ 447 239 1
+ 447 239 1
+448 240 1
+ 448 240 1
+449 241 1
+ 449 241 1
+450 242 1
+ 450 242 1
+451 243 1
+ 451 243 1
+ 452 240 1
+ 452 240 1
+ 453 241 1
+ 453 241 1
+ 454 242 1
+ 454 242 1
+ 455 243 1
+ 455 243 1
+456 244 1
+ 456 244 1
+457 245 1
+ 457 245 1
+458 246 1
+ 458 246 1
+459 247 1
+ 459 247 1
+ 460 244 1
+ 460 244 1
+ 461 245 1
+ 461 245 1
+ 462 246 1
+ 462 246 1
+ 463 247 1
+ 463 247 1
+464 248 1
+ 464 248 1
+465 249 1
+ 465 249 1
+466 250 1
+ 466 250 1
+467 251 1
+ 467 251 1
+ 468 248 1
+ 468 248 1
+ 469 249 1
+ 469 249 1
+ 470 250 1
+ 470 250 1
+ 471 251 1
+ 471 251 1
+472 252 1
+ 472 252 1
+473 253 1
+ 473 253 1
+474 254 1
+ 474 254 1
+475 255 1
+ 475 255 1
+ 476 252 1
+ 476 252 1
+ 477 253 1
+ 477 253 1
+ 478 254 1
+ 478 254 1
+ 479 255 1
+ 479 255 1
diff --git a/tools/regression/ccd/layout/ref.256k_128k_384k_128k_0_0 b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_0_0
new file mode 100644
index 0000000..12de5a4
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_0_0
@@ -0,0 +1,10 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 1728 blocks concatenated
+50ca80e7defff2928b09d9e6c22d14ff
+a5f4fb6b17d948b83b8685b3adfe0926
+7fbfcf4d51719802c3c0f5a1a471a447
+948f0400dc0519463e17b6946b488810
+0 16 496
+ 496 16 240
+ 736 16 752
+ 1488 16 240
diff --git a/tools/regression/ccd/layout/ref.256k_128k_384k_128k_0_4 b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_0_4
new file mode 100644
index 0000000..12de5a4
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_0_4
@@ -0,0 +1,10 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 1728 blocks concatenated
+50ca80e7defff2928b09d9e6c22d14ff
+a5f4fb6b17d948b83b8685b3adfe0926
+7fbfcf4d51719802c3c0f5a1a471a447
+948f0400dc0519463e17b6946b488810
+0 16 496
+ 496 16 240
+ 736 16 752
+ 1488 16 240
diff --git a/tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_0 b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_0
new file mode 100644
index 0000000..caf85b1
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_0
@@ -0,0 +1,98 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 1728 blocks interleaved at 16 blocks
+9f63a6ab2d5bd7c183e338387d9c4b59
+89518c095e85649516fa08fe98bf0a3e
+b400c2ac2de4e1dbb5930d55a89055e8
+65a3638152f0b6eaabf6a94f7aec6740
+0 16 16
+ 16 16 16
+ 32 16 16
+ 48 16 16
+64 32 16
+ 80 32 16
+ 96 32 16
+ 112 32 16
+128 48 16
+ 144 48 16
+ 160 48 16
+ 176 48 16
+192 64 16
+ 208 64 16
+ 224 64 16
+ 240 64 16
+256 80 16
+ 272 80 16
+ 288 80 16
+ 304 80 16
+320 96 16
+ 336 96 16
+ 352 96 16
+ 368 96 16
+384 112 16
+ 400 112 16
+ 416 112 16
+ 432 112 16
+448 128 16
+ 464 128 16
+ 480 128 16
+ 496 128 16
+512 144 16
+ 528 144 16
+ 544 144 16
+ 560 144 16
+576 160 16
+ 592 160 16
+ 608 160 16
+ 624 160 16
+640 176 16
+ 656 176 16
+ 672 176 16
+ 688 176 16
+704 192 16
+ 720 192 16
+ 736 192 16
+ 752 192 16
+768 208 16
+ 784 208 16
+ 800 208 16
+ 816 208 16
+832 224 16
+ 848 224 16
+ 864 224 16
+ 880 224 16
+896 240 16
+ 912 240 16
+ 928 240 16
+ 944 240 16
+960 256 16
+ 976 256 16
+992 272 16
+ 1008 272 16
+1024 288 16
+ 1040 288 16
+1056 304 16
+ 1072 304 16
+1088 320 16
+ 1104 320 16
+1120 336 16
+ 1136 336 16
+1152 352 16
+ 1168 352 16
+1184 368 16
+ 1200 368 16
+1216 384 16
+ 1232 384 16
+1248 400 16
+ 1264 400 16
+1280 416 16
+ 1296 416 16
+1312 432 16
+ 1328 432 16
+1344 448 16
+ 1360 448 16
+1376 464 16
+ 1392 464 16
+1408 480 16
+ 1424 480 16
+1440 496 16
+ 1456 496 272
diff --git a/tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_2 b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_2
new file mode 100644
index 0000000..e00fa6c
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_2
@@ -0,0 +1,68 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 960 blocks interleaved at 16 blocks
+ebe23f400e868c343240761b0b52c2fd
+89518c095e85649516fa08fe98bf0a3e
+39e67c2031238afd4bc4f4a3ada6cb72
+65a3638152f0b6eaabf6a94f7aec6740
+0 16 257
+ 0 256 512
+1 17 15
+ 16 16 16
+ 32 16 16
+ 48 16 16
+64 32 16
+ 80 32 16
+ 96 32 16
+ 112 32 16
+128 48 16
+ 144 48 16
+ 160 48 16
+ 176 48 16
+192 64 16
+ 208 64 16
+ 224 64 16
+ 240 64 16
+256 80 16
+ 272 80 16
+ 288 80 16
+ 304 80 16
+320 96 16
+ 336 96 16
+ 352 96 16
+ 368 96 16
+384 112 16
+ 400 112 16
+ 416 112 16
+ 432 112 16
+448 128 16
+ 464 128 16
+ 480 128 16
+ 496 128 16
+512 144 16
+ 528 144 16
+ 544 144 16
+ 560 144 16
+576 160 16
+ 592 160 16
+ 608 160 16
+ 624 160 16
+640 176 16
+ 656 176 16
+ 672 176 16
+ 688 176 16
+704 192 16
+ 720 192 16
+ 736 192 16
+ 752 192 16
+768 208 16
+ 784 208 16
+ 800 208 16
+ 816 208 16
+832 224 16
+ 848 224 16
+ 864 224 16
+ 880 224 16
+896 240 16
+ 912 240 16
+ 928 240 16
+ 944 240 16
diff --git a/tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_4 b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_4
new file mode 100644
index 0000000..06c4890
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_16_4
@@ -0,0 +1,966 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 480 blocks interleaved at 16 blocks
+f3f609d828a50cca082f6b6f499ca4b5
+721d9967a8e2608d111cfc24304255ca
+6b4636821f4b4ef7cfcd195c1c9c2bd1
+721d9967a8e2608d111cfc24304255ca
+0 16 257
+ 0 16 513
+1 17 1
+ 1 17 1
+2 18 1
+ 2 18 1
+3 19 1
+ 3 19 1
+4 20 1
+ 4 20 1
+5 21 1
+ 5 21 1
+6 22 1
+ 6 22 1
+7 23 1
+ 7 23 1
+8 24 1
+ 8 24 1
+9 25 1
+ 9 25 1
+10 26 1
+ 10 26 1
+11 27 1
+ 11 27 1
+12 28 1
+ 12 28 1
+13 29 1
+ 13 29 1
+14 30 1
+ 14 30 1
+15 31 1
+ 15 31 1
+ 16 16 1
+ 16 16 1
+ 17 17 1
+ 17 17 1
+ 18 18 1
+ 18 18 1
+ 19 19 1
+ 19 19 1
+ 20 20 1
+ 20 20 1
+ 21 21 1
+ 21 21 1
+ 22 22 1
+ 22 22 1
+ 23 23 1
+ 23 23 1
+ 24 24 1
+ 24 24 1
+ 25 25 1
+ 25 25 1
+ 26 26 1
+ 26 26 1
+ 27 27 1
+ 27 27 1
+ 28 28 1
+ 28 28 1
+ 29 29 1
+ 29 29 1
+ 30 30 1
+ 30 30 1
+ 31 31 1
+ 31 31 1
+32 32 1
+ 32 32 1
+33 33 1
+ 33 33 1
+34 34 1
+ 34 34 1
+35 35 1
+ 35 35 1
+36 36 1
+ 36 36 1
+37 37 1
+ 37 37 1
+38 38 1
+ 38 38 1
+39 39 1
+ 39 39 1
+40 40 1
+ 40 40 1
+41 41 1
+ 41 41 1
+42 42 1
+ 42 42 1
+43 43 1
+ 43 43 1
+44 44 1
+ 44 44 1
+45 45 1
+ 45 45 1
+46 46 1
+ 46 46 1
+47 47 1
+ 47 47 1
+ 48 32 1
+ 48 32 1
+ 49 33 1
+ 49 33 1
+ 50 34 1
+ 50 34 1
+ 51 35 1
+ 51 35 1
+ 52 36 1
+ 52 36 1
+ 53 37 1
+ 53 37 1
+ 54 38 1
+ 54 38 1
+ 55 39 1
+ 55 39 1
+ 56 40 1
+ 56 40 1
+ 57 41 1
+ 57 41 1
+ 58 42 1
+ 58 42 1
+ 59 43 1
+ 59 43 1
+ 60 44 1
+ 60 44 1
+ 61 45 1
+ 61 45 1
+ 62 46 1
+ 62 46 1
+ 63 47 1
+ 63 47 1
+64 48 1
+ 64 48 1
+65 49 1
+ 65 49 1
+66 50 1
+ 66 50 1
+67 51 1
+ 67 51 1
+68 52 1
+ 68 52 1
+69 53 1
+ 69 53 1
+70 54 1
+ 70 54 1
+71 55 1
+ 71 55 1
+72 56 1
+ 72 56 1
+73 57 1
+ 73 57 1
+74 58 1
+ 74 58 1
+75 59 1
+ 75 59 1
+76 60 1
+ 76 60 1
+77 61 1
+ 77 61 1
+78 62 1
+ 78 62 1
+79 63 1
+ 79 63 1
+ 80 48 1
+ 80 48 1
+ 81 49 1
+ 81 49 1
+ 82 50 1
+ 82 50 1
+ 83 51 1
+ 83 51 1
+ 84 52 1
+ 84 52 1
+ 85 53 1
+ 85 53 1
+ 86 54 1
+ 86 54 1
+ 87 55 1
+ 87 55 1
+ 88 56 1
+ 88 56 1
+ 89 57 1
+ 89 57 1
+ 90 58 1
+ 90 58 1
+ 91 59 1
+ 91 59 1
+ 92 60 1
+ 92 60 1
+ 93 61 1
+ 93 61 1
+ 94 62 1
+ 94 62 1
+ 95 63 1
+ 95 63 1
+96 64 1
+ 96 64 1
+97 65 1
+ 97 65 1
+98 66 1
+ 98 66 1
+99 67 1
+ 99 67 1
+100 68 1
+ 100 68 1
+101 69 1
+ 101 69 1
+102 70 1
+ 102 70 1
+103 71 1
+ 103 71 1
+104 72 1
+ 104 72 1
+105 73 1
+ 105 73 1
+106 74 1
+ 106 74 1
+107 75 1
+ 107 75 1
+108 76 1
+ 108 76 1
+109 77 1
+ 109 77 1
+110 78 1
+ 110 78 1
+111 79 1
+ 111 79 1
+ 112 64 1
+ 112 64 1
+ 113 65 1
+ 113 65 1
+ 114 66 1
+ 114 66 1
+ 115 67 1
+ 115 67 1
+ 116 68 1
+ 116 68 1
+ 117 69 1
+ 117 69 1
+ 118 70 1
+ 118 70 1
+ 119 71 1
+ 119 71 1
+ 120 72 1
+ 120 72 1
+ 121 73 1
+ 121 73 1
+ 122 74 1
+ 122 74 1
+ 123 75 1
+ 123 75 1
+ 124 76 1
+ 124 76 1
+ 125 77 1
+ 125 77 1
+ 126 78 1
+ 126 78 1
+ 127 79 1
+ 127 79 1
+128 80 1
+ 128 80 1
+129 81 1
+ 129 81 1
+130 82 1
+ 130 82 1
+131 83 1
+ 131 83 1
+132 84 1
+ 132 84 1
+133 85 1
+ 133 85 1
+134 86 1
+ 134 86 1
+135 87 1
+ 135 87 1
+136 88 1
+ 136 88 1
+137 89 1
+ 137 89 1
+138 90 1
+ 138 90 1
+139 91 1
+ 139 91 1
+140 92 1
+ 140 92 1
+141 93 1
+ 141 93 1
+142 94 1
+ 142 94 1
+143 95 1
+ 143 95 1
+ 144 80 1
+ 144 80 1
+ 145 81 1
+ 145 81 1
+ 146 82 1
+ 146 82 1
+ 147 83 1
+ 147 83 1
+ 148 84 1
+ 148 84 1
+ 149 85 1
+ 149 85 1
+ 150 86 1
+ 150 86 1
+ 151 87 1
+ 151 87 1
+ 152 88 1
+ 152 88 1
+ 153 89 1
+ 153 89 1
+ 154 90 1
+ 154 90 1
+ 155 91 1
+ 155 91 1
+ 156 92 1
+ 156 92 1
+ 157 93 1
+ 157 93 1
+ 158 94 1
+ 158 94 1
+ 159 95 1
+ 159 95 1
+160 96 1
+ 160 96 1
+161 97 1
+ 161 97 1
+162 98 1
+ 162 98 1
+163 99 1
+ 163 99 1
+164 100 1
+ 164 100 1
+165 101 1
+ 165 101 1
+166 102 1
+ 166 102 1
+167 103 1
+ 167 103 1
+168 104 1
+ 168 104 1
+169 105 1
+ 169 105 1
+170 106 1
+ 170 106 1
+171 107 1
+ 171 107 1
+172 108 1
+ 172 108 1
+173 109 1
+ 173 109 1
+174 110 1
+ 174 110 1
+175 111 1
+ 175 111 1
+ 176 96 1
+ 176 96 1
+ 177 97 1
+ 177 97 1
+ 178 98 1
+ 178 98 1
+ 179 99 1
+ 179 99 1
+ 180 100 1
+ 180 100 1
+ 181 101 1
+ 181 101 1
+ 182 102 1
+ 182 102 1
+ 183 103 1
+ 183 103 1
+ 184 104 1
+ 184 104 1
+ 185 105 1
+ 185 105 1
+ 186 106 1
+ 186 106 1
+ 187 107 1
+ 187 107 1
+ 188 108 1
+ 188 108 1
+ 189 109 1
+ 189 109 1
+ 190 110 1
+ 190 110 1
+ 191 111 1
+ 191 111 1
+192 112 1
+ 192 112 1
+193 113 1
+ 193 113 1
+194 114 1
+ 194 114 1
+195 115 1
+ 195 115 1
+196 116 1
+ 196 116 1
+197 117 1
+ 197 117 1
+198 118 1
+ 198 118 1
+199 119 1
+ 199 119 1
+200 120 1
+ 200 120 1
+201 121 1
+ 201 121 1
+202 122 1
+ 202 122 1
+203 123 1
+ 203 123 1
+204 124 1
+ 204 124 1
+205 125 1
+ 205 125 1
+206 126 1
+ 206 126 1
+207 127 1
+ 207 127 1
+ 208 112 1
+ 208 112 1
+ 209 113 1
+ 209 113 1
+ 210 114 1
+ 210 114 1
+ 211 115 1
+ 211 115 1
+ 212 116 1
+ 212 116 1
+ 213 117 1
+ 213 117 1
+ 214 118 1
+ 214 118 1
+ 215 119 1
+ 215 119 1
+ 216 120 1
+ 216 120 1
+ 217 121 1
+ 217 121 1
+ 218 122 1
+ 218 122 1
+ 219 123 1
+ 219 123 1
+ 220 124 1
+ 220 124 1
+ 221 125 1
+ 221 125 1
+ 222 126 1
+ 222 126 1
+ 223 127 1
+ 223 127 1
+224 128 1
+ 224 128 1
+225 129 1
+ 225 129 1
+226 130 1
+ 226 130 1
+227 131 1
+ 227 131 1
+228 132 1
+ 228 132 1
+229 133 1
+ 229 133 1
+230 134 1
+ 230 134 1
+231 135 1
+ 231 135 1
+232 136 1
+ 232 136 1
+233 137 1
+ 233 137 1
+234 138 1
+ 234 138 1
+235 139 1
+ 235 139 1
+236 140 1
+ 236 140 1
+237 141 1
+ 237 141 1
+238 142 1
+ 238 142 1
+239 143 1
+ 239 143 1
+ 240 128 1
+ 240 128 1
+ 241 129 1
+ 241 129 1
+ 242 130 1
+ 242 130 1
+ 243 131 1
+ 243 131 1
+ 244 132 1
+ 244 132 1
+ 245 133 1
+ 245 133 1
+ 246 134 1
+ 246 134 1
+ 247 135 1
+ 247 135 1
+ 248 136 1
+ 248 136 1
+ 249 137 1
+ 249 137 1
+ 250 138 1
+ 250 138 1
+ 251 139 1
+ 251 139 1
+ 252 140 1
+ 252 140 1
+ 253 141 1
+ 253 141 1
+ 254 142 1
+ 254 142 1
+ 255 143 1
+ 255 143 1
+256 144 1
+ 256 144 1
+257 145 1
+ 257 145 1
+258 146 1
+ 258 146 1
+259 147 1
+ 259 147 1
+260 148 1
+ 260 148 1
+261 149 1
+ 261 149 1
+262 150 1
+ 262 150 1
+263 151 1
+ 263 151 1
+264 152 1
+ 264 152 1
+265 153 1
+ 265 153 1
+266 154 1
+ 266 154 1
+267 155 1
+ 267 155 1
+268 156 1
+ 268 156 1
+269 157 1
+ 269 157 1
+270 158 1
+ 270 158 1
+271 159 1
+ 271 159 1
+ 272 144 1
+ 272 144 1
+ 273 145 1
+ 273 145 1
+ 274 146 1
+ 274 146 1
+ 275 147 1
+ 275 147 1
+ 276 148 1
+ 276 148 1
+ 277 149 1
+ 277 149 1
+ 278 150 1
+ 278 150 1
+ 279 151 1
+ 279 151 1
+ 280 152 1
+ 280 152 1
+ 281 153 1
+ 281 153 1
+ 282 154 1
+ 282 154 1
+ 283 155 1
+ 283 155 1
+ 284 156 1
+ 284 156 1
+ 285 157 1
+ 285 157 1
+ 286 158 1
+ 286 158 1
+ 287 159 1
+ 287 159 1
+288 160 1
+ 288 160 1
+289 161 1
+ 289 161 1
+290 162 1
+ 290 162 1
+291 163 1
+ 291 163 1
+292 164 1
+ 292 164 1
+293 165 1
+ 293 165 1
+294 166 1
+ 294 166 1
+295 167 1
+ 295 167 1
+296 168 1
+ 296 168 1
+297 169 1
+ 297 169 1
+298 170 1
+ 298 170 1
+299 171 1
+ 299 171 1
+300 172 1
+ 300 172 1
+301 173 1
+ 301 173 1
+302 174 1
+ 302 174 1
+303 175 1
+ 303 175 1
+ 304 160 1
+ 304 160 1
+ 305 161 1
+ 305 161 1
+ 306 162 1
+ 306 162 1
+ 307 163 1
+ 307 163 1
+ 308 164 1
+ 308 164 1
+ 309 165 1
+ 309 165 1
+ 310 166 1
+ 310 166 1
+ 311 167 1
+ 311 167 1
+ 312 168 1
+ 312 168 1
+ 313 169 1
+ 313 169 1
+ 314 170 1
+ 314 170 1
+ 315 171 1
+ 315 171 1
+ 316 172 1
+ 316 172 1
+ 317 173 1
+ 317 173 1
+ 318 174 1
+ 318 174 1
+ 319 175 1
+ 319 175 1
+320 176 1
+ 320 176 1
+321 177 1
+ 321 177 1
+322 178 1
+ 322 178 1
+323 179 1
+ 323 179 1
+324 180 1
+ 324 180 1
+325 181 1
+ 325 181 1
+326 182 1
+ 326 182 1
+327 183 1
+ 327 183 1
+328 184 1
+ 328 184 1
+329 185 1
+ 329 185 1
+330 186 1
+ 330 186 1
+331 187 1
+ 331 187 1
+332 188 1
+ 332 188 1
+333 189 1
+ 333 189 1
+334 190 1
+ 334 190 1
+335 191 1
+ 335 191 1
+ 336 176 1
+ 336 176 1
+ 337 177 1
+ 337 177 1
+ 338 178 1
+ 338 178 1
+ 339 179 1
+ 339 179 1
+ 340 180 1
+ 340 180 1
+ 341 181 1
+ 341 181 1
+ 342 182 1
+ 342 182 1
+ 343 183 1
+ 343 183 1
+ 344 184 1
+ 344 184 1
+ 345 185 1
+ 345 185 1
+ 346 186 1
+ 346 186 1
+ 347 187 1
+ 347 187 1
+ 348 188 1
+ 348 188 1
+ 349 189 1
+ 349 189 1
+ 350 190 1
+ 350 190 1
+ 351 191 1
+ 351 191 1
+352 192 1
+ 352 192 1
+353 193 1
+ 353 193 1
+354 194 1
+ 354 194 1
+355 195 1
+ 355 195 1
+356 196 1
+ 356 196 1
+357 197 1
+ 357 197 1
+358 198 1
+ 358 198 1
+359 199 1
+ 359 199 1
+360 200 1
+ 360 200 1
+361 201 1
+ 361 201 1
+362 202 1
+ 362 202 1
+363 203 1
+ 363 203 1
+364 204 1
+ 364 204 1
+365 205 1
+ 365 205 1
+366 206 1
+ 366 206 1
+367 207 1
+ 367 207 1
+ 368 192 1
+ 368 192 1
+ 369 193 1
+ 369 193 1
+ 370 194 1
+ 370 194 1
+ 371 195 1
+ 371 195 1
+ 372 196 1
+ 372 196 1
+ 373 197 1
+ 373 197 1
+ 374 198 1
+ 374 198 1
+ 375 199 1
+ 375 199 1
+ 376 200 1
+ 376 200 1
+ 377 201 1
+ 377 201 1
+ 378 202 1
+ 378 202 1
+ 379 203 1
+ 379 203 1
+ 380 204 1
+ 380 204 1
+ 381 205 1
+ 381 205 1
+ 382 206 1
+ 382 206 1
+ 383 207 1
+ 383 207 1
+384 208 1
+ 384 208 1
+385 209 1
+ 385 209 1
+386 210 1
+ 386 210 1
+387 211 1
+ 387 211 1
+388 212 1
+ 388 212 1
+389 213 1
+ 389 213 1
+390 214 1
+ 390 214 1
+391 215 1
+ 391 215 1
+392 216 1
+ 392 216 1
+393 217 1
+ 393 217 1
+394 218 1
+ 394 218 1
+395 219 1
+ 395 219 1
+396 220 1
+ 396 220 1
+397 221 1
+ 397 221 1
+398 222 1
+ 398 222 1
+399 223 1
+ 399 223 1
+ 400 208 1
+ 400 208 1
+ 401 209 1
+ 401 209 1
+ 402 210 1
+ 402 210 1
+ 403 211 1
+ 403 211 1
+ 404 212 1
+ 404 212 1
+ 405 213 1
+ 405 213 1
+ 406 214 1
+ 406 214 1
+ 407 215 1
+ 407 215 1
+ 408 216 1
+ 408 216 1
+ 409 217 1
+ 409 217 1
+ 410 218 1
+ 410 218 1
+ 411 219 1
+ 411 219 1
+ 412 220 1
+ 412 220 1
+ 413 221 1
+ 413 221 1
+ 414 222 1
+ 414 222 1
+ 415 223 1
+ 415 223 1
+416 224 1
+ 416 224 1
+417 225 1
+ 417 225 1
+418 226 1
+ 418 226 1
+419 227 1
+ 419 227 1
+420 228 1
+ 420 228 1
+421 229 1
+ 421 229 1
+422 230 1
+ 422 230 1
+423 231 1
+ 423 231 1
+424 232 1
+ 424 232 1
+425 233 1
+ 425 233 1
+426 234 1
+ 426 234 1
+427 235 1
+ 427 235 1
+428 236 1
+ 428 236 1
+429 237 1
+ 429 237 1
+430 238 1
+ 430 238 1
+431 239 1
+ 431 239 1
+ 432 224 1
+ 432 224 1
+ 433 225 1
+ 433 225 1
+ 434 226 1
+ 434 226 1
+ 435 227 1
+ 435 227 1
+ 436 228 1
+ 436 228 1
+ 437 229 1
+ 437 229 1
+ 438 230 1
+ 438 230 1
+ 439 231 1
+ 439 231 1
+ 440 232 1
+ 440 232 1
+ 441 233 1
+ 441 233 1
+ 442 234 1
+ 442 234 1
+ 443 235 1
+ 443 235 1
+ 444 236 1
+ 444 236 1
+ 445 237 1
+ 445 237 1
+ 446 238 1
+ 446 238 1
+ 447 239 1
+ 447 239 1
+448 240 1
+ 448 240 1
+449 241 1
+ 449 241 1
+450 242 1
+ 450 242 1
+451 243 1
+ 451 243 1
+452 244 1
+ 452 244 1
+453 245 1
+ 453 245 1
+454 246 1
+ 454 246 1
+455 247 1
+ 455 247 1
+456 248 1
+ 456 248 1
+457 249 1
+ 457 249 1
+458 250 1
+ 458 250 1
+459 251 1
+ 459 251 1
+460 252 1
+ 460 252 1
+461 253 1
+ 461 253 1
+462 254 1
+ 462 254 1
+463 255 1
+ 463 255 1
+ 464 240 1
+ 464 240 1
+ 465 241 1
+ 465 241 1
+ 466 242 1
+ 466 242 1
+ 467 243 1
+ 467 243 1
+ 468 244 1
+ 468 244 1
+ 469 245 1
+ 469 245 1
+ 470 246 1
+ 470 246 1
+ 471 247 1
+ 471 247 1
+ 472 248 1
+ 472 248 1
+ 473 249 1
+ 473 249 1
+ 474 250 1
+ 474 250 1
+ 475 251 1
+ 475 251 1
+ 476 252 1
+ 476 252 1
+ 477 253 1
+ 477 253 1
+ 478 254 1
+ 478 254 1
+ 479 255 1
+ 479 255 1
diff --git a/tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_0 b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_0
new file mode 100644
index 0000000..3b57123
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_0
@@ -0,0 +1,374 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 1728 blocks interleaved at 4 blocks
+50f78fd6083bea22e664f78350e24f2f
+ddef760dcef4784565cfe7d76e5aa3ce
+2be7c8a52a34487ed03453f9a45c1efe
+be4d327cb8085aa69a446f15b42521c7
+0 16 4
+ 4 16 4
+ 8 16 4
+ 12 16 4
+16 20 4
+ 20 20 4
+ 24 20 4
+ 28 20 4
+32 24 4
+ 36 24 4
+ 40 24 4
+ 44 24 4
+48 28 4
+ 52 28 4
+ 56 28 4
+ 60 28 4
+64 32 4
+ 68 32 4
+ 72 32 4
+ 76 32 4
+80 36 4
+ 84 36 4
+ 88 36 4
+ 92 36 4
+96 40 4
+ 100 40 4
+ 104 40 4
+ 108 40 4
+112 44 4
+ 116 44 4
+ 120 44 4
+ 124 44 4
+128 48 4
+ 132 48 4
+ 136 48 4
+ 140 48 4
+144 52 4
+ 148 52 4
+ 152 52 4
+ 156 52 4
+160 56 4
+ 164 56 4
+ 168 56 4
+ 172 56 4
+176 60 4
+ 180 60 4
+ 184 60 4
+ 188 60 4
+192 64 4
+ 196 64 4
+ 200 64 4
+ 204 64 4
+208 68 4
+ 212 68 4
+ 216 68 4
+ 220 68 4
+224 72 4
+ 228 72 4
+ 232 72 4
+ 236 72 4
+240 76 4
+ 244 76 4
+ 248 76 4
+ 252 76 4
+256 80 4
+ 260 80 4
+ 264 80 4
+ 268 80 4
+272 84 4
+ 276 84 4
+ 280 84 4
+ 284 84 4
+288 88 4
+ 292 88 4
+ 296 88 4
+ 300 88 4
+304 92 4
+ 308 92 4
+ 312 92 4
+ 316 92 4
+320 96 4
+ 324 96 4
+ 328 96 4
+ 332 96 4
+336 100 4
+ 340 100 4
+ 344 100 4
+ 348 100 4
+352 104 4
+ 356 104 4
+ 360 104 4
+ 364 104 4
+368 108 4
+ 372 108 4
+ 376 108 4
+ 380 108 4
+384 112 4
+ 388 112 4
+ 392 112 4
+ 396 112 4
+400 116 4
+ 404 116 4
+ 408 116 4
+ 412 116 4
+416 120 4
+ 420 120 4
+ 424 120 4
+ 428 120 4
+432 124 4
+ 436 124 4
+ 440 124 4
+ 444 124 4
+448 128 4
+ 452 128 4
+ 456 128 4
+ 460 128 4
+464 132 4
+ 468 132 4
+ 472 132 4
+ 476 132 4
+480 136 4
+ 484 136 4
+ 488 136 4
+ 492 136 4
+496 140 4
+ 500 140 4
+ 504 140 4
+ 508 140 4
+512 144 4
+ 516 144 4
+ 520 144 4
+ 524 144 4
+528 148 4
+ 532 148 4
+ 536 148 4
+ 540 148 4
+544 152 4
+ 548 152 4
+ 552 152 4
+ 556 152 4
+560 156 4
+ 564 156 4
+ 568 156 4
+ 572 156 4
+576 160 4
+ 580 160 4
+ 584 160 4
+ 588 160 4
+592 164 4
+ 596 164 4
+ 600 164 4
+ 604 164 4
+608 168 4
+ 612 168 4
+ 616 168 4
+ 620 168 4
+624 172 4
+ 628 172 4
+ 632 172 4
+ 636 172 4
+640 176 4
+ 644 176 4
+ 648 176 4
+ 652 176 4
+656 180 4
+ 660 180 4
+ 664 180 4
+ 668 180 4
+672 184 4
+ 676 184 4
+ 680 184 4
+ 684 184 4
+688 188 4
+ 692 188 4
+ 696 188 4
+ 700 188 4
+704 192 4
+ 708 192 4
+ 712 192 4
+ 716 192 4
+720 196 4
+ 724 196 4
+ 728 196 4
+ 732 196 4
+736 200 4
+ 740 200 4
+ 744 200 4
+ 748 200 4
+752 204 4
+ 756 204 4
+ 760 204 4
+ 764 204 4
+768 208 4
+ 772 208 4
+ 776 208 4
+ 780 208 4
+784 212 4
+ 788 212 4
+ 792 212 4
+ 796 212 4
+800 216 4
+ 804 216 4
+ 808 216 4
+ 812 216 4
+816 220 4
+ 820 220 4
+ 824 220 4
+ 828 220 4
+832 224 4
+ 836 224 4
+ 840 224 4
+ 844 224 4
+848 228 4
+ 852 228 4
+ 856 228 4
+ 860 228 4
+864 232 4
+ 868 232 4
+ 872 232 4
+ 876 232 4
+880 236 4
+ 884 236 4
+ 888 236 4
+ 892 236 4
+896 240 4
+ 900 240 4
+ 904 240 4
+ 908 240 4
+912 244 4
+ 916 244 4
+ 920 244 4
+ 924 244 4
+928 248 4
+ 932 248 4
+ 936 248 4
+ 940 248 4
+944 252 4
+ 948 252 4
+ 952 252 4
+ 956 252 4
+960 256 4
+ 964 256 4
+968 260 4
+ 972 260 4
+976 264 4
+ 980 264 4
+984 268 4
+ 988 268 4
+992 272 4
+ 996 272 4
+1000 276 4
+ 1004 276 4
+1008 280 4
+ 1012 280 4
+1016 284 4
+ 1020 284 4
+1024 288 4
+ 1028 288 4
+1032 292 4
+ 1036 292 4
+1040 296 4
+ 1044 296 4
+1048 300 4
+ 1052 300 4
+1056 304 4
+ 1060 304 4
+1064 308 4
+ 1068 308 4
+1072 312 4
+ 1076 312 4
+1080 316 4
+ 1084 316 4
+1088 320 4
+ 1092 320 4
+1096 324 4
+ 1100 324 4
+1104 328 4
+ 1108 328 4
+1112 332 4
+ 1116 332 4
+1120 336 4
+ 1124 336 4
+1128 340 4
+ 1132 340 4
+1136 344 4
+ 1140 344 4
+1144 348 4
+ 1148 348 4
+1152 352 4
+ 1156 352 4
+1160 356 4
+ 1164 356 4
+1168 360 4
+ 1172 360 4
+1176 364 4
+ 1180 364 4
+1184 368 4
+ 1188 368 4
+1192 372 4
+ 1196 372 4
+1200 376 4
+ 1204 376 4
+1208 380 4
+ 1212 380 4
+1216 384 4
+ 1220 384 4
+1224 388 4
+ 1228 388 4
+1232 392 4
+ 1236 392 4
+1240 396 4
+ 1244 396 4
+1248 400 4
+ 1252 400 4
+1256 404 4
+ 1260 404 4
+1264 408 4
+ 1268 408 4
+1272 412 4
+ 1276 412 4
+1280 416 4
+ 1284 416 4
+1288 420 4
+ 1292 420 4
+1296 424 4
+ 1300 424 4
+1304 428 4
+ 1308 428 4
+1312 432 4
+ 1316 432 4
+1320 436 4
+ 1324 436 4
+1328 440 4
+ 1332 440 4
+1336 444 4
+ 1340 444 4
+1344 448 4
+ 1348 448 4
+1352 452 4
+ 1356 452 4
+1360 456 4
+ 1364 456 4
+1368 460 4
+ 1372 460 4
+1376 464 4
+ 1380 464 4
+1384 468 4
+ 1388 468 4
+1392 472 4
+ 1396 472 4
+1400 476 4
+ 1404 476 4
+1408 480 4
+ 1412 480 4
+1416 484 4
+ 1420 484 4
+1424 488 4
+ 1428 488 4
+1432 492 4
+ 1436 492 4
+1440 496 4
+ 1444 496 4
+1448 500 4
+ 1452 500 4
+1456 504 4
+ 1460 504 4
+1464 508 4
+ 1468 508 260
diff --git a/tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_2 b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_2
new file mode 100644
index 0000000..7cccecf
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_2
@@ -0,0 +1,248 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 960 blocks interleaved at 4 blocks
+c7d32c7a0aacde7259cac3ab214bda77
+ddef760dcef4784565cfe7d76e5aa3ce
+809aae6bd417fb347af3832ab9cf7197
+be4d327cb8085aa69a446f15b42521c7
+0 16 257
+ 0 256 512
+1 17 3
+ 4 16 4
+ 8 16 4
+ 12 16 4
+16 20 4
+ 20 20 4
+ 24 20 4
+ 28 20 4
+32 24 4
+ 36 24 4
+ 40 24 4
+ 44 24 4
+48 28 4
+ 52 28 4
+ 56 28 4
+ 60 28 4
+64 32 4
+ 68 32 4
+ 72 32 4
+ 76 32 4
+80 36 4
+ 84 36 4
+ 88 36 4
+ 92 36 4
+96 40 4
+ 100 40 4
+ 104 40 4
+ 108 40 4
+112 44 4
+ 116 44 4
+ 120 44 4
+ 124 44 4
+128 48 4
+ 132 48 4
+ 136 48 4
+ 140 48 4
+144 52 4
+ 148 52 4
+ 152 52 4
+ 156 52 4
+160 56 4
+ 164 56 4
+ 168 56 4
+ 172 56 4
+176 60 4
+ 180 60 4
+ 184 60 4
+ 188 60 4
+192 64 4
+ 196 64 4
+ 200 64 4
+ 204 64 4
+208 68 4
+ 212 68 4
+ 216 68 4
+ 220 68 4
+224 72 4
+ 228 72 4
+ 232 72 4
+ 236 72 4
+240 76 4
+ 244 76 4
+ 248 76 4
+ 252 76 4
+256 80 4
+ 260 80 4
+ 264 80 4
+ 268 80 4
+272 84 4
+ 276 84 4
+ 280 84 4
+ 284 84 4
+288 88 4
+ 292 88 4
+ 296 88 4
+ 300 88 4
+304 92 4
+ 308 92 4
+ 312 92 4
+ 316 92 4
+320 96 4
+ 324 96 4
+ 328 96 4
+ 332 96 4
+336 100 4
+ 340 100 4
+ 344 100 4
+ 348 100 4
+352 104 4
+ 356 104 4
+ 360 104 4
+ 364 104 4
+368 108 4
+ 372 108 4
+ 376 108 4
+ 380 108 4
+384 112 4
+ 388 112 4
+ 392 112 4
+ 396 112 4
+400 116 4
+ 404 116 4
+ 408 116 4
+ 412 116 4
+416 120 4
+ 420 120 4
+ 424 120 4
+ 428 120 4
+432 124 4
+ 436 124 4
+ 440 124 4
+ 444 124 4
+448 128 4
+ 452 128 4
+ 456 128 4
+ 460 128 4
+464 132 4
+ 468 132 4
+ 472 132 4
+ 476 132 4
+480 136 4
+ 484 136 4
+ 488 136 4
+ 492 136 4
+496 140 4
+ 500 140 4
+ 504 140 4
+ 508 140 4
+512 144 4
+ 516 144 4
+ 520 144 4
+ 524 144 4
+528 148 4
+ 532 148 4
+ 536 148 4
+ 540 148 4
+544 152 4
+ 548 152 4
+ 552 152 4
+ 556 152 4
+560 156 4
+ 564 156 4
+ 568 156 4
+ 572 156 4
+576 160 4
+ 580 160 4
+ 584 160 4
+ 588 160 4
+592 164 4
+ 596 164 4
+ 600 164 4
+ 604 164 4
+608 168 4
+ 612 168 4
+ 616 168 4
+ 620 168 4
+624 172 4
+ 628 172 4
+ 632 172 4
+ 636 172 4
+640 176 4
+ 644 176 4
+ 648 176 4
+ 652 176 4
+656 180 4
+ 660 180 4
+ 664 180 4
+ 668 180 4
+672 184 4
+ 676 184 4
+ 680 184 4
+ 684 184 4
+688 188 4
+ 692 188 4
+ 696 188 4
+ 700 188 4
+704 192 4
+ 708 192 4
+ 712 192 4
+ 716 192 4
+720 196 4
+ 724 196 4
+ 728 196 4
+ 732 196 4
+736 200 4
+ 740 200 4
+ 744 200 4
+ 748 200 4
+752 204 4
+ 756 204 4
+ 760 204 4
+ 764 204 4
+768 208 4
+ 772 208 4
+ 776 208 4
+ 780 208 4
+784 212 4
+ 788 212 4
+ 792 212 4
+ 796 212 4
+800 216 4
+ 804 216 4
+ 808 216 4
+ 812 216 4
+816 220 4
+ 820 220 4
+ 824 220 4
+ 828 220 4
+832 224 4
+ 836 224 4
+ 840 224 4
+ 844 224 4
+848 228 4
+ 852 228 4
+ 856 228 4
+ 860 228 4
+864 232 4
+ 868 232 4
+ 872 232 4
+ 876 232 4
+880 236 4
+ 884 236 4
+ 888 236 4
+ 892 236 4
+896 240 4
+ 900 240 4
+ 904 240 4
+ 908 240 4
+912 244 4
+ 916 244 4
+ 920 244 4
+ 924 244 4
+928 248 4
+ 932 248 4
+ 936 248 4
+ 940 248 4
+944 252 4
+ 948 252 4
+ 952 252 4
+ 956 252 4
diff --git a/tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_4 b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_4
new file mode 100644
index 0000000..db2dcd8
--- /dev/null
+++ b/tools/regression/ccd/layout/ref.256k_128k_384k_128k_4_4
@@ -0,0 +1,966 @@
+$FreeBSD$
+ccd3: 4 components (md90, md91, md92, md93), 480 blocks interleaved at 4 blocks
+ab2274c3b7241753a015c243417c0c29
+8db0b90ec1fa54feca98ad8fd292b07c
+9593c41bb3a0f6589cf9389d80670cbe
+8db0b90ec1fa54feca98ad8fd292b07c
+0 16 257
+ 0 16 513
+1 17 1
+ 1 17 1
+2 18 1
+ 2 18 1
+3 19 1
+ 3 19 1
+ 4 16 1
+ 4 16 1
+ 5 17 1
+ 5 17 1
+ 6 18 1
+ 6 18 1
+ 7 19 1
+ 7 19 1
+8 20 1
+ 8 20 1
+9 21 1
+ 9 21 1
+10 22 1
+ 10 22 1
+11 23 1
+ 11 23 1
+ 12 20 1
+ 12 20 1
+ 13 21 1
+ 13 21 1
+ 14 22 1
+ 14 22 1
+ 15 23 1
+ 15 23 1
+16 24 1
+ 16 24 1
+17 25 1
+ 17 25 1
+18 26 1
+ 18 26 1
+19 27 1
+ 19 27 1
+ 20 24 1
+ 20 24 1
+ 21 25 1
+ 21 25 1
+ 22 26 1
+ 22 26 1
+ 23 27 1
+ 23 27 1
+24 28 1
+ 24 28 1
+25 29 1
+ 25 29 1
+26 30 1
+ 26 30 1
+27 31 1
+ 27 31 1
+ 28 28 1
+ 28 28 1
+ 29 29 1
+ 29 29 1
+ 30 30 1
+ 30 30 1
+ 31 31 1
+ 31 31 1
+32 32 1
+ 32 32 1
+33 33 1
+ 33 33 1
+34 34 1
+ 34 34 1
+35 35 1
+ 35 35 1
+ 36 32 1
+ 36 32 1
+ 37 33 1
+ 37 33 1
+ 38 34 1
+ 38 34 1
+ 39 35 1
+ 39 35 1
+40 36 1
+ 40 36 1
+41 37 1
+ 41 37 1
+42 38 1
+ 42 38 1
+43 39 1
+ 43 39 1
+ 44 36 1
+ 44 36 1
+ 45 37 1
+ 45 37 1
+ 46 38 1
+ 46 38 1
+ 47 39 1
+ 47 39 1
+48 40 1
+ 48 40 1
+49 41 1
+ 49 41 1
+50 42 1
+ 50 42 1
+51 43 1
+ 51 43 1
+ 52 40 1
+ 52 40 1
+ 53 41 1
+ 53 41 1
+ 54 42 1
+ 54 42 1
+ 55 43 1
+ 55 43 1
+56 44 1
+ 56 44 1
+57 45 1
+ 57 45 1
+58 46 1
+ 58 46 1
+59 47 1
+ 59 47 1
+ 60 44 1
+ 60 44 1
+ 61 45 1
+ 61 45 1
+ 62 46 1
+ 62 46 1
+ 63 47 1
+ 63 47 1
+64 48 1
+ 64 48 1
+65 49 1
+ 65 49 1
+66 50 1
+ 66 50 1
+67 51 1
+ 67 51 1
+ 68 48 1
+ 68 48 1
+ 69 49 1
+ 69 49 1
+ 70 50 1
+ 70 50 1
+ 71 51 1
+ 71 51 1
+72 52 1
+ 72 52 1
+73 53 1
+ 73 53 1
+74 54 1
+ 74 54 1
+75 55 1
+ 75 55 1
+ 76 52 1
+ 76 52 1
+ 77 53 1
+ 77 53 1
+ 78 54 1
+ 78 54 1
+ 79 55 1
+ 79 55 1
+80 56 1
+ 80 56 1
+81 57 1
+ 81 57 1
+82 58 1
+ 82 58 1
+83 59 1
+ 83 59 1
+ 84 56 1
+ 84 56 1
+ 85 57 1
+ 85 57 1
+ 86 58 1
+ 86 58 1
+ 87 59 1
+ 87 59 1
+88 60 1
+ 88 60 1
+89 61 1
+ 89 61 1
+90 62 1
+ 90 62 1
+91 63 1
+ 91 63 1
+ 92 60 1
+ 92 60 1
+ 93 61 1
+ 93 61 1
+ 94 62 1
+ 94 62 1
+ 95 63 1
+ 95 63 1
+96 64 1
+ 96 64 1
+97 65 1
+ 97 65 1
+98 66 1
+ 98 66 1
+99 67 1
+ 99 67 1
+ 100 64 1
+ 100 64 1
+ 101 65 1
+ 101 65 1
+ 102 66 1
+ 102 66 1
+ 103 67 1
+ 103 67 1
+104 68 1
+ 104 68 1
+105 69 1
+ 105 69 1
+106 70 1
+ 106 70 1
+107 71 1
+ 107 71 1
+ 108 68 1
+ 108 68 1
+ 109 69 1
+ 109 69 1
+ 110 70 1
+ 110 70 1
+ 111 71 1
+ 111 71 1
+112 72 1
+ 112 72 1
+113 73 1
+ 113 73 1
+114 74 1
+ 114 74 1
+115 75 1
+ 115 75 1
+ 116 72 1
+ 116 72 1
+ 117 73 1
+ 117 73 1
+ 118 74 1
+ 118 74 1
+ 119 75 1
+ 119 75 1
+120 76 1
+ 120 76 1
+121 77 1
+ 121 77 1
+122 78 1
+ 122 78 1
+123 79 1
+ 123 79 1
+ 124 76 1
+ 124 76 1
+ 125 77 1
+ 125 77 1
+ 126 78 1
+ 126 78 1
+ 127 79 1
+ 127 79 1
+128 80 1
+ 128 80 1
+129 81 1
+ 129 81 1
+130 82 1
+ 130 82 1
+131 83 1
+ 131 83 1
+ 132 80 1
+ 132 80 1
+ 133 81 1
+ 133 81 1
+ 134 82 1
+ 134 82 1
+ 135 83 1
+ 135 83 1
+136 84 1
+ 136 84 1
+137 85 1
+ 137 85 1
+138 86 1
+ 138 86 1
+139 87 1
+ 139 87 1
+ 140 84 1
+ 140 84 1
+ 141 85 1
+ 141 85 1
+ 142 86 1
+ 142 86 1
+ 143 87 1
+ 143 87 1
+144 88 1
+ 144 88 1
+145 89 1
+ 145 89 1
+146 90 1
+ 146 90 1
+147 91 1
+ 147 91 1
+ 148 88 1
+ 148 88 1
+ 149 89 1
+ 149 89 1
+ 150 90 1
+ 150 90 1
+ 151 91 1
+ 151 91 1
+152 92 1
+ 152 92 1
+153 93 1
+ 153 93 1
+154 94 1
+ 154 94 1
+155 95 1
+ 155 95 1
+ 156 92 1
+ 156 92 1
+ 157 93 1
+ 157 93 1
+ 158 94 1
+ 158 94 1
+ 159 95 1
+ 159 95 1
+160 96 1
+ 160 96 1
+161 97 1
+ 161 97 1
+162 98 1
+ 162 98 1
+163 99 1
+ 163 99 1
+ 164 96 1
+ 164 96 1
+ 165 97 1
+ 165 97 1
+ 166 98 1
+ 166 98 1
+ 167 99 1
+ 167 99 1
+168 100 1
+ 168 100 1
+169 101 1
+ 169 101 1
+170 102 1
+ 170 102 1
+171 103 1
+ 171 103 1
+ 172 100 1
+ 172 100 1
+ 173 101 1
+ 173 101 1
+ 174 102 1
+ 174 102 1
+ 175 103 1
+ 175 103 1
+176 104 1
+ 176 104 1
+177 105 1
+ 177 105 1
+178 106 1
+ 178 106 1
+179 107 1
+ 179 107 1
+ 180 104 1
+ 180 104 1
+ 181 105 1
+ 181 105 1
+ 182 106 1
+ 182 106 1
+ 183 107 1
+ 183 107 1
+184 108 1
+ 184 108 1
+185 109 1
+ 185 109 1
+186 110 1
+ 186 110 1
+187 111 1
+ 187 111 1
+ 188 108 1
+ 188 108 1
+ 189 109 1
+ 189 109 1
+ 190 110 1
+ 190 110 1
+ 191 111 1
+ 191 111 1
+192 112 1
+ 192 112 1
+193 113 1
+ 193 113 1
+194 114 1
+ 194 114 1
+195 115 1
+ 195 115 1
+ 196 112 1
+ 196 112 1
+ 197 113 1
+ 197 113 1
+ 198 114 1
+ 198 114 1
+ 199 115 1
+ 199 115 1
+200 116 1
+ 200 116 1
+201 117 1
+ 201 117 1
+202 118 1
+ 202 118 1
+203 119 1
+ 203 119 1
+ 204 116 1
+ 204 116 1
+ 205 117 1
+ 205 117 1
+ 206 118 1
+ 206 118 1
+ 207 119 1
+ 207 119 1
+208 120 1
+ 208 120 1
+209 121 1
+ 209 121 1
+210 122 1
+ 210 122 1
+211 123 1
+ 211 123 1
+ 212 120 1
+ 212 120 1
+ 213 121 1
+ 213 121 1
+ 214 122 1
+ 214 122 1
+ 215 123 1
+ 215 123 1
+216 124 1
+ 216 124 1
+217 125 1
+ 217 125 1
+218 126 1
+ 218 126 1
+219 127 1
+ 219 127 1
+ 220 124 1
+ 220 124 1
+ 221 125 1
+ 221 125 1
+ 222 126 1
+ 222 126 1
+ 223 127 1
+ 223 127 1
+224 128 1
+ 224 128 1
+225 129 1
+ 225 129 1
+226 130 1
+ 226 130 1
+227 131 1
+ 227 131 1
+ 228 128 1
+ 228 128 1
+ 229 129 1
+ 229 129 1
+ 230 130 1
+ 230 130 1
+ 231 131 1
+ 231 131 1
+232 132 1
+ 232 132 1
+233 133 1
+ 233 133 1
+234 134 1
+ 234 134 1
+235 135 1
+ 235 135 1
+ 236 132 1
+ 236 132 1
+ 237 133 1
+ 237 133 1
+ 238 134 1
+ 238 134 1
+ 239 135 1
+ 239 135 1
+240 136 1
+ 240 136 1
+241 137 1
+ 241 137 1
+242 138 1
+ 242 138 1
+243 139 1
+ 243 139 1
+ 244 136 1
+ 244 136 1
+ 245 137 1
+ 245 137 1
+ 246 138 1
+ 246 138 1
+ 247 139 1
+ 247 139 1
+248 140 1
+ 248 140 1
+249 141 1
+ 249 141 1
+250 142 1
+ 250 142 1
+251 143 1
+ 251 143 1
+ 252 140 1
+ 252 140 1
+ 253 141 1
+ 253 141 1
+ 254 142 1
+ 254 142 1
+ 255 143 1
+ 255 143 1
+256 144 1
+ 256 144 1
+257 145 1
+ 257 145 1
+258 146 1
+ 258 146 1
+259 147 1
+ 259 147 1
+ 260 144 1
+ 260 144 1
+ 261 145 1
+ 261 145 1
+ 262 146 1
+ 262 146 1
+ 263 147 1
+ 263 147 1
+264 148 1
+ 264 148 1
+265 149 1
+ 265 149 1
+266 150 1
+ 266 150 1
+267 151 1
+ 267 151 1
+ 268 148 1
+ 268 148 1
+ 269 149 1
+ 269 149 1
+ 270 150 1
+ 270 150 1
+ 271 151 1
+ 271 151 1
+272 152 1
+ 272 152 1
+273 153 1
+ 273 153 1
+274 154 1
+ 274 154 1
+275 155 1
+ 275 155 1
+ 276 152 1
+ 276 152 1
+ 277 153 1
+ 277 153 1
+ 278 154 1
+ 278 154 1
+ 279 155 1
+ 279 155 1
+280 156 1
+ 280 156 1
+281 157 1
+ 281 157 1
+282 158 1
+ 282 158 1
+283 159 1
+ 283 159 1
+ 284 156 1
+ 284 156 1
+ 285 157 1
+ 285 157 1
+ 286 158 1
+ 286 158 1
+ 287 159 1
+ 287 159 1
+288 160 1
+ 288 160 1
+289 161 1
+ 289 161 1
+290 162 1
+ 290 162 1
+291 163 1
+ 291 163 1
+ 292 160 1
+ 292 160 1
+ 293 161 1
+ 293 161 1
+ 294 162 1
+ 294 162 1
+ 295 163 1
+ 295 163 1
+296 164 1
+ 296 164 1
+297 165 1
+ 297 165 1
+298 166 1
+ 298 166 1
+299 167 1
+ 299 167 1
+ 300 164 1
+ 300 164 1
+ 301 165 1
+ 301 165 1
+ 302 166 1
+ 302 166 1
+ 303 167 1
+ 303 167 1
+304 168 1
+ 304 168 1
+305 169 1
+ 305 169 1
+306 170 1
+ 306 170 1
+307 171 1
+ 307 171 1
+ 308 168 1
+ 308 168 1
+ 309 169 1
+ 309 169 1
+ 310 170 1
+ 310 170 1
+ 311 171 1
+ 311 171 1
+312 172 1
+ 312 172 1
+313 173 1
+ 313 173 1
+314 174 1
+ 314 174 1
+315 175 1
+ 315 175 1
+ 316 172 1
+ 316 172 1
+ 317 173 1
+ 317 173 1
+ 318 174 1
+ 318 174 1
+ 319 175 1
+ 319 175 1
+320 176 1
+ 320 176 1
+321 177 1
+ 321 177 1
+322 178 1
+ 322 178 1
+323 179 1
+ 323 179 1
+ 324 176 1
+ 324 176 1
+ 325 177 1
+ 325 177 1
+ 326 178 1
+ 326 178 1
+ 327 179 1
+ 327 179 1
+328 180 1
+ 328 180 1
+329 181 1
+ 329 181 1
+330 182 1
+ 330 182 1
+331 183 1
+ 331 183 1
+ 332 180 1
+ 332 180 1
+ 333 181 1
+ 333 181 1
+ 334 182 1
+ 334 182 1
+ 335 183 1
+ 335 183 1
+336 184 1
+ 336 184 1
+337 185 1
+ 337 185 1
+338 186 1
+ 338 186 1
+339 187 1
+ 339 187 1
+ 340 184 1
+ 340 184 1
+ 341 185 1
+ 341 185 1
+ 342 186 1
+ 342 186 1
+ 343 187 1
+ 343 187 1
+344 188 1
+ 344 188 1
+345 189 1
+ 345 189 1
+346 190 1
+ 346 190 1
+347 191 1
+ 347 191 1
+ 348 188 1
+ 348 188 1
+ 349 189 1
+ 349 189 1
+ 350 190 1
+ 350 190 1
+ 351 191 1
+ 351 191 1
+352 192 1
+ 352 192 1
+353 193 1
+ 353 193 1
+354 194 1
+ 354 194 1
+355 195 1
+ 355 195 1
+ 356 192 1
+ 356 192 1
+ 357 193 1
+ 357 193 1
+ 358 194 1
+ 358 194 1
+ 359 195 1
+ 359 195 1
+360 196 1
+ 360 196 1
+361 197 1
+ 361 197 1
+362 198 1
+ 362 198 1
+363 199 1
+ 363 199 1
+ 364 196 1
+ 364 196 1
+ 365 197 1
+ 365 197 1
+ 366 198 1
+ 366 198 1
+ 367 199 1
+ 367 199 1
+368 200 1
+ 368 200 1
+369 201 1
+ 369 201 1
+370 202 1
+ 370 202 1
+371 203 1
+ 371 203 1
+ 372 200 1
+ 372 200 1
+ 373 201 1
+ 373 201 1
+ 374 202 1
+ 374 202 1
+ 375 203 1
+ 375 203 1
+376 204 1
+ 376 204 1
+377 205 1
+ 377 205 1
+378 206 1
+ 378 206 1
+379 207 1
+ 379 207 1
+ 380 204 1
+ 380 204 1
+ 381 205 1
+ 381 205 1
+ 382 206 1
+ 382 206 1
+ 383 207 1
+ 383 207 1
+384 208 1
+ 384 208 1
+385 209 1
+ 385 209 1
+386 210 1
+ 386 210 1
+387 211 1
+ 387 211 1
+ 388 208 1
+ 388 208 1
+ 389 209 1
+ 389 209 1
+ 390 210 1
+ 390 210 1
+ 391 211 1
+ 391 211 1
+392 212 1
+ 392 212 1
+393 213 1
+ 393 213 1
+394 214 1
+ 394 214 1
+395 215 1
+ 395 215 1
+ 396 212 1
+ 396 212 1
+ 397 213 1
+ 397 213 1
+ 398 214 1
+ 398 214 1
+ 399 215 1
+ 399 215 1
+400 216 1
+ 400 216 1
+401 217 1
+ 401 217 1
+402 218 1
+ 402 218 1
+403 219 1
+ 403 219 1
+ 404 216 1
+ 404 216 1
+ 405 217 1
+ 405 217 1
+ 406 218 1
+ 406 218 1
+ 407 219 1
+ 407 219 1
+408 220 1
+ 408 220 1
+409 221 1
+ 409 221 1
+410 222 1
+ 410 222 1
+411 223 1
+ 411 223 1
+ 412 220 1
+ 412 220 1
+ 413 221 1
+ 413 221 1
+ 414 222 1
+ 414 222 1
+ 415 223 1
+ 415 223 1
+416 224 1
+ 416 224 1
+417 225 1
+ 417 225 1
+418 226 1
+ 418 226 1
+419 227 1
+ 419 227 1
+ 420 224 1
+ 420 224 1
+ 421 225 1
+ 421 225 1
+ 422 226 1
+ 422 226 1
+ 423 227 1
+ 423 227 1
+424 228 1
+ 424 228 1
+425 229 1
+ 425 229 1
+426 230 1
+ 426 230 1
+427 231 1
+ 427 231 1
+ 428 228 1
+ 428 228 1
+ 429 229 1
+ 429 229 1
+ 430 230 1
+ 430 230 1
+ 431 231 1
+ 431 231 1
+432 232 1
+ 432 232 1
+433 233 1
+ 433 233 1
+434 234 1
+ 434 234 1
+435 235 1
+ 435 235 1
+ 436 232 1
+ 436 232 1
+ 437 233 1
+ 437 233 1
+ 438 234 1
+ 438 234 1
+ 439 235 1
+ 439 235 1
+440 236 1
+ 440 236 1
+441 237 1
+ 441 237 1
+442 238 1
+ 442 238 1
+443 239 1
+ 443 239 1
+ 444 236 1
+ 444 236 1
+ 445 237 1
+ 445 237 1
+ 446 238 1
+ 446 238 1
+ 447 239 1
+ 447 239 1
+448 240 1
+ 448 240 1
+449 241 1
+ 449 241 1
+450 242 1
+ 450 242 1
+451 243 1
+ 451 243 1
+ 452 240 1
+ 452 240 1
+ 453 241 1
+ 453 241 1
+ 454 242 1
+ 454 242 1
+ 455 243 1
+ 455 243 1
+456 244 1
+ 456 244 1
+457 245 1
+ 457 245 1
+458 246 1
+ 458 246 1
+459 247 1
+ 459 247 1
+ 460 244 1
+ 460 244 1
+ 461 245 1
+ 461 245 1
+ 462 246 1
+ 462 246 1
+ 463 247 1
+ 463 247 1
+464 248 1
+ 464 248 1
+465 249 1
+ 465 249 1
+466 250 1
+ 466 250 1
+467 251 1
+ 467 251 1
+ 468 248 1
+ 468 248 1
+ 469 249 1
+ 469 249 1
+ 470 250 1
+ 470 250 1
+ 471 251 1
+ 471 251 1
+472 252 1
+ 472 252 1
+473 253 1
+ 473 253 1
+474 254 1
+ 474 254 1
+475 255 1
+ 475 255 1
+ 476 252 1
+ 476 252 1
+ 477 253 1
+ 477 253 1
+ 478 254 1
+ 478 254 1
+ 479 255 1
+ 479 255 1
diff --git a/tools/regression/fsx/Makefile b/tools/regression/fsx/Makefile
new file mode 100644
index 0000000..c459487
--- /dev/null
+++ b/tools/regression/fsx/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= fsx
+
+NOMAN= yes
+
+.include <bsd.prog.mk>
diff --git a/tools/regression/fsx/fsx.c b/tools/regression/fsx/fsx.c
new file mode 100644
index 0000000..3430693
--- /dev/null
+++ b/tools/regression/fsx/fsx.c
@@ -0,0 +1,1121 @@
+/*
+ * Copyright (c) 1998-2001 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
+ *
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ *
+ * File: fsx.c
+ * Author: Avadis Tevanian, Jr.
+ *
+ * File system exerciser.
+ *
+ * Rewrite and enhancements 1998-2001 Conrad Minshall -- conrad@mac.com
+ *
+ * Various features from Joe Sokol, Pat Dirks, and Clark Warner.
+ *
+ * Small changes to work under Linux -- davej@suse.de
+ *
+ * Sundry porting patches from Guy Harris 12/2001
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef _UWIN
+# include <sys/param.h>
+# include <limits.h>
+# include <time.h>
+# include <strings.h>
+#endif
+#include <fcntl.h>
+#include <sys/mman.h>
+#ifndef MAP_FILE
+# define MAP_FILE 0
+#endif
+#include <limits.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#define NUMPRINTCOLUMNS 32 /* # columns of data to print on each line */
+
+/*
+ * A log entry is an operation and a bunch of arguments.
+ */
+
+struct log_entry {
+ int operation;
+ int args[3];
+};
+
+#define LOGSIZE 1000
+
+struct log_entry oplog[LOGSIZE]; /* the log */
+int logptr = 0; /* current position in log */
+int logcount = 0; /* total ops */
+
+/*
+ * Define operations
+ */
+
+#define OP_READ 1
+#define OP_WRITE 2
+#define OP_TRUNCATE 3
+#define OP_CLOSEOPEN 4
+#define OP_MAPREAD 5
+#define OP_MAPWRITE 6
+#define OP_SKIPPED 7
+
+int page_size;
+int page_mask;
+
+char *original_buf; /* a pointer to the original data */
+char *good_buf; /* a pointer to the correct data */
+char *temp_buf; /* a pointer to the current data */
+char *fname; /* name of our test file */
+int fd; /* fd for our test file */
+
+off_t file_size = 0;
+off_t biggest = 0;
+char state[256];
+unsigned long testcalls = 0; /* calls to function "test" */
+
+unsigned long simulatedopcount = 0; /* -b flag */
+int closeprob = 0; /* -c flag */
+int debug = 0; /* -d flag */
+unsigned long debugstart = 0; /* -D flag */
+unsigned long maxfilelen = 256 * 1024; /* -l flag */
+int sizechecks = 1; /* -n flag disables them */
+int maxoplen = 64 * 1024; /* -o flag */
+int quiet = 0; /* -q flag */
+unsigned long progressinterval = 0; /* -p flag */
+int readbdy = 1; /* -r flag */
+int style = 0; /* -s flag */
+int truncbdy = 1; /* -t flag */
+int writebdy = 1; /* -w flag */
+long monitorstart = -1; /* -m flag */
+long monitorend = -1; /* -m flag */
+int lite = 0; /* -L flag */
+long numops = -1; /* -N flag */
+int randomoplen = 1; /* -O flag disables it */
+int seed = 1; /* -S flag */
+int mapped_writes = 1; /* -W flag disables */
+int mapped_reads = 1; /* -R flag disables it */
+int fsxgoodfd = 0;
+FILE * fsxlogf = NULL;
+int badoff = -1;
+int closeopen = 0;
+
+
+void
+vwarnc(code, fmt, ap)
+ int code;
+ const char *fmt;
+ va_list ap;
+{
+ fprintf(stderr, "fsx: ");
+ if (fmt != NULL) {
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, ": ");
+ }
+ fprintf(stderr, "%s\n", strerror(code));
+}
+
+
+void
+warn(const char * fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vwarnc(errno, fmt, ap);
+ va_end(ap);
+}
+
+
+void
+prt(char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ vfprintf(stdout, fmt, args);
+ if (fsxlogf)
+ vfprintf(fsxlogf, fmt, args);
+ va_end(args);
+}
+
+void
+prterr(char *prefix)
+{
+ prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno));
+}
+
+
+void
+log4(int operation, int arg0, int arg1, int arg2)
+{
+ struct log_entry *le;
+
+ le = &oplog[logptr];
+ le->operation = operation;
+ if (closeopen)
+ le->operation = ~ le->operation;
+ le->args[0] = arg0;
+ le->args[1] = arg1;
+ le->args[2] = arg2;
+ logptr++;
+ logcount++;
+ if (logptr >= LOGSIZE)
+ logptr = 0;
+}
+
+
+void
+logdump(void)
+{
+ int i, count, down;
+ struct log_entry *lp;
+
+ prt("LOG DUMP (%d total operations):\n", logcount);
+ if (logcount < LOGSIZE) {
+ i = 0;
+ count = logcount;
+ } else {
+ i = logptr;
+ count = LOGSIZE;
+ }
+ for ( ; count > 0; count--) {
+ int opnum;
+
+ opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE;
+ prt("%d(%d mod 256): ", opnum, opnum%256);
+ lp = &oplog[i];
+ if ((closeopen = lp->operation < 0))
+ lp->operation = ~ lp->operation;
+
+ switch (lp->operation) {
+ case OP_MAPREAD:
+ prt("MAPREAD\t0x%x thru 0x%x\t(0x%x bytes)",
+ lp->args[0], lp->args[0] + lp->args[1] - 1,
+ lp->args[1]);
+ if (badoff >= lp->args[0] && badoff <
+ lp->args[0] + lp->args[1])
+ prt("\t***RRRR***");
+ break;
+ case OP_MAPWRITE:
+ prt("MAPWRITE 0x%x thru 0x%x\t(0x%x bytes)",
+ lp->args[0], lp->args[0] + lp->args[1] - 1,
+ lp->args[1]);
+ if (badoff >= lp->args[0] && badoff <
+ lp->args[0] + lp->args[1])
+ prt("\t******WWWW");
+ break;
+ case OP_READ:
+ prt("READ\t0x%x thru 0x%x\t(0x%x bytes)",
+ lp->args[0], lp->args[0] + lp->args[1] - 1,
+ lp->args[1]);
+ if (badoff >= lp->args[0] &&
+ badoff < lp->args[0] + lp->args[1])
+ prt("\t***RRRR***");
+ break;
+ case OP_WRITE:
+ prt("WRITE\t0x%x thru 0x%x\t(0x%x bytes)",
+ lp->args[0], lp->args[0] + lp->args[1] - 1,
+ lp->args[1]);
+ if (lp->args[0] > lp->args[2])
+ prt(" HOLE");
+ else if (lp->args[0] + lp->args[1] > lp->args[2])
+ prt(" EXTEND");
+ if ((badoff >= lp->args[0] || badoff >=lp->args[2]) &&
+ badoff < lp->args[0] + lp->args[1])
+ prt("\t***WWWW");
+ break;
+ case OP_TRUNCATE:
+ down = lp->args[0] < lp->args[1];
+ prt("TRUNCATE %s\tfrom 0x%x to 0x%x",
+ down ? "DOWN" : "UP", lp->args[1], lp->args[0]);
+ if (badoff >= lp->args[!down] &&
+ badoff < lp->args[!!down])
+ prt("\t******WWWW");
+ break;
+ case OP_SKIPPED:
+ prt("SKIPPED (no operation)");
+ break;
+ default:
+ prt("BOGUS LOG ENTRY (operation code = %d)!",
+ lp->operation);
+ }
+ if (closeopen)
+ prt("\n\t\tCLOSE/OPEN");
+ prt("\n");
+ i++;
+ if (i == LOGSIZE)
+ i = 0;
+ }
+}
+
+
+void
+save_buffer(char *buffer, off_t bufferlength, int fd)
+{
+ off_t ret;
+ ssize_t byteswritten;
+
+ if (fd <= 0 || bufferlength == 0)
+ return;
+
+ if (bufferlength > SSIZE_MAX) {
+ prt("fsx flaw: overflow in save_buffer\n");
+ exit(67);
+ }
+ if (lite) {
+ off_t size_by_seek = lseek(fd, (off_t)0, SEEK_END);
+ if (size_by_seek == (off_t)-1)
+ prterr("save_buffer: lseek eof");
+ else if (bufferlength > size_by_seek) {
+ warn("save_buffer: .fsxgood file too short... will
+save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek,
+ (unsigned long long)bufferlength);
+ bufferlength = size_by_seek;
+ }
+ }
+
+ ret = lseek(fd, (off_t)0, SEEK_SET);
+ if (ret == (off_t)-1)
+ prterr("save_buffer: lseek 0");
+
+ byteswritten = write(fd, buffer, (size_t)bufferlength);
+ if (byteswritten != bufferlength) {
+ if (byteswritten == -1)
+ prterr("save_buffer write");
+ else
+ warn("save_buffer: short write, 0x%x bytes instead
+of 0x%llx\n",
+ (unsigned)byteswritten,
+ (unsigned long long)bufferlength);
+ }
+}
+
+
+void
+report_failure(int status)
+{
+ logdump();
+
+ if (fsxgoodfd) {
+ if (good_buf) {
+ save_buffer(good_buf, file_size, fsxgoodfd);
+ prt("Correct content saved for comparison\n");
+ prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n",
+ fname, fname);
+ }
+ close(fsxgoodfd);
+ }
+ exit(status);
+}
+
+
+#define short_at(cp) ((unsigned short)((*((unsigned char *)(cp)) << 8) | \
+ *(((unsigned char *)(cp)) + 1)))
+
+void
+check_buffers(unsigned offset, unsigned size)
+{
+ unsigned char c, t;
+ unsigned i = 0;
+ unsigned n = 0;
+ unsigned op = 0;
+ unsigned bad = 0;
+
+ if (memcmp(good_buf + offset, temp_buf, size) != 0) {
+ prt("READ BAD DATA: offset = 0x%x, size = 0x%x\n",
+ offset, size);
+ prt("OFFSET\tGOOD\tBAD\tRANGE\n");
+ while (size > 0) {
+ c = good_buf[offset];
+ t = temp_buf[i];
+ if (c != t) {
+ if (n == 0) {
+ bad = short_at(&temp_buf[i]);
+ prt("0x%5x\t0x%04x\t0x%04x", offset,
+ short_at(&good_buf[offset]), bad);
+ op = temp_buf[offset & 1 ? i+1 : i];
+ }
+ n++;
+ badoff = offset;
+ }
+ offset++;
+ i++;
+ size--;
+ }
+ if (n) {
+ prt("\t0x%5x\n", n);
+ if (bad)
+ prt("operation# (mod 256) for the bad data
+may be %u\n", ((unsigned)op & 0xff));
+ else
+ prt("operation# (mod 256) for the bad data
+unknown, check HOLE and EXTEND ops\n");
+ } else
+ prt("????????????????\n");
+ report_failure(110);
+ }
+}
+
+
+void
+check_size(void)
+{
+ struct stat statbuf;
+ off_t size_by_seek;
+
+ if (fstat(fd, &statbuf)) {
+ prterr("check_size: fstat");
+ statbuf.st_size = -1;
+ }
+ size_by_seek = lseek(fd, (off_t)0, SEEK_END);
+ if (file_size != statbuf.st_size || file_size != size_by_seek) {
+ prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n",
+ (unsigned long long)file_size,
+ (unsigned long long)statbuf.st_size,
+ (unsigned long long)size_by_seek);
+ report_failure(120);
+ }
+}
+
+
+void
+check_trunc_hack(void)
+{
+ struct stat statbuf;
+
+ ftruncate(fd, (off_t)0);
+ ftruncate(fd, (off_t)100000);
+ fstat(fd, &statbuf);
+ if (statbuf.st_size != (off_t)100000) {
+ prt("no extend on truncate! not posix!\n");
+ exit(130);
+ }
+ ftruncate(fd, 0);
+}
+
+
+void
+doread(unsigned offset, unsigned size)
+{
+ off_t ret;
+ unsigned iret;
+
+ offset -= offset % readbdy;
+ if (size == 0) {
+ if (!quiet && testcalls > simulatedopcount)
+ prt("skipping zero size read\n");
+ log4(OP_SKIPPED, OP_READ, offset, size);
+ return;
+ }
+ if (size + offset > file_size) {
+ if (!quiet && testcalls > simulatedopcount)
+ prt("skipping seek/read past end of file\n");
+ log4(OP_SKIPPED, OP_READ, offset, size);
+ return;
+ }
+
+ log4(OP_READ, offset, size, 0);
+
+ if (testcalls <= simulatedopcount)
+ return;
+
+ if (!quiet && ((progressinterval &&
+ testcalls % progressinterval == 0) ||
+ (debug &&
+ (monitorstart == -1 ||
+ (offset + size > monitorstart &&
+ (monitorend == -1 || offset <= monitorend))))))
+ prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
+ offset, offset + size - 1, size);
+ ret = lseek(fd, (off_t)offset, SEEK_SET);
+ if (ret == (off_t)-1) {
+ prterr("doread: lseek");
+ report_failure(140);
+ }
+ iret = read(fd, temp_buf, size);
+ if (iret != size) {
+ if (iret == -1)
+ prterr("doread: read");
+ else
+ prt("short read: 0x%x bytes instead of 0x%x\n",
+ iret, size);
+ report_failure(141);
+ }
+ check_buffers(offset, size);
+}
+
+
+void
+domapread(unsigned offset, unsigned size)
+{
+ unsigned pg_offset;
+ unsigned map_size;
+ char *p;
+
+ offset -= offset % readbdy;
+ if (size == 0) {
+ if (!quiet && testcalls > simulatedopcount)
+ prt("skipping zero size read\n");
+ log4(OP_SKIPPED, OP_MAPREAD, offset, size);
+ return;
+ }
+ if (size + offset > file_size) {
+ if (!quiet && testcalls > simulatedopcount)
+ prt("skipping seek/read past end of file\n");
+ log4(OP_SKIPPED, OP_MAPREAD, offset, size);
+ return;
+ }
+
+ log4(OP_MAPREAD, offset, size, 0);
+
+ if (testcalls <= simulatedopcount)
+ return;
+
+ if (!quiet && ((progressinterval &&
+ testcalls % progressinterval == 0) ||
+ (debug &&
+ (monitorstart == -1 ||
+ (offset + size > monitorstart &&
+ (monitorend == -1 || offset <= monitorend))))))
+ prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
+ offset, offset + size - 1, size);
+
+ pg_offset = offset & page_mask;
+ map_size = pg_offset + size;
+
+ if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE |
+MAP_SHARED, fd,
+ (off_t)(offset - pg_offset))) == (char *)-1) {
+ prterr("domapread: mmap");
+ report_failure(190);
+ }
+ memcpy(temp_buf, p + pg_offset, size);
+ if (munmap(p, map_size) != 0) {
+ prterr("domapread: munmap");
+ report_failure(191);
+ }
+
+ check_buffers(offset, size);
+}
+
+
+void
+gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
+{
+ while (size--) {
+ good_buf[offset] = testcalls % 256;
+ if (offset % 2)
+ good_buf[offset] += original_buf[offset];
+ offset++;
+ }
+}
+
+
+void
+dowrite(unsigned offset, unsigned size)
+{
+ off_t ret;
+ unsigned iret;
+
+ offset -= offset % writebdy;
+ if (size == 0) {
+ if (!quiet && testcalls > simulatedopcount)
+ prt("skipping zero size write\n");
+ log4(OP_SKIPPED, OP_WRITE, offset, size);
+ return;
+ }
+
+ log4(OP_WRITE, offset, size, file_size);
+
+ gendata(original_buf, good_buf, offset, size);
+ if (file_size < offset + size) {
+ if (file_size < offset)
+ memset(good_buf + file_size, '\0', offset - file_size);
+ file_size = offset + size;
+ if (lite) {
+ warn("Lite file size bug in fsx!");
+ report_failure(149);
+ }
+ }
+
+ if (testcalls <= simulatedopcount)
+ return;
+
+ if (!quiet && ((progressinterval &&
+ testcalls % progressinterval == 0) ||
+ (debug &&
+ (monitorstart == -1 ||
+ (offset + size > monitorstart &&
+ (monitorend == -1 || offset <= monitorend))))))
+ prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
+ offset, offset + size - 1, size);
+ ret = lseek(fd, (off_t)offset, SEEK_SET);
+ if (ret == (off_t)-1) {
+ prterr("dowrite: lseek");
+ report_failure(150);
+ }
+ iret = write(fd, good_buf + offset, size);
+ if (iret != size) {
+ if (iret == -1)
+ prterr("dowrite: write");
+ else
+ prt("short write: 0x%x bytes instead of 0x%x\n",
+ iret, size);
+ report_failure(151);
+ }
+}
+
+
+void
+domapwrite(unsigned offset, unsigned size)
+{
+ unsigned pg_offset;
+ unsigned map_size;
+ off_t cur_filesize;
+ char *p;
+
+ offset -= offset % writebdy;
+ if (size == 0) {
+ if (!quiet && testcalls > simulatedopcount)
+ prt("skipping zero size write\n");
+ log4(OP_SKIPPED, OP_MAPWRITE, offset, size);
+ return;
+ }
+ cur_filesize = file_size;
+
+ log4(OP_MAPWRITE, offset, size, 0);
+
+ gendata(original_buf, good_buf, offset, size);
+ if (file_size < offset + size) {
+ if (file_size < offset)
+ memset(good_buf + file_size, '\0', offset - file_size);
+ file_size = offset + size;
+ if (lite) {
+ warn("Lite file size bug in fsx!");
+ report_failure(200);
+ }
+ }
+
+ if (testcalls <= simulatedopcount)
+ return;
+
+ if (!quiet && ((progressinterval &&
+ testcalls % progressinterval == 0) ||
+ (debug &&
+ (monitorstart == -1 ||
+ (offset + size > monitorstart &&
+ (monitorend == -1 || offset <= monitorend))))))
+ prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
+ offset, offset + size - 1, size);
+
+ if (file_size > cur_filesize) {
+ if (ftruncate(fd, file_size) == -1) {
+ prterr("domapwrite: ftruncate");
+ exit(201);
+ }
+ }
+ pg_offset = offset & page_mask;
+ map_size = pg_offset + size;
+
+ if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE,
+ MAP_FILE | MAP_SHARED, fd,
+ (off_t)(offset - pg_offset))) == (char *)-1) {
+ prterr("domapwrite: mmap");
+ report_failure(202);
+ }
+ memcpy(p + pg_offset, good_buf + offset, size);
+ if (msync(p, map_size, 0) != 0) {
+ prterr("domapwrite: msync");
+ report_failure(203);
+ }
+ if (munmap(p, map_size) != 0) {
+ prterr("domapwrite: munmap");
+ report_failure(204);
+ }
+}
+
+
+void
+dotruncate(unsigned size)
+{
+ int oldsize = file_size;
+
+ size -= size % truncbdy;
+ if (size > biggest) {
+ biggest = size;
+ if (!quiet && testcalls > simulatedopcount)
+ prt("truncating to largest ever: 0x%x\n", size);
+ }
+
+ log4(OP_TRUNCATE, size, (unsigned)file_size, 0);
+
+ if (size > file_size)
+ memset(good_buf + file_size, '\0', size - file_size);
+ file_size = size;
+
+ if (testcalls <= simulatedopcount)
+ return;
+
+ if ((progressinterval && testcalls % progressinterval == 0) ||
+ (debug && (monitorstart == -1 || monitorend == -1 ||
+ size <= monitorend)))
+ prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize,
+size);
+ if (ftruncate(fd, (off_t)size) == -1) {
+ prt("ftruncate1: %x\n", size);
+ prterr("dotruncate: ftruncate");
+ report_failure(160);
+ }
+}
+
+
+void
+writefileimage()
+{
+ ssize_t iret;
+
+ if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
+ prterr("writefileimage: lseek");
+ report_failure(171);
+ }
+ iret = write(fd, good_buf, file_size);
+ if ((off_t)iret != file_size) {
+ if (iret == -1)
+ prterr("writefileimage: write");
+ else
+ prt("short write: 0x%x bytes instead of 0x%llx\n",
+ iret, (unsigned long long)file_size);
+ report_failure(172);
+ }
+ if (lite ? 0 : ftruncate(fd, file_size) == -1) {
+ prt("ftruncate2: %llx\n", (unsigned long long)file_size);
+ prterr("writefileimage: ftruncate");
+ report_failure(173);
+ }
+}
+
+
+void
+docloseopen(void)
+{
+ if (testcalls <= simulatedopcount)
+ return;
+
+ if (debug)
+ prt("%lu close/open\n", testcalls);
+ if (close(fd)) {
+ prterr("docloseopen: close");
+ report_failure(180);
+ }
+ fd = open(fname, O_RDWR, 0);
+ if (fd < 0) {
+ prterr("docloseopen: open");
+ report_failure(181);
+ }
+}
+
+
+void
+test(void)
+{
+ unsigned long offset;
+ unsigned long size = maxoplen;
+ unsigned long rv = random();
+ unsigned long op = rv % (3 + !lite + mapped_writes);
+
+ /* turn off the map read if necessary */
+
+ if (op == 2 && !mapped_reads)
+ op = 0;
+
+ if (simulatedopcount > 0 && testcalls == simulatedopcount)
+ writefileimage();
+
+ testcalls++;
+
+ if (closeprob)
+ closeopen = (rv >> 3) < (1 << 28) / closeprob;
+
+ if (debugstart > 0 && testcalls >= debugstart)
+ debug = 1;
+
+ if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0)
+ prt("%lu...\n", testcalls);
+
+ /*
+ * READ: op = 0
+ * WRITE: op = 1
+ * MAPREAD: op = 2
+ * TRUNCATE: op = 3
+ * MAPWRITE: op = 3 or 4
+ */
+ if (lite ? 0 : op == 3 && (style & 1) == 0) /* vanilla truncate? */
+ dotruncate(random() % maxfilelen);
+ else {
+ if (randomoplen)
+ size = random() % (maxoplen+1);
+ if (lite ? 0 : op == 3)
+ dotruncate(size);
+ else {
+ offset = random();
+ if (op == 1 || op == (lite ? 3 : 4)) {
+ offset %= maxfilelen;
+ if (offset + size > maxfilelen)
+ size = maxfilelen - offset;
+ if (op != 1)
+ domapwrite(offset, size);
+ else
+ dowrite(offset, size);
+ } else {
+ if (file_size)
+ offset %= file_size;
+ else
+ offset = 0;
+ if (offset + size > file_size)
+ size = file_size - offset;
+ if (op != 0)
+ domapread(offset, size);
+ else
+ doread(offset, size);
+ }
+ }
+ }
+ if (sizechecks && testcalls > simulatedopcount)
+ check_size();
+ if (closeopen)
+ docloseopen();
+}
+
+
+void
+cleanup(sig)
+ int sig;
+{
+ if (sig)
+ prt("signal %d\n", sig);
+ prt("testcalls = %lu\n", testcalls);
+ exit(sig);
+}
+
+
+void
+usage(void)
+{
+ fprintf(stdout, "usage: %s",
+ "fsx [-dnqLOW] [-b opnum] [-c Prob] [-l flen] [-m
+start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t
+truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed]
+fname\n\
+ -b opnum: beginning operation number (default 1)\n\
+ -c P: 1 in P chance of file close+open at each op (default infinity)\n\
+ -d: debug output for all operations\n\
+ -l flen: the upper bound on file size (default 262144)\n\
+ -m startop:endop: monitor (print debug output) specified byte range
+(default 0:infinity)\n\
+ -n: no verifications of file size\n\
+ -o oplen: the upper bound on operation size (default 65536)\n\
+ -p progressinterval: debug output at specified operation interval\n\
+ -q: quieter operation\n\
+ -r readbdy: 4096 would make reads page aligned (default 1)\n\
+ -s style: 1 gives smaller truncates (default 0)\n\
+ -t truncbdy: 4096 would make truncates page aligned (default 1)\n\
+ -w writebdy: 4096 would make writes page aligned (default 1)\n\
+ -D startingop: debug output starting at specified operation\n\
+ -L: fsxLite - no file creations & no file size changes\n\
+ -N numops: total # operations to do (default infinity)\n\
+ -O: use oplen (see -o flag) for every op (default random)\n\
+ -P: save .fsxlog and .fsxgood files in dirpath (default ./)\n\
+ -S seed: for random # generator (default 1) 0 gets timestamp\n\
+ -W: mapped write operations DISabled\n\
+ -R: read() system calls only (mapped reads disabled)\n\
+ fname: this filename is REQUIRED (no default)\n");
+ exit(90);
+}
+
+
+int
+getnum(char *s, char **e)
+{
+ int ret = -1;
+
+ *e = (char *) 0;
+ ret = strtol(s, e, 0);
+ if (*e)
+ switch (**e) {
+ case 'b':
+ case 'B':
+ ret *= 512;
+ *e = *e + 1;
+ break;
+ case 'k':
+ case 'K':
+ ret *= 1024;
+ *e = *e + 1;
+ break;
+ case 'm':
+ case 'M':
+ ret *= 1024*1024;
+ *e = *e + 1;
+ break;
+ case 'w':
+ case 'W':
+ ret *= 4;
+ *e = *e + 1;
+ break;
+ }
+ return (ret);
+}
+
+
+int
+main(int argc, char **argv)
+{
+ int i, style, ch;
+ char *endp;
+ char goodfile[1024];
+ char logfile[1024];
+
+ goodfile[0] = 0;
+ logfile[0] = 0;
+
+ page_size = getpagesize();
+ page_mask = page_size - 1;
+
+ setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
+
+ while ((ch = getopt(argc, argv, "b:c:dl:m:no:p:qr:s:t:w:D:LN:OP:RS:W"))
+ != EOF)
+ switch (ch) {
+ case 'b':
+ simulatedopcount = getnum(optarg, &endp);
+ if (!quiet)
+ fprintf(stdout, "Will begin at operation
+%ld\n",
+ simulatedopcount);
+ if (simulatedopcount == 0)
+ usage();
+ simulatedopcount -= 1;
+ break;
+ case 'c':
+ closeprob = getnum(optarg, &endp);
+ if (!quiet)
+ fprintf(stdout,
+ "Chance of close/open is 1 in %d\n",
+ closeprob);
+ if (closeprob <= 0)
+ usage();
+ break;
+ case 'd':
+ debug = 1;
+ break;
+ case 'l':
+ maxfilelen = getnum(optarg, &endp);
+ if (maxfilelen <= 0)
+ usage();
+ break;
+ case 'm':
+ monitorstart = getnum(optarg, &endp);
+ if (monitorstart < 0)
+ usage();
+ if (!endp || *endp++ != ':')
+ usage();
+ monitorend = getnum(endp, &endp);
+ if (monitorend < 0)
+ usage();
+ if (monitorend == 0)
+ monitorend = -1; /* aka infinity */
+ debug = 1;
+ case 'n':
+ sizechecks = 0;
+ break;
+ case 'o':
+ maxoplen = getnum(optarg, &endp);
+ if (maxoplen <= 0)
+ usage();
+ break;
+ case 'p':
+ progressinterval = getnum(optarg, &endp);
+ if (progressinterval < 0)
+ usage();
+ break;
+ case 'q':
+ quiet = 1;
+ break;
+ case 'r':
+ readbdy = getnum(optarg, &endp);
+ if (readbdy <= 0)
+ usage();
+ break;
+ case 's':
+ style = getnum(optarg, &endp);
+ if (style < 0 || style > 1)
+ usage();
+ break;
+ case 't':
+ truncbdy = getnum(optarg, &endp);
+ if (truncbdy <= 0)
+ usage();
+ break;
+ case 'w':
+ writebdy = getnum(optarg, &endp);
+ if (writebdy <= 0)
+ usage();
+ break;
+ case 'D':
+ debugstart = getnum(optarg, &endp);
+ if (debugstart < 1)
+ usage();
+ break;
+ case 'L':
+ lite = 1;
+ break;
+ case 'N':
+ numops = getnum(optarg, &endp);
+ if (numops < 0)
+ usage();
+ break;
+ case 'O':
+ randomoplen = 0;
+ break;
+ case 'P':
+ strncpy(goodfile, optarg, sizeof(goodfile));
+ strcat(goodfile, "/");
+ strncpy(logfile, optarg, sizeof(logfile));
+ strcat(logfile, "/");
+ break;
+ case 'R':
+ mapped_reads = 0;
+ break;
+ case 'S':
+ seed = getnum(optarg, &endp);
+ if (seed == 0)
+ seed = time(0) % 10000;
+ if (!quiet)
+ fprintf(stdout, "Seed set to %d\n", seed);
+ if (seed < 0)
+ usage();
+ break;
+ case 'W':
+ mapped_writes = 0;
+ if (!quiet)
+ fprintf(stdout, "mapped writes DISABLED\n");
+ break;
+
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc != 1)
+ usage();
+ fname = argv[0];
+
+ signal(SIGHUP, cleanup);
+ signal(SIGINT, cleanup);
+ signal(SIGPIPE, cleanup);
+ signal(SIGALRM, cleanup);
+ signal(SIGTERM, cleanup);
+ signal(SIGXCPU, cleanup);
+ signal(SIGXFSZ, cleanup);
+ signal(SIGVTALRM, cleanup);
+ signal(SIGUSR1, cleanup);
+ signal(SIGUSR2, cleanup);
+
+ initstate(seed, state, 256);
+ setstate(state);
+ fd = open(fname, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC), 0666);
+ if (fd < 0) {
+ prterr(fname);
+ exit(91);
+ }
+ strncat(goodfile, fname, 256);
+ strcat (goodfile, ".fsxgood");
+ fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ if (fsxgoodfd < 0) {
+ prterr(goodfile);
+ exit(92);
+ }
+ strncat(logfile, fname, 256);
+ strcat (logfile, ".fsxlog");
+ fsxlogf = fopen(logfile, "w");
+ if (fsxlogf == NULL) {
+ prterr(logfile);
+ exit(93);
+ }
+ if (lite) {
+ off_t ret;
+ file_size = maxfilelen = lseek(fd, (off_t)0, SEEK_END);
+ if (file_size == (off_t)-1) {
+ prterr(fname);
+ warn("main: lseek eof");
+ exit(94);
+ }
+ ret = lseek(fd, (off_t)0, SEEK_SET);
+ if (ret == (off_t)-1) {
+ prterr(fname);
+ warn("main: lseek 0");
+ exit(95);
+ }
+ }
+ original_buf = (char *) malloc(maxfilelen);
+ for (i = 0; i < maxfilelen; i++)
+ original_buf[i] = random() % 256;
+ good_buf = (char *) malloc(maxfilelen);
+ memset(good_buf, '\0', maxfilelen);
+ temp_buf = (char *) malloc(maxoplen);
+ memset(temp_buf, '\0', maxoplen);
+ if (lite) { /* zero entire existing file */
+ ssize_t written;
+
+ written = write(fd, good_buf, (size_t)maxfilelen);
+ if (written != maxfilelen) {
+ if (written == -1) {
+ prterr(fname);
+ warn("main: error on write");
+ } else
+ warn("main: short write, 0x%x bytes instead
+of 0x%x\n",
+ (unsigned)written, maxfilelen);
+ exit(98);
+ }
+ } else
+ check_trunc_hack();
+
+ while (numops == -1 || numops--)
+ test();
+
+ if (close(fd)) {
+ prterr("close");
+ report_failure(99);
+ }
+ prt("All operations completed A-OK!\n");
+
+ exit(0);
+ return 0;
+}
diff --git a/tools/regression/geom/ConfCmp/ConfCmp.c b/tools/regression/geom/ConfCmp/ConfCmp.c
new file mode 100644
index 0000000..69a3c58
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/ConfCmp.c
@@ -0,0 +1,377 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/queue.h>
+#include <sys/sbuf.h>
+#include <err.h>
+#include <bsdxml.h>
+
+FILE *fsubs;
+
+struct node {
+ LIST_HEAD(, node) children;
+ LIST_ENTRY(node) siblings;
+ struct node *parent;
+ const char *name;
+ struct sbuf *cont;
+ struct sbuf *key;
+ char *id;
+ char *ref;
+};
+
+struct mytree {
+ struct node *top;
+ struct node *cur;
+ int indent;
+ int ignore;
+};
+
+struct ref {
+ LIST_ENTRY(ref) next;
+ char *k1;
+ char *k2;
+};
+
+LIST_HEAD(, ref) refs = LIST_HEAD_INITIALIZER(&refs);
+
+static struct node *
+new_node(void)
+{
+ struct node *np;
+
+ np = calloc(1, sizeof *np);
+ np->cont = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
+ sbuf_clear(np->cont);
+ np->key = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
+ sbuf_clear(np->key);
+ LIST_INIT(&np->children);
+ return (np);
+}
+
+static void
+indent(int n)
+{
+
+ printf("%*.*s", n, n, "");
+}
+
+static void
+StartElement(void *userData, const char *name, const char **attr)
+{
+ struct mytree *mt;
+ struct node *np;
+ int i;
+
+ mt = userData;
+ if (!strcmp(name, "FreeBSD")) {
+ mt->ignore = 1;
+ return;
+ }
+ mt->ignore = 0;
+ mt->indent += 2;
+ np = new_node();
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp(attr[i], "id"))
+ np->id = strdup(attr[i+1]);
+ else if (!strcmp(attr[i], "ref"))
+ np->ref = strdup(attr[i+1]);
+ }
+ np->name = strdup(name);
+ sbuf_cat(np->key, name);
+ sbuf_cat(np->key, "::");
+ np->parent = mt->cur;
+ LIST_INSERT_HEAD(&mt->cur->children, np, siblings);
+ mt->cur = np;
+}
+
+static void
+EndElement(void *userData, const char *name __unused)
+{
+ struct mytree *mt;
+ struct node *np;
+
+ mt = userData;
+ if (mt->ignore)
+ return;
+
+ mt->indent -= 2;
+ sbuf_finish(mt->cur->cont);
+ LIST_FOREACH(np, &mt->cur->children, siblings) {
+ if (strcmp(np->name, "name"))
+ continue;
+ sbuf_cat(mt->cur->key, sbuf_data(np->cont));
+ break;
+ }
+ sbuf_finish(mt->cur->key);
+ mt->cur = mt->cur->parent;
+}
+
+static void
+CharData(void *userData , const XML_Char *s , int len)
+{
+ struct mytree *mt;
+ const char *b, *e;
+
+ mt = userData;
+ if (mt->ignore)
+ return;
+ b = s;
+ e = s + len - 1;
+ while (isspace(*b) && b < e)
+ b++;
+ while (isspace(*e) && e > b)
+ e--;
+ if (e != b)
+ sbuf_bcat(mt->cur->cont, b, e - b + 1);
+}
+
+static struct mytree *
+dofile(char *filename)
+{
+ XML_Parser parser;
+ struct mytree *mt;
+ struct stat st;
+ int fd;
+ char *p;
+ int i;
+
+ parser = XML_ParserCreate(NULL);
+ mt = calloc(1, sizeof *mt);
+ mt->top = new_node();
+ mt->top->name = "(top)";
+ mt->top->parent = mt->top;
+ mt->cur = mt->top;
+ sbuf_finish(mt->top->key);
+ sbuf_finish(mt->top->cont);
+ XML_SetUserData(parser, mt);
+ XML_SetElementHandler(parser, StartElement, EndElement);
+ XML_SetCharacterDataHandler(parser, CharData);
+ fd = open(filename, O_RDONLY);
+ if (fd < 0)
+ err(1, filename);
+ fstat(fd, &st);
+ p = mmap(NULL, st.st_size, PROT_READ, MAP_NOCORE|MAP_PRIVATE, fd, 0);
+ i = XML_Parse(parser, p, st.st_size, 1);
+ if (i != 1)
+ errx(1, "XML_Parse complained -> %d", i);
+ munmap(p, st.st_size);
+ close(fd);
+ XML_ParserFree(parser);
+ sbuf_finish(mt->top->cont);
+ if (i)
+ return (mt);
+ else
+ return (NULL);
+}
+
+static void
+print_node(struct node *np)
+{
+ printf("\"%s\" -- \"%s\" -- \"%s\"", np->name, sbuf_data(np->cont), sbuf_data(np->key));
+ if (np->id)
+ printf(" id=\"%s\"", np->id);
+ if (np->ref)
+ printf(" ref=\"%s\"", np->ref);
+ printf("\n");
+}
+
+static void
+print_tree(struct node *np, int n)
+{
+ struct node *np1;
+
+ indent(n); printf("%s id=%s ref=%s\n", np->name, np->id, np->ref);
+ LIST_FOREACH(np1, &np->children, siblings)
+ print_tree(np1, n + 2);
+}
+
+static void
+sort_node(struct node *np)
+{
+ struct node *np1, *np2;
+ int n;
+
+ LIST_FOREACH(np1, &np->children, siblings)
+ sort_node(np1);
+ do {
+ np1 = LIST_FIRST(&np->children);
+ n = 0;
+ for (;;) {
+ if (np1 == NULL)
+ return;
+ np2 = LIST_NEXT(np1, siblings);
+ if (np2 == NULL)
+ return;
+ if (strcmp(sbuf_data(np1->key), sbuf_data(np2->key)) > 0) {
+ LIST_REMOVE(np2, siblings);
+ LIST_INSERT_BEFORE(np1, np2, siblings);
+ n++;
+ break;
+ }
+ np1 = np2;
+ }
+ } while (n);
+}
+
+static int
+refcmp(char *r1, char *r2)
+{
+ struct ref *r;
+
+ LIST_FOREACH(r, &refs, next) {
+ if (!strcmp(r1, r->k1))
+ return (strcmp(r2, r->k2));
+ }
+ r = calloc(1, sizeof(*r));
+ r->k1 = strdup(r1);
+ r->k2 = strdup(r2);
+ LIST_INSERT_HEAD(&refs, r, next);
+ if (fsubs != NULL) {
+ fprintf(fsubs, "s/%s/%s/g\n", r1, r2);
+ fflush(fsubs);
+ }
+ return (0);
+}
+
+static int compare_node2(struct node *n1, struct node *n2, int in);
+
+static int
+compare_node(struct node *n1, struct node *n2, int in)
+{
+ int i;
+ struct node *n1a, *n2a;
+
+ i = strcmp(n1->name, n2->name);
+ if (i)
+ return (i);
+ if (n1->id && n2->id)
+ i = refcmp(n1->id, n2->id);
+ else if (n1->id || n2->id)
+ i = -1;
+ if (i)
+ return (i);
+ if (n1->ref && n2->ref)
+ i = refcmp(n1->ref, n2->ref);
+ else if (n1->ref || n2->ref)
+ i = -1;
+ if (i)
+ return (i);
+ if (!strcmp(n1->name, "ref"))
+ i = refcmp(sbuf_data(n1->cont), sbuf_data(n2->cont));
+ else
+ i = strcmp(sbuf_data(n1->cont), sbuf_data(n2->cont));
+ if (i)
+ return (1);
+ n1a = LIST_FIRST(&n1->children);
+ n2a = LIST_FIRST(&n2->children);
+ for (;;) {
+ if (n1a == NULL && n2a == NULL)
+ return (0);
+ if (n1a != NULL && n2a == NULL) {
+ printf("1>");
+ indent(in);
+ print_node(n1a);
+ printf("2>\n");
+ return (1);
+ }
+ if (n1a == NULL && n2a != NULL) {
+ printf("1>\n");
+ printf("2>");
+ indent(in);
+ print_node(n2a);
+ return (1);
+ }
+ i = compare_node2(n1a, n2a, in + 2);
+ if (i)
+ return (1);
+ n1a = LIST_NEXT(n1a, siblings);
+ n2a = LIST_NEXT(n2a, siblings);
+ }
+ return (0);
+}
+
+static int
+compare_node2(struct node *n1, struct node *n2, int in)
+{
+ int i;
+
+ i = compare_node(n1, n2, in);
+ if (i) {
+ printf("1>");
+ indent(in);
+ print_node(n1);
+ printf("2>");
+ indent(in);
+ print_node(n2);
+ }
+ return (i);
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ struct mytree *t1, *t2;
+ int i;
+
+ fsubs = fopen("_.subs", "w");
+ setbuf(stdout, NULL);
+ setbuf(stderr, NULL);
+ if (argc != 3)
+ errx(1, "usage: %s file1 file2", argv[0]);
+
+ t1 = dofile(argv[1]);
+ if (t1 == NULL)
+ errx(2, "XML parser error on file %s", argv[1]);
+ sort_node(t1->top);
+ t2 = dofile(argv[2]);
+ if (t2 == NULL)
+ errx(2, "XML parser error on file %s", argv[2]);
+ sort_node(t2->top);
+ i = compare_node(t1->top, t2->top, 0);
+ return (i);
+}
+
diff --git a/tools/regression/geom/ConfCmp/Makefile b/tools/regression/geom/ConfCmp/Makefile
new file mode 100644
index 0000000..5966b4b
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/Makefile
@@ -0,0 +1,34 @@
+# $FreeBSD$
+
+PROG= ConfCmp
+SRCS+= ConfCmp.c
+SRCS+= subr_sbuf.c
+
+.PATH: ../../../../sys/kern
+
+NOOBJ= youbet
+WARNS= 5
+CFLAGS+= -g -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -static
+# Uncomment for ElectricFence
+#LDADD += -lefence -L/usr/local/lib
+
+LDADD += -lbsdxml
+
+NOMAN= yeah
+CLEANFILES += _*
+
+.include <bsd.prog.mk>
+
+test: ${PROG}
+ rm -f _* *.core
+ ./${PROG} a1.conf a1.conf
+ ./${PROG} a1.conf a1a.conf
+ if ./${PROG} a1.conf a1b.conf > /dev/null 2>&1 ; then exit 1 ; fi
+ if ./${PROG} a1.conf a1c.conf > /dev/null 2>&1 ; then exit 1 ; fi
+ if ./${PROG} a1.conf a1d.conf > /dev/null 2>&1 ; then exit 1 ; fi
+ ./${PROG} a2.conf a2.conf
+ ./${PROG} a2.conf a2a.conf
+ if ./${PROG} a2.conf a2b.conf > /dev/null 2>&1 ; then exit 1 ; fi
+ if ./${PROG} a2.conf a2c.conf > /dev/null 2>&1 ; then exit 1 ; fi
+ if ./${PROG} a2.conf a2d.conf > /dev/null 2>&1 ; then exit 1 ; fi
+
diff --git a/tools/regression/geom/ConfCmp/a1.conf b/tools/regression/geom/ConfCmp/a1.conf
new file mode 100644
index 0000000..94171cd
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/a1.conf
@@ -0,0 +1,414 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <method>
+ <ref>0x80712c0</ref>
+ <name>DEV-method</name>
+ <geom>
+ <ref>0x80bfd00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3d</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9500</ref>
+ <geom><ref>0x80bfd00</ref></geom>
+ <provider><ref>0x80bf880</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfc80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b94c0</ref>
+ <geom><ref>0x80bfc80</ref></geom>
+ <provider><ref>0x80bf800</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfc00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3a</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9480</ref>
+ <geom><ref>0x80bfc00</ref></geom>
+ <provider><ref>0x80bf780</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfb80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s2c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9440</ref>
+ <geom><ref>0x80bfb80</ref></geom>
+ <provider><ref>0x80bf600</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfb00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1f</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9400</ref>
+ <geom><ref>0x80bfb00</ref></geom>
+ <provider><ref>0x80bf480</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfa80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1e</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b93c0</ref>
+ <geom><ref>0x80bfa80</ref></geom>
+ <provider><ref>0x80bf400</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfa00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9380</ref>
+ <geom><ref>0x80bfa00</ref></geom>
+ <provider><ref>0x80bf380</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf980</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1b</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9340</ref>
+ <geom><ref>0x80bf980</ref></geom>
+ <provider><ref>0x80bf300</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf900</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1a</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9300</ref>
+ <geom><ref>0x80bf900</ref></geom>
+ <provider><ref>0x80bf280</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf680</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9280</ref>
+ <geom><ref>0x80bf680</ref></geom>
+ <provider><ref>0x80bf100</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf500</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9200</ref>
+ <geom><ref>0x80bf500</ref></geom>
+ <provider><ref>0x80bf080</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf180</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9180</ref>
+ <geom><ref>0x80bf180</ref></geom>
+ <provider><ref>0x80bf000</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80b9080</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer>
+ <ref>0x80b90c0</ref>
+ <geom><ref>0x80b9080</ref></geom>
+ <provider><ref>0x80b9040</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </method>
+ <method>
+ <ref>0x8071280</ref>
+ <name>MBREXT-method</name>
+ </method>
+ <method>
+ <ref>0x8071260</ref>
+ <name>MBR-method</name>
+ <geom>
+ <ref>0x80b9100</ref>
+ <method><ref>0x8071260</ref></method>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b9140</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <provider><ref>0x80b9040</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf100</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3</name>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf080</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s2</name>
+ <config>
+ <index>1</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>3220439040</offset>
+ <secoffset>6289920</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf000</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1</name>
+ <config>
+ <index>0</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ </geom>
+ </method>
+ <method>
+ <ref>0x80712a0</ref>
+ <name>BSD-method</name>
+ <geom>
+ <ref>0x80bf700</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b92c0</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <provider><ref>0x80bf100</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf880</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3d</name>
+ <config>
+ <index>3</index>
+ <length>6488104960</length>
+ <seclength>12672080</seclength>
+ <offset>10682408960</offset>
+ <secoffset>20864080</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf800</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3c</name>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf780</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3a</name>
+ <config>
+ <index>0</index>
+ <length>2097152000</length>
+ <seclength>4096000</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ </config>
+ </provider>
+ </geom>
+ <geom>
+ <ref>0x80bf580</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b9240</ref>
+ <geom><ref>0x80bf580</ref></geom>
+ <provider><ref>0x80bf080</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf600</ref>
+ <geom><ref>0x80bf580</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s2c</name>
+ <config>
+ <index>2</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>3220439040</offset>
+ <secoffset>6289920</secoffset>
+ </config>
+ </provider>
+ </geom>
+ <geom>
+ <ref>0x80bf200</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b91c0</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <provider><ref>0x80bf000</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf480</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1f</name>
+ <config>
+ <index>5</index>
+ <length>2066973184</length>
+ <seclength>4037057</seclength>
+ <offset>1153465856</offset>
+ <secoffset>2252863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf400</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1e</name>
+ <config>
+ <index>4</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>629177856</offset>
+ <secoffset>1228863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf380</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1c</name>
+ <config>
+ <index>2</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf300</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1b</name>
+ <config>
+ <index>1</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>104889856</offset>
+ <secoffset>204863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf280</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1a</name>
+ <config>
+ <index>0</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </method>
+ <method>
+ <ref>0x80711c0</ref>
+ <name>SIMDISK-method</name>
+ <geom>
+ <ref>0x80b9000</ref>
+ <method><ref>0x80711c0</ref></method>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider>
+ <ref>0x80b9040</ref>
+ <geom><ref>0x80b9000</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0</name>
+ </provider>
+ </geom>
+ </method>
+</mesh>
diff --git a/tools/regression/geom/ConfCmp/a1a.conf b/tools/regression/geom/ConfCmp/a1a.conf
new file mode 100644
index 0000000..01110f3
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/a1a.conf
@@ -0,0 +1,414 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <method>
+ <ref>0x90712c0</ref>
+ <name>DEV-method</name>
+ <geom>
+ <ref>0x90bfd00</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s3d</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x90b9500</ref>
+ <geom><ref>0x90bfd00</ref></geom>
+ <provider><ref>0x90bf880</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90bfc80</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s3c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x90b94c0</ref>
+ <geom><ref>0x90bfc80</ref></geom>
+ <provider><ref>0x90bf800</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90bfc00</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s3a</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x90b9480</ref>
+ <geom><ref>0x90bfc00</ref></geom>
+ <provider><ref>0x90bf780</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90bfb80</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s2c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x90b9440</ref>
+ <geom><ref>0x90bfb80</ref></geom>
+ <provider><ref>0x90bf600</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90bfb00</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s1f</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x90b9400</ref>
+ <geom><ref>0x90bfb00</ref></geom>
+ <provider><ref>0x90bf480</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90bfa80</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s1e</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x90b93c0</ref>
+ <geom><ref>0x90bfa80</ref></geom>
+ <provider><ref>0x90bf400</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90bfa00</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s1c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x90b9380</ref>
+ <geom><ref>0x90bfa00</ref></geom>
+ <provider><ref>0x90bf380</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90bf980</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s1b</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x90b9340</ref>
+ <geom><ref>0x90bf980</ref></geom>
+ <provider><ref>0x90bf300</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90bf900</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s1a</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x90b9300</ref>
+ <geom><ref>0x90bf900</ref></geom>
+ <provider><ref>0x90bf280</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90bf680</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x90b9280</ref>
+ <geom><ref>0x90bf680</ref></geom>
+ <provider><ref>0x90bf100</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90bf500</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x90b9200</ref>
+ <geom><ref>0x90bf500</ref></geom>
+ <provider><ref>0x90bf080</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90bf180</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x90b9180</ref>
+ <geom><ref>0x90bf180</ref></geom>
+ <provider><ref>0x90bf000</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x90b9080</ref>
+ <method><ref>0x90712c0</ref></method>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer>
+ <ref>0x90b90c0</ref>
+ <geom><ref>0x90b9080</ref></geom>
+ <provider><ref>0x90b9040</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </method>
+ <method>
+ <ref>0x9071280</ref>
+ <name>MBREXT-method</name>
+ </method>
+ <method>
+ <ref>0x9071260</ref>
+ <name>MBR-method</name>
+ <geom>
+ <ref>0x90b9100</ref>
+ <method><ref>0x9071260</ref></method>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x90b9140</ref>
+ <geom><ref>0x90b9100</ref></geom>
+ <provider><ref>0x90b9040</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x90bf100</ref>
+ <geom><ref>0x90b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3</name>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x90bf080</ref>
+ <geom><ref>0x90b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s2</name>
+ <config>
+ <index>1</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>3220439040</offset>
+ <secoffset>6289920</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x90bf000</ref>
+ <geom><ref>0x90b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1</name>
+ <config>
+ <index>0</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ </geom>
+ </method>
+ <method>
+ <ref>0x90712a0</ref>
+ <name>BSD-method</name>
+ <geom>
+ <ref>0x90bf700</ref>
+ <method><ref>0x90712a0</ref></method>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x90b92c0</ref>
+ <geom><ref>0x90bf700</ref></geom>
+ <provider><ref>0x90bf100</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x90bf880</ref>
+ <geom><ref>0x90bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3d</name>
+ <config>
+ <index>3</index>
+ <length>6488104960</length>
+ <seclength>12672080</seclength>
+ <offset>10682408960</offset>
+ <secoffset>20864080</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x90bf800</ref>
+ <geom><ref>0x90bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3c</name>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x90bf780</ref>
+ <geom><ref>0x90bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3a</name>
+ <config>
+ <index>0</index>
+ <length>2097152000</length>
+ <seclength>4096000</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ </config>
+ </provider>
+ </geom>
+ <geom>
+ <ref>0x90bf580</ref>
+ <method><ref>0x90712a0</ref></method>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x90b9240</ref>
+ <geom><ref>0x90bf580</ref></geom>
+ <provider><ref>0x90bf080</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x90bf600</ref>
+ <geom><ref>0x90bf580</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s2c</name>
+ <config>
+ <index>2</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>3220439040</offset>
+ <secoffset>6289920</secoffset>
+ </config>
+ </provider>
+ </geom>
+ <geom>
+ <ref>0x90bf200</ref>
+ <method><ref>0x90712a0</ref></method>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x90b91c0</ref>
+ <geom><ref>0x90bf200</ref></geom>
+ <provider><ref>0x90bf000</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x90bf480</ref>
+ <geom><ref>0x90bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1f</name>
+ <config>
+ <index>5</index>
+ <length>2066973184</length>
+ <seclength>4037057</seclength>
+ <offset>1153465856</offset>
+ <secoffset>2252863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x90bf400</ref>
+ <geom><ref>0x90bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1e</name>
+ <config>
+ <index>4</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>629177856</offset>
+ <secoffset>1228863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x90bf380</ref>
+ <geom><ref>0x90bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1c</name>
+ <config>
+ <index>2</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x90bf300</ref>
+ <geom><ref>0x90bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1b</name>
+ <config>
+ <index>1</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>104889856</offset>
+ <secoffset>204863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x90bf280</ref>
+ <geom><ref>0x90bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1a</name>
+ <config>
+ <index>0</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </method>
+ <method>
+ <ref>0x90711c0</ref>
+ <name>SIMDISK-method</name>
+ <geom>
+ <ref>0x90b9000</ref>
+ <method><ref>0x90711c0</ref></method>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider>
+ <ref>0x90b9040</ref>
+ <geom><ref>0x90b9000</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0</name>
+ </provider>
+ </geom>
+ </method>
+</mesh>
diff --git a/tools/regression/geom/ConfCmp/a1b.conf b/tools/regression/geom/ConfCmp/a1b.conf
new file mode 100644
index 0000000..46f423b
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/a1b.conf
@@ -0,0 +1,414 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <method>
+ <ref>0x80712c0</ref>
+ <name>DEV-method</name>
+ <geom>
+ <ref>0x80bfd00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3d</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9500</ref>
+ <geom><ref>0x80bfd00</ref></geom>
+ <provider><ref>0x80bf880</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfc80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b94c0</ref>
+ <geom><ref>0x80bfc80</ref></geom>
+ <provider><ref>0x80bf800</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfc00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3a</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9480</ref>
+ <geom><ref>0x80bfc00</ref></geom>
+ <provider><ref>0x80bf780</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfb80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s2c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9440</ref>
+ <geom><ref>0x80bfb80</ref></geom>
+ <provider><ref>0x80bf600</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfb00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1f</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9400</ref>
+ <geom><ref>0x80bfb00</ref></geom>
+ <provider><ref>0x80bf480</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfa80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1e</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b93c0</ref>
+ <geom><ref>0x80bfa80</ref></geom>
+ <provider><ref>0x80bf400</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfa00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9380</ref>
+ <geom><ref>0x80bfa00</ref></geom>
+ <provider><ref>0x80bf380</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf980</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1b</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9340</ref>
+ <geom><ref>0x80bf980</ref></geom>
+ <provider><ref>0x80bf300</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf900</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1a</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9300</ref>
+ <geom><ref>0x80bf900</ref></geom>
+ <provider><ref>0x80bf280</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf680</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9280</ref>
+ <geom><ref>0x80bf680</ref></geom>
+ <provider><ref>0x80bf100</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf500</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9200</ref>
+ <geom><ref>0x80bf500</ref></geom>
+ <provider><ref>0x80bf080</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf180</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9180</ref>
+ <geom><ref>0x80bf180</ref></geom>
+ <provider><ref>0x80bf000</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80b9080</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer>
+ <ref>0x80b90c0</ref>
+ <geom><ref>0x80b9080</ref></geom>
+ <provider><ref>0x80b9040</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </method>
+ <method>
+ <ref>0x8071280</ref>
+ <name>MBREXT-method</name>
+ </method>
+ <method>
+ <ref>0x8071260</ref>
+ <name>MBR-method</name>
+ <geom>
+ <ref>0x80b9100</ref>
+ <method><ref>0x8071260</ref></method>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b9140</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <provider><ref>0x80b9040</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf100</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3</name>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf080</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s2</name>
+ <config>
+ <index>1</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>3220439040</offset>
+ <secoffset>6289920</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf000</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1</name>
+ <config>
+ <index>0</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ </geom>
+ </method>
+ <method>
+ <ref>0x80712a0</ref>
+ <name>BSD-method</name>
+ <geom>
+ <ref>0x80bf700</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b92c0</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <provider><ref>0x80bf100</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf880</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3d</name>
+ <config>
+ <index>3</index>
+ <length>6488104960</length>
+ <seclength>12672080</seclength>
+ <offset>10682408960</offset>
+ <secoffset>20864080</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf800</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3c</name>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf780</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3a</name>
+ <config>
+ <index>0</index>
+ <length>2097152000</length>
+ <seclength>4096000</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ </config>
+ </provider>
+ </geom>
+ <geom>
+ <ref>0x80bf580</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b9240</ref>
+ <geom><ref>0x80bf580</ref></geom>
+ <provider><ref>0x80bf080</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf600</ref>
+ <geom><ref>0x80bf580</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s2c</name>
+ <config>
+ <index>2</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>3220439040</offset>
+ <secoffset>6289920</secoffset>
+ </config>
+ </provider>
+ </geom>
+ <geom>
+ <ref>0x80bf200</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b91c0</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <provider><ref>0x80bf000</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf480</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1f</name>
+ <config>
+ <index>5</index>
+ <length>2066973184</length>
+ <seclength>4037057</seclength>
+ <offset>1153465856</offset>
+ <secoffset>2252863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf400</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1e</name>
+ <config>
+ <index>4</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>629177856</offset>
+ <secoffset>1228863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf380</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1c</name>
+ <config>
+ <index>2</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf300</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1b</name>
+ <config>
+ <index>1</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>104889856</offset>
+ <secoffset>204863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf280</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1a</name>
+ <config>
+ <index>0</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </method>
+ <method>
+ <ref>0x80711c0</ref>
+ <name>SIMDISK-method</name>
+ <geom>
+ <ref>0x80b9000</ref>
+ <method><ref>0x80711c0</ref></method>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider>
+ <ref>0x80b9041</ref>
+ <geom><ref>0x80b9000</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0</name>
+ </provider>
+ </geom>
+ </method>
+</mesh>
diff --git a/tools/regression/geom/ConfCmp/a1c.conf b/tools/regression/geom/ConfCmp/a1c.conf
new file mode 100644
index 0000000..1b5a2b9
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/a1c.conf
@@ -0,0 +1,414 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <method>
+ <ref>0x80712c0</ref>
+ <name>DEV-method</name>
+ <geom>
+ <ref>0x80bfd00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3d</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9500</ref>
+ <geom><ref>0x80bfd00</ref></geom>
+ <provider><ref>0x80bf880</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfc80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b94c0</ref>
+ <geom><ref>0x80bfc80</ref></geom>
+ <provider><ref>0x80bf800</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfc00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3a</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9480</ref>
+ <geom><ref>0x80bfc00</ref></geom>
+ <provider><ref>0x80bf780</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfb80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s2c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9440</ref>
+ <geom><ref>0x80bfb80</ref></geom>
+ <provider><ref>0x80bf600</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfb00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1f</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9400</ref>
+ <geom><ref>0x80bfb00</ref></geom>
+ <provider><ref>0x80bf480</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfa80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1e</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b93c0</ref>
+ <geom><ref>0x80bfa80</ref></geom>
+ <provider><ref>0x80bf400</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfa00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9380</ref>
+ <geom><ref>0x80bfa00</ref></geom>
+ <provider><ref>0x80bf380</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf980</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1b</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9340</ref>
+ <geom><ref>0x80bf980</ref></geom>
+ <provider><ref>0x80bf300</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf900</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1a</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9300</ref>
+ <geom><ref>0x80bf900</ref></geom>
+ <provider><ref>0x80bf280</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf680</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9280</ref>
+ <geom><ref>0x80bf680</ref></geom>
+ <provider><ref>0x80bf100</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf500</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9200</ref>
+ <geom><ref>0x80bf500</ref></geom>
+ <provider><ref>0x80bf080</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf180</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9180</ref>
+ <geom><ref>0x80bf180</ref></geom>
+ <provider><ref>0x80bf000</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80b9080</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer>
+ <ref>0x80b90c0</ref>
+ <geom><ref>0x80b9080</ref></geom>
+ <provider><ref>0x80b9040</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </method>
+ <method>
+ <ref>0x8071280</ref>
+ <name>MBREXT-method</name>
+ </method>
+ <method>
+ <ref>0x8071260</ref>
+ <name>MBR-method</name>
+ <geom>
+ <ref>0x80b9100</ref>
+ <method><ref>0x8071260</ref></method>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b9140</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <provider><ref>0x80b9040</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf100</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3</name>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf080</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s2</name>
+ <config>
+ <index>1</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>3220439040</offset>
+ <secoffset>6289920</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf000</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1</name>
+ <config>
+ <index>0</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ </geom>
+ </method>
+ <method>
+ <ref>0x80712a0</ref>
+ <name>BSD-method</name>
+ <geom>
+ <ref>0x80bf700</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b92c0</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <provider><ref>0x80bf100</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf880</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3d</name>
+ <config>
+ <index>3</index>
+ <length>6488104960</length>
+ <seclength>12672080</seclength>
+ <offset>10682408960</offset>
+ <secoffset>20864080</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf800</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3c</name>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf780</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3a</name>
+ <config>
+ <index>0</index>
+ <length>2097152000</length>
+ <seclength>4096000</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ </config>
+ </provider>
+ </geom>
+ <geom>
+ <ref>0x80bf580</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b9240</ref>
+ <geom><ref>0x80bf580</ref></geom>
+ <provider><ref>0x80bf080</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf600</ref>
+ <geom><ref>0x80bf580</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s2c</name>
+ <config>
+ <index>2</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>3220439040</offset>
+ <secoffset>6289920</secoffset>
+ </config>
+ </provider>
+ </geom>
+ <geom>
+ <ref>0x80bf200</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b91c0</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <provider><ref>0x80bf000</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf480</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1f</name>
+ <config>
+ <index>5</index>
+ <length>2066973184</length>
+ <seclength>4037057</seclength>
+ <offset>1153465856</offset>
+ <secoffset>2252863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf400</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1e</name>
+ <config>
+ <index>4</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>629177856</offset>
+ <secoffset>1228863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf380</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1c</name>
+ <config>
+ <index>2</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf300</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1b</name>
+ <config>
+ <index>1</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>104889856</offset>
+ <secoffset>204863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf280</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1a</name>
+ <config>
+ <index>0</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </method>
+ <method>
+ <ref>0x80711c0</ref>
+ <name>SIMDISK-method</name>
+ <geom>
+ <ref>0x80b9000</ref>
+ <method><ref>0x80711c0</ref></method>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider>
+ <ref>0x80b9040</ref>
+ <geom><ref>0x80b9000</ref></geom>
+ <mode>r0w0e1</mode>
+ <name>ad0</name>
+ </provider>
+ </geom>
+ </method>
+</mesh>
diff --git a/tools/regression/geom/ConfCmp/a1d.conf b/tools/regression/geom/ConfCmp/a1d.conf
new file mode 100644
index 0000000..a9063c5
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/a1d.conf
@@ -0,0 +1,414 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <method>
+ <ref>0x80712c0</ref>
+ <name>DEV-method</name>
+ <geom>
+ <ref>0x80bfd00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3d</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9500</ref>
+ <geom><ref>0x80bfd00</ref></geom>
+ <provider><ref>0x80bf880</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfc80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b94c0</ref>
+ <geom><ref>0x80bfc80</ref></geom>
+ <provider><ref>0x80bf800</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfc00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3a</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9480</ref>
+ <geom><ref>0x80bfc00</ref></geom>
+ <provider><ref>0x80bf780</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfb80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s2c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9440</ref>
+ <geom><ref>0x80bfb80</ref></geom>
+ <provider><ref>0x80bf600</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfb00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1f</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9400</ref>
+ <geom><ref>0x80bfb00</ref></geom>
+ <provider><ref>0x80bf480</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfa80</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1e</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b93c0</ref>
+ <geom><ref>0x80bfa80</ref></geom>
+ <provider><ref>0x80bf400</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bfa00</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1c</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9380</ref>
+ <geom><ref>0x80bfa00</ref></geom>
+ <provider><ref>0x80bf380</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf980</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1b</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9340</ref>
+ <geom><ref>0x80bf980</ref></geom>
+ <provider><ref>0x80bf300</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf900</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1a</name>
+ <rank>4</rank>
+ <consumer>
+ <ref>0x80b9300</ref>
+ <geom><ref>0x80bf900</ref></geom>
+ <provider><ref>0x80bf280</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf680</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9280</ref>
+ <geom><ref>0x80bf680</ref></geom>
+ <provider><ref>0x80bf100</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf500</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9200</ref>
+ <geom><ref>0x80bf500</ref></geom>
+ <provider><ref>0x80bf080</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80bf180</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <consumer>
+ <ref>0x80b9180</ref>
+ <geom><ref>0x80bf180</ref></geom>
+ <provider><ref>0x80bf000</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom>
+ <ref>0x80b9080</ref>
+ <method><ref>0x80712c0</ref></method>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer>
+ <ref>0x80b90c0</ref>
+ <geom><ref>0x80b9080</ref></geom>
+ <provider><ref>0x80b9040</ref></provider>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </method>
+ <method>
+ <ref>0x8071280</ref>
+ <name>MBREXT-method</name>
+ </method>
+ <method>
+ <ref>0x8071260</ref>
+ <name>MBR-method</name>
+ <geom>
+ <ref>0x80b9100</ref>
+ <method><ref>0x8071260</ref></method>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b9140</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <provider><ref>0x80b9040</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf100</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3</name>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf080</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s2</name>
+ <config>
+ <index>1</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>3220439040</offset>
+ <secoffset>6289920</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf000</ref>
+ <geom><ref>0x80b9100</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1</name>
+ <config>
+ <index>0</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ </geom>
+ </method>
+ <method>
+ <ref>0x80712a0</ref>
+ <name>BSD-method</name>
+ <geom>
+ <ref>0x80bf700</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b92c0</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <provider><ref>0x80bf100</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf880</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3d</name>
+ <config>
+ <index>3</index>
+ <length>6488104960</length>
+ <seclength>12672080</seclength>
+ <offset>10682408960</offset>
+ <secoffset>20864080</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf800</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3c</name>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf780</ref>
+ <geom><ref>0x80bf700</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s3a</name>
+ <config>
+ <index>0</index>
+ <length>2097152000</length>
+ <seclength>4096000</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ </config>
+ </provider>
+ </geom>
+ <geom>
+ <ref>0x80bf580</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b9240</ref>
+ <geom><ref>0x80bf580</ref></geom>
+ <provider><ref>0x80bf080</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf600</ref>
+ <geom><ref>0x80bf580</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s2c</name>
+ <config>
+ <index>2</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>3220439040</offset>
+ <secoffset>6289920</secoffset>
+ </config>
+ </provider>
+ </geom>
+ <geom>
+ <ref>0x80bf200</ref>
+ <method><ref>0x80712a0</ref></method>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <config>
+ </config>
+ <consumer>
+ <ref>0x80b91c0</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <provider><ref>0x80bf000</ref></provider>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider>
+ <ref>0x80bf480</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1f</name>
+ <config>
+ <index>5</index>
+ <length>2066973184</length>
+ <seclength>4037057</seclength>
+ <offset>1153465856</offset>
+ <secoffset>2252863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf400</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1e</name>
+ <config>
+ <index>4</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>629177856</offset>
+ <secoffset>1228863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf380</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1c</name>
+ <config>
+ <index>2</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf300</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1b</name>
+ <config>
+ <index>1</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>104889856</offset>
+ <secoffset>204863</secoffset>
+ </config>
+ </provider>
+ <provider>
+ <ref>0x80bf280</ref>
+ <geom><ref>0x80bf200</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0s1a</name>
+ <config>
+ <index>0</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </method>
+ <method>
+ <ref>0x80711c0</ref>
+ <name>SIMDISK-method</name>
+ <geom>
+ <ref>0x80b9000</ref>
+ <method><ref>0x80711c0</ref></method>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider>
+ <ref>0x80b9040</ref>
+ <geom><ref>0x80b9000</ref></geom>
+ <mode>r0w0e0</mode>
+ <name>ad0</namf>
+ </provider>
+ </geom>
+ </method>
+</mesh>
diff --git a/tools/regression/geom/ConfCmp/a2.conf b/tools/regression/geom/ConfCmp/a2.conf
new file mode 100644
index 0000000..6688fd1
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/a2.conf
@@ -0,0 +1,207 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x80740e0">
+ <name>DEV-class</name>
+ <geom id="0x80bce00">
+ <class ref="0x80740e0"/>
+ <name>wd0s1f</name>
+ <rank>4</rank>
+ <consumer id="0x80ba240">
+ <geom ref="0x80bce00"/>
+ <provider ref="0x80bc880"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bcc80">
+ <class ref="0x80740e0"/>
+ <name>wd0s1e</name>
+ <rank>4</rank>
+ <consumer id="0x80ba200">
+ <geom ref="0x80bcc80"/>
+ <provider ref="0x80bc800"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bcb00">
+ <class ref="0x80740e0"/>
+ <name>wd0s1c</name>
+ <rank>4</rank>
+ <consumer id="0x80ba1c0">
+ <geom ref="0x80bcb00"/>
+ <provider ref="0x80bc780"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc980">
+ <class ref="0x80740e0"/>
+ <name>wd0s1b</name>
+ <rank>4</rank>
+ <consumer id="0x80ba180">
+ <geom ref="0x80bc980"/>
+ <provider ref="0x80bc700"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc900">
+ <class ref="0x80740e0"/>
+ <name>wd0s1a</name>
+ <rank>4</rank>
+ <consumer id="0x80ba140">
+ <geom ref="0x80bc900"/>
+ <provider ref="0x80bc680"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc300">
+ <class ref="0x80740e0"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <consumer id="0x80ba0c0">
+ <geom ref="0x80bc300"/>
+ <provider ref="0x80bc280"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc100">
+ <class ref="0x80740e0"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <consumer id="0x80ba040">
+ <geom ref="0x80bc100"/>
+ <provider ref="0x80bc080"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8073fc0">
+ <name>PC98-class</name>
+ <geom id="0x80bc180">
+ <class ref="0x8073fc0"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8704</frontstuff>
+ </config>
+ <consumer id="0x80ba080">
+ <geom ref="0x80bc180"/>
+ <provider ref="0x80bc080"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80bc280">
+ <geom ref="0x80bc180"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1</name>
+ <config>
+ <index>0</index>
+ <length>1626533888</length>
+ <seclength>3176824</seclength>
+ <offset>69632</offset>
+ <secoffset>136</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8073fe0">
+ <name>SUNLABEL-class</name>
+ </class>
+ <class id="0x80740c0">
+ <name>MBREXT-class</name>
+ </class>
+ <class id="0x80740a0">
+ <name>MBR-class</name>
+ </class>
+ <class id="0x8074100">
+ <name>BSD-class</name>
+ <geom id="0x80bc480">
+ <class ref="0x8074100"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <config>
+ <labeloffset>512</labeloffset>
+ <frontstuff>8192</frontstuff>
+ </config>
+ <consumer id="0x80ba100">
+ <geom ref="0x80bc480"/>
+ <provider ref="0x80bc280"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80bc880">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1f</name>
+ <config>
+ <index>5</index>
+ <length>1390673920</length>
+ <seclength>2716160</seclength>
+ <offset>235929600</offset>
+ <secoffset>460800</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc800">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1e</name>
+ <config>
+ <index>4</index>
+ <length>52428800</length>
+ <seclength>102400</seclength>
+ <offset>183500800</offset>
+ <secoffset>358400</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc780">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1c</name>
+ <config>
+ <index>2</index>
+ <length>1626603520</length>
+ <seclength>3176960</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc700">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1b</name>
+ <config>
+ <index>1</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>78643200</offset>
+ <secoffset>153600</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc680">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1a</name>
+ <config>
+ <index>0</index>
+ <length>78643200</length>
+ <seclength>153600</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8074000">
+ <name>SIMDISK-class</name>
+ <geom id="0x80bc000">
+ <class ref="0x8074000"/>
+ <name>wd0</name>
+ <rank>1</rank>
+ <provider id="0x80bc080">
+ <geom ref="0x80bc000"/>
+ <mode>r0w0e0</mode>
+ <name>wd0</name>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/ConfCmp/a2a.conf b/tools/regression/geom/ConfCmp/a2a.conf
new file mode 100644
index 0000000..3d35fe9
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/a2a.conf
@@ -0,0 +1,207 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x90740e0">
+ <name>DEV-class</name>
+ <geom id="0x90bce00">
+ <class ref="0x90740e0"/>
+ <name>wd0s1f</name>
+ <rank>4</rank>
+ <consumer id="0x90ba240">
+ <geom ref="0x90bce00"/>
+ <provider ref="0x90bc880"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x90bcc80">
+ <class ref="0x90740e0"/>
+ <name>wd0s1e</name>
+ <rank>4</rank>
+ <consumer id="0x90ba200">
+ <geom ref="0x90bcc80"/>
+ <provider ref="0x90bc800"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x90bcb00">
+ <class ref="0x90740e0"/>
+ <name>wd0s1c</name>
+ <rank>4</rank>
+ <consumer id="0x90ba1c0">
+ <geom ref="0x90bcb00"/>
+ <provider ref="0x90bc780"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x90bc980">
+ <class ref="0x90740e0"/>
+ <name>wd0s1b</name>
+ <rank>4</rank>
+ <consumer id="0x90ba180">
+ <geom ref="0x90bc980"/>
+ <provider ref="0x90bc700"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x90bc900">
+ <class ref="0x90740e0"/>
+ <name>wd0s1a</name>
+ <rank>4</rank>
+ <consumer id="0x90ba140">
+ <geom ref="0x90bc900"/>
+ <provider ref="0x90bc680"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x90bc300">
+ <class ref="0x90740e0"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <consumer id="0x90ba0c0">
+ <geom ref="0x90bc300"/>
+ <provider ref="0x90bc280"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x90bc100">
+ <class ref="0x90740e0"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <consumer id="0x90ba040">
+ <geom ref="0x90bc100"/>
+ <provider ref="0x90bc080"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x9073fc0">
+ <name>PC98-class</name>
+ <geom id="0x90bc180">
+ <class ref="0x9073fc0"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8704</frontstuff>
+ </config>
+ <consumer id="0x90ba080">
+ <geom ref="0x90bc180"/>
+ <provider ref="0x90bc080"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x90bc280">
+ <geom ref="0x90bc180"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1</name>
+ <config>
+ <index>0</index>
+ <length>1626533888</length>
+ <seclength>3176824</seclength>
+ <offset>69632</offset>
+ <secoffset>136</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x9073fe0">
+ <name>SUNLABEL-class</name>
+ </class>
+ <class id="0x90740c0">
+ <name>MBREXT-class</name>
+ </class>
+ <class id="0x90740a0">
+ <name>MBR-class</name>
+ </class>
+ <class id="0x9074100">
+ <name>BSD-class</name>
+ <geom id="0x90bc480">
+ <class ref="0x9074100"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <config>
+ <labeloffset>512</labeloffset>
+ <frontstuff>8192</frontstuff>
+ </config>
+ <consumer id="0x90ba100">
+ <geom ref="0x90bc480"/>
+ <provider ref="0x90bc280"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x90bc880">
+ <geom ref="0x90bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1f</name>
+ <config>
+ <index>5</index>
+ <length>1390673920</length>
+ <seclength>2716160</seclength>
+ <offset>235929600</offset>
+ <secoffset>460800</secoffset>
+ </config>
+ </provider>
+ <provider id="0x90bc800">
+ <geom ref="0x90bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1e</name>
+ <config>
+ <index>4</index>
+ <length>52428800</length>
+ <seclength>102400</seclength>
+ <offset>183500800</offset>
+ <secoffset>358400</secoffset>
+ </config>
+ </provider>
+ <provider id="0x90bc780">
+ <geom ref="0x90bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1c</name>
+ <config>
+ <index>2</index>
+ <length>1626603520</length>
+ <seclength>3176960</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ <provider id="0x90bc700">
+ <geom ref="0x90bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1b</name>
+ <config>
+ <index>1</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>78643200</offset>
+ <secoffset>153600</secoffset>
+ </config>
+ </provider>
+ <provider id="0x90bc680">
+ <geom ref="0x90bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1a</name>
+ <config>
+ <index>0</index>
+ <length>78643200</length>
+ <seclength>153600</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x9074000">
+ <name>SIMDISK-class</name>
+ <geom id="0x90bc000">
+ <class ref="0x9074000"/>
+ <name>wd0</name>
+ <rank>1</rank>
+ <provider id="0x90bc080">
+ <geom ref="0x90bc000"/>
+ <mode>r0w0e0</mode>
+ <name>wd0</name>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/ConfCmp/a2b.conf b/tools/regression/geom/ConfCmp/a2b.conf
new file mode 100644
index 0000000..58c0e15
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/a2b.conf
@@ -0,0 +1,207 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x80740e0">
+ <name>DEV-class</name>
+ <geom id="0x80bce00">
+ <class ref="0x80740e0"/>
+ <name>wd0s1f</name>
+ <rank>4</rank>
+ <consumer id="0x80ba240">
+ <geom ref="0x80bce00"/>
+ <provider ref="0x80bc880"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bcc80">
+ <class ref="0x80740e0"/>
+ <name>wd0s1e</name>
+ <rank>4</rank>
+ <consumer id="0x80ba200">
+ <geom ref="0x80bcc80"/>
+ <provider ref="0x80bc800"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bcb00">
+ <class ref="0x80740e0"/>
+ <name>wd0s1c</name>
+ <rank>4</rank>
+ <consumer id="0x80ba1c0">
+ <geom ref="0x80bcb00"/>
+ <provider ref="0x80bc780"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc980">
+ <class ref="0x80740e0"/>
+ <name>wd0s1b</name>
+ <rank>4</rank>
+ <consumer id="0x80ba180">
+ <geom ref="0x80bc981"/>
+ <provider ref="0x80bc700"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc900">
+ <class ref="0x80740e0"/>
+ <name>wd0s1a</name>
+ <rank>4</rank>
+ <consumer id="0x80ba140">
+ <geom ref="0x80bc900"/>
+ <provider ref="0x80bc680"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc300">
+ <class ref="0x80740e0"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <consumer id="0x80ba0c0">
+ <geom ref="0x80bc300"/>
+ <provider ref="0x80bc280"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc100">
+ <class ref="0x80740e0"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <consumer id="0x80ba040">
+ <geom ref="0x80bc100"/>
+ <provider ref="0x80bc080"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8073fc0">
+ <name>PC98-class</name>
+ <geom id="0x80bc180">
+ <class ref="0x8073fc0"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8704</frontstuff>
+ </config>
+ <consumer id="0x80ba080">
+ <geom ref="0x80bc180"/>
+ <provider ref="0x80bc080"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80bc280">
+ <geom ref="0x80bc180"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1</name>
+ <config>
+ <index>0</index>
+ <length>1626533888</length>
+ <seclength>3176824</seclength>
+ <offset>69632</offset>
+ <secoffset>136</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8073fe0">
+ <name>SUNLABEL-class</name>
+ </class>
+ <class id="0x80740c0">
+ <name>MBREXT-class</name>
+ </class>
+ <class id="0x80740a0">
+ <name>MBR-class</name>
+ </class>
+ <class id="0x8074100">
+ <name>BSD-class</name>
+ <geom id="0x80bc480">
+ <class ref="0x8074100"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <config>
+ <labeloffset>512</labeloffset>
+ <frontstuff>8192</frontstuff>
+ </config>
+ <consumer id="0x80ba100">
+ <geom ref="0x80bc480"/>
+ <provider ref="0x80bc280"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80bc880">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1f</name>
+ <config>
+ <index>5</index>
+ <length>1390673920</length>
+ <seclength>2716160</seclength>
+ <offset>235929600</offset>
+ <secoffset>460800</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc800">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1e</name>
+ <config>
+ <index>4</index>
+ <length>52428800</length>
+ <seclength>102400</seclength>
+ <offset>183500800</offset>
+ <secoffset>358400</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc780">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1c</name>
+ <config>
+ <index>2</index>
+ <length>1626603520</length>
+ <seclength>3176960</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc700">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1b</name>
+ <config>
+ <index>1</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>78643200</offset>
+ <secoffset>153600</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc680">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1a</name>
+ <config>
+ <index>0</index>
+ <length>78643200</length>
+ <seclength>153600</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8074000">
+ <name>SIMDISK-class</name>
+ <geom id="0x80bc000">
+ <class ref="0x8074000"/>
+ <name>wd0</name>
+ <rank>1</rank>
+ <provider id="0x80bc080">
+ <geom ref="0x80bc000"/>
+ <mode>r0w0e0</mode>
+ <name>wd0</name>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/ConfCmp/a2c.conf b/tools/regression/geom/ConfCmp/a2c.conf
new file mode 100644
index 0000000..381c410
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/a2c.conf
@@ -0,0 +1,206 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x80740e0">
+ <name>DEV-class</name>
+ <geom id="0x80bce00">
+ <class ref="0x80740e0"/>
+ <name>wd0s1f</name>
+ <rank>4</rank>
+ <consumer id="0x80ba240">
+ <geom ref="0x80bce00"/>
+ <provider ref="0x80bc880"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bcc80">
+ <class ref="0x80740e0"/>
+ <name>wd0s1e</name>
+ <rank>4</rank>
+ <consumer id="0x80ba200">
+ <geom ref="0x80bcc80"/>
+ <provider ref="0x80bc800"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bcb00">
+ <class ref="0x80740e0"/>
+ <name>wd0s1c</name>
+ <rank>4</rank>
+ <consumer id="0x80ba1c0">
+ <geom ref="0x80bcb00"/>
+ <provider ref="0x80bc780"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc980">
+ <class ref="0x80740e0"/>
+ <name>wd0s1b</name>
+ <rank>4</rank>
+ <consumer id="0x80ba180">
+ <geom ref="0x80bc980"/>
+ <provider ref="0x80bc700"/>
+ </consumer>
+ </geom>
+ <geom id="0x80bc900">
+ <class ref="0x80740e0"/>
+ <name>wd0s1a</name>
+ <rank>4</rank>
+ <consumer id="0x80ba140">
+ <geom ref="0x80bc900"/>
+ <provider ref="0x80bc680"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc300">
+ <class ref="0x80740e0"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <consumer id="0x80ba0c0">
+ <geom ref="0x80bc300"/>
+ <provider ref="0x80bc280"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc100">
+ <class ref="0x80740e0"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <consumer id="0x80ba040">
+ <geom ref="0x80bc100"/>
+ <provider ref="0x80bc080"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8073fc0">
+ <name>PC98-class</name>
+ <geom id="0x80bc180">
+ <class ref="0x8073fc0"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8704</frontstuff>
+ </config>
+ <consumer id="0x80ba080">
+ <geom ref="0x80bc180"/>
+ <provider ref="0x80bc080"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80bc280">
+ <geom ref="0x80bc180"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1</name>
+ <config>
+ <index>0</index>
+ <length>1626533888</length>
+ <seclength>3176824</seclength>
+ <offset>69632</offset>
+ <secoffset>136</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8073fe0">
+ <name>SUNLABEL-class</name>
+ </class>
+ <class id="0x80740c0">
+ <name>MBREXT-class</name>
+ </class>
+ <class id="0x80740a0">
+ <name>MBR-class</name>
+ </class>
+ <class id="0x8074100">
+ <name>BSD-class</name>
+ <geom id="0x80bc480">
+ <class ref="0x8074100"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <config>
+ <labeloffset>512</labeloffset>
+ <frontstuff>8192</frontstuff>
+ </config>
+ <consumer id="0x80ba100">
+ <geom ref="0x80bc480"/>
+ <provider ref="0x80bc280"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80bc880">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1f</name>
+ <config>
+ <index>5</index>
+ <length>1390673920</length>
+ <seclength>2716160</seclength>
+ <offset>235929600</offset>
+ <secoffset>460800</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc800">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1e</name>
+ <config>
+ <index>4</index>
+ <length>52428800</length>
+ <seclength>102400</seclength>
+ <offset>183500800</offset>
+ <secoffset>358400</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc780">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1c</name>
+ <config>
+ <index>2</index>
+ <length>1626603520</length>
+ <seclength>3176960</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc700">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1b</name>
+ <config>
+ <index>1</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>78643200</offset>
+ <secoffset>153600</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc680">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1a</name>
+ <config>
+ <index>0</index>
+ <length>78643200</length>
+ <seclength>153600</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8074000">
+ <name>SIMDISK-class</name>
+ <geom id="0x80bc000">
+ <class ref="0x8074000"/>
+ <name>wd0</name>
+ <rank>1</rank>
+ <provider id="0x80bc080">
+ <geom ref="0x80bc000"/>
+ <mode>r0w0e0</mode>
+ <name>wd0</name>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/ConfCmp/a2d.conf b/tools/regression/geom/ConfCmp/a2d.conf
new file mode 100644
index 0000000..bccaed5
--- /dev/null
+++ b/tools/regression/geom/ConfCmp/a2d.conf
@@ -0,0 +1,211 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x80740e0">
+ <name>DEV-class</name>
+ <geom id="0x80bce00">
+ <class ref="0x80740e0"/>
+ <name>wd0s1f</name>
+ <rank>4</rank>
+ <consumer id="0x80ba240">
+ <geom ref="0x80bce00"/>
+ <provider ref="0x80bc880"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bcc80">
+ <class ref="0x80740e0"/>
+ <name>wd0s1e</name>
+ <rank>4</rank>
+ <consumer id="0x80ba200">
+ <geom ref="0x80bcc80"/>
+ <provider ref="0x80bc800"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bcb00">
+ <class ref="0x80740e0"/>
+ <name>wd0s1c</name>
+ <rank>4</rank>
+ <consumer id="0x80ba1c0">
+ <geom ref="0x80bcb00"/>
+ <provider ref="0x80bc780"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc980">
+ <class ref="0x80740e0"/>
+ <name>wd0s1b</name>
+ <rank>4</rank>
+ <consumer id="0x80ba180">
+ <geom ref="0x80bc980"/>
+ <provider ref="0x80bc700"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc900">
+ <class ref="0x80740e0"/>
+ <name>wd0s1a</name>
+ <rank>4</rank>
+ <consumer id="0x80ba140">
+ <geom ref="0x80bc900"/>
+ <provider ref="0x80bc680"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ <consumer id="0x80ba141">
+ <geom ref="0x80bc900"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc300">
+ <class ref="0x80740e0"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <consumer id="0x80ba0c0">
+ <geom ref="0x80bc300"/>
+ <provider ref="0x80bc280"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc100">
+ <class ref="0x80740e0"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <consumer id="0x80ba040">
+ <geom ref="0x80bc100"/>
+ <provider ref="0x80bc080"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8073fc0">
+ <name>PC98-class</name>
+ <geom id="0x80bc180">
+ <class ref="0x8073fc0"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8704</frontstuff>
+ </config>
+ <consumer id="0x80ba080">
+ <geom ref="0x80bc180"/>
+ <provider ref="0x80bc080"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80bc280">
+ <geom ref="0x80bc180"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1</name>
+ <config>
+ <index>0</index>
+ <length>1626533888</length>
+ <seclength>3176824</seclength>
+ <offset>69632</offset>
+ <secoffset>136</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8073fe0">
+ <name>SUNLABEL-class</name>
+ </class>
+ <class id="0x80740c0">
+ <name>MBREXT-class</name>
+ </class>
+ <class id="0x80740a0">
+ <name>MBR-class</name>
+ </class>
+ <class id="0x8074100">
+ <name>BSD-class</name>
+ <geom id="0x80bc480">
+ <class ref="0x8074100"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <config>
+ <labeloffset>512</labeloffset>
+ <frontstuff>8192</frontstuff>
+ </config>
+ <consumer id="0x80ba100">
+ <geom ref="0x80bc480"/>
+ <provider ref="0x80bc280"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80bc880">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1f</name>
+ <config>
+ <index>5</index>
+ <length>1390673920</length>
+ <seclength>2716160</seclength>
+ <offset>235929600</offset>
+ <secoffset>460800</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc800">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1e</name>
+ <config>
+ <index>4</index>
+ <length>52428800</length>
+ <seclength>102400</seclength>
+ <offset>183500800</offset>
+ <secoffset>358400</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc780">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1c</name>
+ <config>
+ <index>2</index>
+ <length>1626603520</length>
+ <seclength>3176960</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc700">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1b</name>
+ <config>
+ <index>1</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>78643200</offset>
+ <secoffset>153600</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bc680">
+ <geom ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1a</name>
+ <config>
+ <index>0</index>
+ <length>78643200</length>
+ <seclength>153600</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8074000">
+ <name>SIMDISK-class</name>
+ <geom id="0x80bc000">
+ <class ref="0x8074000"/>
+ <name>wd0</name>
+ <rank>1</rank>
+ <provider id="0x80bc080">
+ <geom ref="0x80bc000"/>
+ <mode>r0w0e0</mode>
+ <name>wd0</name>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Data/disk.alpha.da0.xml b/tools/regression/geom/Data/disk.alpha.da0.xml
new file mode 100644
index 0000000..670fcc3
--- /dev/null
+++ b/tools/regression/geom/Data/disk.alpha.da0.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <comment>
+ Yet an alpha disklabel.
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <fwsectors>0</fwsectors>
+ <fwheads>0</fwheads>
+ <fwcylinders>0</fwcylinders>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 574556820400000057444947544c202000000000000000000000000000000000
+ 0000000000000000000200003f000000ff000000b2080000c13e00002eae2102
+ 0000000000000000100e01000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000057455682a22908000020000000200000008007000000000000040000
+ 07081600c05f20000080070000000000010000002eae21020000000000000000
+ 000000000000000000000000000000000000000000a00000c0df270000040000
+ 070818006e2ef901c07f28000004000007081600000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0e0000000000000001000000000000000000000000000000c51a45ca2ad1dba8
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.alpha2.da0.xml b/tools/regression/geom/Data/disk.alpha2.da0.xml
new file mode 100644
index 0000000..5b341b1
--- /dev/null
+++ b/tools/regression/geom/Data/disk.alpha2.da0.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <comment>
+ alpha label which O'brien says blows up libdisk
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <fwsectors>0</fwsectors>
+ <fwheads>0</fwheads>
+ <fwcylinders>0</fwcylinders>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ 5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
+ 5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
+ 5745568204000000000000000000000000000000000000000000000000000000
+ 0000000000000000000200003f000000ff00000009020000c13e0000c9b67f00
+ 0000000000000000100e01000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 000000005745568219cf0300002000000020000043bc0000c13e000000000000
+ 08000000fc867c0004fb00000000000008000000c934020000827d0000000000
+ 0100000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 00000000000000000000000000000000000000005a5a5a5a5a5a5a5a5a5a5a5a
+ 5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
+ 5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
+ 5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
+ 5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
+ 9800000000000000020000000000000000000000000000007a13ad55a1c382b0
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.apple.xml b/tools/regression/geom/Data/disk.apple.xml
new file mode 100644
index 0000000..ecdd523
--- /dev/null
+++ b/tools/regression/geom/Data/disk.apple.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <sectorsize>512</sectorsize>
+ <mediasize>366530560</mediasize>
+ <fwsectors>0</fwsectors>
+ <fwheads>0</fwheads>
+ <fwcylinders>0</fwcylinders>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ 45520200000aec68000100010000000000010000004000120001000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>512</offset>
+ <hexdata>
+ 504d00000000000300000060000aec084d61634f530000000000000000000000
+ 000000000000000000000000000000004170706c655f48465300000000000000
+ 0000000000000000000000000000000000000000000aec08000000b700000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>1024</offset>
+ <hexdata>
+ 504d000000000003000000010000003f4170706c650000000000000000000000
+ 000000000000000000000000000000004170706c655f706172746974696f6e5f
+ 6d617000000000000000000000000000000000000000003f0000003700000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>1536</offset>
+ <hexdata>
+ 504d00000000000300000040000000204d6163696e746f736800000000000000
+ 000000000000000000000000000000004170706c655f44726976657234330000
+ 0000000000000000000000000000000000000000000000200000007f00000000
+ 000023ee0000000000000000000000000000000000007c083638303030000000
+ 0000000000000000000106000000000000000001000700000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.beast.da0.xml b/tools/regression/geom/Data/disk.beast.da0.xml
new file mode 100644
index 0000000..96ad5f7
--- /dev/null
+++ b/tools/regression/geom/Data/disk.beast.da0.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <comment>
+ $FreeBSD$
+ alpha BSD label from beast.freebsd.org
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <fwsectors>0</fwsectors>
+ <fwheads>0</fwheads>
+ <fwcylinders>0</fwcylinders>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 5745568204000000646130000000000000000000000000000000000000000000
+ 0000000000000000000200003f000000ff0000000f020000c13e000000338100
+ 0000000000000000100e01000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000057455682594e08000020000000200000002079000000000000040000
+ 0708100000130800002079000000000001000000003381000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0f0000000000000001000000000000000000000000000000fc8c1983a904da83
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.critter.ad0.xml b/tools/regression/geom/Data/disk.critter.ad0.xml
new file mode 100644
index 0000000..9e93b24
--- /dev/null
+++ b/tools/regression/geom/Data/disk.critter.ad0.xml
@@ -0,0 +1,178 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <comment>
+ $FreeBSD$
+ This image contains the MBR and disklabel sectors from my Asus M1300
+ laptop.
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ fc31c08ec08ed88ed0bc007cbe1a7cbf1a06b9e601f3a4e9008a31f6bbbe07b1
+ 04382f74087f7885f6757489de80c310e2ef85f67502cd1880fa80720b8a3675
+ 0480c68038f272028a1489e78a74018b4c02bb007c80feff753283f9ff752d51
+ 53bbaa55b441cd13722081fb55aa751af6c10174155b666a0066ff740806536a
+ 016a1089e6b80042eb055b59b80102cd1389fc720f81bffe0155aa750cffe3be
+ bc06eb11bed406eb0cbef306eb07bb0700b40ecd10ac84c075f4ebfe496e7661
+ 6c696420706172746974696f6e207461626c65004572726f72206c6f6164696e
+ 67206f7065726174696e672073797374656d004d697373696e67206f70657261
+ 74696e672073797374656d000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000008001
+ 0100a50fffff3f00000041295402000000000000000000000000000000000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>512</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>32768</offset>
+ <hexdata>
+ 5745568205000000616430733100000000000000000000000000000000000000
+ 0000000000000000000200003f0000001000000067970000f003000041295402
+ 0000000000000000100e01000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 00000000574556824fa608000020000000200000000020003f00000000040000
+ 07081600000020003f0020000000000001000000412954023f00000000000000
+ 00000000418984003fa0cf01000400000708160000a00f003f00400000040000
+ 07081600000080003fa04f000004000007081600000060003fa0cf0000040000
+ 070816000000a0003fa02f010004000007081600000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>64512</offset>
+ <hexdata>
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>1073806336</offset>
+ <hexdata>
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>1598094336</offset>
+ <hexdata>
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ 4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2147548160</offset>
+ <hexdata>
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2671836160</offset>
+ <hexdata>
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffff00000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.empty.flp.xml b/tools/regression/geom/Data/disk.empty.flp.xml
new file mode 100644
index 0000000..88c603a
--- /dev/null
+++ b/tools/regression/geom/Data/disk.empty.flp.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <comment>
+ $FreeBSD$
+ An empty floppy disk
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>1474560</mediasize>
+ <fwsectors>18</fwsectors>
+ <fwheads>2</fwheads>
+ <fwcylinders>80</fwcylinders>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.far.ad0.xml b/tools/regression/geom/Data/disk.far.ad0.xml
new file mode 100644
index 0000000..0a8d3ca
--- /dev/null
+++ b/tools/regression/geom/Data/disk.far.ad0.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <comment>
+ $FreeBSD$
+ A Windows laptop.
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ 33c08ed0bc007cfb5007501ffcbe1b7cbf1b065057b9e501f3a4cbbebe07b104
+ 382c7c09751583c610e2f5cd188b148bee83c610497416382c74f6be10074eac
+ 3c0074fabb0700b40ecd10ebf2894625968a4604b4063c0e7411b40b3c0c7405
+ 3ac4752b40c64625067524bbaa5550b441cd1358721681fb55aa7510f6c10174
+ 0b8ae0885624c706a106eb1e886604bf0a00b801028bdc33c983ff057f038b4e
+ 25034e02cd137229be4607813efe7d55aa745a83ef057fda85f67583be2707eb
+ 8a9891529903460813560ae812005aebd54f74e433c0cd13ebb8000080093521
+ 5633f656565250065351be1000568bf45052b800428a5624cd135a588d641072
+ 0a4075014280c702e2f7f85ec3eb74496e76616c696420706172746974696f6e
+ 207461626c65004572726f72206c6f6164696e67206f7065726174696e672073
+ 797374656d004d697373696e67206f7065726174696e672073797374656d0000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000008bfc1e578bf5cb00000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 0100a05304263f00000092d80800805401260befbf730cd90800340a88000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>512</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.flat.da1.xml b/tools/regression/geom/Data/disk.flat.da1.xml
new file mode 100644
index 0000000..2302a7c
--- /dev/null
+++ b/tools/regression/geom/Data/disk.flat.da1.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <comment>
+ $FreeBSD$
+ This image contains an interesting setup: there is an MBR+BSD
+ but also another BSD at sector one which is valid but bogus.
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <fwsectors>0</fwsectors>
+ <fwheads>0</fwheads>
+ <fwcylinders>0</fwcylinders>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ fc31c08ec08ed88ed0bc007cbe1a7cbf1a06b9e601f3a4e9008a31f6bbbe07b1
+ 04382f74087f7885f6757489de80c310e2ef85f67502cd1880fa80720b8a3675
+ 0480c68038f272028a1489e78a74018b4c02bb007c80feff753283f9ff752d51
+ 53bbaa55b441cd13722081fb55aa751af6c10174155b666a0066ff740806536a
+ 016a1089e6b80042eb055b59b80102cd1389fc720f81bffe0155aa750cffe3be
+ bc06eb11bed406eb0cbef306eb07bb0700b40ecd10ac84c075f4ebfe496e7661
+ 6c696420706172746974696f6e207461626c65004572726f72206c6f6164696e
+ 67206f7065726174696e672073797374656d004d697373696e67206f70657261
+ 74696e672073797374656d000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000008001
+ 0100a5feffff3f0000003a612302000000000000000000000000000000000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>512</offset>
+ <hexdata>
+ 5745568204000000534541474154452053543331383433360000000000000000
+ 000000000000000000020000000800000100000072440000000800000004fb00
+ 0000000000000000100e01000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000057455682e29908000020000000200000002001000000000000040000
+ 07081000000008000020010000000000010000000004fb000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000e0f100002009000004000007081000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>32256</offset>
+ <hexdata>
+ eb1b9090161f666a005150065331c088f0506a1089e5e8c7008d6610cbfc31c9
+ 8ec18ed98ed1bc007c89e6bf0007fec5f3a5beee7d80fa80722cb601e86700b9
+ 0100bebe8db601807c04a57507e319f60480751483c610fec680fe0572e949e3
+ e1be8b7deb5231d289160009b610e83500bb00908b770a01debf00b0b900ac29
+ f1f3a429f930c0f3aae80300e98113fae464a80275fab0d1e664e464a80275fa
+ b0dfe660fbc3bb008c8b44088b4c0a0ee853ff732abe867de81c00be907de816
+ 0030e4cd16c70672043412ea0000ffffbb0700b40ecd10ac84c075f4b401f9c3
+ 52b408cd1388f55a72f580e13f74edfa668b460852660fb6d96631d266f7f388
+ eb88d54330d266f7f388d75a663dff030000fb774486c4c0c80208e8409188fe
+ 28e08a660238e0720288e0bf0500c45e0450b402cd135b730a4f741c30e4cd13
+ 93ebeb0fb6c30146087303ff460ad0e3005e052846027788c32ef6069908800f
+ 8479ffbbaa5552b441cd135a0f826fff81fb55aa0f8564fff6c1010f845dff89
+ eeb442cd13c35265616400426f6f7400206572726f720d0a0080909090909090
+ 9090909090909090909090909090909090909090909090909090909090900000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 000000000000000000000000000080000100a5ffffff0000000050c3000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>32768</offset>
+ <hexdata>
+ 5745568204000000646131733100000000000000000000000000000000000000
+ 0000000000000000000200003f000000ff000000b8080000c13e00003a612302
+ 0000000000000000100e01000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 000000005745568233c408000020000000200000000000000000000000000000
+ 0000000000800c003f800c0000000000010000003a6123023f00000000000000
+ 000000000000000000000000000000000000000000800c003f00000000040000
+ 07081600000020003f00190000040000070816003a61ea013f00390000040000
+ 0708160000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.kern.flp.xml b/tools/regression/geom/Data/disk.kern.flp.xml
new file mode 100644
index 0000000..6640c48
--- /dev/null
+++ b/tools/regression/geom/Data/disk.kern.flp.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <comment>
+ $FreeBSD$
+ A FreeBSD kern.flp image.
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ eb1b9090161f666a005150065331c088f0506a1089e5e8c7008d6610cbfc31c9
+ 8ec18ed98ed1bc007c89e6bf0007fec5f3a5beee7d80fa80722cb601e86700b9
+ 0100bebe8db601807c04a57507e319f60480751483c610fec680fe0572e949e3
+ e1be8b7deb5231d289160009b610e83500bb00908b770a01debf00b0b900ac29
+ f1f3a429f930c0f3aae80300e98113fae464a80275fab0d1e664e464a80275fa
+ b0dfe660fbc3bb008c8b44088b4c0a0ee853ff732abe867de81c00be907de816
+ 0030e4cd16c70672043412ea0000ffffbb0700b40ecd10ac84c075f4b401f9c3
+ 52b408cd1388f55a72f580e13f74edfa668b460852660fb6d96631d266f7f388
+ eb88d54330d266f7f388d75a663dff030000fb774486c4c0c80208e8409188fe
+ 28e08a660238e0720288e0bf0500c45e0450b402cd135b730a4f741c30e4cd13
+ 93ebeb0fb6c30146087303ff460ad0e3005e052846027788c32ef6069908800f
+ 8479ffbbaa5552b441cd135a0f826fff81fb55aa0f8564fff6c1010f845dff89
+ eeb442cd13c35265616400426f6f7400206572726f720d0a0080909090909090
+ 9090909090909090909090909090909090909090909090909090909090900000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 000000000000000000000000000080000100a5ffffff0000000050c3000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>512</offset>
+ <hexdata>
+ 5745568200000000666431343430000000000000000000000000000000000000
+ 00000000000000000002000012000000020000005000000024000000400b0000
+ 00000000000000002c0101000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000057455682286903000020000000200000400b00000000000000020000
+ 00080000400b0000000000000002000000080000400b00000000000000020000
+ 0708060000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.msdos.ext.xml b/tools/regression/geom/Data/disk.msdos.ext.xml
new file mode 100644
index 0000000..868a88f7
--- /dev/null
+++ b/tools/regression/geom/Data/disk.msdos.ext.xml
@@ -0,0 +1,534 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <comment>
+ $FreeBSD$
+ A MSDOS 6.22 disk with maximal number of extended partitions.
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ fa33c08ed0bc007c8bf45007501ffbfcbf0006b90001f2a5ea1d060000bebe07
+ b304803c80740e803c00751c83c610fecb75efcd188b148b4c028bee83c610fe
+ cb741a803c0074f4be8b06ac3c00740b56bb0700b40ecd105eebf0ebfebf0500
+ bb007cb8010257cd135f730c33c0cd134f75edbea306ebd3bec206bffe7d813d
+ 55aa75c78bf5ea007c0000496e76616c696420706172746974696f6e20746162
+ 6c65004572726f72206c6f6164696e67206f7065726174696e67207379737465
+ 6d004d697373696e67206f7065726174696e672073797374656d000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000008001
+ 010006fe7f043f00000086fa3f000000410505fe7f38c5fa3f0034bf0c000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>512</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2146798080</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 410501fe7f053f000000823e00000000410605fe7f06c13e0000c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2155023360</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 410601fe7f063f000000823e00000000410705fe7f07827d0000c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2163248640</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 410701fe7f073f000000823e00000000410805fe7f0843bc0000c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2171473920</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 410801fe7f083f000000823e00000000410905fe7f0904fb0000c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2179699200</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 410901fe7f093f000000823e00000000410a05fe7f0ac5390100c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2187924480</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 410a01fe7f0a3f000000823e00000000410b05fe7f0b86780100c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2196149760</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 410b01fe7f0b3f000000823e00000000410c05fe7f0c47b70100c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2204375040</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 410c01fe7f0c3f000000823e00000000410d05fe7f0d08f60100c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2212600320</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 410d01fe7f0d3f000000823e00000000410e05fe7f0ec9340200c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2220825600</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 410e01fe7f0e3f000000823e00000000410f05fe7f0f8a730200c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2229050880</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 410f01fe7f0f3f000000823e00000000411005fe7f104bb20200c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2237276160</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411001fe7f103f000000823e00000000411105fe7f110cf10200c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2245501440</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411101fe7f113f000000823e00000000411205fe7f12cd2f0300c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2253726720</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411201fe7f123f000000823e00000000411305fe7f138e6e0300c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2261952000</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411301fe7f133f000000823e00000000411405fe7f144fad0300c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2270177280</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411401fe7f143f000000823e00000000411505fe7f1510ec0300c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2278402560</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411501fe7f153f000000823e00000000411605fe7f16d12a0400c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2286627840</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411601fe7f163f000000823e00000000411705fe7f1792690400c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2294853120</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411701fe7f173f000000823e00000000411805fe7f1853a80400c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2303078400</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411801fe7f183f000000823e00000000411905fe7f1914e70400c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2311303680</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411901fe7f193f000000823e00000000411a05fe7f1ad5250500c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2319528960</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411a01fe7f1a3f000000823e00000000411b05fe7f1b96640500c13e00000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>2327754240</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000001
+ 411b01fe7f1b3f000000823e0000000000000000000000000000000000000000
+ 00000000000000000000000000000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.msdos.flp.xml b/tools/regression/geom/Data/disk.msdos.flp.xml
new file mode 100644
index 0000000..d057d1a
--- /dev/null
+++ b/tools/regression/geom/Data/disk.msdos.flp.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <comment>
+ $FreeBSD$
+ A MSDOS floppy image.
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ eb3c904d53444f53352e30000201010002e000400bf009001200020000000000
+ 0000000000002911053b114e4f204e414d45202020204641543132202020fa33
+ c08ed0bc007c1607bb780036c5371e561653bf3e7cb90b00fcf3a4061fc645fe
+ 0f8b0e187c884df9894702c7073e7cfbcd13727933c03906137c74088b0e137c
+ 890e207ca0107cf726167c03061c7c13161e7c03060e7c83d200a3507c891652
+ 7ca3497c89164b7cb82000f726117c8b1e0b7c03c348f7f30106497c83164b7c
+ 00bb00058b16527ca1507ce89200721db001e8ac0072168bfbb90b00bee67df3
+ a6750a8d7f20b90b00f3a67418be9e7de85f0033c0cd165e1f8f048f4402cd19
+ 585858ebe88b471a48488a1e0d7c32fff7e30306497c13164b7cbb0007b90300
+ 505251e83a0072d8b001e85400595a5872bb05010083d200031e0b7ce2e28a2e
+ 157c8a16247c8b1e497ca14b7cea00007000ac0ac07429b40ebb0700cd10ebf2
+ 3b16187c7319f736187cfec288164f7c33d2f7361a7c8816257ca34d7cf8c3f9
+ c3b4028b164d7cb106d2e60a364f7c8bca86e98a16247c8a36257ccd13c30d0a
+ 4e6f6e2d53797374656d206469736b206f72206469736b206572726f720d0a52
+ 65706c61636520616e6420707265737320616e79206b6579207768656e207265
+ 6164790d0a00494f2020202020205359534d53444f53202020535953000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>512</offset>
+ <hexdata>
+ f0ffff03400005600007800009a0000bc0000de0000f00011120011340011560
+ 0117800119a0011bc0011de0011f000221200223400225600227800229a0022b
+ c0022de0022f000331200333400335600337800339a0033bc0033de0033f0004
+ 41200443400445600447800449a0044bc0044de0044f000551f0ff5340055560
+ 0557800559a0055bc0055de0055f000661200663400665600667800669a0066b
+ c0066de0066f000771200773400775600777800779a0077bc0077de0077f0008
+ 81200883400885600887800889a0088bc0088de0088f00099120099340099560
+ 0997800999a0099bc009ffef099f000aa1200aa3400aa5600aa7800aa9a00aab
+ c00aade00aaf000bb1200bb3400bb5600bb7800bb9a00bbbc00bbde00bbf000c
+ c1200cc3400cc5600cc7800cc9a00ccbc00ccde00ccf000dd1200dd3400dd560
+ 0dd7800dd9a00ddbc00ddde00ddf000ee1200ee3400ee5600ee7800ee9a00eeb
+ c00eede00eef000ff1200ff3400ff5600ff7800ff9a00ffbc00ffde00fff0010
+ 01211003411005611007f1ff09a1100bc1100de1100f01111121111341111561
+ 1117811119a1111bc1111de1111f011221211223411225611227811229a1122b
+ c1122de1122f011331211333411335611337811339a1133bc1133de1133f0114
+ 41211443411445611447811449a1144bc1144de1144f01155121155341155561
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.pc98.wdc0.xml b/tools/regression/geom/Data/disk.pc98.wdc0.xml
new file mode 100644
index 0000000..6bae97f
--- /dev/null
+++ b/tools/regression/geom/Data/disk.pc98.wdc0.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <comment>
+ A PC98 disklabel from Warner
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <fwsectors>17</fwsectors>
+ <fwheads>8</fwheads>
+ <fwcylinders>0</fwcylinders>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ e9fd009049504c310000001ea08405b48ecd1ba820742232dbb414cd1b721a80
+ fb847515e896007303eb6b90b424bb0004b93012ba4001cd1bbb0001b484cd1b
+ b40633c933d2508cc82dc0038ec05833edcd1b7241b406ba010081c50008cd1b
+ 7234ba0400f7c300aa7403ba0200b406bb001c81c50008cd1b721b508bc5b104
+ d3e88cc103c18bf058e815002e89360a002eff1e0800e80800b40ecd1bb90100
+ cb56a0840532dbb414cd1b720e80fb8475092ec606d40000e802005ec3b4b0be
+ d000ba06001e0e1fcd1bb4b0cd1b1fc31e000000010000000000000000000000
+ 000000000000000000000000000000000000000000000000000000000d0055aa
+ fa601e066800d81f33f6b51e813c8b46750e817c0204eb7507817c05b4007405
+ 46e2e9eb6032ff8a5c040358f18d7c03be9a012e015c03b00cba6104eeb002ba
+ 3d05ee68009807b95b00f32ea4b9ff0f33f633d226ad02f402d0e2f8f6def6da
+ 268914b416b3c2e4f0a840750680cc2080cb048ac3ba3f04ee8ac4ba3d05eeb0
+ 08ba6104ee071f612ec7060000eb0a2ec70602009090fbe966fec390e8ebffb9
+ 21007402b1118bc1f6660702460612e5912ef66703f7660403c183d200c3fec2
+ 26881605205926880e0a20c390909090905191b81100502ef6670291f7f126a3
+ 0220599233d2f7f12680260420f02608060420ebc9000000000080010d0055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>512</offset>
+ <hexdata>
+ 94c4000000000100000001000000405b46726565425344000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>70144</offset>
+ <hexdata>
+ 5745568205000000776430733100000000000000000000000000000000000000
+ 0000000000000000000200001100000008000000415b000088000000887a3000
+ 0000000000000000100e01000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 000000005745568295f208000020000000200000005802008800000000000000
+ 0700000000200300885802000000000001000000007a30008800000000000000
+ 0000000000000000000000000000000000000000009001008878050000000000
+ 0700000000722900880807000000000007000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.sun.da0.xml b/tools/regression/geom/Data/disk.sun.da0.xml
new file mode 100644
index 0000000..826581f
--- /dev/null
+++ b/tools/regression/geom/Data/disk.sun.da0.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <comment>
+ $FreeBSD$
+ A Solaris 8 disklabel
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <fwsectors>0</fwsectors>
+ <fwheads>0</fwheads>
+ <fwcylinders>0</fwcylinders>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ 49424d2d444459532d5433363935304d2d533936482063796c20313439373020
+ 616c742032206864203132207365632033393900000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000100000000000000000008000200000003000100050000000000000000
+ 0000000000000000000000080000003f000000000000000000000000600ddeee
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000027103a7c00000000000000013a7a0002000c018f00000000000000dc
+ 002d96c000000000001012b0000000000445b1c8000000000000000000000000
+ 00000000000000000000000000000000000000000000034c04080858dabe5ec8
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.sun.da1.xml b/tools/regression/geom/Data/disk.sun.da1.xml
new file mode 100644
index 0000000..0aac8e5
--- /dev/null
+++ b/tools/regression/geom/Data/disk.sun.da1.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <comment>
+ $FreeBSD$
+ A Solaris 8 disklabel
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <fwsectors>0</fwsectors>
+ <fwheads>0</fwheads>
+ <fwcylinders>0</fwcylinders>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ 53554e3138472063796c203735303620616c7420322068642031392073656320
+ 3234380000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000170686b00000000000008000200000003000100050000000800010000
+ 00000007000000040000000800000000000000000000000000000000600ddeee
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 000000001c201d5400000000000000011d520002001300f80000000000000000
+ 0007d6480000006d0020113000000000021bad5000000b4e014b873800000000
+ 000000000000022b00400ff8000005a600400ff80000092100280c48dabe971e
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/Data/disk.typo.ad0.xml b/tools/regression/geom/Data/disk.typo.ad0.xml
new file mode 100644
index 0000000..56383ab
--- /dev/null
+++ b/tools/regression/geom/Data/disk.typo.ad0.xml
@@ -0,0 +1,219 @@
+<?xml version="1.0"?>
+<DISKIMAGE>
+ <comment>
+ $FreeBSD$
+ A multislice FreeBSD disk
+ </comment>
+ <sectorsize>512</sectorsize>
+ <mediasize>0</mediasize>
+ <sector>
+ <offset>0</offset>
+ <hexdata>
+ fc31c08ec08ed88ed0bc007cbd000a89efb108f3abfe45f252bb000689eeb802
+ 02e82e015ae9008af686bbfd20750484d278048a96bafd885600e8fc0052bbc2
+ 0731d2886ffc0fa396bbfd731c8a07bf0f08b103f2ae7411b10df2ae750481c7
+ 0d008a0d01cfe8c1004280c31073d4582c7f3a067504720548740e30c004b088
+ 86b8fdbfb207e8a100be0308e8ad008a96b9fd4ee8880030e4cd1a89d703bebc
+ fdb401cd16751330e4cd1a39fa72f28a86b9fdeb15b007e88e0030e4cd1688e0
+ 3c1c74eb2c3b3c0477eb980fa3460c73e48886b9fdbe000a8a1489f33c049c74
+ 0ac0e00405be0793c6078053f686bbfd407509bb0006b80103e856005e9d7507
+ 8a96b8fd80ea30bb007cb80102e8420072a381bffe0155aa759be81c00ffe3b0
+ 46e82400b03100d0eb170fab560cbe0008e8ebff89fee80300be0d08aca88075
+ 05e80400ebf6247f53bb0700b40ecd105bc38a74018b4c025689e780feff7540
+ 83f9ff753bf686bbfd8074345153bbaa5550b441cd1358720e81fb55aa7508f6
+ c101740380cc405b59f6c4407412666a0066ff740806536a006a1089e6864402
+ cd1389fc5ec39090909090909090909001014472697665200000808fb6008001
+ 0100a5ef7f9f3f000000c1f95f00000041a0a5efffff00fa5f0050e29f0000ff
+ ffffa5efffff50dcff0050dcff000000000000000000000000000000000055aa
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>512</offset>
+ <hexdata>
+ 2020a00a44656661756c743aa00d8a00050f010406070b0c0e6383a5a6a9b70e
+ 141312141d1c1b2124282e3439556e6b6e6f77ee444fd357696e646f7773204e
+ d457696e646f77f3554e49d84c696e75f8467265654253c44f70656e4253c44e
+ 65744253c44253442f4fd3000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>32768</offset>
+ <hexdata>
+ 5745568205000000616430733100000000000000000000000000000000000000
+ 0000000000000000000200003f000000f0000000180a0000103b000080295402
+ 0000000000000000100e01000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 000000005745568204c108000020000000200000002003003f00000000000000
+ 0700000000a00f003f2003000000000001000000c1f95f003f00000000000000
+ 000000000000000000000000000000000000000000a00f003fc0120000000000
+ 07000000c1993d003f6022000000000007000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>64512</offset>
+ <hexdata>
+ 0000007c0000010002000400f8ff0000000400f8000000000000000000000004
+ 0000004000000008000000000010007e00800000070000fe1f00000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>104922112</offset>
+ <hexdata>
+ 3310f30d0350fbf66f44ebd906c9963d46b2bf609bb753131e7c24cf9ed194ce
+ a59117b612772b207ddcb753df72456f98d0cac567f60526c7b9308afd87e657
+ dd45b3d1eb075b6820aa6ea5a0f10511f65a257f0d7d89d88e189bef43786ff5
+ a0316511a7a07168f2ef001e71fbc56dd8ddc7866c4856dc979742be22f4badd
+ e1fcba7aebe4b5f4bb8b0c89e84de59f0ba48d7a8b00bb1797fc057e3d3d8058
+ 4b1987ac49b74bed74cb4985850d5be64e8188d40ad0323165b355c512a91523
+ 5d5211eeb021c754f552b160f9a73c4c5e59370163cf531ca0382cc462f9ac9d
+ 35612380f7a5d9d5e3bde129ef6fab02347088025d0937fb6c56dc68c283ce9d
+ 1cfc5b3c7ad1f52faeae05188386cb57cb88c5dccaa2db17a09420ae7d9f9d6e
+ 058370711f445cff4d4543ee9f0c3054400116304018f68d9c08d05b04680162
+ 23172b8b1775157790fe5e5100c530e3377d383a0080468b0125e87e8d7dee5f
+ 46030a238dc8a0000cb4eafc6ad4735f2c16d1642e3834aefbb5bfc25fcc0062
+ 3a89410ab88839e3ed151cd6bc2b5704c5db4c9fc39662bd3a41347212c664be
+ 04684e551c0a0362bb3139a460a7c8d178c349a47d724b7d456606b2f47a8d99
+ d4af7998148ed93443a828ece96cdb7eb158a21189ed1527bdad7b18b74f168b
+ d01fcfde994977174e41ad8f6ea19fac8bb95e5d68643d0457d746cf32531639
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>629210112</offset>
+ <hexdata>
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>1153498112</offset>
+ <hexdata>
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>3220439552</offset>
+ <hexdata>
+ 5745568205000000616430733200000000000000000000000000000000000000
+ 0000000000000000000200003f000000f0000000180a0000103b000080295402
+ 0000000000000000100e01000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000057455682fc1908000020000000200000000000000000000000000000
+ 000000000000000000000000000000000000000050e29f0000fa5f0000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>6440878080</offset>
+ <hexdata>
+ 0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a
+ 0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a
+ 0a0a0a0a0a0a0a0a0a0a0a0a3c4120200a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a
+ 0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a
+ 0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a
+ 0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a
+ 0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a687265663d22687474703a2f2f777777
+ 2e706c6179626f7973746f72652e636f6d2f70626c696e6b2e6367693f616666
+ 696c696174653d4d4f3130303030303034353426736b753d4249303130362220
+ 7461726765743d225f626c616e6b22206f6e6d6f7573656f7665723d22706172
+ 656e742e77696e646f772e7374617475733d27506c6179626f792053746f7265
+ 273b2072657475726e2074727565223e3c494d47207372633d22687474703a2f
+ 2f61313833322e672e616b2e706c6179626f792e636f6d2f372f313833322f32
+ 332f3939303232313437302f7777772e706c6179626f792e636f6d2f6d616761
+ 7a696e652f63757272656e742f696d782f636f7665725f696e6465782e6a7067
+ 2220616c69676e3d72696768742077696474683d223135302220686569676874
+ </hexdata>
+ </sector>
+ <sector>
+ <offset>8585257472</offset>
+ <hexdata>
+ 5745568205000000616430733300000000000000000000000000000000000000
+ 0000000000000000000200003f000000f000000055040000103b000050dcff00
+ 0000000000000000100e01000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000057455682bcbd0800002000000020000000803e0050dcff0000040000
+ 070816000000000000000000000000000000000050dcff0050dcff0000000000
+ 00000000505cc100505c3e010010000007049f00000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ 0000000000000000000000000000000000000000000000000000000000000000
+ </hexdata>
+ </sector>
+</DISKIMAGE>
diff --git a/tools/regression/geom/GLib/Makefile b/tools/regression/geom/GLib/Makefile
new file mode 100644
index 0000000..344f88a
--- /dev/null
+++ b/tools/regression/geom/GLib/Makefile
@@ -0,0 +1,25 @@
+# $FreeBSD$
+
+LIB= G
+SRCS= geom.c \
+ geom_aes.c geom_apple.c geom_bsd.c geom_simdev.c geom_dump.c \
+ geom_event.c \
+ geom_io.c \
+ geom_kernsim.c geom_mbr.c geom_simdisk.c geom_enc.c \
+ geom_simdisk_xml.c geom_slice.c geom_subr.c subr_sbuf.c \
+ geom_sunlabel.c geom_pc98.c
+
+
+CFLAGS += -gstabs -static
+CFLAGS += -I/usr/src/sys -I..
+CFLAGS += -DKERNELSIM
+NOPIC = static
+NOPROFILE = bingo
+NOOBJ = youbet
+WARNS = 5
+
+.PATH: /sys/geom .. /sys/kern
+
+.include <bsd.lib.mk>
+
+test:
diff --git a/tools/regression/geom/Makefile b/tools/regression/geom/Makefile
new file mode 100644
index 0000000..bbb5ddf
--- /dev/null
+++ b/tools/regression/geom/Makefile
@@ -0,0 +1,19 @@
+# $FreeBSD$
+
+SUBDIR+= ConfCmp GLib Test
+
+.include <bsd.subdir.mk>
+
+test: all _SUBDIR
+
+
+toflat:
+ scp *.c *.h *.sh Makefile root@flat:/sys/geom
+
+fromflat:
+ scp root@flat:/sys/geom/\* .
+
+publish:
+ $(MAKE) cleandir
+ tar --exclude CVS -czf - . | \
+ ssh phk@phk "cd www/geom && cat > geom.tgz && rm -rf src && mkdir -p src && cd src && tar xzf ../geom.tgz"
diff --git a/tools/regression/geom/Test/Makefile b/tools/regression/geom/Test/Makefile
new file mode 100644
index 0000000..0ba78f0
--- /dev/null
+++ b/tools/regression/geom/Test/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+SUBDIR+= T000 T001 T002 T003 T004 T005 T006 T007 T008 T009
+SUBDIR+= T011 T012 T013 T014 T015
+
+# SUBDIR+= T999
+
+.include <bsd.subdir.mk>
+
+test: _SUBDIR
+
+mkref: _SUBDIR
diff --git a/tools/regression/geom/Test/Makefile.inc b/tools/regression/geom/Test/Makefile.inc
new file mode 100644
index 0000000..d25f84d
--- /dev/null
+++ b/tools/regression/geom/Test/Makefile.inc
@@ -0,0 +1,37 @@
+# $FreeBSD$
+
+PROG = testprg
+NOMAN = no
+NOOBJ = youbet
+CFLAGS += -gstabs -static
+CFLAGS += -I/usr/src/sys -I../..
+CFLAGS += -DKERNELSIM -pthread
+LDADD += -L../../GLib -lG
+LDADD += -lbsdxml
+LDADD += -lmd
+DPADD += ../../GLib/libG.a
+CLEANFILES += _* *.core
+WARNS= 5
+
+foo:
+ echo ${SRCS}
+ echo ${OBJS}
+
+ttest: ${PROG}
+ ./${PROG} -t 2>&1 | tee _test
+
+tbtest: ${PROG}
+ ./${PROG} -t -b 2>&1 | tee _test
+
+test: ${PROG}
+ ./${PROG}
+.if exists(ref.conf)
+ ../../ConfCmp/ConfCmp _1.conf ref.conf
+.endif
+ echo "Passed ${.CURDIR}"
+
+mkref:
+ mv _1.conf ref.conf
+
+gdb:
+ gdb ${PROG} ${PROG}.core
diff --git a/tools/regression/geom/Test/T000/Makefile b/tools/regression/geom/Test/T000/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T000/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T000/ref.conf b/tools/regression/geom/Test/T000/ref.conf
new file mode 100644
index 0000000..83518fc1
--- /dev/null
+++ b/tools/regression/geom/Test/T000/ref.conf
@@ -0,0 +1,18 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x806c100">
+ <name>DEV-class</name>
+ </class>
+ <class id="0x806c0e0">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x806c0c0">
+ <name>MBR</name>
+ </class>
+ <class id="0x806c120">
+ <name>BSD</name>
+ </class>
+ <class id="0x806c020">
+ <name>SIMDISK-class</name>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T000/testprg.c b/tools/regression/geom/Test/T000/testprg.c
new file mode 100644
index 0000000..eb53a9c
--- /dev/null
+++ b/tools/regression/geom/Test/T000/testprg.c
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+ conff("1");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T001/Makefile b/tools/regression/geom/Test/T001/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T001/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T001/ref.conf b/tools/regression/geom/Test/T001/ref.conf
new file mode 100644
index 0000000..e602ddd
--- /dev/null
+++ b/tools/regression/geom/Test/T001/ref.conf
@@ -0,0 +1,409 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8087380">
+ <name>DEV-class</name>
+ <geom id="0x80bde00">
+ <class ref="0x8087380"/>
+ <name>ad0s3d</name>
+ <rank>4</rank>
+ <consumer id="0x80b9c00">
+ <geom ref="0x80bde00"/>
+ <provider ref="0x80bd280"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bdc80">
+ <class ref="0x8087380"/>
+ <name>ad0s3c</name>
+ <rank>4</rank>
+ <consumer id="0x80b9bc0">
+ <geom ref="0x80bdc80"/>
+ <provider ref="0x80bd200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bdb00">
+ <class ref="0x8087380"/>
+ <name>ad0s3a</name>
+ <rank>4</rank>
+ <consumer id="0x80b9a80">
+ <geom ref="0x80bdb00"/>
+ <provider ref="0x80bd180"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bd980">
+ <class ref="0x8087380"/>
+ <name>ad0s2c</name>
+ <rank>4</rank>
+ <consumer id="0x80b9940">
+ <geom ref="0x80bd980"/>
+ <provider ref="0x80b8e80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bd800">
+ <class ref="0x8087380"/>
+ <name>ad0s1f</name>
+ <rank>4</rank>
+ <consumer id="0x80b9900">
+ <geom ref="0x80bd800"/>
+ <provider ref="0x80b8b80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bd680">
+ <class ref="0x8087380"/>
+ <name>ad0s1e</name>
+ <rank>4</rank>
+ <consumer id="0x80b98c0">
+ <geom ref="0x80bd680"/>
+ <provider ref="0x80b8b00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bd500">
+ <class ref="0x8087380"/>
+ <name>ad0s1c</name>
+ <rank>4</rank>
+ <consumer id="0x80b9880">
+ <geom ref="0x80bd500"/>
+ <provider ref="0x80b8a80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bd380">
+ <class ref="0x8087380"/>
+ <name>ad0s1b</name>
+ <rank>4</rank>
+ <consumer id="0x80b9840">
+ <geom ref="0x80bd380"/>
+ <provider ref="0x80b8a00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bd300">
+ <class ref="0x8087380"/>
+ <name>ad0s1a</name>
+ <rank>4</rank>
+ <consumer id="0x80b96c0">
+ <geom ref="0x80bd300"/>
+ <provider ref="0x80b8980"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8f00">
+ <class ref="0x8087380"/>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <consumer id="0x80b9680">
+ <geom ref="0x80b8f00"/>
+ <provider ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8c00">
+ <class ref="0x8087380"/>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <consumer id="0x80b9640">
+ <geom ref="0x80b8c00"/>
+ <provider ref="0x80b8580"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8680">
+ <class ref="0x8087380"/>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <consumer id="0x80b9540">
+ <geom ref="0x80b8680"/>
+ <provider ref="0x80b8500"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8280">
+ <class ref="0x8087380"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer id="0x80b9580">
+ <geom ref="0x80b8280"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8087360">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x8087340">
+ <name>MBR</name>
+ <geom id="0x80b8300">
+ <class ref="0x8087340"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>0</frontstuff>
+ </config>
+ <consumer id="0x80b9600">
+ <geom ref="0x80b8300"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8600">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s3</name>
+ <mediasize>8585256960</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>8585256960</offset>
+ <secoffset>16768080</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider id="0x80b8580">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s2</name>
+ <mediasize>5364817920</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>3220439040</offset>
+ <secoffset>6289920</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ <provider id="0x80b8500">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1</name>
+ <mediasize>3220406784</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x80873a0">
+ <name>BSD</name>
+ <geom id="0x80b8f80">
+ <class ref="0x80873a0"/>
+ <name>ad0s3</name>
+ <rank>3</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ <labeloffset>512</labeloffset>
+ <rawoffset>16768080</rawoffset>
+ <mbroffset>8585256960</mbroffset>
+ </config>
+ <consumer id="0x80b9b80">
+ <geom ref="0x80b8f80"/>
+ <provider ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80bd280">
+ <geom ref="0x80b8f80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s3d</name>
+ <mediasize>6488104960</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>3</index>
+ <length>6488104960</length>
+ <seclength>12672080</seclength>
+ <offset>2097152000</offset>
+ <secoffset>4096000</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80bd200">
+ <geom ref="0x80b8f80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s3c</name>
+ <mediasize>8585256960</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>8585256960</length>
+ <seclength>16768080</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>0</type>
+ </config>
+ </provider>
+ <provider id="0x80bd180">
+ <geom ref="0x80b8f80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s3a</name>
+ <mediasize>2097152000</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>2097152000</length>
+ <seclength>4096000</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ </geom>
+ <geom id="0x80b8c80">
+ <class ref="0x80873a0"/>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ <labeloffset>512</labeloffset>
+ <rawoffset>6289920</rawoffset>
+ <mbroffset>3220439040</mbroffset>
+ </config>
+ <consumer id="0x80b9a40">
+ <geom ref="0x80b8c80"/>
+ <provider ref="0x80b8580"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8e80">
+ <geom ref="0x80b8c80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s2c</name>
+ <mediasize>5364817920</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>5364817920</length>
+ <seclength>10478160</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>0</type>
+ </config>
+ </provider>
+ </geom>
+ <geom id="0x80b8700">
+ <class ref="0x80873a0"/>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ <labeloffset>512</labeloffset>
+ <rawoffset>63</rawoffset>
+ <mbroffset>32256</mbroffset>
+ </config>
+ <consumer id="0x80b9800">
+ <geom ref="0x80b8700"/>
+ <provider ref="0x80b8500"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8b80">
+ <geom ref="0x80b8700"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1f</name>
+ <mediasize>2066973184</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>5</index>
+ <length>2066973184</length>
+ <seclength>4037057</seclength>
+ <offset>1153433600</offset>
+ <secoffset>2252800</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8b00">
+ <geom ref="0x80b8700"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1e</name>
+ <mediasize>524288000</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>4</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>629145600</offset>
+ <secoffset>1228800</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8a80">
+ <geom ref="0x80b8700"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1c</name>
+ <mediasize>3220406784</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>3220406784</length>
+ <seclength>6289857</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>0</type>
+ </config>
+ </provider>
+ <provider id="0x80b8a00">
+ <geom ref="0x80b8700"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1b</name>
+ <mediasize>524288000</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>104857600</offset>
+ <secoffset>204800</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8980">
+ <geom ref="0x80b8700"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1a</name>
+ <mediasize>104857600</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x80872a0">
+ <name>SIMDISK-class</name>
+ <geom id="0x80b8180">
+ <class ref="0x80872a0"/>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider id="0x80b8200">
+ <geom ref="0x80b8180"/>
+ <mode>r0w0e0</mode>
+ <name>ad0</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T001/testprg.c b/tools/regression/geom/Test/T001/testprg.c
new file mode 100644
index 0000000..263665e
--- /dev/null
+++ b/tools/regression/geom/Test/T001/testprg.c
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.typo.ad0.xml");
+ rattle();
+ conff("1");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T002/Makefile b/tools/regression/geom/Test/T002/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T002/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T002/ref.conf b/tools/regression/geom/Test/T002/ref.conf
new file mode 100644
index 0000000..dc852781
--- /dev/null
+++ b/tools/regression/geom/Test/T002/ref.conf
@@ -0,0 +1,105 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8087380">
+ <name>DEV-class</name>
+ <geom id="0x80b8680">
+ <class ref="0x8087380"/>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <consumer id="0x80b9640">
+ <geom ref="0x80b8680"/>
+ <provider ref="0x80b8580"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8600">
+ <class ref="0x8087380"/>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <consumer id="0x80b9540">
+ <geom ref="0x80b8600"/>
+ <provider ref="0x80b8500"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8280">
+ <class ref="0x8087380"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer id="0x80b9580">
+ <geom ref="0x80b8280"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8087360">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x8087340">
+ <name>MBR</name>
+ <geom id="0x80b8300">
+ <class ref="0x8087340"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>0</frontstuff>
+ </config>
+ <consumer id="0x80b9600">
+ <geom ref="0x80b8300"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8580">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s2</name>
+ <mediasize>4564740096</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>4564740096</length>
+ <seclength>8915508</seclength>
+ <offset>296884224</offset>
+ <secoffset>579852</secoffset>
+ <type>11</type>
+ </config>
+ </provider>
+ <provider id="0x80b8500">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1</name>
+ <mediasize>296821760</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>296821760</length>
+ <seclength>579730</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ <type>160</type>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x80873a0">
+ <name>BSD</name>
+ </class>
+ <class id="0x80872a0">
+ <name>SIMDISK-class</name>
+ <geom id="0x80b8180">
+ <class ref="0x80872a0"/>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider id="0x80b8200">
+ <geom ref="0x80b8180"/>
+ <mode>r0w0e0</mode>
+ <name>ad0</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T002/testprg.c b/tools/regression/geom/Test/T002/testprg.c
new file mode 100644
index 0000000..d7e6181
--- /dev/null
+++ b/tools/regression/geom/Test/T002/testprg.c
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.far.ad0.xml");
+ rattle();
+ conff("1");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T003/Makefile b/tools/regression/geom/Test/T003/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T003/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T003/ref.conf b/tools/regression/geom/Test/T003/ref.conf
new file mode 100644
index 0000000..3631934
--- /dev/null
+++ b/tools/regression/geom/Test/T003/ref.conf
@@ -0,0 +1,695 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8087380">
+ <name>DEV-class</name>
+ <geom id="0x80cc680">
+ <class ref="0x8087380"/>
+ <name>ad0s27</name>
+ <rank>4</rank>
+ <consumer id="0x80b9d80">
+ <geom ref="0x80cc680"/>
+ <provider ref="0x80bc500"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80cc500">
+ <class ref="0x8087380"/>
+ <name>ad0s26</name>
+ <rank>4</rank>
+ <consumer id="0x80b9d40">
+ <geom ref="0x80cc500"/>
+ <provider ref="0x80bc480"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80cc380">
+ <class ref="0x8087380"/>
+ <name>ad0s25</name>
+ <rank>4</rank>
+ <consumer id="0x80b9d00">
+ <geom ref="0x80cc380"/>
+ <provider ref="0x80bc400"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80cc200">
+ <class ref="0x8087380"/>
+ <name>ad0s24</name>
+ <rank>4</rank>
+ <consumer id="0x80b9cc0">
+ <geom ref="0x80cc200"/>
+ <provider ref="0x80bc380"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80cc080">
+ <class ref="0x8087380"/>
+ <name>ad0s23</name>
+ <rank>4</rank>
+ <consumer id="0x80b9c80">
+ <geom ref="0x80cc080"/>
+ <provider ref="0x80bc300"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c0f00">
+ <class ref="0x8087380"/>
+ <name>ad0s22</name>
+ <rank>4</rank>
+ <consumer id="0x80b9c40">
+ <geom ref="0x80c0f00"/>
+ <provider ref="0x80bc280"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c0d80">
+ <class ref="0x8087380"/>
+ <name>ad0s21</name>
+ <rank>4</rank>
+ <consumer id="0x80b9c00">
+ <geom ref="0x80c0d80"/>
+ <provider ref="0x80bc200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c0c00">
+ <class ref="0x8087380"/>
+ <name>ad0s20</name>
+ <rank>4</rank>
+ <consumer id="0x80b9bc0">
+ <geom ref="0x80c0c00"/>
+ <provider ref="0x80bc180"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c0a80">
+ <class ref="0x8087380"/>
+ <name>ad0s19</name>
+ <rank>4</rank>
+ <consumer id="0x80b9b80">
+ <geom ref="0x80c0a80"/>
+ <provider ref="0x80bc100"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c0900">
+ <class ref="0x8087380"/>
+ <name>ad0s18</name>
+ <rank>4</rank>
+ <consumer id="0x80b9b40">
+ <geom ref="0x80c0900"/>
+ <provider ref="0x80bc080"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c0780">
+ <class ref="0x8087380"/>
+ <name>ad0s17</name>
+ <rank>4</rank>
+ <consumer id="0x80b9b00">
+ <geom ref="0x80c0780"/>
+ <provider ref="0x80bc000"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c0600">
+ <class ref="0x8087380"/>
+ <name>ad0s16</name>
+ <rank>4</rank>
+ <consumer id="0x80b9ac0">
+ <geom ref="0x80c0600"/>
+ <provider ref="0x80b8f80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c0480">
+ <class ref="0x8087380"/>
+ <name>ad0s15</name>
+ <rank>4</rank>
+ <consumer id="0x80b9a80">
+ <geom ref="0x80c0480"/>
+ <provider ref="0x80b8f00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c0300">
+ <class ref="0x8087380"/>
+ <name>ad0s14</name>
+ <rank>4</rank>
+ <consumer id="0x80b9a40">
+ <geom ref="0x80c0300"/>
+ <provider ref="0x80b8e80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c0180">
+ <class ref="0x8087380"/>
+ <name>ad0s13</name>
+ <rank>4</rank>
+ <consumer id="0x80b9a00">
+ <geom ref="0x80c0180"/>
+ <provider ref="0x80b8e00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c0000">
+ <class ref="0x8087380"/>
+ <name>ad0s12</name>
+ <rank>4</rank>
+ <consumer id="0x80b99c0">
+ <geom ref="0x80c0000"/>
+ <provider ref="0x80b8d80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bce80">
+ <class ref="0x8087380"/>
+ <name>ad0s11</name>
+ <rank>4</rank>
+ <consumer id="0x80b9980">
+ <geom ref="0x80bce80"/>
+ <provider ref="0x80b8d00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bcd00">
+ <class ref="0x8087380"/>
+ <name>ad0s10</name>
+ <rank>4</rank>
+ <consumer id="0x80b9940">
+ <geom ref="0x80bcd00"/>
+ <provider ref="0x80b8c80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bcb80">
+ <class ref="0x8087380"/>
+ <name>ad0s9</name>
+ <rank>4</rank>
+ <consumer id="0x80b9900">
+ <geom ref="0x80bcb80"/>
+ <provider ref="0x80b8c00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bca00">
+ <class ref="0x8087380"/>
+ <name>ad0s8</name>
+ <rank>4</rank>
+ <consumer id="0x80b98c0">
+ <geom ref="0x80bca00"/>
+ <provider ref="0x80b8b80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc880">
+ <class ref="0x8087380"/>
+ <name>ad0s7</name>
+ <rank>4</rank>
+ <consumer id="0x80b9880">
+ <geom ref="0x80bc880"/>
+ <provider ref="0x80b8b00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc700">
+ <class ref="0x8087380"/>
+ <name>ad0s6</name>
+ <rank>4</rank>
+ <consumer id="0x80b9840">
+ <geom ref="0x80bc700"/>
+ <provider ref="0x80b8a80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bc580">
+ <class ref="0x8087380"/>
+ <name>ad0s5</name>
+ <rank>4</rank>
+ <consumer id="0x80b9680">
+ <geom ref="0x80bc580"/>
+ <provider ref="0x80b8a00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8680">
+ <class ref="0x8087380"/>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <consumer id="0x80b9640">
+ <geom ref="0x80b8680"/>
+ <provider ref="0x80b8580"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8600">
+ <class ref="0x8087380"/>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <consumer id="0x80b9540">
+ <geom ref="0x80b8600"/>
+ <provider ref="0x80b8500"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8280">
+ <class ref="0x8087380"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer id="0x80b9580">
+ <geom ref="0x80b8280"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8087360">
+ <name>MBREXT</name>
+ <geom id="0x80b8880">
+ <class ref="0x8087360"/>
+ <name>ad0s2</name>
+ <rank>3</rank>
+ <config>
+ <frontstuff>0</frontstuff>
+ </config>
+ <consumer id="0x80b9800">
+ <geom ref="0x80b8880"/>
+ <provider ref="0x80b8580"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80bc500">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s27</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>22</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>180988416</offset>
+ <secoffset>353493</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80bc480">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s26</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>21</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>172763136</offset>
+ <secoffset>337428</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80bc400">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s25</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>20</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>164537856</offset>
+ <secoffset>321363</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80bc380">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s24</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>19</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>156312576</offset>
+ <secoffset>305298</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80bc300">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s23</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>18</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>148087296</offset>
+ <secoffset>289233</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80bc280">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s22</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>17</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>139862016</offset>
+ <secoffset>273168</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80bc200">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s21</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>16</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>131636736</offset>
+ <secoffset>257103</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80bc180">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s20</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>15</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>123411456</offset>
+ <secoffset>241038</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80bc100">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s19</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>14</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>115186176</offset>
+ <secoffset>224973</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80bc080">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s18</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>13</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>106960896</offset>
+ <secoffset>208908</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80bc000">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s17</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>12</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>98735616</offset>
+ <secoffset>192843</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8f80">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s16</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>11</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>90510336</offset>
+ <secoffset>176778</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8f00">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s15</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>10</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>82285056</offset>
+ <secoffset>160713</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8e80">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s14</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>9</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>74059776</offset>
+ <secoffset>144648</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8e00">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s13</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>8</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>65834496</offset>
+ <secoffset>128583</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8d80">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s12</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>7</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>57609216</offset>
+ <secoffset>112518</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8d00">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s11</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>6</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>49383936</offset>
+ <secoffset>96453</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8c80">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s10</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>5</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>41158656</offset>
+ <secoffset>80388</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8c00">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s9</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>4</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>32933376</offset>
+ <secoffset>64323</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8b80">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s8</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>3</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>24708096</offset>
+ <secoffset>48258</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8b00">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s7</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>16482816</offset>
+ <secoffset>32193</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8a80">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s6</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>8257536</offset>
+ <secoffset>16128</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8a00">
+ <geom ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s5</name>
+ <mediasize>8193024</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>8193024</length>
+ <seclength>16002</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8087340">
+ <name>MBR</name>
+ <geom id="0x80b8300">
+ <class ref="0x8087340"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>0</frontstuff>
+ </config>
+ <consumer id="0x80b9600">
+ <geom ref="0x80b8300"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8580">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s2</name>
+ <mediasize>427714560</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>427714560</length>
+ <seclength>835380</seclength>
+ <offset>2146798080</offset>
+ <secoffset>4192965</secoffset>
+ <type>5</type>
+ </config>
+ </provider>
+ <provider id="0x80b8500">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1</name>
+ <mediasize>2146765824</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>2146765824</length>
+ <seclength>4192902</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ <type>6</type>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x80873a0">
+ <name>BSD</name>
+ </class>
+ <class id="0x80872a0">
+ <name>SIMDISK-class</name>
+ <geom id="0x80b8180">
+ <class ref="0x80872a0"/>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider id="0x80b8200">
+ <geom ref="0x80b8180"/>
+ <mode>r0w0e0</mode>
+ <name>ad0</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T003/testprg.c b/tools/regression/geom/Test/T003/testprg.c
new file mode 100644
index 0000000..3acfcec
--- /dev/null
+++ b/tools/regression/geom/Test/T003/testprg.c
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.msdos.ext.xml");
+ rattle();
+ conff("1");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T004/Makefile b/tools/regression/geom/Test/T004/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T004/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T004/ref.conf b/tools/regression/geom/Test/T004/ref.conf
new file mode 100644
index 0000000..e6718be
--- /dev/null
+++ b/tools/regression/geom/Test/T004/ref.conf
@@ -0,0 +1,298 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x80873c0">
+ <name>DEV-class</name>
+ <geom id="0x80bd600">
+ <class ref="0x80873c0"/>
+ <name>ad0s1h</name>
+ <rank>4</rank>
+ <consumer id="0x80b9940">
+ <geom ref="0x80bd600"/>
+ <provider ref="0x80b8c00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bd480">
+ <class ref="0x80873c0"/>
+ <name>ad0s1g</name>
+ <rank>4</rank>
+ <consumer id="0x80b9900">
+ <geom ref="0x80bd480"/>
+ <provider ref="0x80b8b80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bd300">
+ <class ref="0x80873c0"/>
+ <name>ad0s1f</name>
+ <rank>4</rank>
+ <consumer id="0x80b98c0">
+ <geom ref="0x80bd300"/>
+ <provider ref="0x80b8b00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bd180">
+ <class ref="0x80873c0"/>
+ <name>ad0s1e</name>
+ <rank>4</rank>
+ <consumer id="0x80b9880">
+ <geom ref="0x80bd180"/>
+ <provider ref="0x80b8a80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bd000">
+ <class ref="0x80873c0"/>
+ <name>ad0s1d</name>
+ <rank>4</rank>
+ <consumer id="0x80b9840">
+ <geom ref="0x80bd000"/>
+ <provider ref="0x80b8a00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8e80">
+ <class ref="0x80873c0"/>
+ <name>ad0s1c</name>
+ <rank>4</rank>
+ <consumer id="0x80b9800">
+ <geom ref="0x80b8e80"/>
+ <provider ref="0x80b8980"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8d00">
+ <class ref="0x80873c0"/>
+ <name>ad0s1b</name>
+ <rank>4</rank>
+ <consumer id="0x80b97c0">
+ <geom ref="0x80b8d00"/>
+ <provider ref="0x80b8900"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8c80">
+ <class ref="0x80873c0"/>
+ <name>ad0s1a</name>
+ <rank>4</rank>
+ <consumer id="0x80b9640">
+ <geom ref="0x80b8c80"/>
+ <provider ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8580">
+ <class ref="0x80873c0"/>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <consumer id="0x80b9540">
+ <geom ref="0x80b8580"/>
+ <provider ref="0x80b8500"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8280">
+ <class ref="0x80873c0"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer id="0x80b9580">
+ <geom ref="0x80b8280"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x80873a0">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x8087380">
+ <name>MBR</name>
+ <geom id="0x80b8300">
+ <class ref="0x8087380"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>0</frontstuff>
+ </config>
+ <consumer id="0x80b9600">
+ <geom ref="0x80b8300"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8500">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1</name>
+ <mediasize>20003848704</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>20003848704</length>
+ <seclength>39070017</seclength>
+ <offset>32256</offset>
+ <secoffset>63</secoffset>
+ <type>165</type>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x80873e0">
+ <name>BSD</name>
+ <geom id="0x80b8600">
+ <class ref="0x80873e0"/>
+ <name>ad0s1</name>
+ <rank>3</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ <labeloffset>512</labeloffset>
+ <rawoffset>63</rawoffset>
+ <mbroffset>32256</mbroffset>
+ </config>
+ <consumer id="0x80b9780">
+ <geom ref="0x80b8600"/>
+ <provider ref="0x80b8500"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8c00">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1h</name>
+ <mediasize>5368709120</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>7</index>
+ <length>5368709120</length>
+ <seclength>10485760</seclength>
+ <offset>10187964416</offset>
+ <secoffset>19898368</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8b80">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1g</name>
+ <mediasize>3221225472</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>6</index>
+ <length>3221225472</length>
+ <seclength>6291456</seclength>
+ <offset>6966738944</offset>
+ <secoffset>13606912</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8b00">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1f</name>
+ <mediasize>4294967296</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>5</index>
+ <length>4294967296</length>
+ <seclength>8388608</seclength>
+ <offset>2671771648</offset>
+ <secoffset>5218304</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8a80">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1e</name>
+ <mediasize>524288000</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>4</index>
+ <length>524288000</length>
+ <seclength>1024000</seclength>
+ <offset>2147483648</offset>
+ <secoffset>4194304</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8a00">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1d</name>
+ <mediasize>4447175168</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>3</index>
+ <length>4447175168</length>
+ <seclength>8685889</seclength>
+ <offset>15556673536</offset>
+ <secoffset>30384128</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8980">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1c</name>
+ <mediasize>20003848704</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>20003848704</length>
+ <seclength>39070017</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>0</type>
+ </config>
+ </provider>
+ <provider id="0x80b8900">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1b</name>
+ <mediasize>1073741824</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>1073741824</length>
+ <seclength>2097152</seclength>
+ <offset>1073741824</offset>
+ <secoffset>2097152</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8880">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>ad0s1a</name>
+ <mediasize>1073741824</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>1073741824</length>
+ <seclength>2097152</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x80872e0">
+ <name>SIMDISK-class</name>
+ <geom id="0x80b8180">
+ <class ref="0x80872e0"/>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider id="0x80b8200">
+ <geom ref="0x80b8180"/>
+ <mode>r0w0e0</mode>
+ <name>ad0</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T004/testprg.c b/tools/regression/geom/Test/T004/testprg.c
new file mode 100644
index 0000000..2c0dcd2
--- /dev/null
+++ b/tools/regression/geom/Test/T004/testprg.c
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.critter.ad0.xml");
+ rattle();
+ conff("1");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T005/Makefile b/tools/regression/geom/Test/T005/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T005/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T005/ref.conf b/tools/regression/geom/Test/T005/ref.conf
new file mode 100644
index 0000000..f031c5a
--- /dev/null
+++ b/tools/regression/geom/Test/T005/ref.conf
@@ -0,0 +1,133 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8087380">
+ <name>DEV-class</name>
+ <geom id="0x80b8880">
+ <class ref="0x8087380"/>
+ <name>ad0c</name>
+ <rank>3</rank>
+ <consumer id="0x80b96c0">
+ <geom ref="0x80b8880"/>
+ <provider ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8700">
+ <class ref="0x8087380"/>
+ <name>ad0b</name>
+ <rank>3</rank>
+ <consumer id="0x80b9680">
+ <geom ref="0x80b8700"/>
+ <provider ref="0x80b8580"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8680">
+ <class ref="0x8087380"/>
+ <name>ad0a</name>
+ <rank>3</rank>
+ <consumer id="0x80b9540">
+ <geom ref="0x80b8680"/>
+ <provider ref="0x80b8500"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8280">
+ <class ref="0x8087380"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer id="0x80b9580">
+ <geom ref="0x80b8280"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8087360">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x8087340">
+ <name>MBR</name>
+ </class>
+ <class id="0x80873a0">
+ <name>BSD</name>
+ <geom id="0x80b8300">
+ <class ref="0x80873a0"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ <labeloffset>512</labeloffset>
+ <rawoffset>0</rawoffset>
+ <mbroffset>0</mbroffset>
+ </config>
+ <consumer id="0x80b9640">
+ <geom ref="0x80b8300"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8600">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>ad0c</name>
+ <mediasize>1474560</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>1474560</length>
+ <seclength>2880</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8580">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>ad0b</name>
+ <mediasize>1474560</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>1474560</length>
+ <seclength>2880</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>0</type>
+ </config>
+ </provider>
+ <provider id="0x80b8500">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>ad0a</name>
+ <mediasize>1474560</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>1474560</length>
+ <seclength>2880</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>0</type>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x80872a0">
+ <name>SIMDISK-class</name>
+ <geom id="0x80b8180">
+ <class ref="0x80872a0"/>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider id="0x80b8200">
+ <geom ref="0x80b8180"/>
+ <mode>r0w0e0</mode>
+ <name>ad0</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T005/testprg.c b/tools/regression/geom/Test/T005/testprg.c
new file mode 100644
index 0000000..af1d3f7
--- /dev/null
+++ b/tools/regression/geom/Test/T005/testprg.c
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.kern.flp.xml");
+ rattle();
+ conff("1");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T006/Makefile b/tools/regression/geom/Test/T006/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T006/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T006/ref.conf b/tools/regression/geom/Test/T006/ref.conf
new file mode 100644
index 0000000..ded94cd
--- /dev/null
+++ b/tools/regression/geom/Test/T006/ref.conf
@@ -0,0 +1,40 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8087380">
+ <name>DEV-class</name>
+ <geom id="0x80b8280">
+ <class ref="0x8087380"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer id="0x80b9580">
+ <geom ref="0x80b8280"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8087360">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x8087340">
+ <name>MBR</name>
+ </class>
+ <class id="0x80873a0">
+ <name>BSD</name>
+ </class>
+ <class id="0x80872a0">
+ <name>SIMDISK-class</name>
+ <geom id="0x80b8180">
+ <class ref="0x80872a0"/>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider id="0x80b8200">
+ <geom ref="0x80b8180"/>
+ <mode>r0w0e0</mode>
+ <name>ad0</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T006/testprg.c b/tools/regression/geom/Test/T006/testprg.c
new file mode 100644
index 0000000..57c9522
--- /dev/null
+++ b/tools/regression/geom/Test/T006/testprg.c
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.msdos.flp.xml");
+ rattle();
+ conff("1");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T007/Makefile b/tools/regression/geom/Test/T007/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T007/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T007/ref.conf b/tools/regression/geom/Test/T007/ref.conf
new file mode 100644
index 0000000..275d6b9
--- /dev/null
+++ b/tools/regression/geom/Test/T007/ref.conf
@@ -0,0 +1,18 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x80873a0">
+ <name>DEV-class</name>
+ </class>
+ <class id="0x8087380">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x8087360">
+ <name>MBR</name>
+ </class>
+ <class id="0x80873c0">
+ <name>BSD</name>
+ </class>
+ <class id="0x80872c0">
+ <name>SIMDISK-class</name>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T007/testprg.c b/tools/regression/geom/Test/T007/testprg.c
new file mode 100644
index 0000000..bc302be
--- /dev/null
+++ b/tools/regression/geom/Test/T007/testprg.c
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.typo.ad0.xml");
+ rattle();
+ sdumpf("2a");
+ g_simdisk_destroy("ad0");
+ rattle();
+ conff("1");
+ sdumpf("2b");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T008/Makefile b/tools/regression/geom/Test/T008/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T008/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T008/ref.conf b/tools/regression/geom/Test/T008/ref.conf
new file mode 100644
index 0000000..73a023b
--- /dev/null
+++ b/tools/regression/geom/Test/T008/ref.conf
@@ -0,0 +1,18 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x80873e0">
+ <name>DEV-class</name>
+ </class>
+ <class id="0x80873c0">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x80873a0">
+ <name>MBR</name>
+ </class>
+ <class id="0x8087400">
+ <name>BSD</name>
+ </class>
+ <class id="0x8087300">
+ <name>SIMDISK-class</name>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T008/testprg.c b/tools/regression/geom/Test/T008/testprg.c
new file mode 100644
index 0000000..eca224a
--- /dev/null
+++ b/tools/regression/geom/Test/T008/testprg.c
@@ -0,0 +1,75 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+ struct g_consumer *cp;
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.typo.ad0.xml");
+ rattle();
+ cp = g_dev_opendev("ad0s1a", 1, 0, 0);
+ sdumpf("2a");
+ g_simdisk_destroy("ad0");
+ rattle();
+ conff("1");
+ sdumpf("2b");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T009/Makefile b/tools/regression/geom/Test/T009/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T009/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T009/ref.conf b/tools/regression/geom/Test/T009/ref.conf
new file mode 100644
index 0000000..caea5ce
--- /dev/null
+++ b/tools/regression/geom/Test/T009/ref.conf
@@ -0,0 +1,18 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8087100">
+ <name>DEV-class</name>
+ </class>
+ <class id="0x80870e0">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x80870c0">
+ <name>MBR</name>
+ </class>
+ <class id="0x8087120">
+ <name>BSD</name>
+ </class>
+ <class id="0x8087020">
+ <name>SIMDISK-class</name>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T009/testprg.c b/tools/regression/geom/Test/T009/testprg.c
new file mode 100644
index 0000000..ab71e92
--- /dev/null
+++ b/tools/regression/geom/Test/T009/testprg.c
@@ -0,0 +1,89 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+ struct g_consumer *cp;
+ struct bio *bp;
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.typo.ad0.xml");
+ rattle();
+ cp = g_dev_opendev("ad0s1a", 1, 0, 0);
+ g_simdisk_stop("ad0");
+ bp = g_new_bio();
+ bp->bio_cmd = BIO_READ;
+ bp->bio_offset = 0;
+ bp->bio_length = 512;
+ bp->bio_data = g_malloc(512, M_WAITOK);
+ g_dev_request("ad0s1a", bp);
+ rattle();
+ sdumpf("2a");
+ g_simdisk_destroy("ad0");
+ rattle();
+ conff("1");
+ sdumpf("2b");
+ g_simdisk_restart("ad0");
+ rattle();
+ conff("1");
+ sdumpf("2c");
+
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T010/Makefile b/tools/regression/geom/Test/T010/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T010/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T010/ref.conf b/tools/regression/geom/Test/T010/ref.conf
new file mode 100644
index 0000000..6d12ea4
--- /dev/null
+++ b/tools/regression/geom/Test/T010/ref.conf
@@ -0,0 +1,38 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8072460">
+ <name>DEV-class</name>
+ <geom id="0x80bb180">
+ <class ref="0x8072460"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer id="0x80b8040">
+ <geom ref="0x80bb180"/>
+ <provider ref="0x80bb100"/>
+ <mode>r1w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8072440">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x8072420">
+ <name>MBR</name>
+ </class>
+ <class id="0x8072480">
+ <name>BSD</name>
+ </class>
+ <class id="0x8072380">
+ <name>SIMDISK-class</name>
+ <geom id="0x80bb080">
+ <class ref="0x8072380"/>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider id="0x80bb100">
+ <geom ref="0x80bb080"/>
+ <mode>r1w0e0</mode>
+ <name>ad0</name>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T010/testprg.c b/tools/regression/geom/Test/T010/testprg.c
new file mode 100644
index 0000000..29dd6ca
--- /dev/null
+++ b/tools/regression/geom/Test/T010/testprg.c
@@ -0,0 +1,78 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+ struct g_consumer *cp;
+ struct g_geom *gp;
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.empty.flp.xml");
+ rattle();
+ cp = g_dev_opendev("ad0", 1, 0, 0);
+ g_topology_lock();
+ gp = g_create_geomf("BSD-class", cp->provider, NULL);
+ g_topology_unlock();
+ printf("gp = %p\n", gp);
+ rattle();
+ conff("1");
+ sdumpf("2");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T011/Makefile b/tools/regression/geom/Test/T011/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T011/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T011/ref.conf b/tools/regression/geom/Test/T011/ref.conf
new file mode 100644
index 0000000..8461dce
--- /dev/null
+++ b/tools/regression/geom/Test/T011/ref.conf
@@ -0,0 +1,40 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8087400">
+ <name>DEV-class</name>
+ <geom id="0x80b8300">
+ <class ref="0x8087400"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer id="0x80b9580">
+ <geom ref="0x80b8300"/>
+ <provider ref="0x80b8280"/>
+ <mode>r1w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x80873e0">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x80873c0">
+ <name>MBR</name>
+ </class>
+ <class id="0x8087420">
+ <name>BSD</name>
+ </class>
+ <class id="0x8087320">
+ <name>SIMDISK-class</name>
+ <geom id="0x80b8180">
+ <class ref="0x8087320"/>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider id="0x80b8280">
+ <geom ref="0x80b8180"/>
+ <mode>r1w0e0</mode>
+ <name>ad0</name>
+ <mediasize>1474560</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T011/testprg.c b/tools/regression/geom/Test/T011/testprg.c
new file mode 100644
index 0000000..44e4b69
--- /dev/null
+++ b/tools/regression/geom/Test/T011/testprg.c
@@ -0,0 +1,78 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+ struct g_consumer *cp;
+ struct g_geom *gp;
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.empty.flp.xml");
+ rattle();
+ cp = g_dev_opendev("ad0", 1, 0, 0);
+ g_topology_lock();
+ gp = g_insert_geom("BSD-class", cp);
+ g_topology_unlock();
+ printf("gp = %p\n", gp);
+ rattle();
+ conff("1");
+ sdumpf("2");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T012/Makefile b/tools/regression/geom/Test/T012/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T012/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T012/ref.conf b/tools/regression/geom/Test/T012/ref.conf
new file mode 100644
index 0000000..f6ad633
--- /dev/null
+++ b/tools/regression/geom/Test/T012/ref.conf
@@ -0,0 +1,359 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8087020">
+ <name>SUN</name>
+ <geom id="0x80b8e80">
+ <class ref="0x8087020"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ </config>
+ <consumer id="0x80b9a40">
+ <geom ref="0x80b8e80"/>
+ <provider ref="0x80b8e00"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80c2200">
+ <geom ref="0x80b8e80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0h</name>
+ <mediasize>1343787008</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>7</index>
+ <length>1343787008</length>
+ <seclength>2624584</seclength>
+ <offset>5638115328</offset>
+ <secoffset>11011944</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80c2180">
+ <geom ref="0x80b8e80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0g</name>
+ <mediasize>2149576704</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>6</index>
+ <length>2149576704</length>
+ <seclength>4198392</seclength>
+ <offset>3488538624</offset>
+ <secoffset>6813552</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80c2100">
+ <geom ref="0x80b8e80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0f</name>
+ <mediasize>2149576704</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>5</index>
+ <length>2149576704</length>
+ <seclength>4198392</seclength>
+ <offset>1338961920</offset>
+ <secoffset>2615160</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80c2080">
+ <geom ref="0x80b8e80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0d</name>
+ <mediasize>11124240384</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>3</index>
+ <length>11124240384</length>
+ <seclength>21727032</seclength>
+ <offset>6981902336</offset>
+ <secoffset>13636528</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80c2000">
+ <geom ref="0x80b8e80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0c</name>
+ <mediasize>18108555264</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>18108555264</length>
+ <seclength>35368272</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80b8f80">
+ <geom ref="0x80b8e80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0b</name>
+ <mediasize>1075994624</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>1075994624</length>
+ <seclength>2101552</seclength>
+ <offset>262967296</offset>
+ <secoffset>513608</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80b8f00">
+ <geom ref="0x80b8e80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0a</name>
+ <mediasize>262967296</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>262967296</length>
+ <seclength>513608</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ </geom>
+ <geom id="0x80b8280">
+ <class ref="0x8087020"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ </config>
+ <consumer id="0x80b95c0">
+ <geom ref="0x80b8280"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8500">
+ <geom ref="0x80b8280"/>
+ <mode>r0w0e0</mode>
+ <name>ad0h</name>
+ <mediasize>34629267456</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>7</index>
+ <length>34629267456</length>
+ <seclength>67635288</seclength>
+ <offset>2069028864</offset>
+ <secoffset>4041072</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80b8480">
+ <geom ref="0x80b8280"/>
+ <mode>r0w0e0</mode>
+ <name>ad0c</name>
+ <mediasize>36698296320</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>36698296320</length>
+ <seclength>71676360</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80b8400">
+ <geom ref="0x80b8280"/>
+ <mode>r0w0e0</mode>
+ <name>ad0b</name>
+ <mediasize>539320320</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>539320320</length>
+ <seclength>1053360</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80b8380">
+ <geom ref="0x80b8280"/>
+ <mode>r0w0e0</mode>
+ <name>ad0a</name>
+ <mediasize>1529708544</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>1529708544</length>
+ <seclength>2987712</seclength>
+ <offset>539320320</offset>
+ <secoffset>1053360</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8087120">
+ <name>DEV-class</name>
+ <geom id="0x80c2c00">
+ <class ref="0x8087120"/>
+ <name>ad0h</name>
+ <rank>3</rank>
+ <consumer id="0x80b9bc0">
+ <geom ref="0x80c2c00"/>
+ <provider ref="0x80c2200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c2a80">
+ <class ref="0x8087120"/>
+ <name>ad0g</name>
+ <rank>3</rank>
+ <consumer id="0x80b9b80">
+ <geom ref="0x80c2a80"/>
+ <provider ref="0x80c2180"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c2900">
+ <class ref="0x8087120"/>
+ <name>ad0f</name>
+ <rank>3</rank>
+ <consumer id="0x80b9b40">
+ <geom ref="0x80c2900"/>
+ <provider ref="0x80c2100"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c2780">
+ <class ref="0x8087120"/>
+ <name>ad0d</name>
+ <rank>3</rank>
+ <consumer id="0x80b9b00">
+ <geom ref="0x80c2780"/>
+ <provider ref="0x80c2080"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c2600">
+ <class ref="0x8087120"/>
+ <name>ad0c</name>
+ <rank>3</rank>
+ <consumer id="0x80b9ac0">
+ <geom ref="0x80c2600"/>
+ <provider ref="0x80c2000"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c2480">
+ <class ref="0x8087120"/>
+ <name>ad0b</name>
+ <rank>3</rank>
+ <consumer id="0x80b9a80">
+ <geom ref="0x80c2480"/>
+ <provider ref="0x80b8f80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c2300">
+ <class ref="0x8087120"/>
+ <name>ad0a</name>
+ <rank>3</rank>
+ <consumer id="0x80b99c0">
+ <geom ref="0x80c2300"/>
+ <provider ref="0x80b8f00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c2280">
+ <class ref="0x8087120"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer id="0x80b9c40">
+ <geom ref="0x80c2280"/>
+ <provider ref="0x80b8e00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8b00">
+ <class ref="0x8087120"/>
+ <name>ad0h</name>
+ <rank>3</rank>
+ <consumer id="0x80b9680">
+ <geom ref="0x80b8b00"/>
+ <provider ref="0x80b8500"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8980">
+ <class ref="0x8087120"/>
+ <name>ad0c</name>
+ <rank>3</rank>
+ <consumer id="0x80b9640">
+ <geom ref="0x80b8980"/>
+ <provider ref="0x80b8480"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8780">
+ <class ref="0x8087120"/>
+ <name>ad0b</name>
+ <rank>3</rank>
+ <consumer id="0x80b9600">
+ <geom ref="0x80b8780"/>
+ <provider ref="0x80b8400"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8600">
+ <class ref="0x8087120"/>
+ <name>ad0a</name>
+ <rank>3</rank>
+ <consumer id="0x80b9540">
+ <geom ref="0x80b8600"/>
+ <provider ref="0x80b8380"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8580">
+ <class ref="0x8087120"/>
+ <name>ad0</name>
+ <rank>2</rank>
+ <consumer id="0x80b9700">
+ <geom ref="0x80b8580"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8087100">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x80870e0">
+ <name>MBR</name>
+ </class>
+ <class id="0x8087140">
+ <name>BSD</name>
+ </class>
+ <class id="0x8087040">
+ <name>SIMDISK-class</name>
+ <geom id="0x80b8c80">
+ <class ref="0x8087040"/>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider id="0x80b8e00">
+ <geom ref="0x80b8c80"/>
+ <mode>r0w0e0</mode>
+ <name>ad0</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ <geom id="0x80b8180">
+ <class ref="0x8087040"/>
+ <name>ad0</name>
+ <rank>1</rank>
+ <provider id="0x80b8200">
+ <geom ref="0x80b8180"/>
+ <mode>r0w0e0</mode>
+ <name>ad0</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T012/testprg.c b/tools/regression/geom/Test/T012/testprg.c
new file mode 100644
index 0000000..28645d7
--- /dev/null
+++ b/tools/regression/geom/Test/T012/testprg.c
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ g_sunlabel_init();
+ rattle();
+
+ g_simdisk_xml_load("ad0", "../../Data/disk.sun.da0.xml");
+ rattle();
+ g_simdisk_xml_load("ad0", "../../Data/disk.sun.da1.xml");
+ rattle();
+ conff("1");
+ sdumpf("2");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T013/Makefile b/tools/regression/geom/Test/T013/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T013/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T013/ref.conf b/tools/regression/geom/Test/T013/ref.conf
new file mode 100644
index 0000000..6f8dc7a
--- /dev/null
+++ b/tools/regression/geom/Test/T013/ref.conf
@@ -0,0 +1,413 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8087420">
+ <name>DEV-class</name>
+ <geom id="0x80c1e80">
+ <class ref="0x8087420"/>
+ <name>da2c</name>
+ <rank>3</rank>
+ <consumer id="0x80b9b40">
+ <geom ref="0x80c1e80"/>
+ <provider ref="0x80c1000"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c1d00">
+ <class ref="0x8087420"/>
+ <name>da2b</name>
+ <rank>3</rank>
+ <consumer id="0x80b9b00">
+ <geom ref="0x80c1d00"/>
+ <provider ref="0x80b8f80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c1b80">
+ <class ref="0x8087420"/>
+ <name>da2a</name>
+ <rank>3</rank>
+ <consumer id="0x80b9a00">
+ <geom ref="0x80c1b80"/>
+ <provider ref="0x80b8f00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c1a00">
+ <class ref="0x8087420"/>
+ <name>da1f</name>
+ <rank>3</rank>
+ <consumer id="0x80b99c0">
+ <geom ref="0x80c1a00"/>
+ <provider ref="0x80b8c80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c1880">
+ <class ref="0x8087420"/>
+ <name>da1e</name>
+ <rank>3</rank>
+ <consumer id="0x80b9980">
+ <geom ref="0x80c1880"/>
+ <provider ref="0x80b8c00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c1700">
+ <class ref="0x8087420"/>
+ <name>da1c</name>
+ <rank>3</rank>
+ <consumer id="0x80b9940">
+ <geom ref="0x80c1700"/>
+ <provider ref="0x80b8b80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c1580">
+ <class ref="0x8087420"/>
+ <name>da1b</name>
+ <rank>3</rank>
+ <consumer id="0x80b9900">
+ <geom ref="0x80c1580"/>
+ <provider ref="0x80b8b00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c1400">
+ <class ref="0x8087420"/>
+ <name>da1a</name>
+ <rank>3</rank>
+ <consumer id="0x80b9800">
+ <geom ref="0x80c1400"/>
+ <provider ref="0x80b8a80"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c1280">
+ <class ref="0x8087420"/>
+ <name>da0c</name>
+ <rank>3</rank>
+ <consumer id="0x80b97c0">
+ <geom ref="0x80c1280"/>
+ <provider ref="0x80b8800"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c1100">
+ <class ref="0x8087420"/>
+ <name>da0b</name>
+ <rank>3</rank>
+ <consumer id="0x80b9780">
+ <geom ref="0x80c1100"/>
+ <provider ref="0x80b8780"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80c1080">
+ <class ref="0x8087420"/>
+ <name>da0a</name>
+ <rank>3</rank>
+ <consumer id="0x80b9640">
+ <geom ref="0x80c1080"/>
+ <provider ref="0x80b8700"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8d00">
+ <class ref="0x8087420"/>
+ <name>da2</name>
+ <rank>2</rank>
+ <consumer id="0x80b95c0">
+ <geom ref="0x80b8d00"/>
+ <provider ref="0x80b8400"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8880">
+ <class ref="0x8087420"/>
+ <name>da1</name>
+ <rank>2</rank>
+ <consumer id="0x80b9540">
+ <geom ref="0x80b8880"/>
+ <provider ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8480">
+ <class ref="0x8087420"/>
+ <name>da0</name>
+ <rank>2</rank>
+ <consumer id="0x80b9680">
+ <geom ref="0x80b8480"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8087400">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x80873e0">
+ <name>MBR</name>
+ </class>
+ <class id="0x8087440">
+ <name>BSD</name>
+ <geom id="0x80b8d80">
+ <class ref="0x8087440"/>
+ <name>da2</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ <labeloffset>64</labeloffset>
+ <rawoffset>0</rawoffset>
+ <mbroffset>0</mbroffset>
+ </config>
+ <consumer id="0x80b9ac0">
+ <geom ref="0x80b8d80"/>
+ <provider ref="0x80b8400"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80c1000">
+ <geom ref="0x80b8d80"/>
+ <mode>r0w0e0</mode>
+ <name>da2c</name>
+ <mediasize>74027520</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>74027520</length>
+ <seclength>144585</seclength>
+ <offset>4211343360</offset>
+ <secoffset>8225280</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8f80">
+ <geom ref="0x80b8d80"/>
+ <mode>r0w0e0</mode>
+ <name>da2b</name>
+ <mediasize>4178442240</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>4178442240</length>
+ <seclength>8161020</seclength>
+ <offset>32901120</offset>
+ <secoffset>64260</secoffset>
+ <type>8</type>
+ </config>
+ </provider>
+ <provider id="0x80b8f00">
+ <geom ref="0x80b8d80"/>
+ <mode>r0w0e0</mode>
+ <name>da2a</name>
+ <mediasize>24675840</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>24675840</length>
+ <seclength>48195</seclength>
+ <offset>8225280</offset>
+ <secoffset>16065</secoffset>
+ <type>8</type>
+ </config>
+ </provider>
+ </geom>
+ <geom id="0x80b8900">
+ <class ref="0x8087440"/>
+ <name>da1</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ <labeloffset>64</labeloffset>
+ <rawoffset>0</rawoffset>
+ <mbroffset>0</mbroffset>
+ </config>
+ <consumer id="0x80b98c0">
+ <geom ref="0x80b8900"/>
+ <provider ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8c80">
+ <geom ref="0x80b8900"/>
+ <mode>r0w0e0</mode>
+ <name>da1f</name>
+ <mediasize>16951073792</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>5</index>
+ <length>16951073792</length>
+ <seclength>33107566</seclength>
+ <offset>1358921728</offset>
+ <secoffset>2654144</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8c00">
+ <geom ref="0x80b8900"/>
+ <mode>r0w0e0</mode>
+ <name>da1e</name>
+ <mediasize>20971520</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>4</index>
+ <length>20971520</length>
+ <seclength>40960</seclength>
+ <offset>1337950208</offset>
+ <secoffset>2613184</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8b80">
+ <geom ref="0x80b8900"/>
+ <mode>r0w0e0</mode>
+ <name>da1c</name>
+ <mediasize>18309995520</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>18309995520</length>
+ <seclength>35761710</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>0</type>
+ </config>
+ </provider>
+ <provider id="0x80b8b00">
+ <geom ref="0x80b8900"/>
+ <mode>r0w0e0</mode>
+ <name>da1b</name>
+ <mediasize>1086291968</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>1086291968</length>
+ <seclength>2121664</seclength>
+ <offset>251658240</offset>
+ <secoffset>491520</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8a80">
+ <geom ref="0x80b8900"/>
+ <mode>r0w0e0</mode>
+ <name>da1a</name>
+ <mediasize>251658240</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>251658240</length>
+ <seclength>491520</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ </geom>
+ <geom id="0x80b8500">
+ <class ref="0x8087440"/>
+ <name>da0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ <labeloffset>64</labeloffset>
+ <rawoffset>0</rawoffset>
+ <mbroffset>0</mbroffset>
+ </config>
+ <consumer id="0x80b9740">
+ <geom ref="0x80b8500"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8800">
+ <geom ref="0x80b8500"/>
+ <mode>r0w0e0</mode>
+ <name>da0c</name>
+ <mediasize>4335206400</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>4335206400</length>
+ <seclength>8467200</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>0</type>
+ </config>
+ </provider>
+ <provider id="0x80b8780">
+ <geom ref="0x80b8500"/>
+ <mode>r0w0e0</mode>
+ <name>da0b</name>
+ <mediasize>270925824</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>270925824</length>
+ <seclength>529152</seclength>
+ <offset>4064280576</offset>
+ <secoffset>7938048</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8700">
+ <geom ref="0x80b8500"/>
+ <mode>r0w0e0</mode>
+ <name>da0a</name>
+ <mediasize>4064280576</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>4064280576</length>
+ <seclength>7938048</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8087340">
+ <name>SIMDISK-class</name>
+ <geom id="0x80b8380">
+ <class ref="0x8087340"/>
+ <name>da2</name>
+ <rank>1</rank>
+ <provider id="0x80b8400">
+ <geom ref="0x80b8380"/>
+ <mode>r0w0e0</mode>
+ <name>da2</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ <geom id="0x80b8280">
+ <class ref="0x8087340"/>
+ <name>da1</name>
+ <rank>1</rank>
+ <provider id="0x80b8300">
+ <geom ref="0x80b8280"/>
+ <mode>r0w0e0</mode>
+ <name>da1</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ <geom id="0x80b8180">
+ <class ref="0x8087340"/>
+ <name>da0</name>
+ <rank>1</rank>
+ <provider id="0x80b8200">
+ <geom ref="0x80b8180"/>
+ <mode>r0w0e0</mode>
+ <name>da0</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T013/testprg.c b/tools/regression/geom/Test/T013/testprg.c
new file mode 100644
index 0000000..d014161
--- /dev/null
+++ b/tools/regression/geom/Test/T013/testprg.c
@@ -0,0 +1,71 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_dev_init(NULL);
+ rattle();
+
+
+ g_simdisk_xml_load("da0", "../../Data/disk.beast.da0.xml");
+ g_simdisk_xml_load("da1", "../../Data/disk.alpha.da0.xml");
+ g_simdisk_xml_load("da2", "../../Data/disk.alpha2.da0.xml");
+ rattle();
+ conff("1");
+ printf("Done\n");
+ done();
+ return (0);
+}
diff --git a/tools/regression/geom/Test/T014/Makefile b/tools/regression/geom/Test/T014/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T014/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T014/ref.conf b/tools/regression/geom/Test/T014/ref.conf
new file mode 100644
index 0000000..a1c0e2a
--- /dev/null
+++ b/tools/regression/geom/Test/T014/ref.conf
@@ -0,0 +1,230 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8087140">
+ <name>DEV-class</name>
+ <geom id="0x80b8f80">
+ <class ref="0x8087140"/>
+ <name>wd0s1f</name>
+ <rank>4</rank>
+ <consumer id="0x80b9900">
+ <geom ref="0x80b8f80"/>
+ <provider ref="0x80b8a00"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8e00">
+ <class ref="0x8087140"/>
+ <name>wd0s1e</name>
+ <rank>4</rank>
+ <consumer id="0x80b98c0">
+ <geom ref="0x80b8e00"/>
+ <provider ref="0x80b8980"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8c80">
+ <class ref="0x8087140"/>
+ <name>wd0s1c</name>
+ <rank>4</rank>
+ <consumer id="0x80b9880">
+ <geom ref="0x80b8c80"/>
+ <provider ref="0x80b8900"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8b00">
+ <class ref="0x8087140"/>
+ <name>wd0s1b</name>
+ <rank>4</rank>
+ <consumer id="0x80b9840">
+ <geom ref="0x80b8b00"/>
+ <provider ref="0x80b8880"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8a80">
+ <class ref="0x8087140"/>
+ <name>wd0s1a</name>
+ <rank>4</rank>
+ <consumer id="0x80b9640">
+ <geom ref="0x80b8a80"/>
+ <provider ref="0x80b8800"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8480">
+ <class ref="0x8087140"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <consumer id="0x80b9540">
+ <geom ref="0x80b8480"/>
+ <provider ref="0x80b8400"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80b8280">
+ <class ref="0x8087140"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <consumer id="0x80b9580">
+ <geom ref="0x80b8280"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8087020">
+ <name>PC98</name>
+ <geom id="0x80b8300">
+ <class ref="0x8087020"/>
+ <name>wd0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8704</frontstuff>
+ </config>
+ <consumer id="0x80b9600">
+ <geom ref="0x80b8300"/>
+ <provider ref="0x80b8200"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8400">
+ <geom ref="0x80b8300"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1</name>
+ <mediasize>1626603520</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>1626603520</length>
+ <seclength>3176960</seclength>
+ <offset>69632</offset>
+ <secoffset>136</secoffset>
+ <type>50324</type>
+ <sname>FreeBSD</sname>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8087040">
+ <name>SUN</name>
+ </class>
+ <class id="0x8087120">
+ <name>MBREXT</name>
+ </class>
+ <class id="0x8087100">
+ <name>MBR</name>
+ </class>
+ <class id="0x8087160">
+ <name>BSD</name>
+ <geom id="0x80b8600">
+ <class ref="0x8087160"/>
+ <name>wd0s1</name>
+ <rank>3</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ <labeloffset>512</labeloffset>
+ <rawoffset>136</rawoffset>
+ <mbroffset>69632</mbroffset>
+ </config>
+ <consumer id="0x80b9800">
+ <geom ref="0x80b8600"/>
+ <provider ref="0x80b8400"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80b8a00">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1f</name>
+ <mediasize>1390673920</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>5</index>
+ <length>1390673920</length>
+ <seclength>2716160</seclength>
+ <offset>235929600</offset>
+ <secoffset>460800</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8980">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1e</name>
+ <mediasize>52428800</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>4</index>
+ <length>52428800</length>
+ <seclength>102400</seclength>
+ <offset>183500800</offset>
+ <secoffset>358400</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ <provider id="0x80b8900">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1c</name>
+ <mediasize>1626603520</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>1626603520</length>
+ <seclength>3176960</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>0</type>
+ </config>
+ </provider>
+ <provider id="0x80b8880">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1b</name>
+ <mediasize>104857600</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>104857600</length>
+ <seclength>204800</seclength>
+ <offset>78643200</offset>
+ <secoffset>153600</secoffset>
+ <type>1</type>
+ </config>
+ </provider>
+ <provider id="0x80b8800">
+ <geom ref="0x80b8600"/>
+ <mode>r0w0e0</mode>
+ <name>wd0s1a</name>
+ <mediasize>78643200</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>78643200</length>
+ <seclength>153600</seclength>
+ <offset>0</offset>
+ <secoffset>0</secoffset>
+ <type>7</type>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8087060">
+ <name>SIMDISK-class</name>
+ <geom id="0x80b8180">
+ <class ref="0x8087060"/>
+ <name>wd0</name>
+ <rank>1</rank>
+ <provider id="0x80b8200">
+ <geom ref="0x80b8180"/>
+ <mode>r0w0e0</mode>
+ <name>wd0</name>
+ <mediasize>1099511627776</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T014/testprg.c b/tools/regression/geom/Test/T014/testprg.c
new file mode 100644
index 0000000..eb76581
--- /dev/null
+++ b/tools/regression/geom/Test/T014/testprg.c
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_bsd_init();
+ g_mbr_init();
+ g_mbrext_init();
+ g_sunlabel_init();
+ g_pc98_init();
+ g_dev_init(NULL);
+ rattle();
+
+
+ g_simdisk_xml_load("wd0", "../../Data/disk.pc98.wdc0.xml");
+ rattle();
+ conff("1");
+ sdumpf("2");
+ printf("Done\n");
+ done();
+ return (0);
+}
+
diff --git a/tools/regression/geom/Test/T015/Makefile b/tools/regression/geom/Test/T015/Makefile
new file mode 100644
index 0000000..18fd955
--- /dev/null
+++ b/tools/regression/geom/Test/T015/Makefile
@@ -0,0 +1,2 @@
+# $FreeBSD$
+.include <bsd.prog.mk>
diff --git a/tools/regression/geom/Test/T015/ref.conf b/tools/regression/geom/Test/T015/ref.conf
new file mode 100644
index 0000000..5775799
--- /dev/null
+++ b/tools/regression/geom/Test/T015/ref.conf
@@ -0,0 +1,121 @@
+<mesh>
+ <FreeBSD>$FreeBSD$</FreeBSD>
+ <class id="0x8087020">
+ <name>DEV-class</name>
+ <geom id="0x80bb680">
+ <class ref="0x8087020"/>
+ <name>da0p2</name>
+ <rank>3</rank>
+ <consumer id="0x80bc640">
+ <geom ref="0x80bb680"/>
+ <provider ref="0x80bb500"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bb600">
+ <class ref="0x8087020"/>
+ <name>da0p1</name>
+ <rank>3</rank>
+ <consumer id="0x80bc600">
+ <geom ref="0x80bb600"/>
+ <provider ref="0x80bb480"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bb580">
+ <class ref="0x8087020"/>
+ <name>da0p0</name>
+ <rank>3</rank>
+ <consumer id="0x80bc500">
+ <geom ref="0x80bb580"/>
+ <provider ref="0x80bb400"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ <geom id="0x80bb280">
+ <class ref="0x8087020"/>
+ <name>da0</name>
+ <rank>2</rank>
+ <consumer id="0x80bc540">
+ <geom ref="0x80bb280"/>
+ <provider ref="0x80bb200"/>
+ <mode>r0w0e0</mode>
+ </consumer>
+ </geom>
+ </class>
+ <class id="0x8087040">
+ <name>APPLE</name>
+ <geom id="0x80bb300">
+ <class ref="0x8087040"/>
+ <name>da0</name>
+ <rank>2</rank>
+ <config>
+ <frontstuff>8192</frontstuff>
+ </config>
+ <consumer id="0x80bc5c0">
+ <geom ref="0x80bb300"/>
+ <provider ref="0x80bb200"/>
+ <mode>r0w0e0</mode>
+ <config>
+ </config>
+ </consumer>
+ <provider id="0x80bb500">
+ <geom ref="0x80bb300"/>
+ <mode>r0w0e0</mode>
+ <name>da0p2</name>
+ <mediasize>16384</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>2</index>
+ <length>16384</length>
+ <seclength>32</seclength>
+ <offset>32768</offset>
+ <secoffset>64</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bb480">
+ <geom ref="0x80bb300"/>
+ <mode>r0w0e0</mode>
+ <name>da0p1</name>
+ <mediasize>32256</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>1</index>
+ <length>32256</length>
+ <seclength>63</seclength>
+ <offset>512</offset>
+ <secoffset>1</secoffset>
+ </config>
+ </provider>
+ <provider id="0x80bb400">
+ <geom ref="0x80bb300"/>
+ <mode>r0w0e0</mode>
+ <name>da0p0</name>
+ <mediasize>366481408</mediasize>
+ <sectorsize>512</sectorsize>
+ <config>
+ <index>0</index>
+ <length>366481408</length>
+ <seclength>715784</seclength>
+ <offset>49152</offset>
+ <secoffset>96</secoffset>
+ </config>
+ </provider>
+ </geom>
+ </class>
+ <class id="0x8087000">
+ <name>SIMDISK-class</name>
+ <geom id="0x80bb180">
+ <class ref="0x8087000"/>
+ <name>da0</name>
+ <rank>1</rank>
+ <provider id="0x80bb200">
+ <geom ref="0x80bb180"/>
+ <mode>r0w0e0</mode>
+ <name>da0</name>
+ <mediasize>366530560</mediasize>
+ <sectorsize>512</sectorsize>
+ </provider>
+ </geom>
+ </class>
+</mesh>
diff --git a/tools/regression/geom/Test/T015/testprg.c b/tools/regression/geom/Test/T015/testprg.c
new file mode 100644
index 0000000..cd7f4b8
--- /dev/null
+++ b/tools/regression/geom/Test/T015/testprg.c
@@ -0,0 +1,67 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+void *
+thread_sim(void *ptr __unused)
+{
+
+ rattle();
+ g_simdisk_init();
+ g_apple_init();
+ g_dev_init(NULL);
+ rattle();
+
+
+ g_simdisk_xml_load("da0", "../../Data/disk.apple.xml");
+ rattle();
+ conff("1");
+ printf("Done\n");
+ done();
+ return (0);
+}
diff --git a/tools/regression/geom/geom.c b/tools/regression/geom/geom.c
new file mode 100644
index 0000000..68217b8
--- /dev/null
+++ b/tools/regression/geom/geom.c
@@ -0,0 +1,196 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+#include <geom/geom_int.h>
+
+void
+conff(const char *file)
+{
+ FILE *f;
+ char *s;
+ struct sbuf *sb;
+
+ printf(">> conf to %s\n", file);
+ asprintf(&s, "_%s.conf", file);
+ f = fopen(s, "w");
+ if (f == NULL)
+ err(1, s);
+ sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
+ sbuf_clear(sb);
+ g_confxml(sb);
+ fputs(sbuf_data(sb), f);
+ fclose(f);
+ free(s);
+}
+
+static void *
+thread_up(void *ptr)
+{
+ struct thread *tp = ptr;
+ int error;
+
+ printf("Running %s\n", tp->name);
+ error = pthread_cond_init(&ptc_up, NULL);
+ if (error)
+ err(1, "pthread_cond_init(ptc_up)");
+ error = pthread_mutex_init(&ptm_up, NULL);
+ if (error)
+ err(1, "pthread_mutex_init(ptm_up)");
+
+ error = pthread_mutex_lock(&ptm_up);
+ if (error)
+ err(1, "pthread_mutex_init(ptm_up)");
+ for (;;) {
+ g_io_schedule_up(tp);
+ error = pthread_cond_wait(&ptc_up, &ptm_up);
+ }
+}
+
+static void *
+thread_down(void *ptr)
+{
+ struct thread *tp = ptr;
+ int error;
+
+ printf("Running %s\n", tp->name);
+ error = pthread_cond_init(&ptc_down, NULL);
+ if (error)
+ err(1, "pthread_cond_init(ptc_down)");
+ error = pthread_mutex_init(&ptm_down, NULL);
+ if (error)
+ err(1, "pthread_mutex_init(ptm_down)");
+ error = pthread_mutex_lock(&ptm_down);
+ if (error)
+ err(1, "pthread_mutex_init(ptm_down)");
+ for (;;) {
+ g_io_schedule_down(tp);
+ error = pthread_cond_wait(&ptc_down, &ptm_down);
+ }
+}
+
+static void *
+thread_event(void *ptr)
+{
+ struct thread *tp = ptr;
+ int error;
+
+ printf("Running %s\n", tp->name);
+ error = pthread_cond_init(&ptc_event, NULL);
+ if (error)
+ err(1, "pthread_cond_init(ptc_event)");
+ error = pthread_mutex_init(&ptm_event, NULL);
+ if (error)
+ err(1, "pthread_mutex_init(ptm_event)");
+ error = pthread_mutex_lock(&ptm_event);
+ if (error)
+ err(1, "pthread_mutex_init(ptm_event)");
+ for (;;) {
+ g_run_events();
+ error = pthread_cond_wait(&ptc_event, &ptm_event);
+ }
+}
+
+
+int
+main(int argc __unused, char **argv __unused)
+{
+ int ch;
+
+ while ((ch = getopt(argc, argv, "bt")) != -1) {
+ switch (ch) {
+ case 'b':
+ g_debugflags |= G_T_BIO;
+ break;
+ case 't':
+ g_debugflags |= G_T_TOPOLOGY;
+ break;
+ }
+ }
+
+
+ setbuf(stdout, NULL);
+ printf("Sizeof g_class = %d\n", sizeof(struct g_class));
+ printf("Sizeof g_geom = %d\n", sizeof(struct g_geom));
+ printf("Sizeof g_consumer = %d\n", sizeof(struct g_consumer));
+ printf("Sizeof g_provider = %d\n", sizeof(struct g_provider));
+ printf("Sizeof g_event = %d\n", sizeof(struct g_event));
+ g_init();
+ new_thread(thread_up, "UP");
+ new_thread(thread_down, "DOWN");
+ new_thread(thread_event, "EVENT");
+ new_thread(thread_sim, "SIM");
+
+ while (1) {
+ sleep (1);
+ secrethandshake();
+ }
+}
+
+void
+sdumpf(const char *file)
+{
+ FILE *f;
+ char *s;
+ struct sbuf *sb;
+
+ printf(">> dump to %s\n", file);
+ asprintf(&s, "_%s.dot", file);
+ f = fopen(s, "w");
+ if (f == NULL)
+ err(1, s);
+ sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
+ sbuf_clear(sb);
+ g_confdot(sb);
+ fprintf(f, "%s", sbuf_data(sb));
+ fclose(f);
+ free(s);
+ asprintf(&s, "dot -Tps _%s.dot > _%s.ps", file, file);
+ system(s);
+ free(s);
+}
+
diff --git a/tools/regression/geom/geom_kernsim.c b/tools/regression/geom/geom_kernsim.c
new file mode 100644
index 0000000..8b05154
--- /dev/null
+++ b/tools/regression/geom/geom_kernsim.c
@@ -0,0 +1,288 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sched.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <geom/geom.h>
+#include <geom/geom_int.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <machine/atomic.h>
+
+#include <pthread.h>
+
+#define NTHREAD 30
+static struct thread thr[NTHREAD];
+
+static int weredone;
+int g_debugflags;
+int bootverbose = 1;
+
+void
+done(void)
+{
+
+ rattle();
+ weredone = 1;
+ exit(0);
+}
+
+void
+secrethandshake()
+{
+ int i;
+
+ if (weredone)
+ exit(0);
+ for (i = 0; i < NTHREAD; i++) {
+ if (thr[i].pid == 0)
+ continue;
+ if (kill(thr[i].pid, 0)) {
+ printf("\n\nMissing process for thread %d (\"%s\")\n",
+ i, thr[i].name);
+ goto scram;
+ }
+ }
+ return;
+
+scram:
+ for (i = 0; i < NTHREAD; i++) {
+ if (thr[i].pid == 0)
+ continue;
+ if (thr[i].pid == getpid())
+ continue;
+ kill(thr[i].pid, 9);
+ }
+ exit(9);
+}
+
+
+void
+biodone(struct bio *bp)
+{
+ bp->bio_flags |= BIO_DONE;
+ if (bp->bio_done != NULL)
+ bp->bio_done(bp);
+}
+
+int
+biowait(struct bio *bp, const char *wchan __unused)
+{
+
+ while ((bp->bio_flags & BIO_DONE) == 0)
+ usleep(10000);
+ if (!(bp->bio_flags & BIO_ERROR))
+ return (0);
+ if (bp->bio_error)
+ return (bp->bio_error);
+ return (EIO);
+}
+
+void
+wakeup(void *chan)
+{
+
+ if (chan == &g_wait_event)
+ pthread_cond_signal(&ptc_event);
+ else if (chan == &g_wait_up)
+ pthread_cond_signal(&ptc_up);
+ else if (chan == &g_wait_down)
+ pthread_cond_signal(&ptc_down);
+ else
+ return;
+}
+
+int hz;
+
+int
+tsleep(void *chan __unused, int pri __unused, const char *wmesg __unused, int timo)
+{
+
+ usleep(timo);
+ return (0);
+}
+
+void
+rattle()
+{
+ int i;
+
+ pthread_yield();
+
+ for (;;) {
+ i = pthread_mutex_trylock(&ptm_up);
+ if (i != EBUSY) {
+ i = pthread_mutex_trylock(&ptm_down);
+ if (i != EBUSY) {
+ i = pthread_mutex_trylock(&ptm_event);
+ if (i != EBUSY)
+ break;
+ pthread_mutex_unlock(&ptm_down);
+ }
+ pthread_mutex_unlock(&ptm_up);
+ }
+ usleep(100000);
+ }
+ pthread_mutex_unlock(&ptm_event);
+ pthread_mutex_unlock(&ptm_down);
+ pthread_mutex_unlock(&ptm_up);
+ return;
+}
+
+
+void
+new_thread(void *(*func)(void *arg), const char *name)
+{
+ struct thread *tp;
+ static int nextt;
+ int error;
+
+ tp = thr + nextt++;
+ error = pthread_create(&tp->tid, NULL, func, tp);
+ if (error)
+ err(1, "pthread_create(%s)", name);
+ tp->name = strdup(name);
+ printf("New Thread %d %s %p %d\n", tp - thr, name, tp, tp->pid);
+}
+
+#define FASCIST 0
+
+void *
+g_malloc(int size, int flags)
+{
+ void *p;
+
+#if FASCIST
+ p = malloc(4096);
+ printf("Malloc %p \n", p);
+#else
+ p = malloc(size);
+#endif
+ if (flags & M_ZERO)
+ memset(p, 0, size);
+ else
+ memset(p, 0xd0, size);
+ return (p);
+}
+
+void
+g_free(void *ptr)
+{
+
+ secrethandshake();
+#if FASCIST
+ printf("Free %p \n", ptr);
+ munmap(ptr, 4096);
+#else
+ free(ptr);
+#endif
+}
+
+static pthread_mutex_t pt_topology;
+
+void
+g_init(void)
+{
+
+ pthread_mutex_init(&pt_topology, NULL);
+ g_io_init();
+ g_event_init();
+}
+
+void
+g_topology_lock()
+{
+
+ pthread_mutex_lock(&pt_topology);
+}
+
+void
+g_topology_unlock()
+{
+
+ pthread_mutex_unlock(&pt_topology);
+}
+
+void
+g_topology_assert()
+{
+
+#if 0
+ if (topology_lock == getpid())
+ return;
+ KASSERT(1 == 0, ("Lacking topology_lock"));
+#endif
+}
+
+void
+mtx_init(struct mtx *mp, const char *bla __unused, const char *yak __unused, int foo __unused)
+{
+
+ pthread_mutex_init((pthread_mutex_t *)&mp->mtx_object, NULL);
+}
+
+void
+mtx_destroy(struct mtx *mp)
+{
+
+ pthread_mutex_destroy((pthread_mutex_t *)&mp->mtx_object);
+}
+
+void
+mtx_lock(struct mtx *mp)
+{
+
+ pthread_mutex_lock((pthread_mutex_t *)&mp->mtx_object);
+}
+
+void
+mtx_unlock(struct mtx *mp)
+{
+
+ pthread_mutex_unlock((pthread_mutex_t *)&mp->mtx_object);
+}
+
+struct mtx Giant;
+
diff --git a/tools/regression/geom/geom_sim.c b/tools/regression/geom/geom_sim.c
new file mode 100644
index 0000000..cdb145f
--- /dev/null
+++ b/tools/regression/geom/geom_sim.c
@@ -0,0 +1,185 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/sbuf.h>
+#include <geom/geom.h>
+
+int
+thread_sim(void *ptr)
+{
+ struct thread *tp = ptr;
+ struct g_consumer *cp;
+
+ printf("Running %s\n", tp->name);
+ rattle();
+ g_topology_lock();
+ printf("--- g_simdisk_init();\n");
+ g_simdisk_init();
+ printf("--- g_bsd_init();\n");
+ g_bsd_init();
+ printf("--- g_mbr_init();\n");
+ g_mbr_init();
+ g_mbrext_init();
+ printf("--- g_dev_init();\n");
+ g_dev_init(NULL);
+ g_topology_unlock();
+ rattle();
+
+#if 0
+ g_simdisk_new("ad0", "/dev/ad0");
+#else
+ g_simdisk_xml_load("ad0", "Data/disk.typo.ad0.xml");
+ // g_simdisk_xml_load("ad0", "Data/disk.msdos.ext.xml");
+ // g_simdisk_xml_load("ad0", "Data/disk.far.ad0.xml");
+#endif
+ rattle();
+ dumpf("1");
+ conff("1");
+ sdumpf("2");
+ g_simdisk_xml_save("ad0", "_ad0");
+ g_simdisk_destroy("ad0");
+ rattle();
+ dumpf("1");
+ conff("1");
+ sdumpf("2");
+
+ printf("Done\n");
+ exit (0);
+
+#if 0
+ printf("--- g_dev_finddev(\"ad0s1a\");\n");
+ cp = g_dev_finddev("ad0s1a");
+ if (cp == NULL)
+ errx(1, "argh!");
+ printf("--- g_access_rel(cp, 1, 1, 1);\n");
+ g_access_rel(cp, 1, 1, 1);
+ sleep(3);
+ dumpf("1");
+ conff("1");
+ sdumpf("2");
+
+ printf("--- g_access_rel(cp, -1, -1, -1);\n");
+ g_access_rel(cp, -1, -1, -1);
+ sleep(3);
+ dumpf("1");
+ conff("1");
+ sdumpf("2");
+
+ printf("--- g_dev_finddev(\"ad0\");\n");
+ cp = g_dev_finddev("ad0");
+ if (cp == NULL)
+ errx(1, "argh!");
+ printf("--- g_access_rel(cp, 1, 1, 1);\n");
+ g_access_rel(cp, 1, 1, 1);
+ sleep(3);
+ dumpf("1");
+ conff("1");
+ sdumpf("2");
+
+ printf("--- g_access_rel(cp, -1, -1, -1);\n");
+ g_access_rel(cp, -1, -1, -1);
+
+ sleep (3);
+ dumpf("1");
+ conff("1");
+ sdumpf("2");
+#if 0
+ printf("--- Simulation done...\n");
+ for (;;)
+ sleep(1);
+ exit (0);
+#endif
+
+#endif
+#if 1
+ g_simdisk_new("../Disks/typo.freebsd.dk:ad0", "ad1");
+#else
+ g_simdisk_xml_load("ad0", "disk.critter.ad0.xml");
+#endif
+ sleep (3);
+ dumpf("1");
+ conff("1");
+ sdumpf("2");
+ g_simdisk_xml_save("ad1", "_ad1");
+
+#if 1
+ sleep (3);
+ g_simdisk_new("/home/phk/phk2001/msdos_6_2-1.flp", "fd0");
+ sleep (3);
+ dumpf("1");
+ conff("1");
+ sdumpf("2");
+ g_simdisk_xml_save("fd0", "_fd0");
+
+ sleep (3);
+ g_simdisk_new("/home/phk/phk2001/kern.flp", "fd1");
+ sleep (3);
+ dumpf("1");
+ conff("1");
+ sdumpf("2");
+ g_simdisk_xml_save("fd1", "_fd1");
+
+ sleep (3);
+ g_simdisk_new("../Disks/far:ad0", "ad2");
+ sleep (3);
+ dumpf("1");
+ conff("1");
+ sdumpf("2");
+ g_simdisk_xml_save("ad2", "_ad2");
+
+#endif
+ sleep (3);
+ g_simdisk_destroy("ad1");
+ sleep (5);
+ dumpf("1");
+ conff("1");
+ sdumpf("2");
+
+ printf("Simulation done...\n");
+
+ exit (0);
+}
+
diff --git a/tools/regression/geom/geom_sim.h b/tools/regression/geom/geom_sim.h
new file mode 100644
index 0000000..a28d7e7
--- /dev/null
+++ b/tools/regression/geom/geom_sim.h
@@ -0,0 +1,176 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <pthread.h>
+
+pthread_cond_t ptc_up, ptc_down, ptc_event;
+pthread_mutex_t ptm_up, ptm_down, ptm_event;
+
+#define CTASSERT(foo)
+
+#define DROP_GIANT()
+#define PICKUP_GIANT()
+
+#define EDIRIOCTL -6
+
+#define copyin(foo, bar, barf) 0
+
+/* bio.h */
+
+struct bio {
+ enum {
+ BIO_INVALID = 0,
+ BIO_READ = 1,
+ BIO_WRITE = 2,
+ BIO_DELETE = 4,
+ BIO_GETATTR = 8,
+ BIO_SETATTR = 16
+ } bio_cmd;
+ struct { int foo; } stats;
+ TAILQ_ENTRY(bio) bio_queue;
+ TAILQ_ENTRY(bio) bio_sort;
+ struct g_consumer *bio_from;
+ struct g_provider *bio_to;
+ void (*bio_done)(struct bio *);
+
+ off_t bio_offset;
+ off_t bio_length;
+ off_t bio_completed;
+ void *bio_data;
+ const char *bio_attribute; /* BIO_GETATTR/BIO_SETATTR */
+ int bio_error;
+ u_int bio_children; /* Number of spawned bios */
+
+
+ struct bio *bio_linkage;
+ int bio_flags;
+#define BIO_DONE 0x1
+#define BIO_ERROR 0x2
+};
+
+void biodone(struct bio *bp);
+int biowait(struct bio *bp, const char *wchan);
+
+/* geom_dev.c */
+void g_dev_init(void *junk);
+struct g_consumer *g_dev_opendev(const char *name, int w, int r, int e);
+int g_dev_request(const char *name, struct bio *bp);
+
+/* geom_kernsim.c */
+struct thread {
+ char *name;
+ pthread_t tid;
+ int pid;
+ void *wchan;
+ const char *wmesg;
+ int pipe[2];
+};
+
+void done(void);
+void rattle(void);
+void secrethandshake(void);
+void wakeup(void *chan);
+int tsleep __P((void *chan, int pri, const char *wmesg, int timo));
+#define PPAUSE 0
+extern int hz;
+
+void new_thread(void *(*func)(void *arg), const char *name);
+
+extern int bootverbose;
+#define KASSERT(cond, txt) do {if (!(cond)) {printf txt; conff("err"); abort();}} while(0)
+#define M_WAITOK 0
+#define M_NOWAIT 1
+#define M_ZERO 2
+
+extern struct mtx Giant;
+void *g_malloc(int size, int flags);
+void g_free(void *ptr);
+
+#define MTX_DEF 0
+#define MTX_SPIN 1
+void mtx_lock(struct mtx *);
+void mtx_lock_spin(struct mtx *);
+void mtx_unlock(struct mtx *);
+void mtx_unlock_spin(struct mtx *);
+void mtx_init(struct mtx *, const char *, const char *, int);
+void mtx_destroy(struct mtx *);
+
+#define MALLOC_DECLARE(foo) /* */
+
+void g_topology_lock(void);
+void g_topology_unlock(void);
+void g_topology_assert(void);
+
+
+/* geom_simdisk.c */
+void g_simdisk_init(void);
+void g_simdisk_destroy(const char *);
+struct g_geom *g_simdisk_new(const char *, const char *);
+struct g_geom * g_simdisk_xml_load(const char *name, const char *file);
+void g_simdisk_xml_save(const char *name, const char *file);
+void g_simdisk_stop(const char *name);
+void g_simdisk_restart(const char *name);
+
+#define DECLARE_GEOM_CLASS(class, name) \
+void name##_init(void); \
+ void \
+ name##_init(void) \
+ { \
+ g_add_class(&class); \
+ }
+
+void g_aes_init(void);
+void g_apple_init(void);
+void g_bsd_init(void);
+void g_mbr_init(void);
+void g_mbrext_init(void);
+void g_sunlabel_init(void);
+void g_pc98_init(void);
+
+
+void *thread_sim(void *ptr);
+
+void dumpf(const char *file);
+void conff(const char *file);
+void sdumpf(const char *file);
+
+#define THR_MAIN 0
+#define THR_UP 1
+#define THR_DOWN 2
+#define THR_EVENT 3
+
+#define EJUSTRETURN (-2)
diff --git a/tools/regression/geom/geom_simdev.c b/tools/regression/geom/geom_simdev.c
new file mode 100644
index 0000000..4221742
--- /dev/null
+++ b/tools/regression/geom/geom_simdev.c
@@ -0,0 +1,159 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <sys/param.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <geom/geom.h>
+
+static g_orphan_t g_dev_orphan;
+
+static struct g_geom *
+dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
+{
+ struct g_geom *gp;
+ struct g_consumer *cp;
+
+ g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name);
+ g_topology_assert();
+ LIST_FOREACH(cp, &pp->consumers, consumers) {
+ if (cp->geom->class == mp) {
+ g_topology_unlock();
+ return (NULL);
+ }
+ }
+ gp = g_new_geomf(mp, pp->name);
+ gp->orphan = g_dev_orphan;
+ cp = g_new_consumer(gp);
+ g_attach(cp, pp);
+ return (gp);
+}
+
+
+static void
+g_dev_orphan(struct g_consumer *cp)
+{
+ struct g_geom *gp;
+
+ gp = cp->geom;
+ gp->flags |= G_GEOM_WITHER;
+ g_trace(G_T_TOPOLOGY, "g_dev_orphan(%p(%s))", cp, gp->name);
+ if (cp->biocount > 0)
+ return;
+ if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0)
+ g_access_rel(cp, -cp->acr, -cp->acw, -cp->ace);
+ g_detach(cp);
+ g_destroy_consumer(cp);
+ g_destroy_geom(gp);
+}
+
+
+static struct g_class dev_class = {
+ "DEV-class",
+ dev_taste,
+ NULL,
+ G_CLASS_INITIALIZER
+};
+
+static struct g_geom *
+g_dev_findg(const char *name)
+{
+ struct g_geom *gp;
+
+ LIST_FOREACH(gp, &dev_class.geom, geom)
+ if (!strcmp(gp->name, name))
+ break;
+ return (gp);
+}
+
+void
+g_dev_init(void *junk __unused)
+{
+
+ g_add_class(&dev_class);
+}
+
+
+struct g_consumer *
+g_dev_opendev(const char *name, int r, int w, int e)
+{
+ struct g_geom *gp;
+ struct g_consumer *cp;
+ int error;
+
+ gp = g_dev_findg(name);
+ if (gp == NULL)
+ return (NULL);
+ g_topology_lock();
+ cp = LIST_FIRST(&gp->consumer);
+ error = g_access_rel(cp, r, w, e);
+ g_topology_unlock();
+ if (error)
+ return(NULL);
+ return(cp);
+}
+
+static void
+g_dev_done(struct bio *bp)
+{
+
+ if (bp->bio_from->biocount > 0)
+ return;
+ g_topology_lock();
+ g_dev_orphan(bp->bio_from);
+ g_topology_unlock();
+}
+
+int
+g_dev_request(const char *name, struct bio *bp)
+{
+ struct g_geom *gp;
+
+ gp = g_dev_findg(name);
+ if (gp == NULL)
+ return (-1);
+ bp->bio_done = g_dev_done;
+ g_io_request(bp, LIST_FIRST(&gp->consumer));
+ return (1);
+}
diff --git a/tools/regression/geom/geom_simdisk.c b/tools/regression/geom/geom_simdisk.c
new file mode 100644
index 0000000..ed9ed1f
--- /dev/null
+++ b/tools/regression/geom/geom_simdisk.c
@@ -0,0 +1,259 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <err.h>
+#include <sys/errno.h>
+#include <sys/stat.h>
+#include <geom/geom.h>
+
+#include "geom_simdisk.h"
+
+struct g_class g_simdisk_class = {
+ "SIMDISK-class",
+ NULL,
+ NULL,
+ G_CLASS_INITIALIZER
+};
+
+static void
+g_simdisk_start(struct bio *bp)
+{
+ off_t ot, off;
+ unsigned nsec;
+ u_char *op;
+ int i;
+ struct g_geom *gp = bp->bio_to->geom;
+ struct simdisk_softc *sc = gp->softc;
+ struct sector *dsp;
+
+
+ printf("SIMDISK: OP%d %qd at %qd\n",
+ bp->bio_cmd, bp->bio_length, bp->bio_offset);
+ if (sc->stop) {
+ TAILQ_INSERT_TAIL(&sc->sort, bp, bio_sort);
+ return;
+ }
+ if (bp->bio_cmd == BIO_READ) {
+ off = bp->bio_offset;
+ nsec = bp->bio_length /= sc->sectorsize;
+ op = bp->bio_data;
+ while (nsec) {
+ dsp = g_simdisk_findsector(sc, off, 0);
+ if (dsp == NULL) {
+ dsp = g_simdisk_findsector(sc, off, 1);
+ ot = lseek(sc->fd, off, SEEK_SET);
+ if (ot != off) {
+ g_io_deliver(bp, EIO);
+ return;
+ }
+ i = read(sc->fd, dsp->data, sc->sectorsize);
+ if (i < 0) {
+ g_io_deliver(bp, errno);
+ return;
+ }
+ if (i == 0)
+ memset(dsp->data, 0, sc->sectorsize);
+ }
+ memcpy(op, dsp->data, sc->sectorsize);
+ bp->bio_completed += sc->sectorsize;
+ off += sc->sectorsize;
+ op += sc->sectorsize;
+ nsec--;
+ }
+ g_io_deliver(bp, 0);
+ return;
+ }
+ if (bp->bio_cmd == BIO_GETATTR) {
+ if (g_handleattr_int(bp, "GEOM::fwsectors", sc->fwsectors))
+ return;
+ if (g_handleattr_int(bp, "GEOM::fwheads", sc->fwheads))
+ return;
+ if (g_handleattr_int(bp, "GEOM::fwcylinders", sc->fwcylinders))
+ return;
+ }
+ g_io_deliver(bp, EOPNOTSUPP);
+}
+
+void
+g_simdisk_init(void)
+{
+ g_add_class(&g_simdisk_class);
+}
+
+struct g_geom *
+g_simdisk_create(const char *name, struct simdisk_softc *sc)
+{
+ struct g_geom *gp;
+ struct g_provider *pp;
+ static int unit;
+
+ printf("g_simdisk_create(\"%s\", %p)\n", name, sc);
+ g_topology_lock();
+ gp = g_new_geomf(&g_simdisk_class, "%s", name);
+ gp->start = g_simdisk_start;
+ gp->softc = sc;
+ gp->access = g_std_access;
+
+ pp = g_new_providerf(gp, "%s", name);
+ pp->mediasize = sc->mediasize;
+ pp->sectorsize = sc->sectorsize;
+ g_error_provider(pp, 0);
+ unit++;
+ g_topology_unlock();
+ return (gp);
+}
+
+struct g_geom *
+g_simdisk_new(const char *name, const char *path)
+{
+ struct simdisk_softc *sc;
+ struct stat st;
+
+ sc = calloc(1, sizeof *sc);
+
+ sc->fd = open(path, O_RDONLY);
+ if (sc->fd < 0)
+ err(1, path);
+ fstat(sc->fd, &st);
+ sc->mediasize = st.st_size;
+ sc->sectorsize = 512;
+ LIST_INIT(&sc->sectors);
+ TAILQ_INIT(&sc->sort);
+ return (g_simdisk_create(name, sc));
+}
+
+void
+g_simdisk_destroy(const char *name)
+{
+ struct g_geom *gp;
+
+ LIST_FOREACH(gp, &g_simdisk_class.geom, geom) {
+ if (strcmp(name, gp->name))
+ continue;
+ gp->flags |= G_GEOM_WITHER;
+ g_orphan_provider(LIST_FIRST(&gp->provider), ENXIO);
+ return;
+ }
+}
+
+struct sector *
+g_simdisk_findsector(struct simdisk_softc *sc, off_t off, int create)
+{
+ struct sector *dsp;
+
+ LIST_FOREACH(dsp, &sc->sectors, sectors) {
+ if (dsp->offset < off)
+ continue;
+ if (dsp->offset == off)
+ return (dsp);
+ break;
+ }
+ if (!create)
+ return (NULL);
+ printf("Creating sector at offset %lld (%u)\n",
+ off, (unsigned)(off / sc->sectorsize));
+ dsp = calloc(1, sizeof *dsp + sc->sectorsize);
+ dsp->data = (u_char *)(dsp + 1);
+ dsp->offset = off;
+ g_simdisk_insertsector(sc, dsp);
+ return (dsp);
+}
+
+void
+g_simdisk_insertsector(struct simdisk_softc *sc, struct sector *dsp)
+{
+ struct sector *dsp2, *dsp3;
+
+ if (LIST_EMPTY(&sc->sectors)) {
+ LIST_INSERT_HEAD(&sc->sectors, dsp, sectors);
+ return;
+ }
+ dsp3 = NULL;
+ LIST_FOREACH(dsp2, &sc->sectors, sectors) {
+ dsp3 = dsp2;
+ if (dsp2->offset > dsp->offset) {
+ LIST_INSERT_BEFORE(dsp2, dsp, sectors);
+ return;
+ }
+ }
+ LIST_INSERT_AFTER(dsp3, dsp, sectors);
+}
+
+void
+g_simdisk_stop(const char *name)
+{
+ struct g_geom *gp;
+ struct simdisk_softc *sc;
+
+ g_trace(G_T_TOPOLOGY, "g_simdisk_stop(%s)", name);
+ LIST_FOREACH(gp, &g_simdisk_class.geom, geom) {
+ if (strcmp(name, gp->name))
+ continue;
+ sc = gp->softc;
+ sc->stop = 1;
+ return;
+ }
+}
+
+void
+g_simdisk_restart(const char *name)
+{
+ struct g_geom *gp;
+ struct simdisk_softc *sc;
+ struct bio *bp;
+
+ g_trace(G_T_TOPOLOGY, "g_simdisk_restart(%s)", name);
+ LIST_FOREACH(gp, &g_simdisk_class.geom, geom) {
+ if (strcmp(name, gp->name))
+ continue;
+ sc = gp->softc;
+ sc->stop = 0;
+ bp = TAILQ_FIRST(&sc->sort);
+ while (bp != NULL) {
+ TAILQ_REMOVE(&sc->sort, bp, bio_sort);
+ g_simdisk_start(bp);
+ bp = TAILQ_FIRST(&sc->sort);
+ }
+ return;
+ }
+}
diff --git a/tools/regression/geom/geom_simdisk.h b/tools/regression/geom/geom_simdisk.h
new file mode 100644
index 0000000..de4d0fb
--- /dev/null
+++ b/tools/regression/geom/geom_simdisk.h
@@ -0,0 +1,64 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+struct sector {
+ LIST_ENTRY(sector) sectors;
+ off_t offset;
+ unsigned char *data;
+};
+
+struct simdisk_softc {
+ int fd;
+ int sectorsize;
+ off_t mediasize;
+ off_t lastsector;
+ LIST_HEAD(,sector) sectors;
+ struct sbuf *sbuf;
+ struct sector *sp;
+ int stop;
+ u_int fwsectors;
+ u_int fwheads;
+ u_int fwcylinders;
+ TAILQ_HEAD(,bio) sort;
+};
+
+extern struct g_class g_simdisk_class;
+
+struct sector * g_simdisk_findsector(struct simdisk_softc *sc, off_t off, int create);
+struct g_geom *g_simdisk_create(const char *name, struct simdisk_softc *sc);
+
+void g_simdisk_insertsector(struct simdisk_softc *sc, struct sector *dsp);
diff --git a/tools/regression/geom/geom_simdisk_xml.c b/tools/regression/geom/geom_simdisk_xml.c
new file mode 100644
index 0000000..47dcea5
--- /dev/null
+++ b/tools/regression/geom/geom_simdisk_xml.c
@@ -0,0 +1,244 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <strings.h>
+#include <err.h>
+#include <md5.h>
+#include <sys/errno.h>
+#include <geom/geom.h>
+#include <string.h>
+#include <ctype.h>
+#include <bsdxml.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/queue.h>
+#include <sys/sbuf.h>
+
+#include "geom_simdisk.h"
+
+void
+g_simdisk_xml_save(const char *name, const char *file)
+{
+ struct g_geom *gp;
+ struct simdisk_softc *sc;
+ struct sector *dsp;
+ int i, j;
+ FILE *f;
+ u_char *p;
+
+ LIST_FOREACH(gp, &g_simdisk_class.geom, geom) {
+ if (strcmp(name, gp->name))
+ continue;
+ sc = gp->softc;
+ f = fopen(file, "w");
+ if (f == NULL)
+ err(1, file);
+ fprintf(f, "<?xml version=\"1.0\"?>\n");
+ fprintf(f, "<DISKIMAGE>\n");
+#if 0
+ {
+ struct sbuf *sb;
+ sb = g_conf_specific(&g_simdisk_class, gp, NULL, NULL);
+ fprintf(f, " <config>%s</config>\n", sbuf_data(sb));
+ }
+#endif
+ fprintf(f, " <sectorsize>%u</sectorsize>\n", sc->sectorsize);
+ fprintf(f, " <mediasize>%llu</mediasize>\n", sc->mediasize);
+ fprintf(f, " <fwsectors>%u</fwsectors>\n", sc->fwsectors);
+ fprintf(f, " <fwheads>%u</fwheads>\n", sc->fwheads);
+ fprintf(f, " <fwcylinders>%u</fwcylinders>\n", sc->fwcylinders);
+ LIST_FOREACH(dsp, &sc->sectors, sectors) {
+ fprintf(f, " <sector>\n");
+ fprintf(f, " <offset>%llu</offset>\n", dsp->offset);
+ fprintf(f, " <hexdata>\n");
+ p = dsp->data;
+ for (j = 0 ; j < sc->sectorsize; j += 32) {
+ fprintf(f, "\t");
+ for (i = 0; i < 32; i++)
+ fprintf(f, "%02x", *p++);
+ fprintf(f, "\n");
+ }
+ fprintf(f, " </hexdata>\n");
+ fprintf(f, " </sector>\n");
+ }
+ fprintf(f, "</DISKIMAGE>\n");
+ fclose(f);
+ }
+}
+
+static void
+startElement(void *userData, const char *name, const char **atts __unused)
+{
+ struct simdisk_softc *sc;
+
+ sc = userData;
+ if (!strcasecmp(name, "sector")) {
+ sc->sp = calloc(1, sizeof(*sc->sp) + sc->sectorsize);
+ sc->sp->data = (u_char *)(sc->sp + 1);
+ }
+ sbuf_clear(sc->sbuf);
+}
+
+static void
+endElement(void *userData, const char *name)
+{
+ struct simdisk_softc *sc;
+ char *p;
+ u_char *q;
+ int i, j;
+ off_t o;
+
+ sc = userData;
+
+ if (!strcasecmp(name, "comment")) {
+ sbuf_clear(sc->sbuf);
+ return;
+ }
+ sbuf_finish(sc->sbuf);
+ if (!strcasecmp(name, "sectorsize")) {
+ sc->sectorsize = strtoul(sbuf_data(sc->sbuf), &p, 0);
+ if (*p != '\0')
+ errx(1, "strtoul croaked on sectorsize");
+ } else if (!strcasecmp(name, "mediasize")) {
+ o = strtoull(sbuf_data(sc->sbuf), &p, 0);
+ if (*p != '\0')
+ errx(1, "strtoul croaked on mediasize");
+ if (o > 0)
+ sc->mediasize = o;
+ } else if (!strcasecmp(name, "fwsectors")) {
+ sc->fwsectors = strtoul(sbuf_data(sc->sbuf), &p, 0);
+ if (*p != '\0')
+ errx(1, "strtoul croaked on fwsectors");
+ } else if (!strcasecmp(name, "fwheads")) {
+ sc->fwheads = strtoul(sbuf_data(sc->sbuf), &p, 0);
+ if (*p != '\0')
+ errx(1, "strtoul croaked on fwheads");
+ } else if (!strcasecmp(name, "fwcylinders")) {
+ sc->fwcylinders = strtoul(sbuf_data(sc->sbuf), &p, 0);
+ if (*p != '\0')
+ errx(1, "strtoul croaked on fwcylinders");
+ } else if (!strcasecmp(name, "offset")) {
+ sc->sp->offset= strtoull(sbuf_data(sc->sbuf), &p, 0);
+ if (*p != '\0')
+ errx(1, "strtoul croaked on offset");
+ } else if (!strcasecmp(name, "fill")) {
+ j = strtoul(sbuf_data(sc->sbuf), NULL, 16);
+ memset(sc->sp->data, j, sc->sectorsize);
+ } else if (!strcasecmp(name, "hexdata")) {
+ q = sc->sp->data;
+ p = sbuf_data(sc->sbuf);
+ for (i = 0; i < sc->sectorsize; i++) {
+ if (!isxdigit(*p))
+ errx(1, "I croaked on hexdata %d:(%02x)", i, *p);
+ if (isdigit(*p))
+ j = (*p - '0') << 4;
+ else
+ j = (tolower(*p) - 'a' + 10) << 4;
+ p++;
+ if (!isxdigit(*p))
+ errx(1, "I croaked on hexdata %d:(%02x)", i, *p);
+ if (isdigit(*p))
+ j |= *p - '0';
+ else
+ j |= tolower(*p) - 'a' + 10;
+ p++;
+ *q++ = j;
+ }
+ } else if (!strcasecmp(name, "sector")) {
+ g_simdisk_insertsector(sc, sc->sp);
+ sc->sp = NULL;
+ } else if (!strcasecmp(name, "diskimage")) {
+ } else if (!strcasecmp(name, "FreeBSD")) {
+ } else {
+ printf("<%s>[[%s]]\n", name, sbuf_data(sc->sbuf));
+ }
+ sbuf_clear(sc->sbuf);
+}
+
+static void
+characterData(void *userData, const XML_Char *s, int len)
+{
+ const char *b, *e;
+ struct simdisk_softc *sc;
+
+ sc = userData;
+ b = s;
+ e = s + len - 1;
+ while (isspace(*b) && b < e)
+ b++;
+ while (isspace(*e) && e > b)
+ e--;
+ if (e != b || !isspace(*b))
+ sbuf_bcat(sc->sbuf, b, e - b + 1);
+}
+
+struct g_geom *
+g_simdisk_xml_load(const char *name, const char *file)
+{
+ XML_Parser parser = XML_ParserCreate(NULL);
+ struct stat st;
+ char *p;
+ struct simdisk_softc *sc;
+ int fd, i;
+
+ sc = calloc(1, sizeof *sc);
+ sc->fd = -1;
+ sc->sbuf = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
+ sc->mediasize = 1024 * 1024 * 1024 * (off_t)1024;
+ LIST_INIT(&sc->sectors);
+ TAILQ_INIT(&sc->sort);
+ XML_SetUserData(parser, sc);
+ XML_SetElementHandler(parser, startElement, endElement);
+ XML_SetCharacterDataHandler(parser, characterData);
+
+ fd = open(file, O_RDONLY);
+ if (fd < 0)
+ err(1, file);
+ fstat(fd, &st);
+ p = mmap(NULL, st.st_size, PROT_READ, MAP_NOCORE|MAP_PRIVATE, fd, 0);
+ i = XML_Parse(parser, p, st.st_size, 1);
+ if (i != 1)
+ errx(1, "XML_Parse complains: return %d", i);
+ munmap(p, st.st_size);
+ close(fd);
+ XML_ParserFree(parser);
+ return (g_simdisk_create(name, sc));
+}
diff --git a/tools/regression/ia64_unaligned/Makefile b/tools/regression/ia64_unaligned/Makefile
new file mode 100644
index 0000000..a5f1107
--- /dev/null
+++ b/tools/regression/ia64_unaligned/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+PROG= unaligned
+NOMAN= t
+
+.include <bsd.prog.mk>
diff --git a/tools/regression/ia64_unaligned/unaligned.c b/tools/regression/ia64_unaligned/unaligned.c
new file mode 100644
index 0000000..e45bcd9
--- /dev/null
+++ b/tools/regression/ia64_unaligned/unaligned.c
@@ -0,0 +1,131 @@
+/*-
+ * Copyright (c) 2001 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+static u_int64_t ld2(char** pp, int add)
+{
+ u_int64_t p = (u_int64_t) *pp;
+ u_int64_t v;
+ __asm __volatile("ld2 %0=[%1]" : "=r" (v) : "r" (p));
+ return v;
+}
+
+static u_int64_t ld4(char** pp, int add)
+{
+ u_int64_t p = (u_int64_t) *pp;
+ u_int64_t v;
+ __asm __volatile("ld4 %0=[%1]" : "=r" (v) : "r" (p));
+ return v;
+}
+
+static u_int64_t ld8(char** pp, int add)
+{
+ u_int64_t p = (u_int64_t) *pp;
+ u_int64_t v;
+ __asm __volatile("ld8 %0=[%1]" : "=r" (v) : "r" (p));
+ return v;
+}
+
+static u_int64_t ld8_reg(char** pp, int add)
+{
+ u_int64_t p = (u_int64_t) *pp;
+ u_int64_t v;
+ __asm __volatile("ld8 %0=[%1],%3"
+ : "=r" (v), "=r" (p)
+ : "1" (p), "r" (add));
+ *pp = (char*) p;
+ return v;
+}
+
+static u_int64_t ld8_8(char** pp, int add)
+{
+ u_int64_t p = (u_int64_t) *pp;
+ u_int64_t v;
+ __asm __volatile("ld8 %0=[%1],8"
+ : "=r" (v), "=r" (p)
+ : "1" (p));
+ *pp = (char*) p;
+ return v;
+}
+
+struct load_test {
+ u_int64_t (*ldfunc)(char**, int);
+ int off, add;
+ u_int64_t value;
+};
+
+char testbuf[16] = {
+ 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
+ 0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff
+};
+
+struct load_test tests[] = {
+ {ld8, 1, 0, 0x8877665544332211L},
+ {ld8, 2, 0, 0x9988776655443322L},
+ {ld4, 1, 0, 0x44332211L},
+ {ld4, 2, 0, 0x55443322L},
+ {ld2, 1, 0, 0x2211L},
+ {ld8_reg, 1, 4, 0x8877665544332211L},
+ {ld8_8, 1, 8, 0x8877665544332211L},
+};
+
+int
+main(int argc, char** argv)
+{
+ int verbose = 0;
+ int passed = 1;
+ int i;
+
+ if (argc == 2 && !strcmp(argv[1], "-v"))
+ verbose = 1;
+
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ struct load_test *tp = &tests[i];
+ char* p;
+ u_int64_t value;
+ p = &testbuf[tp->off];
+ value = tp->ldfunc(&p, tp->add);
+ if (verbose)
+ printf("read 0x%lx, expected 0x%lx\n",
+ value, tp->value);
+ if (value != tp->value)
+ passed = 0;
+ if (p - &testbuf[tp->off] != tp->add) {
+ printf("postincrement was %d, %d expected\n",
+ p - &testbuf[tp->off], tp->add);
+ passed = 0;
+ }
+ }
+ if (passed)
+ printf("passed\n");
+ else
+ printf("failed\n");
+}
diff --git a/tools/regression/lib/libc/gen/Makefile b/tools/regression/lib/libc/gen/Makefile
new file mode 100644
index 0000000..140b789
--- /dev/null
+++ b/tools/regression/lib/libc/gen/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+TESTS= test-fpclassify test-wordexp
+
+.PHONY: tests
+tests: ${TESTS}
+ for p in ${TESTS}; do ${.OBJDIR}/$$p; done
+
+.PHONY: clean
+clean:
+ -rm -f ${TESTS}
diff --git a/tools/regression/lib/libc/gen/test-fpclassify.c b/tools/regression/lib/libc/gen/test-fpclassify.c
new file mode 100644
index 0000000..cf20c84
--- /dev/null
+++ b/tools/regression/lib/libc/gen/test-fpclassify.c
@@ -0,0 +1,75 @@
+/*-
+ * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <assert.h>
+#include <math.h>
+#include <stdlib.h>
+
+int
+main(void)
+{
+
+ assert(fpclassify((float)0) == FP_ZERO);
+ assert(fpclassify((float)-0) == FP_ZERO);
+ assert(fpclassify((float)1) == FP_NORMAL);
+ assert(fpclassify((float)1000) == FP_NORMAL);
+#ifndef __alpha__
+ assert(fpclassify(0x1.2p-150f) == FP_SUBNORMAL);
+#endif
+ assert(fpclassify(HUGE_VALF) == FP_INFINITE);
+ assert(fpclassify((float)HUGE_VAL) == FP_INFINITE);
+ assert(fpclassify((float)HUGE_VALL) == FP_INFINITE);
+ assert(fpclassify(NAN) == FP_NAN);
+
+ assert(fpclassify((double)0) == FP_ZERO);
+ assert(fpclassify((double)-0) == FP_ZERO);
+ assert(fpclassify((double)1) == FP_NORMAL);
+ assert(fpclassify((double)1000) == FP_NORMAL);
+#ifndef __alpha__
+ assert(fpclassify(0x1.2p-1075) == FP_SUBNORMAL);
+#endif
+ assert(fpclassify(HUGE_VAL) == FP_INFINITE);
+ assert(fpclassify((double)HUGE_VALF) == FP_INFINITE);
+ assert(fpclassify((double)HUGE_VALL) == FP_INFINITE);
+ assert(fpclassify((double)NAN) == FP_NAN);
+
+ assert(fpclassify((long double)0) == FP_ZERO);
+ assert(fpclassify((long double)-0) == FP_ZERO);
+ assert(fpclassify((long double)1) == FP_NORMAL);
+ assert(fpclassify((long double)1000) == FP_NORMAL);
+#ifndef __alpha__
+ assert(fpclassify(0x1.2p-16383L) == FP_SUBNORMAL);
+#endif
+ assert(fpclassify(HUGE_VALL) == FP_INFINITE);
+ assert(fpclassify((long double)HUGE_VALF) == FP_INFINITE);
+ assert(fpclassify((long double)HUGE_VAL) == FP_INFINITE);
+ assert(fpclassify((long double)NAN) == FP_NAN);
+
+ printf("PASS fpclassify()\n");
+ exit(0);
+}
diff --git a/tools/regression/lib/libc/gen/test-wordexp.c b/tools/regression/lib/libc/gen/test-wordexp.c
new file mode 100644
index 0000000..49490d8
--- /dev/null
+++ b/tools/regression/lib/libc/gen/test-wordexp.c
@@ -0,0 +1,174 @@
+/*-
+ * Copyright (c) 2003 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for wordexp() and wordfree() as specified by
+ * IEEE Std. 1003.1-2001.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wordexp.h>
+
+int
+main(int argc, char *argv[])
+{
+ wordexp_t we;
+ int r;
+
+ /* Test that the macros are there. */
+ (void)(WRDE_APPEND + WRDE_DOOFS + WRDE_NOCMD + WRDE_REUSE +
+ WRDE_SHOWERR + WRDE_UNDEF);
+ (void)(WRDE_BADCHAR + WRDE_BADVAL + WRDE_CMDSUB + WRDE_NOSPACE +
+ WRDE_SYNTAX);
+
+ /* Simple test. */
+ r = wordexp("hello world", &we, 0);
+ assert(r == 0);
+ assert(we.we_wordc == 2);
+ assert(strcmp(we.we_wordv[0], "hello") == 0);
+ assert(strcmp(we.we_wordv[1], "world") == 0);
+ assert(we.we_wordv[2] == NULL);
+ wordfree(&we);
+
+ /* WRDE_DOOFS */
+ we.we_offs = 3;
+ r = wordexp("hello world", &we, WRDE_DOOFS);
+ assert(r == 0);
+ assert(we.we_wordc == 2);
+ assert(we.we_wordv[0] == NULL);
+ assert(we.we_wordv[1] == NULL);
+ assert(we.we_wordv[2] == NULL);
+ assert(strcmp(we.we_wordv[3], "hello") == 0);
+ assert(strcmp(we.we_wordv[4], "world") == 0);
+ assert(we.we_wordv[5] == NULL);
+ wordfree(&we);
+
+ /* WRDE_REUSE */
+ r = wordexp("hello world", &we, 0);
+ r = wordexp("hello world", &we, WRDE_REUSE);
+ assert(r == 0);
+ assert(we.we_wordc == 2);
+ assert(strcmp(we.we_wordv[0], "hello") == 0);
+ assert(strcmp(we.we_wordv[1], "world") == 0);
+ assert(we.we_wordv[2] == NULL);
+ wordfree(&we);
+
+ /* WRDE_APPEND */
+ r = wordexp("this is", &we, 0);
+ assert(r == 0);
+ r = wordexp("a test", &we, WRDE_APPEND);
+ assert(r == 0);
+ assert(we.we_wordc == 4);
+ assert(strcmp(we.we_wordv[0], "this") == 0);
+ assert(strcmp(we.we_wordv[1], "is") == 0);
+ assert(strcmp(we.we_wordv[2], "a") == 0);
+ assert(strcmp(we.we_wordv[3], "test") == 0);
+ assert(we.we_wordv[4] == NULL);
+ wordfree(&we);
+
+ /* WRDE_DOOFS + WRDE_APPEND */
+ we.we_offs = 2;
+ r = wordexp("this is", &we, WRDE_DOOFS);
+ assert(r == 0);
+ r = wordexp("a test", &we, WRDE_APPEND|WRDE_DOOFS);
+ assert(r == 0);
+ r = wordexp("of wordexp", &we, WRDE_APPEND|WRDE_DOOFS);
+ assert(r == 0);
+ assert(we.we_wordc == 6);
+ assert(we.we_wordv[0] == NULL);
+ assert(we.we_wordv[1] == NULL);
+ assert(strcmp(we.we_wordv[2], "this") == 0);
+ assert(strcmp(we.we_wordv[3], "is") == 0);
+ assert(strcmp(we.we_wordv[4], "a") == 0);
+ assert(strcmp(we.we_wordv[5], "test") == 0);
+ assert(strcmp(we.we_wordv[6], "of") == 0);
+ assert(strcmp(we.we_wordv[7], "wordexp") == 0);
+ assert(we.we_wordv[8] == NULL);
+ wordfree(&we);
+
+ /* WRDE_UNDEF */
+ r = wordexp("${dont_set_me}", &we, WRDE_UNDEF);
+ assert(r == WRDE_BADVAL);
+
+ /* WRDE_NOCMD */
+ r = wordexp("`date`", &we, WRDE_NOCMD);
+ assert(r == WRDE_CMDSUB);
+ r = wordexp("\"`date`\"", &we, WRDE_NOCMD);
+ assert(r == WRDE_CMDSUB);
+ r = wordexp("$(date)", &we, WRDE_NOCMD);
+ assert(r == WRDE_CMDSUB);
+ r = wordexp("\"$(date)\"", &we, WRDE_NOCMD);
+ assert(r == WRDE_CMDSUB);
+ r = wordexp("$((3+5))", &we, WRDE_NOCMD);
+ assert(r == 0);
+ r = wordexp("\\$\\(date\\)", &we, WRDE_NOCMD|WRDE_REUSE);
+ assert(r == 0);
+ r = wordexp("'`date`'", &we, WRDE_NOCMD|WRDE_REUSE);
+ assert(r == 0);
+ r = wordexp("'$(date)'", &we, WRDE_NOCMD|WRDE_REUSE);
+ assert(r == 0);
+ wordfree(&we);
+
+ /* WRDE_BADCHAR */
+ r = wordexp("'\n|&;<>(){}'", &we, 0);
+ assert(r == 0);
+ r = wordexp("\"\n|&;<>(){}\"", &we, WRDE_REUSE);
+ assert(r == 0);
+ r = wordexp("\\\n\\|\\&\\;\\<\\>\\(\\)\\{\\}", &we, WRDE_REUSE);
+ assert(r == 0);
+ wordfree(&we);
+ r = wordexp("test \n test", &we, 0);
+ assert(r == WRDE_BADCHAR);
+ r = wordexp("test | test", &we, 0);
+ assert(r == WRDE_BADCHAR);
+ r = wordexp("test & test", &we, 0);
+ assert(r == WRDE_BADCHAR);
+ r = wordexp("test ; test", &we, 0);
+ assert(r == WRDE_BADCHAR);
+ r = wordexp("test > test", &we, 0);
+ assert(r == WRDE_BADCHAR);
+ r = wordexp("test < test", &we, 0);
+ assert(r == WRDE_BADCHAR);
+ r = wordexp("test ( test", &we, 0);
+ assert(r == WRDE_BADCHAR);
+ r = wordexp("test ) test", &we, 0);
+ assert(r == WRDE_BADCHAR);
+ r = wordexp("test { test", &we, 0);
+ assert(r == WRDE_BADCHAR);
+ r = wordexp("test } test", &we, 0);
+ assert(r == WRDE_BADCHAR);
+
+ printf("PASS wordexp()\n");
+ printf("PASS wordfree()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/locale/Makefile b/tools/regression/lib/libc/locale/Makefile
new file mode 100644
index 0000000..cbdfa95
--- /dev/null
+++ b/tools/regression/lib/libc/locale/Makefile
@@ -0,0 +1,21 @@
+# $FreeBSD$
+
+TESTS= test-mbrtowc \
+ test-wcrtomb \
+ test-mbsrtowcs \
+ test-wcsrtombs \
+ test-btowc \
+ test-mbrlen \
+ test-mbtowc \
+ test-wctomb \
+ test-mbstowcs \
+ test-wcstombs \
+ test-mblen
+
+.PHONY: tests
+tests: ${TESTS}
+ for p in ${TESTS}; do ${.OBJDIR}/$$p; done
+
+.PHONY: clean
+clean:
+ -rm -f ${TESTS}
diff --git a/tools/regression/lib/libc/locale/test-btowc.c b/tools/regression/lib/libc/locale/test-btowc.c
new file mode 100644
index 0000000..a28e4f5
--- /dev/null
+++ b/tools/regression/lib/libc/locale/test-btowc.c
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for btowc() and wctob() as specified by IEEE Std. 1003.1-2001
+ * and ISO/IEC 9899:1999.
+ *
+ * The function is tested in the "C" and "ja_JP.eucJP" locales.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <wchar.h>
+
+int
+main(int argc, char *argv[])
+{
+ int i;
+
+ /*
+ * C/POSIX locale.
+ */
+ assert(btowc(EOF) == WEOF);
+ assert(wctob(WEOF) == EOF);
+ for (i = 0; i < UCHAR_MAX; i++)
+ assert(btowc(i) == (wchar_t)i && i == (int)wctob(i));
+
+ /*
+ * Japanese (EUC) locale.
+ */
+
+ assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
+ assert(MB_CUR_MAX > 1);
+ assert(btowc('A') == L'A' && wctob(L'A') == 'A');
+ assert(btowc(0xa3) == WEOF && wctob(0xa3c1) == EOF);
+
+ printf("PASS btowc()\n");
+ printf("PASS wctob()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/locale/test-mblen.c b/tools/regression/lib/libc/locale/test-mblen.c
new file mode 100644
index 0000000..9975e3d
--- /dev/null
+++ b/tools/regression/lib/libc/locale/test-mblen.c
@@ -0,0 +1,109 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for mblen(), as specified by IEEE Std. 1003.1-2001 and
+ * ISO/IEC 9899:1990.
+ *
+ * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and
+ * "ja_JP.eucJP". Other encodings are not tested.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(int argc, char *argv[])
+{
+ size_t len;
+ char buf[MB_LEN_MAX + 1];
+
+ /*
+ * C/POSIX locale.
+ */
+
+ assert(MB_CUR_MAX == 1);
+
+ /* No shift states in C locale. */
+ assert(mblen(NULL, 0) == 0);
+
+ /* Null wide character. */
+ memset(buf, 0xcc, sizeof(buf));
+ buf[0] = '\0';
+ assert(mblen(buf, 1) == 0);
+
+ /* Latin letter A. */
+ buf[0] = 'A';
+ assert(mblen(buf, 1) == 1);
+
+ /* Incomplete character sequence. */
+ buf[0] = '\0';
+ assert(mblen(buf, 0) == -1);
+
+ /*
+ * Japanese (EUC) locale.
+ */
+
+ assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
+ assert(MB_CUR_MAX > 1);
+
+ /* No shift states in EUC. */
+ assert(mblen(NULL, 0) == 0);
+
+ /* Null wide character. */
+ memset(buf, 0xcc, sizeof(buf));
+ buf[0] = '\0';
+ assert(mblen(buf, 1) == 0);
+
+ /* Latin letter A. */
+ buf[0] = 'A';
+ assert(mblen(buf, 1) == 1);
+
+ /* Incomplete character sequence. */
+ buf[0] = '\0';
+ assert(mblen(buf, 0) == -1);
+
+ /* Incomplete character sequence (truncated double-byte). */
+ memset(buf, 0xcc, sizeof(buf));
+ buf[0] = 0xa3;
+ buf[1] = 0x00;
+ assert(mblen(buf, 1) == -1);
+
+ /* Same as above, but complete. */
+ buf[1] = 0xc1;
+ assert(mblen(buf, 2) == 2);
+
+ printf("PASS mblen()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/locale/test-mbrlen.c b/tools/regression/lib/libc/locale/test-mbrlen.c
new file mode 100644
index 0000000..c18df64
--- /dev/null
+++ b/tools/regression/lib/libc/locale/test-mbrlen.c
@@ -0,0 +1,127 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for mbrlen(), as specified by IEEE Std. 1003.1-2001 and
+ * ISO/IEC 9899:1999.
+ *
+ * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and
+ * "ja_JP.eucJP". Other encodings are not tested.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+int
+main(int argc, char *argv[])
+{
+ mbstate_t s;
+ size_t len;
+ char buf[MB_LEN_MAX + 1];
+
+ /*
+ * C/POSIX locale.
+ */
+
+ assert(MB_CUR_MAX == 1);
+
+ /* Null wide character, internal state. */
+ memset(buf, 0xcc, sizeof(buf));
+ buf[0] = 0;
+ assert(mbrlen(buf, 1, NULL) == 0);
+
+ /* Null wide character. */
+ memset(&s, 0, sizeof(s));
+ assert(mbrlen(buf, 1, &s) == 0);
+
+ /* Latin letter A, internal state. */
+ assert(mbrlen(NULL, 0, NULL) == 0);
+ buf[0] = 'A';
+ assert(mbrlen(buf, 1, NULL) == 1);
+
+ /* Latin letter A. */
+ memset(&s, 0, sizeof(s));
+ assert(mbrlen(buf, 1, &s) == 1);
+
+ /* Incomplete character sequence. */
+ memset(&s, 0, sizeof(s));
+ assert(mbrlen(buf, 0, &s) == (size_t)-2);
+
+ /*
+ * Japanese (EUC) locale.
+ */
+
+ assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
+ assert(MB_CUR_MAX > 1);
+
+ /* Null wide character, internal state. */
+ assert(mbrlen(NULL, 0, NULL) == 0);
+ memset(buf, 0xcc, sizeof(buf));
+ buf[0] = 0;
+ assert(mbrlen(buf, 1, NULL) == 0);
+
+ /* Null wide character. */
+ memset(&s, 0, sizeof(s));
+ assert(mbrlen(buf, 1, &s) == 0);
+
+ /* Latin letter A, internal state. */
+ assert(mbrlen(NULL, 0, NULL) == 0);
+ buf[0] = 'A';
+ assert(mbrlen(buf, 1, NULL) == 1);
+
+ /* Latin letter A. */
+ memset(&s, 0, sizeof(s));
+ assert(mbrlen(buf, 1, &s) == 1);
+
+ /* Incomplete character sequence (zero length). */
+ memset(&s, 0, sizeof(s));
+ assert(mbrlen(buf, 0, &s) == (size_t)-2);
+
+ /* Incomplete character sequence (truncated double-byte). */
+ memset(buf, 0xcc, sizeof(buf));
+ buf[0] = 0xa3;
+ buf[1] = 0x00;
+ memset(&s, 0, sizeof(s));
+ assert(mbrlen(buf, 1, &s) == (size_t)-2);
+
+ /* Same as above, but complete. */
+ buf[1] = 0xc1;
+ memset(&s, 0, sizeof(s));
+ assert(mbrlen(buf, 2, &s) == 2);
+
+ printf("PASS mbrlen()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/locale/test-mbrtowc.c b/tools/regression/lib/libc/locale/test-mbrtowc.c
new file mode 100644
index 0000000..630ae2e
--- /dev/null
+++ b/tools/regression/lib/libc/locale/test-mbrtowc.c
@@ -0,0 +1,150 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for mbrtowc(), as specified by IEEE Std. 1003.1-2001 and
+ * ISO/IEC 9899:1999.
+ *
+ * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and
+ * "ja_JP.eucJP". Other encodings are not tested.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+int
+main(int argc, char *argv[])
+{
+ mbstate_t s;
+ size_t len;
+ wchar_t wc;
+ char buf[MB_LEN_MAX + 1];
+
+ /*
+ * C/POSIX locale.
+ */
+
+ assert(MB_CUR_MAX == 1);
+
+ /* Null wide character, internal state. */
+ memset(buf, 0xcc, sizeof(buf));
+ buf[0] = 0;
+ assert(mbrtowc(&wc, buf, 1, NULL) == 0);
+ assert(wc == 0);
+
+ /* Null wide character. */
+ memset(&s, 0, sizeof(s));
+ assert(mbrtowc(&wc, buf, 1, &s) == 0);
+ assert(wc == 0);
+
+ /* Latin letter A, internal state. */
+ assert(mbrtowc(NULL, 0, 0, NULL) == 0);
+ buf[0] = 'A';
+ assert(mbrtowc(&wc, buf, 1, NULL) == 1);
+ assert(wc == L'A');
+
+ /* Latin letter A. */
+ memset(&s, 0, sizeof(s));
+ assert(mbrtowc(&wc, buf, 1, &s) == 1);
+ assert(wc == L'A');
+
+ /* Incomplete character sequence. */
+ wc = L'z';
+ memset(&s, 0, sizeof(s));
+ assert(mbrtowc(&wc, buf, 0, &s) == (size_t)-2);
+ assert(wc == L'z');
+
+ /* Check that mbrtowc() doesn't access the buffer when n == 0. */
+ wc = L'z';
+ memset(&s, 0, sizeof(s));
+ buf[0] = '\0';
+ assert(mbrtowc(&wc, buf, 0, &s) == (size_t)-2);
+ assert(wc == L'z');
+
+ /*
+ * Japanese (EUC) locale.
+ */
+
+ assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
+ assert(MB_CUR_MAX > 1);
+
+ /* Null wide character, internal state. */
+ assert(mbrtowc(NULL, 0, 0, NULL) == 0);
+ memset(buf, 0xcc, sizeof(buf));
+ buf[0] = 0;
+ assert(mbrtowc(&wc, buf, 1, NULL) == 0);
+ assert(wc == 0);
+
+ /* Null wide character. */
+ memset(&s, 0, sizeof(s));
+ assert(mbrtowc(&wc, buf, 1, &s) == 0);
+ assert(wc == 0);
+
+ /* Latin letter A, internal state. */
+ assert(mbrtowc(NULL, 0, 0, NULL) == 0);
+ buf[0] = 'A';
+ assert(mbrtowc(&wc, buf, 1, NULL) == 1);
+ assert(wc == L'A');
+
+ /* Latin letter A. */
+ memset(&s, 0, sizeof(s));
+ assert(mbrtowc(&wc, buf, 1, &s) == 1);
+ assert(wc == L'A');
+
+ /* Incomplete character sequence (zero length). */
+ wc = L'z';
+ memset(&s, 0, sizeof(s));
+ assert(mbrtowc(&wc, buf, 0, &s) == (size_t)-2);
+ assert(wc == L'z');
+
+ /* Incomplete character sequence (truncated double-byte). */
+ memset(buf, 0xcc, sizeof(buf));
+ buf[0] = 0xa3;
+ buf[1] = 0x00;
+ memset(&s, 0, sizeof(s));
+ wc = 0;
+ assert(mbrtowc(&wc, buf, 1, &s) == (size_t)-2);
+
+ /* Same as above, but complete. */
+ buf[1] = 0xc1;
+ memset(&s, 0, sizeof(s));
+ wc = 0;
+ assert(mbrtowc(&wc, buf, 2, &s) == 2);
+ assert(wc == 0xa3c1);
+
+ printf("PASS mbrtowc()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/locale/test-mbsrtowcs.c b/tools/regression/lib/libc/locale/test-mbsrtowcs.c
new file mode 100644
index 0000000..6579be0
--- /dev/null
+++ b/tools/regression/lib/libc/locale/test-mbsrtowcs.c
@@ -0,0 +1,148 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for mbsrtowcs(), as specified by IEEE Std. 1003.1-2001 and
+ * ISO/IEC 9899:1999.
+ *
+ * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and
+ * "ja_JP.eucJP". Other encodings are not tested.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+int
+main(int argc, char *argv[])
+{
+ char srcbuf[128];
+ wchar_t dstbuf[128];
+ char *src;
+ mbstate_t s;
+
+ /*
+ * C/POSIX locale.
+ */
+
+ /* Simple null terminated string. */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "hello");
+ wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf));
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ assert(mbsrtowcs(dstbuf, (const char **)&src, sizeof(dstbuf) /
+ sizeof(*dstbuf), &s) == 5);
+ assert(wcscmp(dstbuf, L"hello") == 0);
+ assert(dstbuf[6] == 0xcccc);
+ assert(src == NULL);
+
+ /* Not enough space in destination buffer. */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "hello");
+ wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf));
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ assert(mbsrtowcs(dstbuf, (const char **)&src, 4, &s) == 4);
+ assert(wmemcmp(dstbuf, L"hell", 4) == 0);
+ assert(dstbuf[5] == 0xcccc);
+ assert(src == srcbuf + 4);
+
+ /* Null terminated string, internal dest. buffer */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "hello");
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ assert(mbsrtowcs(NULL, (const char **)&src, 0, &s) == 5);
+
+ /* Null terminated string, internal state. */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "hello");
+ wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf));
+ src = srcbuf;
+ assert(mbsrtowcs(dstbuf, (const char **)&src, sizeof(dstbuf) /
+ sizeof(*dstbuf), NULL) == 5);
+ assert(wcscmp(dstbuf, L"hello") == 0);
+ assert(dstbuf[6] == 0xcccc);
+ assert(src == NULL);
+
+ /* Null terminated string, internal state, internal dest. buffer. */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "hello");
+ src = srcbuf;
+ assert(mbsrtowcs(NULL, (const char **)&src, 0, NULL) == 5);
+
+ /* Empty source buffer. */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ srcbuf[0] = '\0';
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf));
+ assert(mbsrtowcs(dstbuf, (const char **)&src, 1, &s) == 0);
+ assert(dstbuf[0] == 0);
+ assert(dstbuf[1] == 0xcccc);
+ assert(src == NULL);
+
+ /* Zero length destination buffer. */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "hello");
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf));
+ assert(mbsrtowcs(dstbuf, (const char **)&src, 0, &s) == 0);
+ assert(dstbuf[0] == 0xcccc);
+ assert(src == srcbuf);
+
+ /*
+ * Japanese (EUC) locale.
+ */
+
+ assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
+ assert(MB_CUR_MAX > 1);
+
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "\xA3\xC1 B \xA3\xC3");
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf));
+ assert(mbsrtowcs(dstbuf, (const char **)&src, sizeof(dstbuf) /
+ sizeof(*dstbuf), &s) == 5);
+ assert(dstbuf[0] == 0xA3C1 && dstbuf[1] == 0x20 && dstbuf[2] == 0x42 &&
+ dstbuf[3] == 0x20 && dstbuf[4] == 0xA3C3 && dstbuf[5] == 0);
+ assert(src == NULL);
+
+ printf("PASS mbsrtowcs()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/locale/test-mbstowcs.c b/tools/regression/lib/libc/locale/test-mbstowcs.c
new file mode 100644
index 0000000..1b75be6
--- /dev/null
+++ b/tools/regression/lib/libc/locale/test-mbstowcs.c
@@ -0,0 +1,110 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for mbstowcs(), as specified by IEEE Std. 1003.1-2001 and
+ * ISO/IEC 9899:1999.
+ *
+ * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and
+ * "ja_JP.eucJP". Other encodings are not tested.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+int
+main(int argc, char *argv[])
+{
+ char srcbuf[128];
+ wchar_t dstbuf[128];
+
+ /*
+ * C/POSIX locale.
+ */
+
+ /* Simple null terminated string. */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "hello");
+ wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf));
+ assert(mbstowcs(dstbuf, srcbuf, sizeof(dstbuf) / sizeof(*dstbuf)) == 5);
+ assert(wcscmp(dstbuf, L"hello") == 0);
+ assert(dstbuf[6] == 0xcccc);
+
+ /* Not enough space in destination buffer. */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "hello");
+ wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf));
+ assert(mbstowcs(dstbuf, srcbuf, 4) == 4);
+ assert(wmemcmp(dstbuf, L"hell", 4) == 0);
+ assert(dstbuf[5] == 0xcccc);
+
+ /* Null terminated string, internal dest. buffer (XSI extension) */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "hello");
+ assert(mbstowcs(NULL, srcbuf, 0) == 5);
+
+ /* Empty source buffer. */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ srcbuf[0] = '\0';
+ wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf));
+ assert(mbstowcs(dstbuf, srcbuf, 1) == 0);
+ assert(dstbuf[0] == 0);
+ assert(dstbuf[1] == 0xcccc);
+
+ /* Zero length destination buffer. */
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "hello");
+ wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf));
+ assert(mbstowcs(dstbuf, srcbuf, 0) == 0);
+ assert(dstbuf[0] == 0xcccc);
+
+ /*
+ * Japanese (EUC) locale.
+ */
+
+ assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
+ assert(MB_CUR_MAX > 1);
+
+ memset(srcbuf, 0xcc, sizeof(srcbuf));
+ strcpy(srcbuf, "\xA3\xC1 B \xA3\xC3");
+ wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf));
+ assert(mbstowcs(dstbuf, srcbuf, sizeof(dstbuf) / sizeof(*dstbuf)) == 5);
+ assert(dstbuf[0] == 0xA3C1 && dstbuf[1] == 0x20 && dstbuf[2] == 0x42 &&
+ dstbuf[3] == 0x20 && dstbuf[4] == 0xA3C3 && dstbuf[5] == 0);
+
+ printf("PASS mbstowcs()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/locale/test-mbtowc.c b/tools/regression/lib/libc/locale/test-mbtowc.c
new file mode 100644
index 0000000..e38086e
--- /dev/null
+++ b/tools/regression/lib/libc/locale/test-mbtowc.c
@@ -0,0 +1,119 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for mbtowc(), as specified by IEEE Std. 1003.1-2001 and
+ * ISO/IEC 9899:1990.
+ *
+ * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and
+ * "ja_JP.eucJP". Other encodings are not tested.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(int argc, char *argv[])
+{
+ size_t len;
+ wchar_t wc;
+ char buf[MB_LEN_MAX + 1];
+
+ /*
+ * C/POSIX locale.
+ */
+
+ assert(MB_CUR_MAX == 1);
+
+ /* No shift states in C locale. */
+ assert(mbtowc(NULL, NULL, 0) == 0);
+
+ /* Null wide character. */
+ wc = 0xcccc;
+ memset(buf, 0, sizeof(buf));
+ assert(mbtowc(&wc, buf, 1) == 0);
+ assert(wc == 0);
+
+ /* Latin letter A. */
+ buf[0] = 'A';
+ assert(mbtowc(&wc, buf, 1) == 1);
+ assert(wc == L'A');
+
+ /* Incomplete character sequence. */
+ wc = L'z';
+ buf[0] = '\0';
+ assert(mbtowc(&wc, buf, 0) == -1);
+ assert(wc == L'z');
+
+ /*
+ * Japanese (EUC) locale.
+ */
+
+ assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
+ assert(MB_CUR_MAX > 1);
+
+ /* Null wide character */
+ memset(buf, 0xcc, sizeof(buf));
+ buf[0] = 0;
+ wc = 0xcccc;
+ assert(mbtowc(&wc, buf, 1) == 0);
+ assert(wc == 0);
+
+ /* Latin letter A. */
+ buf[0] = 'A';
+ assert(mbtowc(&wc, buf, 1) == 1);
+ assert(wc == L'A');
+
+ /* Incomplete character sequence (zero length). */
+ wc = L'z';
+ buf[0] = '\0';
+ assert(mbtowc(&wc, buf, 0) == -1);
+ assert(wc == L'z');
+
+ /* Incomplete character sequence (truncated double-byte). */
+ memset(buf, 0xcc, sizeof(buf));
+ buf[0] = 0xa3;
+ buf[1] = 0x00;
+ wc = L'z';
+ assert(mbtowc(&wc, buf, 1) == -1);
+ assert(wc == L'z');
+
+ /* Same as above, but complete. */
+ buf[1] = 0xc1;
+ assert(mbtowc(&wc, buf, 2) == 2);
+ assert(wc == 0xa3c1);
+
+ printf("PASS mbtowc()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/locale/test-wcrtomb.c b/tools/regression/lib/libc/locale/test-wcrtomb.c
new file mode 100644
index 0000000..c00792b
--- /dev/null
+++ b/tools/regression/lib/libc/locale/test-wcrtomb.c
@@ -0,0 +1,132 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for wcrtomb(), as specified by IEEE Std. 1003.1-2001 and
+ * ISO/IEC 9899:1999.
+ *
+ * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and
+ * "ja_JP.eucJP". Other encodings are not tested.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+int
+main(int argc, char *argv[])
+{
+ mbstate_t s;
+ size_t len;
+ char buf[MB_LEN_MAX + 1];
+
+ /*
+ * C/POSIX locale.
+ */
+
+ assert(MB_CUR_MAX == 1);
+
+ /*
+ * If the buffer argument is NULL, wc is implicitly L'\0',
+ * wcrtomb() resets its internal state.
+ */
+ assert(wcrtomb(NULL, L'\0', NULL) == 1);
+ assert(wcrtomb(NULL, UCHAR_MAX + 1, NULL) == 1);
+
+ /* Null wide character. */
+ memset(&s, 0, sizeof(s));
+ memset(buf, 0xcc, sizeof(buf));
+ len = wcrtomb(buf, L'\0', &s);
+ assert(len == 1);
+ assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc);
+
+ /* Latin letter A, internal state. */
+ assert(wcrtomb(NULL, L'\0', NULL) == 1);
+ assert(wcrtomb(NULL, L'A', NULL) == 1);
+
+ /* Latin letter A. */
+ memset(&s, 0, sizeof(s));
+ memset(buf, 0xcc, sizeof(buf));
+ len = wcrtomb(buf, L'A', &s);
+ assert(len == 1);
+ assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc);
+
+ /* Invalid code. */
+ assert(wcrtomb(buf, UCHAR_MAX + 1, NULL) == (size_t)-1);
+ assert(errno == EILSEQ);
+
+ /*
+ * Japanese (EUC) locale.
+ */
+
+ assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
+ assert(MB_CUR_MAX == 3);
+
+ /*
+ * If the buffer argument is NULL, wc is implicitly L'\0',
+ * wcrtomb() resets its internal state.
+ */
+ assert(wcrtomb(NULL, L'\0', NULL) == 1);
+
+ /* Null wide character. */
+ memset(&s, 0, sizeof(s));
+ memset(buf, 0xcc, sizeof(buf));
+ len = wcrtomb(buf, L'\0', &s);
+ assert(len == 1);
+ assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc);
+
+ /* Latin letter A, internal state. */
+ assert(wcrtomb(NULL, L'\0', NULL) == 1);
+ assert(wcrtomb(NULL, L'A', NULL) == 1);
+
+ /* Latin letter A. */
+ memset(&s, 0, sizeof(s));
+ memset(buf, 0xcc, sizeof(buf));
+ len = wcrtomb(buf, L'A', &s);
+ assert(len == 1);
+ assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc);
+
+ /* Full width letter A. */
+ memset(&s, 0, sizeof(s));
+ memset(buf, 0xcc, sizeof(buf));
+ len = wcrtomb(buf, 0xa3c1, &s);
+ assert(len == 2);
+ assert((unsigned char)buf[0] == 0xa3 &&
+ (unsigned char)buf[1] == 0xc1 &&
+ (unsigned char)buf[2] == 0xcc);
+
+ printf("PASS wcrtomb()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/locale/test-wcsrtombs.c b/tools/regression/lib/libc/locale/test-wcsrtombs.c
new file mode 100644
index 0000000..9ed3ff9
--- /dev/null
+++ b/tools/regression/lib/libc/locale/test-wcsrtombs.c
@@ -0,0 +1,153 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for wcsrtombs(), as specified by IEEE Std. 1003.1-2001 and
+ * ISO/IEC 9899:1999.
+ *
+ * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and
+ * "ja_JP.eucJP". Other encodings are not tested.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+int
+main(int argc, char *argv[])
+{
+ wchar_t srcbuf[128];
+ char dstbuf[128];
+ wchar_t *src;
+ mbstate_t s;
+
+ /*
+ * C/POSIX locale.
+ */
+
+ /* Simple null terminated string. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ assert(wcsrtombs(dstbuf, (const wchar_t **)&src, sizeof(dstbuf),
+ &s) == 5);
+ assert(strcmp(dstbuf, "hello") == 0);
+ assert((unsigned char)dstbuf[6] == 0xcc);
+ assert(src == NULL);
+
+ /* Not enough space in destination buffer. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ assert(wcsrtombs(dstbuf, (const wchar_t **)&src, 4,
+ &s) == 4);
+ assert(memcmp(dstbuf, "hell", 4) == 0);
+ assert((unsigned char)dstbuf[5] == 0xcc);
+ assert(src == srcbuf + 4);
+
+ /* Null terminated string, internal dest. buffer */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ assert(wcsrtombs(NULL, (const wchar_t **)&src, sizeof(dstbuf),
+ &s) == 5);
+
+ /* Null terminated string, internal state. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ src = srcbuf;
+ assert(wcsrtombs(dstbuf, (const wchar_t **)&src, sizeof(dstbuf),
+ NULL) == 5);
+ assert(strcmp(dstbuf, "hello") == 0);
+ assert((unsigned char)dstbuf[6] == 0xcc);
+ assert(src == NULL);
+
+ /* Null terminated string, internal state, internal dest. buffer. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ src = srcbuf;
+ assert(wcsrtombs(NULL, (const wchar_t **)&src, 0, NULL) == 5);
+
+ /* Empty source buffer. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ srcbuf[0] = L'\0';
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ assert(wcsrtombs(dstbuf, (const wchar_t **)&src, sizeof(dstbuf),
+ &s) == 0);
+ assert(dstbuf[0] == L'\0');
+
+ /* Zero length destination buffer. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ assert(wcsrtombs(dstbuf, (const wchar_t **)&src, 0, &s) == 0);
+ assert((unsigned char)dstbuf[0] == 0xcc);
+
+ /*
+ * Japanese (EUC) locale.
+ */
+
+ assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
+ assert(MB_CUR_MAX > 1);
+
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ srcbuf[0] = 0xA3C1;
+ srcbuf[1] = 0x0020;
+ srcbuf[2] = 0x0042;
+ srcbuf[3] = 0x0020;
+ srcbuf[4] = 0xA3C3;
+ srcbuf[5] = 0x0000;
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ src = srcbuf;
+ memset(&s, 0, sizeof(s));
+ assert(wcsrtombs(dstbuf, (const wchar_t **)&src, sizeof(dstbuf),
+ &s) == 7);
+ assert(strcmp(dstbuf, "\xA3\xC1 B \xA3\xC3") == 0);
+ assert((unsigned char)dstbuf[8] == 0xcc);
+ assert(src == NULL);
+
+ printf("PASS wcsrtombs()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/locale/test-wcstombs.c b/tools/regression/lib/libc/locale/test-wcstombs.c
new file mode 100644
index 0000000..29a5af9
--- /dev/null
+++ b/tools/regression/lib/libc/locale/test-wcstombs.c
@@ -0,0 +1,127 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for wcstombs(), as specified by IEEE Std. 1003.1-2001 and
+ * ISO/IEC 9899:1999.
+ *
+ * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and
+ * "ja_JP.eucJP". Other encodings are not tested.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+int
+main(int argc, char *argv[])
+{
+ wchar_t srcbuf[128];
+ char dstbuf[128];
+
+ /*
+ * C/POSIX locale.
+ */
+
+ /* Simple null terminated string. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ assert(wcstombs(dstbuf, srcbuf, sizeof(dstbuf)) == 5);
+ assert(strcmp(dstbuf, "hello") == 0);
+ assert((unsigned char)dstbuf[6] == 0xcc);
+
+ /* Not enough space in destination buffer. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ assert(wcstombs(dstbuf, srcbuf, 4) == 4);
+ assert(memcmp(dstbuf, "hell", 4) == 0);
+ assert((unsigned char)dstbuf[5] == 0xcc);
+
+ /* Null terminated string, internal dest. buffer */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ assert(wcstombs(NULL, srcbuf, sizeof(dstbuf)) == 5);
+
+ /* Null terminated string, internal state. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ assert(wcstombs(dstbuf, srcbuf, sizeof(dstbuf)) == 5);
+ assert(strcmp(dstbuf, "hello") == 0);
+ assert((unsigned char)dstbuf[6] == 0xcc);
+
+ /* Null terminated string, internal state, internal dest. buffer. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ assert(wcstombs(NULL, srcbuf, 0) == 5);
+
+ /* Empty source buffer. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ srcbuf[0] = L'\0';
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ assert(wcstombs(dstbuf, srcbuf, sizeof(dstbuf)) == 0);
+ assert(dstbuf[0] == L'\0');
+
+ /* Zero length destination buffer. */
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ wcscpy(srcbuf, L"hello");
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ assert(wcstombs(dstbuf, srcbuf, 0) == 0);
+ assert((unsigned char)dstbuf[0] == 0xcc);
+
+ /*
+ * Japanese (EUC) locale.
+ */
+
+ assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
+ assert(MB_CUR_MAX > 1);
+
+ wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf));
+ srcbuf[0] = 0xA3C1;
+ srcbuf[1] = 0x0020;
+ srcbuf[2] = 0x0042;
+ srcbuf[3] = 0x0020;
+ srcbuf[4] = 0xA3C3;
+ srcbuf[5] = 0x0000;
+ memset(dstbuf, 0xcc, sizeof(dstbuf));
+ assert(wcstombs(dstbuf, srcbuf, sizeof(dstbuf)) == 7);
+ assert(strcmp(dstbuf, "\xA3\xC1 B \xA3\xC3") == 0);
+ assert((unsigned char)dstbuf[8] == 0xcc);
+
+ printf("PASS wcstombs()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/locale/test-wctomb.c b/tools/regression/lib/libc/locale/test-wctomb.c
new file mode 100644
index 0000000..d517944
--- /dev/null
+++ b/tools/regression/lib/libc/locale/test-wctomb.c
@@ -0,0 +1,109 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for wctomb(), as specified by IEEE Std. 1003.1-2001 and
+ * ISO/IEC 9899:1999.
+ *
+ * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and
+ * "ja_JP.eucJP". Other encodings are not tested.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(int argc, char *argv[])
+{
+ size_t len;
+ char buf[MB_LEN_MAX + 1];
+
+ /*
+ * C/POSIX locale.
+ */
+
+ assert(MB_CUR_MAX == 1);
+
+ /* No shift states in C locale. */
+ assert(wctomb(NULL, L'\0') == 0);
+
+ /* Null wide character. */
+ memset(buf, 0xcc, sizeof(buf));
+ len = wctomb(buf, L'\0');
+ assert(len == 1);
+ assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc);
+
+ /* Latin letter A. */
+ memset(buf, 0xcc, sizeof(buf));
+ len = wctomb(buf, L'A');
+ assert(len == 1);
+ assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc);
+
+ /* Invalid code. */
+ assert(wctomb(buf, UCHAR_MAX + 1) == -1);
+
+ /*
+ * Japanese (EUC) locale.
+ */
+
+ assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
+ assert(MB_CUR_MAX == 3);
+
+ /* No shift states in EUC encoding. */
+ assert(wctomb(NULL, L'\0') == 0);
+
+ /* Null wide character. */
+ memset(buf, 0xcc, sizeof(buf));
+ len = wctomb(buf, L'\0');
+ assert(len == 1);
+ assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc);
+
+ /* Latin letter A. */
+ memset(buf, 0xcc, sizeof(buf));
+ len = wctomb(buf, L'A');
+ assert(len == 1);
+ assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc);
+
+ /* Full width letter A. */
+ memset(buf, 0xcc, sizeof(buf));
+ len = wctomb(buf, 0xa3c1);
+ assert(len == 2);
+ assert((unsigned char)buf[0] == 0xa3 &&
+ (unsigned char)buf[1] == 0xc1 &&
+ (unsigned char)buf[2] == 0xcc);
+
+ printf("PASS wctomb()\n");
+
+ return (0);
+}
diff --git a/tools/regression/lib/libc/stdio/Makefile b/tools/regression/lib/libc/stdio/Makefile
new file mode 100644
index 0000000..33d283e
--- /dev/null
+++ b/tools/regression/lib/libc/stdio/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+TESTS= test-perror
+
+.PHONY: tests
+tests: ${TESTS}
+ for p in ${TESTS}; do ${.OBJDIR}/$$p; done
+
+.PHONY: clean
+clean:
+ -rm -f ${TESTS}
diff --git a/tools/regression/lib/libc/stdio/test-perror.c b/tools/regression/lib/libc/stdio/test-perror.c
new file mode 100644
index 0000000..7d83155
--- /dev/null
+++ b/tools/regression/lib/libc/stdio/test-perror.c
@@ -0,0 +1,105 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Test program for perror() as specified by IEEE Std. 1003.1-2001 and
+ * ISO/IEC 9899:1999.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <assert.h>
+#include <err.h>
+#include <errno.h>
+#include <limits.h>
+#include <paths.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void cleanup(void);
+static char tmpfil[PATH_MAX];
+
+int
+main(int argc, char *argv[])
+{
+ char lbuf[512];
+ int i;
+ char *s;
+
+ strcpy(tmpfil, _PATH_TMP "perror.XXXXXXXX");
+ if (mkstemp(tmpfil) < 0)
+ err(1, "mkstemp");
+ atexit(cleanup);
+ /* Reopen stderr on a file descriptor other than 2. */
+ fclose(stderr);
+ for (i = 0; i < 3; i++)
+ dup(0);
+ if (freopen(tmpfil, "r+", stderr) == NULL)
+ err(1, "%s", tmpfil);
+
+ /*
+ * Test that perror() doesn't call strerror() (4.4BSD bug),
+ * the two ways of omitting a program name, and the formatting when
+ * a program name is specified.
+ */
+ s = strerror(ENOENT);
+ assert(strcmp(s, "No such file or directory") == 0);
+ errno = EPERM;
+ perror(NULL);
+ perror("");
+ perror("test-perror");
+ assert(strcmp(s, "No such file or directory") == 0);
+
+ /*
+ * Read it back to check...
+ */
+ rewind(stderr);
+ s = fgets(lbuf, sizeof(lbuf), stderr);
+ assert(s != NULL);
+ assert(strcmp(s, "Operation not permitted\n") == 0);
+ s = fgets(lbuf, sizeof(lbuf), stderr);
+ assert(s != NULL);
+ assert(strcmp(s, "Operation not permitted\n") == 0);
+ s = fgets(lbuf, sizeof(lbuf), stderr);
+ assert(s != NULL);
+ assert(strcmp(s, "test-perror: Operation not permitted\n") == 0);
+ s = fgets(lbuf, sizeof(lbuf), stderr);
+ assert(s == NULL);
+ fclose(stderr);
+
+ printf("PASS perror()\n");
+
+ return (0);
+}
+
+static void
+cleanup(void)
+{
+
+ unlink(tmpfil);
+}
diff --git a/tools/regression/lib/libc/string/Makefile b/tools/regression/lib/libc/string/Makefile
new file mode 100644
index 0000000..5c136e9
--- /dev/null
+++ b/tools/regression/lib/libc/string/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+TESTS= test-strerror
+
+.PHONY: tests
+tests: ${TESTS}
+ for p in ${TESTS}; do ${.OBJDIR}/$$p; done
+
+.PHONY: clean
+clean:
+ -rm -f ${TESTS}
diff --git a/tools/regression/lib/libc/string/test-strerror.c b/tools/regression/lib/libc/string/test-strerror.c
new file mode 100644
index 0000000..375ca64
--- /dev/null
+++ b/tools/regression/lib/libc/string/test-strerror.c
@@ -0,0 +1,130 @@
+/*-
+ * Copyright (c) 2001 Wes Peters <wes@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(void)
+{
+ char buf[64];
+ char *sret;
+ int iret;
+
+ /*
+ * strerror() failure tests.
+ */
+ errno = 0;
+ sret = strerror(0);
+ assert(strcmp(sret, "Unknown error: 0") == 0);
+ assert(errno == EINVAL);
+
+ errno = 0;
+ sret = strerror(INT_MAX);
+ snprintf(buf, sizeof(buf), "Unknown error: %d", INT_MAX);
+ assert(strcmp(sret, buf) == 0);
+ assert(errno == EINVAL);
+
+ /*
+ * strerror() success tests.
+ */
+ errno = 0;
+ sret = strerror(EPERM);
+ assert(strcmp(sret, "Operation not permitted") == 0);
+ assert(errno == 0);
+
+ errno = 0;
+ sret = strerror(EPFNOSUPPORT);
+ assert(strcmp(sret, "Protocol family not supported") == 0);
+ assert(errno == 0);
+
+ errno = 0;
+ sret = strerror(ELAST);
+ assert(errno == 0);
+
+ printf("PASS strerror()\n");
+
+ /*
+ * strerror_r() failure tests.
+ */
+ memset(buf, '*', sizeof(buf));
+ iret = strerror_r(0, buf, sizeof(buf));
+ assert(strcmp(buf, "Unknown error: 0") == 0);
+ assert(iret == EINVAL);
+
+ memset(buf, '*', sizeof(buf));
+ /* One byte too short. */
+ iret = strerror_r(EPERM, buf, strlen("Operation not permitted"));
+ assert(strcmp(buf, "Operation not permitte") == 0);
+ assert(iret == ERANGE);
+
+ memset(buf, '*', sizeof(buf));
+ /* One byte too short. */
+ iret = strerror_r(-1, buf, strlen("Unknown error: -1"));
+ assert(strcmp(buf, "Unknown error: -") == 0);
+ assert(iret == EINVAL);
+
+ memset(buf, '*', sizeof(buf));
+ /* Two bytes too short. */
+ iret = strerror_r(-2, buf, strlen("Unknown error: -2") - 1);
+ assert(strcmp(buf, "Unknown error: ") == 0);
+ assert(iret == EINVAL);
+
+ memset(buf, '*', sizeof(buf));
+ /* Three bytes too short. */
+ iret = strerror_r(-2, buf, strlen("Unknown error: -2") - 2);
+ assert(strcmp(buf, "Unknown error:") == 0);
+ assert(iret == EINVAL);
+
+ memset(buf, '*', sizeof(buf));
+ /* One byte too short. */
+ iret = strerror_r(12345, buf, strlen("Unknown error: 12345"));
+ assert(strcmp(buf, "Unknown error: 1234") == 0);
+ assert(iret == EINVAL);
+
+ /*
+ * strerror_r() success tests.
+ */
+ memset(buf, '*', sizeof(buf));
+ iret = strerror_r(EDEADLK, buf, sizeof(buf));
+ assert(strcmp(buf, "Resource deadlock avoided") == 0);
+ assert(iret == 0);
+
+ memset(buf, '*', sizeof(buf));
+ iret = strerror_r(EPROCLIM, buf, sizeof(buf));
+ assert(strcmp(buf, "Too many processes") == 0);
+ assert(iret == 0);
+
+ printf("PASS strerror_r()\n");
+
+ exit(0);
+}
diff --git a/tools/regression/nfsmmap/Makefile b/tools/regression/nfsmmap/Makefile
new file mode 100644
index 0000000..c731d42
--- /dev/null
+++ b/tools/regression/nfsmmap/Makefile
@@ -0,0 +1,3 @@
+SUBDIR= test1 test2
+
+.include <bsd.subdir.mk>
diff --git a/tools/regression/nfsmmap/README b/tools/regression/nfsmmap/README
new file mode 100644
index 0000000..81c4ad5
--- /dev/null
+++ b/tools/regression/nfsmmap/README
@@ -0,0 +1,20 @@
+These tests are intended to make sure that NFS's use of the
+b_{valid,dirty}{off,end} fields of struct buf is consistent with the
+VM system's use of the underlying VM pages.
+
+Test1:
+ Open the file and write into the file, creating a buf
+ with a valid range and a dirty range
+
+ Fsync, flushing the dirty range
+
+ Mmap and read the whole page. Since only part of the page is
+ valid, the VM system must re-read the invalid parts of the
+ page.
+
+Test2:
+ This is the same as test1 without the fsync. The VM system
+ should first write out the dirty range and then read the rest
+ of the page. This is currently broken since the vnode_pager
+ doesn't use the original buf for its i/o and therefore the
+ information in b_dirtyoff, b_dirtyend is not avalable.
diff --git a/tools/regression/nfsmmap/test1/Makefile b/tools/regression/nfsmmap/test1/Makefile
new file mode 100644
index 0000000..54a7b9d
--- /dev/null
+++ b/tools/regression/nfsmmap/test1/Makefile
@@ -0,0 +1,25 @@
+PROG= test1
+NOMAN= t
+NFSSERVER?= herring.nlsystems.com
+CLEANFILES= test1.zeros test1.good test1.data test1.scratch
+
+all: test1 test1.zeros test1.good
+ @cp ${.OBJDIR}/test1.zeros ${.OBJDIR}/test1.data
+ @if [ `hostname` != ${NFSSERVER} ] ; then \
+ ssh ${NFSSERVER} touch ${.OBJDIR}/test1.data; \
+ fi
+ @cd ${.OBJDIR}; ${.OBJDIR}/test1
+ @if cmp -s ${.OBJDIR}/test1.data ${.OBJDIR}/test1.good && \
+ cmp -s ${.OBJDIR}/test1.scratch ${.OBJDIR}/test1.good ; then \
+ echo passed; \
+ else \
+ echo failed; \
+ fi
+
+test1.zeros: test1.zeros.uu
+ uudecode $?
+
+test1.good: test1.good.uu
+ uudecode $?
+
+.include <bsd.prog.mk>
diff --git a/tools/regression/nfsmmap/test1/test1.c b/tools/regression/nfsmmap/test1/test1.c
new file mode 100644
index 0000000..7a7e69f
--- /dev/null
+++ b/tools/regression/nfsmmap/test1/test1.c
@@ -0,0 +1,46 @@
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+int main(int argc, char** argv)
+{
+ int fd, fd2;
+ caddr_t addr;
+ char zeros[4096];
+ char ones[200];
+
+ memset(zeros, 0, sizeof zeros);
+ memset(ones, 1, sizeof ones);
+#if 0
+ unlink("test1.data");
+ fd = open("test1.data", O_RDWR|O_CREAT, 0666);
+ if (fd < 0)
+ err(1, "creating file");
+ if (write(fd, zeros, sizeof zeros) < 0)
+ err(1, "writing zeros");
+ close(fd);
+#endif
+
+ fd = open("test1.data", O_RDWR);
+ if (fd < 0)
+ err(1, "opening file");
+ if (lseek(fd, 600, SEEK_SET) < 0)
+ err(1, "seeking");
+
+ if (write(fd, ones, sizeof ones) < 0)
+ err(1, "writing ones");
+
+ fsync(fd);
+
+ addr = mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+ if (addr == MAP_FAILED)
+ err(1, "mapping");
+ unlink("test1.scratch");
+ fd2 = open("test1.scratch", O_RDWR|O_CREAT, 0666);
+ if (fd2 < 0)
+ err(1, "creating scratch");
+
+ if (write(fd2, addr, 4096) < 0)
+ err(1, "writing scratch");
+}
diff --git a/tools/regression/nfsmmap/test1/test1.good.uu b/tools/regression/nfsmmap/test1/test1.good.uu
new file mode 100644
index 0000000..633d2d3
--- /dev/null
+++ b/tools/regression/nfsmmap/test1/test1.good.uu
@@ -0,0 +1,95 @@
+begin 644 test1.good
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!
+M`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!
+M`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!
+M`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!
+M`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$`````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+!````
+`
+end
diff --git a/tools/regression/nfsmmap/test1/test1.zeros.uu b/tools/regression/nfsmmap/test1/test1.zeros.uu
new file mode 100644
index 0000000..2332258
--- /dev/null
+++ b/tools/regression/nfsmmap/test1/test1.zeros.uu
@@ -0,0 +1,95 @@
+begin 644 test1.zeros
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+!````
+`
+end
diff --git a/tools/regression/nfsmmap/test2/Makefile b/tools/regression/nfsmmap/test2/Makefile
new file mode 100644
index 0000000..460c0b2
--- /dev/null
+++ b/tools/regression/nfsmmap/test2/Makefile
@@ -0,0 +1,25 @@
+PROG= test2
+NOMAN= t
+NFSSERVER?= herring.nlsystems.com
+CLEANFILES= test2.zeros test2.good test2.data test2.scratch
+
+all: test2 test2.zeros test2.good
+ @cp ${.OBJDIR}/test2.zeros ${.OBJDIR}/test2.data
+ @if [ `hostname` != ${NFSSERVER} ] ; then \
+ ssh ${NFSSERVER} touch ${.OBJDIR}/test2.data; \
+ fi
+ @cd ${.OBJDIR}; ${.OBJDIR}/test2
+ @if cmp -s ${.OBJDIR}/test2.data ${.OBJDIR}/test2.good && \
+ cmp -s ${.OBJDIR}/test2.scratch ${.OBJDIR}/test2.good ; then \
+ echo passed; \
+ else \
+ echo failed; \
+ fi
+
+test2.zeros: test2.zeros.uu
+ uudecode $?
+
+test2.good: test2.good.uu
+ uudecode $?
+
+.include <bsd.prog.mk>
diff --git a/tools/regression/nfsmmap/test2/test2.c b/tools/regression/nfsmmap/test2/test2.c
new file mode 100644
index 0000000..b3a19e1
--- /dev/null
+++ b/tools/regression/nfsmmap/test2/test2.c
@@ -0,0 +1,44 @@
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+int main(int argc, char** argv)
+{
+ int fd, fd2;
+ caddr_t addr;
+ char zeros[4096];
+ char ones[200];
+
+ memset(zeros, 0, sizeof zeros);
+ memset(ones, 1, sizeof ones);
+#if 0
+ unlink("test2.data");
+ fd = open("test2.data", O_RDWR|O_CREAT, 0666);
+ if (fd < 0)
+ err(1, "creating file");
+ if (write(fd, zeros, sizeof zeros) < 0)
+ err(1, "writing zeros");
+ close(fd);
+#endif
+
+ fd = open("test2.data", O_RDWR);
+ if (fd < 0)
+ err(1, "opening file");
+ if (lseek(fd, 600, SEEK_SET) < 0)
+ err(1, "seeking");
+
+ if (write(fd, ones, sizeof ones) < 0)
+ err(1, "writing ones");
+
+ addr = mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+ if (addr == MAP_FAILED)
+ err(1, "mapping");
+ unlink("test2.scratch");
+ fd2 = open("test2.scratch", O_RDWR|O_CREAT, 0666);
+ if (fd2 < 0)
+ err(1, "creating scratch");
+
+ if (write(fd2, addr, 4096) < 0)
+ err(1, "writing scratch");
+}
diff --git a/tools/regression/nfsmmap/test2/test2.good.uu b/tools/regression/nfsmmap/test2/test2.good.uu
new file mode 100644
index 0000000..2edf155
--- /dev/null
+++ b/tools/regression/nfsmmap/test2/test2.good.uu
@@ -0,0 +1,95 @@
+begin 644 test2.good
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!
+M`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!
+M`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!
+M`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!
+M`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$`````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+!````
+`
+end
diff --git a/tools/regression/nfsmmap/test2/test2.zeros.uu b/tools/regression/nfsmmap/test2/test2.zeros.uu
new file mode 100644
index 0000000..9be013a
--- /dev/null
+++ b/tools/regression/nfsmmap/test2/test2.zeros.uu
@@ -0,0 +1,95 @@
+begin 644 test2.zeros
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+!````
+`
+end
diff --git a/tools/regression/p1003_1b/Makefile b/tools/regression/p1003_1b/Makefile
new file mode 100644
index 0000000..66b0be5
--- /dev/null
+++ b/tools/regression/p1003_1b/Makefile
@@ -0,0 +1,17 @@
+# $FreeBSD$
+
+PROG=p1003_1b
+
+SRCS=\
+ fifo.c \
+ main.c \
+ memlock.c \
+ prutil.c \
+ p26.c \
+ sched.c \
+ yield.c
+
+NOMAN=1
+
+COPTS+=-DNO_MEMLOCK
+.include <bsd.prog.mk>
diff --git a/tools/regression/p1003_1b/README b/tools/regression/p1003_1b/README
new file mode 100644
index 0000000..e0b7037
--- /dev/null
+++ b/tools/regression/p1003_1b/README
@@ -0,0 +1,14 @@
+$FreeBSD$
+
+p1003_1b: Regression tests for the scheduling facilities.
+The following should always work as of the release of 4.0:
+
+p1003_1b fifo : Check that the FIFO scheduler seems to work.
+p1003_1b p26 : Check that we support the expected features.
+p1003_1b sched: Check that schedule switching seems to work.
+p1003_1b yield: Check that yielding runs the expected process.
+
+As of today "p1003_1b yield" doesn't work. I have a minimal set
+of patches I'm waiting for approval to commit.
+
+Peter dufault@freebsd.org
diff --git a/tools/regression/p1003_1b/fifo.c b/tools/regression/p1003_1b/fifo.c
new file mode 100644
index 0000000..455f7f9
--- /dev/null
+++ b/tools/regression/p1003_1b/fifo.c
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 1996 - 2000
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <err.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sched.h>
+#include <signal.h>
+
+volatile int ticked;
+#define CAN_USE_ALARMS
+
+#ifdef CAN_USE_ALARMS
+void tick(int arg)
+{
+ ticked = 1;
+}
+#endif
+
+/* Fifo: Verify that fifo and round-robin scheduling seem to work.
+ *
+ * This tests:
+ * 1. That sched_rr_get_interval seems to work;
+ * 2. That FIFO scheduling doesn't seeem to be round-robin;
+ * 3. That round-robin scheduling seems to work.
+ *
+ */
+static pid_t child;
+static void tidyup(void)
+{
+ if (child)
+ kill(child, SIGHUP);
+}
+
+static double
+tvsub(const struct timeval *a, const struct timeval *b)
+{
+ long sdiff;
+ long udiff;
+
+ sdiff = a->tv_sec - b->tv_sec;
+ udiff = a->tv_usec - b->tv_usec;
+
+ return (double)(sdiff * 1000000 + udiff) / 1e6;
+}
+
+int fifo(int argc, char *argv[])
+{
+ int e = 0;
+ volatile long *p, pid;
+ int i;
+ struct sched_param fifo_param;
+ struct timespec interval;
+#define MAX_RANAT 32
+ struct timeval ranat[MAX_RANAT];
+
+#ifdef CAN_USE_ALARMS
+ static struct itimerval itimerval;
+#endif
+
+ /* What is the round robin interval?
+ */
+
+ if (sched_rr_get_interval(0, &interval) == -1) {
+ perror("sched_rr_get_interval");
+ exit(errno);
+ }
+
+#ifdef CAN_USE_ALARMS
+ signal(SIGALRM, tick);
+#endif
+
+ fifo_param.sched_priority = 1;
+
+ p = (long *)mmap(0, sizeof(*p),
+ PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED|MAP_INHERIT, -1, 0);
+
+ if (p == (long *)-1)
+ err(errno, "mmap");
+
+ *p = 0;
+
+ if (sched_setscheduler(0, SCHED_FIFO, &fifo_param) == -1)
+ {
+ perror("sched_setscheduler");
+ return -1;
+ }
+
+ pid = getpid();
+
+ if ((child = fork()) == 0)
+ {
+ /* Child process. Just keep setting the pointer to our
+ * PID. The parent will kill us when it wants to.
+ */
+
+ pid = getpid();
+ while (1)
+ *p = pid;
+ }
+ else
+ {
+ atexit(tidyup);
+ *p = pid;
+
+
+ ticked = 0;
+
+#ifdef CAN_USE_ALARMS
+ /* Set an alarm for 250 times the round-robin interval.
+ * Then we will verify that a similar priority process
+ * will not run when we are using the FIFO scheduler.
+ */
+ itimerval.it_value.tv_usec = interval.tv_nsec / (1000 / 250);
+
+ itimerval.it_value.tv_sec = itimerval.it_value.tv_usec / 1000000;
+ itimerval.it_value.tv_usec %= 1000000;
+
+
+ if (setitimer(ITIMER_REAL, &itimerval, 0) == -1) {
+ perror("setitimer");
+ exit(errno);
+ }
+#endif
+
+
+ gettimeofday(ranat, 0);
+ i = 1;
+ while (!ticked && i < MAX_RANAT)
+ if (*p == child) {
+ gettimeofday(ranat + i, 0);
+ *p = 0;
+ e = -1;
+ i++;
+ }
+
+ if (e) {
+ int j;
+
+ fprintf(stderr,
+ "SCHED_FIFO had erroneous context switches:\n");
+ for (j = 1; j < i; j++) {
+ fprintf(stderr, "%d %g\n", j,
+ tvsub(ranat + j, ranat + j - 1));
+ }
+ return e;
+ }
+
+ /* Switch to the round robin scheduler and the child
+ * should run within twice the interval.
+ */
+ if (sched_setscheduler(child, SCHED_RR, &fifo_param) == -1 ||
+ sched_setscheduler(0, SCHED_RR, &fifo_param) == -1)
+ {
+ perror("sched_setscheduler");
+ return -1;
+ }
+
+ e = -1;
+
+ ticked = 0;
+
+#ifdef CAN_USE_ALARMS
+
+ /* Now we do want to see it run. But only set
+ * the alarm for twice the interval:
+ */
+ itimerval.it_value.tv_usec = interval.tv_nsec / 500;
+
+ if (setitimer(ITIMER_REAL, &itimerval, 0) == -1) {
+ perror("setitimer");
+ exit(errno);
+ }
+#endif
+
+ for (i = 0; !ticked; i++)
+ if (*p == child) {
+ e = 0;
+ break;
+ }
+
+ if (e)
+ fprintf(stderr,"Child never ran when it should have.\n");
+ }
+
+ exit(e);
+}
+
+#ifdef STANDALONE_TESTS
+int main(int argc, char *argv[]) { return fifo(argc, argv); }
+#endif
diff --git a/tools/regression/p1003_1b/main.c b/tools/regression/p1003_1b/main.c
new file mode 100644
index 0000000..0e87c6c
--- /dev/null
+++ b/tools/regression/p1003_1b/main.c
@@ -0,0 +1,78 @@
+/* $FreeBSD$ */
+#include <stdio.h>
+
+int fifo(int argc, char *argv[]);
+int memlock(int argc, char *argv[]);
+int p26(int argc, char *argv[]);
+int sched(int argc, char *argv[]);
+int yield(int argc, char *argv[]);
+
+static struct {
+ const char *t;
+ int (*f)(int, char *[]);
+ int works;
+} tab[] = {
+ { "fifo", fifo, 1 },
+ { "memlock", memlock, 0 },
+ { "p26", p26, 1 },
+ { "sched", sched, 1 },
+ { "yield", yield, 1 },
+};
+
+#define N(T) (sizeof (T)/ sizeof(T[0]))
+
+static int usage(int argc, char *argv[])
+{
+ int i;
+ if (argc > 1)
+ fprintf(stderr, "%s is unknown\n", argv[1]);
+
+ fprintf(stderr, "usage: %s [-a] or one of [", argv[0]);
+ for (i = 0; i < (sizeof(tab) / sizeof(tab[0])); i++)
+ fprintf(stderr, "%s%s", (i)? " | " : "", tab[i].t);
+ fprintf(stderr, "]\n");
+
+ return -1;
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ if (argc == 2 && strcmp(argv[1], "-a") == 0) {
+#if 1
+ fprintf(stderr,
+ "-a should but doesn't really work"
+ " (my notes say \"because things detach\");\n"
+ "meanwhile do these individual tests and look"
+ " for a non-zero exit code:\n");
+ for (i = 0; i < N(tab); i++)
+ if (tab[i].works)
+ fprintf(stderr, "p1003_1b %s\n", tab[i].t);
+ return -1;
+#else
+ {
+ int r;
+ for (i = 0; i < N(tab); i++) {
+ if (tab[i].works) {
+ if ( (r =
+ (*tab[i].f)(argc - 1, argv + 1)) ) {
+ fprintf(stderr,
+ "%s failed\n", tab[i].t);
+ return r;
+ }
+ }
+ }
+ return 0;
+ }
+#endif
+ }
+
+ if (argc > 1) {
+ for (i = 0; i < N(tab); i++)
+ if (strcmp(tab[i].t, argv[1]) == 0)
+ return (*tab[i].f)(argc - 1, argv + 1);
+ }
+
+ return usage(argc, argv);
+}
diff --git a/tools/regression/p1003_1b/memlock.c b/tools/regression/p1003_1b/memlock.c
new file mode 100644
index 0000000..b55b405
--- /dev/null
+++ b/tools/regression/p1003_1b/memlock.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 1996 - 1999
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "prutil.h"
+
+int memlock(int argc, char *argv[])
+{
+ int e = 0;
+
+ /* Is memory locking configured?
+ */
+ errno = 0;
+ if (sysconf(_SC_MEMLOCK) == -1) {
+ if (errno != 0) {
+ /* This isn't valid - may be a standard violation
+ */
+ quit("(should not happen) sysconf(_SC_MEMLOCK)");
+ }
+ else {
+ fprintf(stderr,
+ "Memory locking is not supported in this environment.\n");
+ e = -1;
+ }
+ }
+
+ /* Lock yourself in memory:
+ */
+ if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
+ perror("mlockall(MCL_CURRENT | MCL_FUTURE)");
+ e = errno;
+ }
+ else if (munlockall() == -1) {
+ perror("munlockall");
+ e = errno;
+ }
+
+ return e;
+}
+
+#ifdef NO_MEMLOCK
+int mlockall(int flags)
+{
+ return EOPNOTSUPP;
+}
+
+int munlockall(void)
+{
+ return EOPNOTSUPP;
+}
+
+
+#endif
+
+#ifdef STANDALONE_TESTS
+int main(int argc, char *argv[]) { return memlock(argc, argv); }
+#endif
diff --git a/tools/regression/p1003_1b/p26.c b/tools/regression/p1003_1b/p26.c
new file mode 100644
index 0000000..538deaf
--- /dev/null
+++ b/tools/regression/p1003_1b/p26.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1996-1999
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#define _POSIX_SOURCE
+#define _POSIX_C_SOURCE 199309L
+#include <unistd.h>
+#include <stdio.h>
+
+int p26(int ac, char *av[])
+{
+ int ret = 0;
+
+ #ifndef _POSIX_VERSION
+ printf("POSIX is not supported.\n");
+ ret = -1;
+ #else /* _POSIX_VERSION */
+
+ #if (_POSIX_VERSION == 198808L)
+ printf("POSIX.1 is supported but not POSIX.1B (FIPS 151-1)\n");
+ #elif (_POSIX_VERSION == 199009L)
+ printf("POSIX.1 is supported but not POSIX.1B (FIPS 151-2)\n");
+ #elif (_POSIX_VERSION >= 199309L)
+ printf("POSIX.1 and POSIX.1B are supported.\n");
+ #else
+ printf("_POSIX_VERSION (%ld) not 198808, 199009, or >= 199309.\n",
+ _POSIX_VERSION);
+ ret = -1;
+ #endif
+
+ #endif /* _POSIX_VERSION */
+ return ret;
+}
+#ifdef STANDALONE_TESTS
+int main(int argc, char *argv[]) { return p26(argc, argv); }
+#endif
diff --git a/tools/regression/p1003_1b/prutil.c b/tools/regression/p1003_1b/prutil.c
new file mode 100644
index 0000000..e0e3d6f
--- /dev/null
+++ b/tools/regression/p1003_1b/prutil.c
@@ -0,0 +1,61 @@
+#include <errno.h>
+#include <unistd.h>
+#include <sched.h>
+#include <stdio.h>
+
+#include <err.h>
+#include <sysexits.h>
+#include "prutil.h"
+
+/*
+ * $FreeBSD$
+ */
+void quit(const char *text)
+{
+ err(errno, text);
+}
+
+char *sched_text(int scheduler)
+{
+ switch(scheduler)
+ {
+ case SCHED_FIFO:
+ return "SCHED_FIFO";
+
+ case SCHED_RR:
+ return "SCHED_RR";
+
+ case SCHED_OTHER:
+ return "SCHED_OTHER";
+
+ default:
+ return "Illegal scheduler value";
+ }
+}
+
+int sched_is(int line, struct sched_param *p, int shouldbe)
+{
+ int scheduler;
+ struct sched_param param;
+
+ /* What scheduler are we running now?
+ */
+ errno = 0;
+ scheduler = sched_getscheduler(0);
+ if (sched_getparam(0, &param))
+ quit("sched_getparam");
+
+ if (p)
+ *p = param;
+
+ if (shouldbe != -1 && scheduler != shouldbe)
+ {
+ fprintf(stderr,
+ "At line %d the scheduler should be %s yet it is %s.\n",
+ line, sched_text(shouldbe), sched_text(scheduler));
+
+ exit(-1);
+ }
+
+ return scheduler;
+}
diff --git a/tools/regression/p1003_1b/prutil.h b/tools/regression/p1003_1b/prutil.h
new file mode 100644
index 0000000..3387b99
--- /dev/null
+++ b/tools/regression/p1003_1b/prutil.h
@@ -0,0 +1,14 @@
+#ifndef _PRUTIL_H_
+#define _PRUTIL_H_
+
+/*
+ * $FreeBSD$
+ */
+
+struct sched_param;
+
+void quit(const char *);
+char *sched_text(int);
+int sched_is(int line, struct sched_param *, int);
+
+#endif /* _PRUTIL_H_ */
diff --git a/tools/regression/p1003_1b/sched.c b/tools/regression/p1003_1b/sched.c
new file mode 100644
index 0000000..bd978f8
--- /dev/null
+++ b/tools/regression/p1003_1b/sched.c
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 1996-1999
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * $FreeBSD$
+ *
+ */
+
+/* XXX: The spec says that if _POSIX_C_SOURCE is defined then
+ * _POSIX_SOURCE is ignored. However, this is similar to
+ * the code in the O'Reilly "POSIX.4" book
+ */
+
+#define _POSIX_VERSION 199309L
+#define _POSIX_SOURCE
+#define _POSIX_C_SOURCE 199309L
+
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#include <sched.h>
+
+#include "prutil.h"
+
+static FILE *verbose;
+
+static void
+checkpris(int sched)
+{
+ int smin;
+ int smax;
+
+ errno = 0;
+
+ if ( (smin = sched_get_priority_min(sched)) == -1 && errno)
+ quit("sched_get_priority_min");
+
+ if ( (smax = sched_get_priority_max(sched)) == -1 && errno)
+ quit("sched_get_priority_max");
+
+ if (smax - smin + 1 < 32 || smax < smin) {
+ fprintf(stderr, "Illegal priority range for %s: %d to %d\n",
+ sched_text(sched), smin, smax);
+ exit(-1);
+ }
+
+ if (verbose)
+ fprintf(verbose, "%12s: sched_min %2d sched_max %2d\n",
+ sched_text(sched), smin, smax);
+}
+
+/* Set "try_anyway" to quit if you don't want to go on when
+ * it doesn't look like something should work.
+ */
+static void try_anyway(const char *s)
+{
+ fputs(s, stderr);
+ fprintf(stderr, "(trying anyway)\n");
+ errno = 0;
+}
+
+static void q(int line, int code, const char *text)
+{
+ if (code == -1)
+ {
+ fprintf(stderr, "Error at line %d:\n", line);
+ perror(text);
+ exit(errno);
+ }
+}
+
+int sched(int ac, char *av[])
+{
+ int fifo_schedmin, fifo_schedmax;
+ int i;
+ struct sched_param rt_param;
+ int n_instances = 10;
+ int sched;
+
+ verbose = 0;
+
+#if _POSIX_VERSION < 199309
+ try_anyway("The _POSIX_VERSION predates P1003.1B\n");
+#endif
+
+#if !defined(_POSIX_PRIORITY_SCHEDULING)
+ try_anyway(
+ "The environment does not claim to support Posix scheduling.\n");
+#endif
+
+ /* Is priority scheduling configured?
+ */
+ errno = 0;
+ if (sysconf(_SC_PRIORITY_SCHEDULING) == -1) {
+ if (errno != 0) {
+ /* This isn't valid - may be a standard violation
+ */
+ quit("(should not happen) sysconf(_SC_PRIORITY_SCHEDULING)");
+ }
+ else {
+ try_anyway(
+ "The environment does not have run-time "
+ "support for Posix scheduling.\n");
+ }
+ }
+
+ /* Check that the priorities seem reasonable.
+ */
+
+ checkpris(SCHED_FIFO);
+ checkpris(SCHED_RR);
+ checkpris(SCHED_OTHER);
+
+/* BSD extensions?
+ */
+#if defined(SCHED_IDLE)
+ checkpris(SCHED_IDLE);
+#endif
+
+ fifo_schedmin = sched_get_priority_min(SCHED_FIFO);
+ fifo_schedmax = sched_get_priority_max(SCHED_FIFO);
+
+ /* Make sure we can do some basic schedule switching:
+ */
+ {
+ struct sched_param orig_param, shouldbe;
+ int orig_scheduler = sched_is(__LINE__, &orig_param, -1);
+
+ if (verbose)
+ fprintf(verbose,
+ "The original scheduler is %s and the priority is %d.\n",
+ sched_text(orig_scheduler), orig_param.sched_priority);
+
+ /* Basic check: Try to set current settings:
+ */
+ q(__LINE__, sched_setscheduler(0, orig_scheduler, &orig_param),
+ "sched_setscheduler: Can't set original scheduler");
+
+ rt_param.sched_priority = fifo_schedmin;
+
+ q(__LINE__, sched_setscheduler(0, SCHED_FIFO, &rt_param),
+ "sched_setscheduler SCHED_FIFO");
+
+ (void)sched_is(__LINE__, 0, SCHED_FIFO);
+
+ q(__LINE__, sched_getparam(0, &shouldbe), "sched_getparam");
+
+ if (shouldbe.sched_priority != fifo_schedmin)
+ quit("sched_setscheduler wrong priority (min)");
+
+ rt_param.sched_priority = fifo_schedmin;
+
+ q(__LINE__, sched_setparam(0, &rt_param),
+ "sched_setparam to fifo_schedmin");
+
+ rt_param.sched_priority = fifo_schedmin + 1;
+
+ q(__LINE__, sched_setparam(0, &rt_param),
+ "sched_setparam to fifo_schedmin + 1");
+
+ q(__LINE__, sched_getparam(0, &shouldbe),
+ "sched_getparam");
+
+ if (shouldbe.sched_priority != fifo_schedmin + 1)
+ quit("sched_setscheduler wrong priority (min + 1)");
+
+ q(__LINE__, sched_setscheduler(0, SCHED_RR, &rt_param),
+ "sched_setscheduler SCHED_RR");
+
+ (void)sched_is(__LINE__, 0, SCHED_RR);
+
+ q(__LINE__, sched_setscheduler(0, orig_scheduler, &orig_param),
+ "sched_setscheduler restoring original scheduler");
+
+ (void)sched_is(__LINE__, 0, orig_scheduler);
+ }
+
+
+ {
+#define NAM "P1003_1b_schedXXXX"
+ char nam[L_tmpnam];
+ int fd;
+ pid_t p;
+ pid_t *lastrun;
+
+ strcpy(nam, NAM);
+ if (tmpnam(nam) != nam)
+ q(__LINE__, errno, "tmpnam " NAM);
+ q(__LINE__, (fd = open(nam, O_RDWR|O_CREAT, 0666)),
+ "open " NAM);
+
+ (void)unlink(nam);
+
+ p = (pid_t)0;
+
+ write(fd, &p, sizeof(p));
+
+ q(__LINE__, (int)(lastrun = mmap(0, sizeof(*lastrun), PROT_READ|PROT_WRITE,
+ MAP_SHARED, fd, 0)), "mmap");
+
+ /* Set our priority at the highest:
+ */
+ sched = SCHED_FIFO;
+ rt_param.sched_priority = fifo_schedmax;
+ q(__LINE__, sched_setscheduler(0, sched, &rt_param),
+ "sched_setscheduler sched");
+
+ for (i = 0; i < n_instances; i++)
+ {
+ pid_t me;
+
+ /* XXX This is completely bogus. The children never run.
+ */
+ if ((me = fork()) != 0)
+ {
+ /* Parent.
+ */
+ (void)sched_is(__LINE__, 0, sched);
+
+ /* Lower our priority:
+ */
+ rt_param.sched_priority--;
+
+ q(__LINE__, sched_setscheduler(0, sched, &rt_param),
+ "sched_setscheduler sched");
+
+ while (1)
+ {
+ q(__LINE__, sched_getparam(0, &rt_param), "sched_getparam");
+
+ rt_param.sched_priority--;
+
+
+ if (rt_param.sched_priority < fifo_schedmin)
+ exit(0);
+
+ *lastrun = me;
+ q(__LINE__, sched_setparam(0, &rt_param), "sched_setparam");
+
+ if (*lastrun == me)
+ {
+ /* The child will run twice
+ * at the end:
+ */
+ if (!me || rt_param.sched_priority != 0)
+ {
+ fprintf(stderr,
+ "ran process %ld twice at priority %d\n",
+ (long)me, rt_param.sched_priority + 1);
+ exit(-1);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+#ifdef STANDALONE_TESTS
+int main(int argc, char *argv[]) { return sched(argc, argv); }
+#endif
diff --git a/tools/regression/p1003_1b/yield.c b/tools/regression/p1003_1b/yield.c
new file mode 100644
index 0000000..ac31a99
--- /dev/null
+++ b/tools/regression/p1003_1b/yield.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 1996-1999
+ * HD Associates, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * $FreeBSD$
+ *
+ */
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <err.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sched.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+
+#include "prutil.h"
+
+/* buzz: busy wait a random amount of time.
+ */
+static void buzz(int n)
+{
+ volatile int i;
+ int m = random() & 0x0ffff;
+ for (i = 0; i < m; i++)
+ ;
+}
+
+/* Yield: Verify that "sched_yield" works for the FIFO case.
+ * This runs several processes and verifies that the yield seems
+ * to permit the next one on the ready queue to run.
+ */
+int yield(int argc, char *argv[])
+{
+ volatile int *p;
+ int i;
+ int nslaves, n;
+ int master, slave;
+ pid_t youngest = !0; /* Our youngest child */
+ struct sched_param set, got;
+ int nloops = 1000;
+
+ errno = 0;
+
+ set.sched_priority = sched_get_priority_max(SCHED_FIFO);
+ if (set.sched_priority == -1 && errno) {
+ perror("sched_get_priority_max");
+ exit(errno);
+ }
+
+ if (argc == 1)
+ n = nslaves = 10;
+
+ else if (argc != 2) {
+ fprintf(stderr, "usage: prog [n_instances]\n");
+ exit(-1);
+ }
+ else
+ n = nslaves = atoi(argv[1]);
+
+ p = (int *)mmap(0, sizeof(int),
+ PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED|MAP_INHERIT, -1, 0);
+
+ if (p == (int *)-1)
+ err(errno, "mmap");
+
+ *p = 0;
+
+ if (sched_setscheduler(0, SCHED_FIFO, &set) == -1)
+ err(errno, "sched_setscheduler");
+
+ /* I better still be SCHED_FIFO and RT_PRIO_MAX:
+ */
+ (void)sched_is(__LINE__, &got, SCHED_FIFO);
+ if (got.sched_priority != set.sched_priority) {
+ fprintf(stderr, "line %d: scheduler screwup\n",
+ __LINE__);
+ exit(-1);
+ }
+
+ slave = 0;
+ master = 1;
+
+ /* Fork off the slaves.
+ */
+ for (i = 0; i < nslaves; i++) {
+ if ((youngest = fork()) == 0) {
+ /* I better still be SCHED_FIFO and RT_PRIO_MAX:
+ */
+ (void)sched_is(__LINE__, &got, SCHED_FIFO);
+
+ if (got.sched_priority != set.sched_priority) {
+ fprintf(stderr, "line %d: scheduler screwup\n",
+ __LINE__);
+ exit(-1);
+ }
+
+ master = 0; /* I'm a slave */
+ slave = i + 1; /* With this flag */
+ *p = slave; /* And I live */
+ break;
+ }
+ }
+
+ if (master) {
+ /* If we conform the slave processes haven't run yet.
+ * The master must yield to let the first slave run.
+ */
+ if (*p != 0) {
+ fprintf(stderr,
+ "Error at line %d: Writer %d has run\n", __LINE__, *p);
+ exit(-1);
+ }
+ }
+
+ /* Now the master yields, the first slave runs, and yields,
+ * next runs, yields, ...
+ *
+ * So the master should get through this first.
+ */
+
+ if (sched_yield() == -1)
+ err(errno, "sched_yield");
+
+ if (master) {
+ int status;
+
+ /* The final slave process should be the last one started.
+ */
+ if (*p != nslaves) {
+ fprintf(stderr,
+ "Error at line %d: Final slave is %d not %d.\n",
+ __LINE__, *p, nslaves);
+ exit(-1);
+ }
+
+ /* Wait for our youngest to exit:
+ */
+ waitpid(youngest, &status, 0);
+
+ exit(WEXITSTATUS(status)); /* Let the slaves continue */
+ }
+
+ /* Now the first one has started up.
+ */
+ for (i = 0; i < nloops; i++) {
+ if (((*p) % nslaves) !=
+ ((slave + nslaves - 1) % nslaves)) {
+ fprintf(stderr, "%d ran before %d on iteration %d.\n",
+ *p, slave, i);
+ exit(-1);
+ }
+ *p = slave;
+
+ /* Delay some random amount of time.
+ */
+ buzz(slave);
+
+ if (sched_yield() == -1)
+ err(errno, "sched_yield");
+ }
+
+ exit(0);
+}
+#ifdef STANDALONE_TESTS
+int main(int argc, char *argv[]) { return yield(argc, argv); }
+#endif
diff --git a/tools/regression/security/access/Makefile b/tools/regression/security/access/Makefile
new file mode 100644
index 0000000..4b8039f
--- /dev/null
+++ b/tools/regression/security/access/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+PROG= testaccess
+NOMAN= yes
+
+SRCS= testaccess.c
+CFLAGS += -Wall
+
+.include <bsd.prog.mk>
diff --git a/tools/regression/security/access/testaccess.c b/tools/regression/security/access/testaccess.c
new file mode 100644
index 0000000..46bb01c
--- /dev/null
+++ b/tools/regression/security/access/testaccess.c
@@ -0,0 +1,360 @@
+/*-
+ * Copyright (c) 2001 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Written at NAI Labs at Network Associates by Robert Watson for the
+ * TrustedBSD Project.
+ *
+ * Work sponsored by Defense Advanced Research Projects Agency under the
+ * CHATS research program, CBOSS project.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/*
+ * Regression test to check some basic cases and see if access() and
+ * eaccess() are using the correct portions of the process credential.
+ * This test relies on running with privilege, and on UFS filesystem
+ * semantics. Running the test in other environments may result
+ * in incorrect failure identification.
+ *
+ * Note that this may also break if filesystem access control is
+ * broken, or if the ability to check and set credentials is broken.
+ *
+ * Note that this test uses two hard-coded non-root UIDs; on multi-user
+ * systems, these UIDs may be in use by an untrusted user, in which
+ * case those users could interfere with the test.
+ */
+
+#define ROOT_UID (uid_t)0
+#define WHEEL_GID (gid_t)0
+#define TEST_UID_ONE (uid_t)500
+#define TEST_GID_ONE (gid_t)500
+#define TEST_UID_TWO (uid_t)501
+#define TEST_GID_TWO (gid_t)501
+
+struct file_description {
+ char *fd_name;
+ uid_t fd_owner;
+ gid_t fd_group;
+ mode_t fd_mode;
+};
+
+static struct file_description fd_list[] = {
+{"test1", ROOT_UID, WHEEL_GID, 0400},
+{"test2", TEST_UID_ONE, WHEEL_GID,0400},
+{"test3", TEST_UID_TWO, WHEEL_GID, 0400},
+{"test4", ROOT_UID, WHEEL_GID, 0040},
+{"test5", ROOT_UID, TEST_GID_ONE, 0040},
+{"test6", ROOT_UID, TEST_GID_TWO, 0040}};
+
+static int fd_list_count = sizeof(fd_list) /
+ sizeof(struct file_description);
+
+int
+setup(void)
+{
+ int i, error;
+
+ for (i = 0; i < fd_list_count; i++) {
+ error = open(fd_list[i].fd_name, O_CREAT | O_EXCL, fd_list[i].fd_mode);
+ if (error == -1) {
+ perror("open");
+ return (error);
+ }
+ close(error);
+ error = chown(fd_list[i].fd_name, fd_list[i].fd_owner,
+ fd_list[i].fd_group);
+ if (error) {
+ perror("chown");
+ return (error);
+ }
+ }
+ return (0);
+}
+
+int
+restoreprivilege(void)
+{
+ int error;
+
+ error = setreuid(ROOT_UID, ROOT_UID);
+ if (error)
+ return (error);
+
+ error = setregid(WHEEL_GID, WHEEL_GID);
+ if (error)
+ return (error);
+
+ return (0);
+}
+
+int
+reportprivilege(char *message)
+{
+ uid_t euid, ruid, suid;
+ gid_t egid, rgid, sgid;
+ int error;
+
+ error = getresuid(&ruid, &euid, &suid);
+ if (error) {
+ perror("getresuid");
+ return (error);
+ }
+
+ error = getresgid(&rgid, &egid, &sgid);
+ if (error) {
+ perror("getresgid");
+ return (error);
+ }
+
+ if (message)
+ printf("%s: ", message);
+ printf("ruid: %d, euid: %d, suid: %d, ", ruid, euid, suid);
+ printf("rgid: %d, egid: %d, sgid: %d\n", rgid, egid, sgid);
+
+ return (0);
+}
+
+int
+cleanup(void)
+{
+ int i, error;
+
+ error = restoreprivilege();
+ if (error) {
+ perror("restoreprivilege");
+ return (error);
+ }
+
+ for (i = 0; i < fd_list_count; i++) {
+ error = unlink(fd_list[i].fd_name);
+ if (error)
+ return (error);
+ }
+
+ return (0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int error, errorseen;
+
+ if (geteuid() != 0) {
+ fprintf(stderr, "testaccess must run as root.\n");
+ exit (EXIT_FAILURE);
+ }
+
+ error = setup();
+ if (error) {
+ cleanup();
+ exit (EXIT_FAILURE);
+ }
+
+ /* Make sure saved uid is set appropriately. */
+ error = setresuid(ROOT_UID, ROOT_UID, ROOT_UID);
+ if (error) {
+ perror("setresuid");
+ cleanup();
+ }
+
+ /* Clear out additional groups. */
+ error = setgroups(0, NULL);
+ if (error) {
+ perror("setgroups");
+ cleanup();
+ }
+
+ /* Make sure saved gid is set appropriately. */
+ error = setresgid(WHEEL_GID, WHEEL_GID, WHEEL_GID);
+ if (error) {
+ perror("setresgid");
+ cleanup();
+ }
+
+ /*
+ * UID-only tests.
+ */
+
+ /* Check that saved uid is not used */
+ error = setresuid(TEST_UID_ONE, TEST_UID_ONE, ROOT_UID);
+ if (error) {
+ perror("setresuid.1");
+ cleanup();
+ exit (EXIT_FAILURE);
+ }
+
+ errorseen = 0;
+
+ error = access("test1", R_OK);
+ if (!error) {
+ fprintf(stderr, "saved uid used instead of real uid\n");
+ errorseen++;
+ }
+
+#ifdef EACCESS_AVAILABLE
+ error = eaccess("test1", R_OK);
+ if (!error) {
+ fprintf(stderr, "saved uid used instead of effective uid\n");
+ errorseen++;
+ }
+#endif
+
+ error = restoreprivilege();
+ if (error) {
+ perror("restoreprivilege");
+ cleanup();
+ exit (EXIT_FAILURE);
+ }
+
+ error = setresuid(TEST_UID_ONE, TEST_UID_TWO, ROOT_UID);
+ if (error) {
+ perror("setresid.2");
+ cleanup();
+ exit (EXIT_FAILURE);
+ }
+
+ /* Check that the real uid is used, not the effective uid */
+ error = access("test2", R_OK);
+ if (error) {
+ fprintf(stderr, "Effective uid was used instead of real uid in access().\n");
+ errorseen++;
+ }
+
+#ifdef EACCESS_AVAILABLE
+ /* Check that the effective uid is used, not the real uid */
+ error = eaccess("test3", R_OK);
+ if (error) {
+ fprintf(stderr, "Real uid was used instead of effective uid in eaccess().\n");
+ errorseen++;
+ }
+#endif
+
+ /* Check that the real uid is used, not the effective uid */
+ error = access("test3", R_OK);
+ if (!error) {
+ fprintf(stderr, "Effective uid was used instead of real uid in access().\n");
+ errorseen++;
+ }
+
+#ifdef EACCESS_AVAILABLE
+ /* Check that the effective uid is used, not the real uid */
+ error = eaccess("test2", R_OK);
+ if (!error) {
+ fprintf(stderr, "Real uid was used instead of effective uid in eaccess().\n");
+ errorseen++;
+ }
+#endif
+
+ error = restoreprivilege();
+ if (error) {
+ perror("restoreprivilege");
+ cleanup();
+ exit (EXIT_FAILURE);
+ }
+
+ error = setresgid(TEST_GID_ONE, TEST_GID_TWO, WHEEL_GID);
+ if (error) {
+ perror("setresgid.1");
+ cleanup();
+ exit (EXIT_FAILURE);
+ }
+
+ /* Set non-root effective uid to avoid excess privilege. */
+ error = setresuid(TEST_UID_ONE, TEST_UID_ONE, ROOT_UID);
+ if (error) {
+ perror("setresuid.3");
+ cleanup();
+ exit (EXIT_FAILURE);
+ }
+
+ /* Check that the saved gid is not used */
+ error = access("test4", R_OK);
+ if (!error) {
+ fprintf(stderr, "saved gid used instead of real gid\n");
+ }
+
+#ifdef EACCESS_AVAILABLE
+ error = eaccess("test4", R_OK);
+ if (!error) {
+ fprintf(stderr, "saved gid used instead of effective gid\n");
+ errorseen++;
+ }
+#endif
+
+ /* Check that the real gid is used, not the effective gid */
+ error = access("test5", R_OK);
+ if (error) {
+ fprintf(stderr, "Effective gid was used instead of real gid in access().\n");
+ errorseen++;
+ }
+
+#ifdef EACCESS_AVAILABLE
+ /* Check that the effective gid is used, not the real gid */
+ error = eaccess("test6", R_OK);
+ if (error) {
+ fprintf(stderr, "Real gid was used instead of effective gid in eaccess().\n");
+ errorseen++;
+ }
+#endif
+
+ /* Check that the real gid is used, not the effective gid */
+ error = access("test6", R_OK);
+ if (!error) {
+ fprintf(stderr, "Effective gid was used instead of real gid in access().\n");
+ errorseen++;
+ }
+
+#ifdef EACCESS_AVAILABLE
+ /* Check that the effective gid is used, not the real gid */
+ error = eaccess("test5", R_OK);
+ if (!error) {
+ fprintf(stderr, "Real gid was used instead of effective gid in eaccess().\n");
+ errorseen++;
+ }
+#endif
+
+ fprintf(stderr, "%d errors seen.\n", errorseen);
+
+ /*
+ * All tests done, restore and clean up
+ */
+
+ error = cleanup();
+ if (error) {
+ perror("cleanup");
+ exit (EXIT_FAILURE);
+ }
+
+ exit (EXIT_SUCCESS);
+}
diff --git a/tools/regression/security/proc_to_proc/Makefile b/tools/regression/security/proc_to_proc/Makefile
new file mode 100644
index 0000000..65323f4
--- /dev/null
+++ b/tools/regression/security/proc_to_proc/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+PROG= testuid
+NOMAN= yes
+
+ADDITIONAL_FLAGS=-DSETSUGID_SUPPORTED
+#ADDITIONAL_FLAGS= -DSETSUGID_SUPPORTED_BUT_NO_LIBC_STUB
+ADDITIONAL_FLAGS+= -DCHECK_CRED_SET
+CFLAGS+= ${ADDITIONAL_FLAGS}
+SRCS= testuid.c scenario.c
+
+.include <bsd.prog.mk>
diff --git a/tools/regression/security/proc_to_proc/README b/tools/regression/security/proc_to_proc/README
new file mode 100644
index 0000000..01857b8
--- /dev/null
+++ b/tools/regression/security/proc_to_proc/README
@@ -0,0 +1,54 @@
+$FreeBSD$
+
+ Inter-Process Authorization Test Suite
+ Robert Watson, TrustedBSD Project
+
+This test suite attempts to determine the behavior of inter-process
+authorization policy present in the kernel. It analyzes a series of
+important scenarios using specifically crafted process credentials
+and a set of operations. It then reports on any divergence from the
+expected results.
+
+Test operations:
+
+ptrace cred1 attempts ptrace attach to cred2
+sighup cred1 attempts SIGHUP of cred2
+sigsegv cred1 attempts SIGSEGV of cred2
+see cred1 attempts getpriority() on cred2
+sched cred1 attempts setpriority() on cred2
+
+Test scenarioes:
+
+priv on priv root process on another root process
+priv on unpriv1 root process on a non-root process
+unpriv1 on priv non-root process on a root process
+unpriv1 on unpriv1 non-root process on a similar non-root process
+unpriv1 on unpriv2 non-root process on a different non-root process
+unpriv1 on daemon1 non-root process on a root daemon process acting with
+ same non-root effective credentials
+unpriv1 on daemon2 non-root process on a root daemon process acting with
+ different non-root effective credentials
+unpriv1 on setuid1 non-root process on a setuid-root process with same
+ non-root real credentials
+unpriv1 on setuid2 non-root process on a setuid-root process with
+ different non-root real credentials
+
+The credential elements supported by the test suite are:
+
+ effective uid
+ real uid
+ saved uid
+ P_SUGID flag
+
+Other untested aspects of interest include groups, as well as session
+relationship. Other test operations that might be of interest are SIGCONT,
+and SIGIO.
+
+The current set of tests includes some tests where normally the P_SUGID
+flag is set, but isn't in the test. The result is that some tests fail
+that may not reflect real-world software configurations. However, they
+do point to possible changes that could be made in the authorization system
+to improve resilience to failure or violation of invariants.
+
+These tests rely on __setugid(), a system call enabled using options
+REGRESSION.
diff --git a/tools/regression/security/proc_to_proc/scenario.c b/tools/regression/security/proc_to_proc/scenario.c
new file mode 100644
index 0000000..5ad5105
--- /dev/null
+++ b/tools/regression/security/proc_to_proc/scenario.c
@@ -0,0 +1,431 @@
+/*-
+ * Copyright (c) 2001 Robert N. M. Watson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <sys/uio.h>
+#include <sys/ptrace.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/syscall.h>
+#include <sys/wait.h>
+#include <sys/ktrace.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+/*
+ * Relevant parts of a process credential.
+ */
+struct cred {
+ uid_t cr_euid, cr_ruid, cr_svuid;
+ int cr_issetugid;
+};
+
+/*
+ * Description of a scenario.
+ */
+struct scenario {
+ struct cred *sc_cred1, *sc_cred2; /* credentials of p1 and p2 */
+ int sc_canptrace_errno; /* desired ptrace failure */
+ int sc_canktrace_errno; /* desired ktrace failure */
+ int sc_cansighup_errno; /* desired SIGHUP failure */
+ int sc_cansigsegv_errno; /* desired SIGSEGV failure */
+ int sc_cansee_errno; /* desired getprio failure */
+ int sc_cansched_errno; /* desired setprio failure */
+ char *sc_name; /* test name */
+};
+
+/*
+ * Table of relevant credential combinations.
+ */
+static struct cred creds[] = {
+/* euid ruid svuid issetugid */
+/* 0 */ { 0, 0, 0, 0 }, /* privileged */
+/* 1 */ { 0, 0, 0, 1 }, /* privileged + issetugid */
+/* 2 */ { 1000, 1000, 1000, 0 }, /* unprivileged1 */
+/* 3 */ { 1000, 1000, 1000, 1 }, /* unprivileged1 + issetugid */
+/* 4 */ { 1001, 1001, 1001, 0 }, /* unprivileged2 */
+/* 5 */ { 1001, 1001, 1001, 1 }, /* unprivileged2 + issetugid */
+/* 6 */ { 1000, 0, 0, 0 }, /* daemon1 */
+/* 7 */ { 1000, 0, 0, 1 }, /* daemon1 + issetugid */
+/* 8 */ { 1001, 0, 0, 0 }, /* daemon2 */
+/* 9 */ { 1001, 0, 0, 1 }, /* daemon2 + issetugid */
+/* 10 */{ 0, 1000, 1000, 0 }, /* setuid1 */
+/* 11 */{ 0, 1000, 1000, 1 }, /* setuid1 + issetugid */
+/* 12 */{ 0, 1001, 1001, 0 }, /* setuid2 */
+/* 13 */{ 0, 1001, 1001, 1 }, /* setuid2 + issetugid */
+};
+
+/*
+ * Table of scenarios.
+ */
+static const struct scenario scenarios[] = {
+/* cred1 cred2 ptrace ktrace, sighup sigsegv see sched name */
+/* privileged on privileged */
+{ &creds[0], &creds[0], 0, 0, 0, 0, 0, 0, "0. priv on priv"},
+{ &creds[0], &creds[1], 0, 0, 0, 0, 0, 0, "1. priv on priv"},
+{ &creds[1], &creds[0], 0, 0, 0, 0, 0, 0, "2. priv on priv"},
+{ &creds[1], &creds[1], 0, 0, 0, 0, 0, 0, "3. priv on priv"},
+/* privileged on unprivileged */
+{ &creds[0], &creds[2], 0, 0, 0, 0, 0, 0, "4. priv on unpriv1"},
+{ &creds[0], &creds[3], 0, 0, 0, 0, 0, 0, "5. priv on unpriv1"},
+{ &creds[1], &creds[2], 0, 0, 0, 0, 0, 0, "6. priv on unpriv1"},
+{ &creds[1], &creds[3], 0, 0, 0, 0, 0, 0, "7. priv on unpriv1"},
+/* unprivileged on privileged */
+{ &creds[2], &creds[0], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "8. unpriv1 on priv"},
+{ &creds[2], &creds[1], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "9. unpriv1 on priv"},
+{ &creds[3], &creds[0], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "10. unpriv1 on priv"},
+{ &creds[3], &creds[1], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "11. unpriv1 on priv"},
+/* unprivileged on same unprivileged */
+{ &creds[2], &creds[2], 0, 0, 0, 0, 0, 0, "12. unpriv1 on unpriv1"},
+{ &creds[2], &creds[3], EPERM, EPERM, 0, EPERM, 0, 0, "13. unpriv1 on unpriv1"},
+{ &creds[3], &creds[2], 0, 0, 0, 0, 0, 0, "14. unpriv1 on unpriv1"},
+{ &creds[3], &creds[3], EPERM, EPERM, 0, EPERM, 0, 0, "15. unpriv1 on unpriv1"},
+/* unprivileged on different unprivileged */
+{ &creds[2], &creds[4], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "16. unpriv1 on unpriv2"},
+{ &creds[2], &creds[5], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "17. unpriv1 on unpriv2"},
+{ &creds[3], &creds[4], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "18. unpriv1 on unpriv2"},
+{ &creds[3], &creds[5], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "19. unpriv1 on unpriv2"},
+/* unprivileged on daemon, same */
+{ &creds[2], &creds[6], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "20. unpriv1 on daemon1"},
+{ &creds[2], &creds[7], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "21. unpriv1 on daemon1"},
+{ &creds[3], &creds[6], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "22. unpriv1 on daemon1"},
+{ &creds[3], &creds[7], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "23. unpriv1 on daemon1"},
+/* unprivileged on daemon, different */
+{ &creds[2], &creds[8], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "24. unpriv1 on daemon2"},
+{ &creds[2], &creds[9], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "25. unpriv1 on daemon2"},
+{ &creds[3], &creds[8], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "26. unpriv1 on daemon2"},
+{ &creds[3], &creds[9], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "27. unpriv1 on daemon2"},
+/* unprivileged on setuid, same */
+{ &creds[2], &creds[10], EPERM, EPERM, 0, 0, 0, 0, "28. unpriv1 on setuid1"},
+{ &creds[2], &creds[11], EPERM, EPERM, 0, EPERM, 0, 0, "29. unpriv1 on setuid1"},
+{ &creds[3], &creds[10], EPERM, EPERM, 0, 0, 0, 0, "30. unpriv1 on setuid1"},
+{ &creds[3], &creds[11], EPERM, EPERM, 0, EPERM, 0, 0, "31. unpriv1 on setuid1"},
+/* unprivileged on setuid, different */
+{ &creds[2], &creds[12], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "32. unpriv1 on setuid2"},
+{ &creds[2], &creds[13], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "33. unpriv1 on setuid2"},
+{ &creds[3], &creds[12], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "34. unpriv1 on setuid2"},
+{ &creds[3], &creds[13], EPERM, EPERM, EPERM, EPERM, 0, EPERM, "35. unpriv1 on setuid2"},
+};
+int scenarios_count = sizeof(scenarios) / sizeof(struct scenario);
+
+/*
+ * Convert an error number to a compact string representation. For now,
+ * implement only the error numbers we are likely to see.
+ */
+static char *
+errno_to_string(int error)
+{
+
+ switch (error) {
+ case EPERM:
+ return ("EPERM");
+ case EACCES:
+ return ("EACCES");
+ case EINVAL:
+ return ("EINVAL");
+ case ENOSYS:
+ return ("ENOSYS");
+ case ESRCH:
+ return ("ESRCH");
+ case EOPNOTSUPP:
+ return ("EOPNOTSUPP");
+ case 0:
+ return ("0");
+ default:
+ printf("%d\n", error);
+ return ("unknown");
+ }
+}
+
+/*
+ * Return a process credential describing the current process.
+ */
+static int
+cred_get(struct cred *cred)
+{
+ int error;
+
+ error = getresuid(&cred->cr_ruid, &cred->cr_euid, &cred->cr_svuid);
+ if (error)
+ return (error);
+
+ cred->cr_issetugid = issetugid();
+
+ return (0);
+}
+
+/*
+ * Userland stub for __setsugid() to take into account possible presence
+ * in C library, kernel, et al.
+ */
+int
+setugid(int flag)
+{
+
+#ifdef SETSUGID_SUPPORTED
+ return (__setugid(flag));
+#else
+#ifdef SETSUGID_SUPPORTED_BUT_NO_LIBC_STUB
+ return (syscall(374, flag));
+#else
+ return (ENOSYS);
+#endif
+#endif
+}
+
+/*
+ * Set the current process's credentials to match the passed credential.
+ */
+static int
+cred_set(struct cred *cred)
+{
+ int error;
+
+ error = setresuid(cred->cr_ruid, cred->cr_euid, cred->cr_svuid);
+ if (error)
+ return (error);
+
+ error = setugid(cred->cr_issetugid);
+ if (error) {
+ perror("__setugid");
+ return (error);
+ }
+
+#ifdef CHECK_CRED_SET
+ {
+ uid_t ruid, euid, svuid;
+ error = getresuid(&ruid, &euid, &svuid);
+ if (error) {
+ perror("getresuid");
+ return (-1);
+ }
+ assert(ruid == cred->cr_ruid);
+ assert(euid == cred->cr_euid);
+ assert(svuid == cred->cr_svuid);
+ assert(cred->cr_issetugid == issetugid());
+ }
+#endif /* !CHECK_CRED_SET */
+
+ return (0);
+}
+
+/*
+ * Print the passed process credential to the passed I/O stream.
+ */
+static void
+cred_print(FILE *output, struct cred *cred)
+{
+
+ fprintf(output, "(e:%d r:%d s:%d P_SUGID:%d)", cred->cr_euid,
+ cred->cr_ruid, cred->cr_svuid, cred->cr_issetugid);
+}
+
+#define LOOP_PTRACE 0
+#define LOOP_KTRACE 1
+#define LOOP_SIGHUP 2
+#define LOOP_SIGSEGV 3
+#define LOOP_SEE 4
+#define LOOP_SCHED 5
+#define LOOP_MAX LOOP_SCHED
+
+/*
+ * Enact a scenario by looping through the four test cases for the scenario,
+ * spawning off pairs of processes with the desired credentials, and
+ * reporting results to stdout.
+ */
+static int
+enact_scenario(int scenario)
+{
+ pid_t pid1, pid2;
+ char *name, *tracefile;
+ int error, desirederror, loop;
+
+ for (loop = 0; loop < LOOP_MAX+1; loop++) {
+ /*
+ * Spawn the first child, target of the operation.
+ */
+ pid1 = fork();
+ switch (pid1) {
+ case -1:
+ return (-1);
+ case 0:
+ /* child */
+ error = cred_set(scenarios[scenario].sc_cred2);
+ if (error) {
+ perror("cred_set");
+ return (error);
+ }
+ /* 200 seconds should be plenty of time. */
+ sleep(200);
+ exit(0);
+ default:
+ /* parent */
+ }
+
+ /*
+ * XXX
+ * This really isn't ideal -- give proc 1 a chance to set
+ * its credentials, or we may get spurious errors. Really,
+ * some for of IPC should be used to allow the parent to
+ * wait for the first child to be ready before spawning
+ * the second child.
+ */
+ sleep(1);
+
+ /*
+ * Spawn the second child, source of the operation.
+ */
+ pid2 = fork();
+ switch (pid2) {
+ case -1:
+ return (-1);
+
+ case 0:
+ /* child */
+ error = cred_set(scenarios[scenario].sc_cred1);
+ if (error) {
+ perror("cred_set");
+ return (error);
+ }
+
+ /*
+ * Initialize errno to zero so as to catch any
+ * generated errors. In each case, perform the
+ * operation. Preserve the error number for later
+ * use so it doesn't get stomped on by any I/O.
+ * Determine the desired error for the given case
+ * by extracting it from the scenario table.
+ * Initialize a function name string for output
+ * prettiness.
+ */
+ errno = 0;
+ switch (loop) {
+ case LOOP_PTRACE:
+ error = ptrace(PT_ATTACH, pid1, NULL, 0);
+ error = errno;
+ name = "ptrace";
+ desirederror =
+ scenarios[scenario].sc_canptrace_errno;
+ break;
+ case LOOP_KTRACE:
+ tracefile = mktemp("/tmp/testuid_ktrace.XXXXXX");
+ if (tracefile == NULL) {
+ error = errno;
+ perror("mktemp");
+ break;
+ }
+ error = ktrace(tracefile, KTROP_SET,
+ KTRFAC_SYSCALL, pid1);
+ error = errno;
+ name = "ktrace";
+ desirederror =
+ scenarios[scenario].sc_canktrace_errno;
+ unlink(tracefile);
+ break;
+ case LOOP_SIGHUP:
+ error = kill(pid1, SIGHUP);
+ error = errno;
+ name = "sighup";
+ desirederror =
+ scenarios[scenario].sc_cansighup_errno;
+ break;
+ case LOOP_SIGSEGV:
+ error = kill(pid1, SIGSEGV);
+ error = errno;
+ name = "sigsegv";
+ desirederror =
+ scenarios[scenario].sc_cansigsegv_errno;
+ break;
+ case LOOP_SEE:
+ getpriority(PRIO_PROCESS, pid1);
+ error = errno;
+ name = "see";
+ desirederror =
+ scenarios[scenario].sc_cansee_errno;
+ break;
+ case LOOP_SCHED:
+ error = setpriority(PRIO_PROCESS, pid1,
+ 0);
+ error = errno;
+ name = "sched";
+ desirederror =
+ scenarios[scenario].sc_cansched_errno;
+ break;
+ default:
+ name = "broken";
+ }
+
+ if (error != desirederror) {
+ fprintf(stdout,
+ "[%s].%s: expected %s, got %s\n ",
+ scenarios[scenario].sc_name, name,
+ errno_to_string(desirederror),
+ errno_to_string(error));
+ cred_print(stdout,
+ scenarios[scenario].sc_cred1);
+ cred_print(stdout,
+ scenarios[scenario].sc_cred2);
+ fprintf(stdout, "\n");
+ }
+
+ exit(0);
+
+ default:
+ /* parent */
+ }
+
+ error = waitpid(pid2, NULL, 0);
+ /*
+ * Once pid2 has died, it's safe to kill pid1, if it's still
+ * alive. Mask signal failure in case the test actually
+ * killed pid1 (not unlikely: can occur in both signal and
+ * ptrace cases).
+ */
+ kill(pid1, SIGKILL);
+ error = waitpid(pid2, NULL, 0);
+ }
+
+ return (0);
+}
+
+void
+enact_scenarios(void)
+{
+ int i, error;
+
+ for (i = 0; i < scenarios_count; i++) {
+ error = enact_scenario(i);
+ if (error)
+ perror("enact_scenario");
+ }
+}
diff --git a/tools/regression/security/proc_to_proc/scenario.h b/tools/regression/security/proc_to_proc/scenario.h
new file mode 100644
index 0000000..da08720
--- /dev/null
+++ b/tools/regression/security/proc_to_proc/scenario.h
@@ -0,0 +1,34 @@
+/*-
+ * Copyright (c) 2001 Robert N. M. Watson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef _SCENARIO_H
+#define _SCENARIO_H
+
+int setugid __P((int flag));
+int enact_scenarios __P((void));
+
+#endif /* !_SCENARIO_H */
diff --git a/tools/regression/security/proc_to_proc/testuid.c b/tools/regression/security/proc_to_proc/testuid.c
new file mode 100644
index 0000000..a9b81a08
--- /dev/null
+++ b/tools/regression/security/proc_to_proc/testuid.c
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 2001 Robert N. M. Watson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <unistd.h>
+
+#include "scenario.h"
+
+int
+main(int argc, char *argv[])
+{
+ int error;
+
+ fprintf(stderr, "test capabilities: ");
+#ifdef SETSUGID_SUPPORTED
+ fprintf(stderr, "[SETSUGID_SUPPORTED] ");
+#endif
+#ifdef SETSUGID_SUPPORTED_BUT_NO_LIBC_STUB
+ fprintf(stderr, "[SETSUGID_SUPPORTED_BUT_NO_LIBC_STUB] ");
+#endif
+#ifdef CHECK_CRED_SET
+ fprintf(stderr, "[CHECK_CRED_SET] ");
+#endif
+ fprintf(stderr, "\n");
+
+ error = setugid(1);
+ if (error) {
+ perror("setugid");
+ fprintf(stderr,
+ "This test suite requires options REGRESSION\n");
+ return (-1);
+ }
+
+ enact_scenarios();
+
+ return (0);
+}
+
diff --git a/tools/regression/sysvmsg/Makefile b/tools/regression/sysvmsg/Makefile
new file mode 100644
index 0000000..45f7b72
--- /dev/null
+++ b/tools/regression/sysvmsg/Makefile
@@ -0,0 +1,15 @@
+# $FreeBSD$
+# SysV Message Queue Regression Utility
+# Obtained from: $NetBSD: Makefile,v 1.3 2002/03/05 21:56:59 thorpej Exp $
+
+PROG= msgtest
+NOMAN= yes
+
+regress:
+ @if ./msgtest ./msgtest; then \
+ echo "PASS"; \
+ else \
+ echo "FAIL"; \
+ fi
+
+.include <bsd.prog.mk>
diff --git a/tools/regression/sysvmsg/README b/tools/regression/sysvmsg/README
new file mode 100644
index 0000000..f115b99
--- /dev/null
+++ b/tools/regression/sysvmsg/README
@@ -0,0 +1,13 @@
+$FreeBSD$
+
+SysV IPC Message Queue Regression Utility.
+
+This regression utility will test the SysV Message Queue facility
+in FreeBSD. You can start the test by running ``make regress'', after
+running ``make''.
+
+Obtained from: The NetBSD Foundation.
+Date of port: 13 August 2002
+
+ -- Hiten Pandya
+ -- hiten@uk.FreeBSD.org
diff --git a/tools/regression/sysvmsg/msgtest.c b/tools/regression/sysvmsg/msgtest.c
new file mode 100644
index 0000000..37981d9
--- /dev/null
+++ b/tools/regression/sysvmsg/msgtest.c
@@ -0,0 +1,347 @@
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Obtained from: $NetBSD: msgtest.c,v 1.7 2002/07/20 08:36:25 grant Exp $
+ * $FreeBSD$
+ */
+
+/*
+ * Test the SVID-compatible Message Queue facility.
+ */
+
+#include <sys/param.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+void print_msqid_ds (struct msqid_ds *, mode_t);
+void sigsys_handler(int);
+void sigchld_handler (int);
+void cleanup (void);
+void receiver (void);
+void usage (void);
+
+#define MESSAGE_TEXT_LEN 255
+
+/*
+ * Define it as test_mymsg because we already have struct mymsg and we dont
+ * want to conflict with it. Also, regression fails when the default mymsg
+ * struct is used, because mtext[] array is '1', so the passed string cannot
+ * be processed.
+ */
+struct test_mymsg {
+ long mtype;
+ char mtext[MESSAGE_TEXT_LEN];
+};
+
+const char *m1_str = "California is overrated.";
+const char *m2_str = "The quick brown fox jumped over the lazy dog.";
+
+#define MTYPE_1 1
+#define MTYPE_1_ACK 2
+
+#define MTYPE_2 3
+#define MTYPE_2_ACK 4
+
+int sender_msqid = -1;
+pid_t child_pid;
+
+key_t msgkey;
+
+int
+main(int argc, char *argv[])
+{
+ struct sigaction sa;
+ struct msqid_ds m_ds;
+ struct test_mymsg m;
+ sigset_t sigmask;
+
+ if (argc != 2)
+ usage();
+
+ /*
+ * Install a SIGSYS handler so that we can exit gracefully if
+ * System V Message Queue support isn't in the kernel.
+ */
+ sa.sa_handler = sigsys_handler;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction(SIGSYS, &sa, NULL) == -1)
+ err(1, "sigaction SIGSYS");
+
+ /*
+ * Install and SIGCHLD handler to deal with all possible exit
+ * conditions of the receiver.
+ */
+ sa.sa_handler = sigchld_handler;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction(SIGCHLD, &sa, NULL) == -1)
+ err(1, "sigaction SIGCHLD");
+
+ msgkey = ftok(argv[1], 4160);
+
+ /*
+ * Initialize child_pid to ourselves to that the cleanup function
+ * works before we create the receiver.
+ */
+ child_pid = getpid();
+
+ /*
+ * Make sure that when the sender exits, the message queue is
+ * removed.
+ */
+ if (atexit(cleanup) == -1)
+ err(1, "atexit");
+
+ if ((sender_msqid = msgget(msgkey, IPC_CREAT | 0640)) == -1)
+ err(1, "msgget");
+
+ if (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1)
+ err(1, "msgctl IPC_STAT");
+
+ print_msqid_ds(&m_ds, 0640);
+
+ m_ds.msg_perm.mode = (m_ds.msg_perm.mode & ~0777) | 0600;
+
+ if (msgctl(sender_msqid, IPC_SET, &m_ds) == -1)
+ err(1, "msgctl IPC_SET");
+
+ bzero(&m_ds, sizeof m_ds);
+
+ if (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1)
+ err(1, "msgctl IPC_STAT");
+
+ if ((m_ds.msg_perm.mode & 0777) != 0600)
+ err(1, "IPC_SET of mode didn't hold");
+
+ print_msqid_ds(&m_ds, 0600);
+
+ switch ((child_pid = fork())) {
+ case -1:
+ err(1, "fork");
+ /* NOTREACHED */
+
+ case 0:
+ receiver();
+ break;
+
+ default:
+ break;
+ }
+
+ /*
+ * Send the first message to the receiver and wait for the ACK.
+ */
+ m.mtype = MTYPE_1;
+ strcpy(m.mtext, m1_str);
+ if (msgsnd(sender_msqid, &m, sizeof(m), 0) == -1)
+ err(1, "sender: msgsnd 1");
+
+ if (msgrcv(sender_msqid, &m, sizeof(m), MTYPE_1_ACK, 0) != sizeof(m))
+ err(1, "sender: msgrcv 1 ack");
+
+ print_msqid_ds(&m_ds, 0600);
+
+ /*
+ * Send the second message to the receiver and wait for the ACK.
+ */
+ m.mtype = MTYPE_2;
+ strcpy(m.mtext, m2_str);
+ if (msgsnd(sender_msqid, &m, sizeof(m), 0) == -1)
+ err(1, "sender: msgsnd 2");
+
+ if (msgrcv(sender_msqid, &m, sizeof(m), MTYPE_2_ACK, 0) != sizeof(m))
+ err(1, "sender: msgrcv 2 ack");
+
+ /*
+ * Suspend forever; when we get SIGCHLD, the handler will exit.
+ */
+ sigemptyset(&sigmask);
+ (void) sigsuspend(&sigmask);
+
+ /*
+ * ...and any other signal is an unexpected error.
+ */
+ errx(1, "sender: received unexpected signal");
+}
+
+void
+sigsys_handler(int signo)
+{
+
+ errx(1, "System V Message Queue support is not present in the kernel");
+}
+
+void
+sigchld_handler(int signo)
+{
+ struct msqid_ds m_ds;
+ int cstatus;
+
+ /*
+ * Reap the child; if it exited successfully, then the test passed!
+ */
+ if (waitpid(child_pid, &cstatus, 0) != child_pid)
+ err(1, "waitpid");
+
+ if (WIFEXITED(cstatus) == 0)
+ errx(1, "receiver exited abnormally");
+
+ if (WEXITSTATUS(cstatus) != 0)
+ errx(1, "receiver exited with status %d",
+ WEXITSTATUS(cstatus));
+
+ /*
+ * If we get here, the child has exited normally, and thus
+ * we should exit normally too. First, tho, we print out
+ * the final stats for the message queue.
+ */
+
+ if (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1)
+ err(1, "msgctl IPC_STAT");
+
+ print_msqid_ds(&m_ds, 0600);
+
+ exit(0);
+}
+
+void
+cleanup()
+{
+
+ /*
+ * If we're the sender, and it exists, remove the message queue.
+ */
+ if (child_pid != 0 && sender_msqid != -1) {
+ if (msgctl(sender_msqid, IPC_RMID, NULL) == -1)
+ warn("msgctl IPC_RMID");
+ }
+}
+
+void
+print_msqid_ds(struct msqid_ds *mp, mode_t mode)
+{
+ uid_t uid = geteuid();
+ gid_t gid = getegid();
+
+ printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n",
+ mp->msg_perm.uid, mp->msg_perm.gid,
+ mp->msg_perm.cuid, mp->msg_perm.cgid,
+ mp->msg_perm.mode & 0777);
+
+ printf("qnum %lu, qbytes %lu, lspid %d, lrpid %d\n",
+ mp->msg_qnum, (u_long)mp->msg_qbytes, mp->msg_lspid,
+ mp->msg_lrpid);
+
+ printf("stime: %s", ctime(&mp->msg_stime));
+ printf("rtime: %s", ctime(&mp->msg_rtime));
+ printf("ctime: %s", ctime(&mp->msg_ctime));
+
+ /*
+ * Sanity check a few things.
+ */
+
+ if (mp->msg_perm.uid != uid || mp->msg_perm.cuid != uid)
+ errx(1, "uid mismatch");
+
+ if (mp->msg_perm.gid != gid || mp->msg_perm.cgid != gid)
+ errx(1, "gid mismatch");
+
+ if ((mp->msg_perm.mode & 0777) != mode)
+ errx(1, "mode mismatch");
+}
+
+void
+usage()
+{
+
+ fprintf(stderr, "usage: %s keypath\n", getprogname());
+ exit(1);
+}
+
+void
+receiver()
+{
+ struct test_mymsg m;
+ int msqid;
+
+ if ((msqid = msgget(msgkey, 0)) == -1)
+ err(1, "receiver: msgget");
+
+ /*
+ * Receive the first message, print it, and send an ACK.
+ */
+
+ if (msgrcv(msqid, &m, sizeof(m), MTYPE_1, 0) != sizeof(m))
+ err(1, "receiver: msgrcv 1");
+
+ printf("%s\n", m.mtext);
+ if (strcmp(m.mtext, m1_str) != 0)
+ err(1, "receiver: message 1 data isn't correct");
+
+ m.mtype = MTYPE_1_ACK;
+
+ if (msgsnd(msqid, &m, sizeof(m), 0) == -1)
+ err(1, "receiver: msgsnd ack 1");
+
+ /*
+ * Receive the second message, print it, and send an ACK.
+ */
+
+ if (msgrcv(msqid, &m, sizeof(m), MTYPE_2, 0) != sizeof(m))
+ err(1, "receiver: msgrcv 2");
+
+ printf("%s\n", m.mtext);
+ if (strcmp(m.mtext, m2_str) != 0)
+ err(1, "receiver: message 2 data isn't correct");
+
+ m.mtype = MTYPE_2_ACK;
+
+ if (msgsnd(msqid, &m, sizeof(m), 0) == -1)
+ err(1, "receiver: msgsnd ack 2");
+
+ exit(0);
+}
diff --git a/tools/regression/sysvsem/Makefile b/tools/regression/sysvsem/Makefile
new file mode 100644
index 0000000..f5a3726
--- /dev/null
+++ b/tools/regression/sysvsem/Makefile
@@ -0,0 +1,15 @@
+# $FreeBSD$
+# SysV Semaphores Regression Utility
+# Obtained from: $NetBSD: Makefile,v 1.3 2002/03/05 21:57:00 thorpej Exp $
+
+PROG= semtest
+NOMAN= yes
+
+regress:
+ @if ./semtest ./semtest; then \
+ echo "PASS"; \
+ else \
+ echo "FAIL"; \
+ fi
+
+.include <bsd.prog.mk>
diff --git a/tools/regression/sysvsem/README b/tools/regression/sysvsem/README
new file mode 100644
index 0000000..33b9706
--- /dev/null
+++ b/tools/regression/sysvsem/README
@@ -0,0 +1,13 @@
+$FreeBSD$
+
+SysV IPC Semaphore Regression Utility.
+
+This regression utility will test the SysV semaphore functionality
+in FreeBSD. You can start the test by running ``make regress'', after
+running ``make''.
+
+Obtained from: NetBSD Foundation Inc.
+Date of port: 13 August 2002
+
+ -- Hiten Pandya
+ -- hiten@uk.FreeBSD.org
diff --git a/tools/regression/sysvsem/semtest.c b/tools/regression/sysvsem/semtest.c
new file mode 100644
index 0000000..83f73e9
--- /dev/null
+++ b/tools/regression/sysvsem/semtest.c
@@ -0,0 +1,348 @@
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Obtained from: $NetBSD: semtest.c,v 1.4 2002/07/20 08:36:25 grant Exp $
+ * $FreeBSD$
+ */
+
+/*
+ * Test the SVID-compatible Semaphore facility.
+ */
+
+#include <sys/param.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+int main (int, char *[]);
+void print_semid_ds (struct semid_ds *, mode_t);
+void sigsys_handler (int);
+void sigchld_handler(int);
+void cleanup (void);
+void waiter (void);
+void usage (void);
+
+int sender_semid = -1;
+pid_t child_pid;
+int child_count;
+int signal_was_sigchld;
+
+key_t semkey;
+
+/*
+ * This is the original semun union used by the sysvsem utility.
+ * It is deliberately kept here under #if 0'ed condition for future
+ * reference. PLEASE DO NOT REMOVE. The {SET,GET}ALL in FreeBSD
+ * are signed values, so the default version in sys/sem.h suffices.
+ */
+#if 0
+union semun {
+ int val; /* value for SETVAL */
+ struct semid_ds *buf; /* buffer for IPC_{STAT,SET} */
+ u_short *array; /* array for GETALL & SETALL */
+};
+#endif
+
+int
+main(int argc, char *argv[])
+{
+ struct sigaction sa;
+ union semun sun;
+ struct semid_ds s_ds;
+ sigset_t sigmask;
+ int i;
+
+ if (argc != 2)
+ usage();
+
+ /*
+ * Install a SIGSYS handler so that we can exit gracefully if
+ * System V Semaphore support isn't in the kernel.
+ */
+ sa.sa_handler = sigsys_handler;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction(SIGSYS, &sa, NULL) == -1)
+ err(1, "sigaction SIGSYS");
+
+ /*
+ * Install and SIGCHLD handler to deal with all possible exit
+ * conditions of the receiver.
+ */
+ sa.sa_handler = sigchld_handler;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction(SIGCHLD, &sa, NULL) == -1)
+ err(1, "sigaction SIGCHLD");
+
+ semkey = ftok(argv[1], 4160);
+
+ /*
+ * Initialize child_pid to ourselves to that the cleanup function
+ * works before we create the receiver.
+ */
+ child_pid = getpid();
+
+ /*
+ * Make sure that when the sender exits, the message queue is
+ * removed.
+ */
+ if (atexit(cleanup) == -1)
+ err(1, "atexit");
+
+ if ((sender_semid = semget(semkey, 1, IPC_CREAT | 0640)) == -1)
+ err(1, "semget");
+
+
+ sun.buf = &s_ds;
+ if (semctl(sender_semid, 0, IPC_STAT, sun) == -1)
+ err(1, "semctl IPC_STAT");
+
+ print_semid_ds(&s_ds, 0640);
+
+ s_ds.sem_perm.mode = (s_ds.sem_perm.mode & ~0777) | 0600;
+
+ sun.buf = &s_ds;
+ if (semctl(sender_semid, 0, IPC_SET, sun) == -1)
+ err(1, "semctl IPC_SET");
+
+ memset(&s_ds, 0, sizeof(s_ds));
+
+ sun.buf = &s_ds;
+ if (semctl(sender_semid, 0, IPC_STAT, sun) == -1)
+ err(1, "semctl IPC_STAT");
+
+ if ((s_ds.sem_perm.mode & 0777) != 0600)
+ err(1, "IPC_SET of mode didn't hold");
+
+ print_semid_ds(&s_ds, 0600);
+
+ for (child_count = 0; child_count < 5; child_count++) {
+ switch ((child_pid = fork())) {
+ case -1:
+ err(1, "fork");
+ /* NOTREACHED */
+
+ case 0:
+ waiter();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /*
+ * Wait for all of the waiters to be attempting to acquire the
+ * semaphore.
+ */
+ for (;;) {
+ i = semctl(sender_semid, 0, GETNCNT);
+ if (i == -1)
+ err(1, "semctl GETNCNT");
+ if (i == 5)
+ break;
+ }
+
+ /*
+ * Now set the thundering herd in motion by initializing the
+ * semaphore to the value 1.
+ */
+ sun.val = 1;
+ if (semctl(sender_semid, 0, SETVAL, sun) == -1)
+ err(1, "sender: semctl SETVAL to 1");
+
+ /*
+ * Suspend forever; when we get SIGCHLD, the handler will exit.
+ */
+ sigemptyset(&sigmask);
+ for (;;) {
+ (void) sigsuspend(&sigmask);
+ if (signal_was_sigchld)
+ signal_was_sigchld = 0;
+ else
+ break;
+ }
+
+ /*
+ * ...and any other signal is an unexpected error.
+ */
+ errx(1, "sender: received unexpected signal");
+}
+
+void
+sigsys_handler(int signo)
+{
+
+ errx(1, "System V Semaphore support is not present in the kernel");
+}
+
+void
+sigchld_handler(int signo)
+{
+ union semun sun;
+ struct semid_ds s_ds;
+ int cstatus;
+
+ /*
+ * Reap the child; if it exited successfully, then we're on the
+ * right track!
+ */
+ if (wait(&cstatus) == -1)
+ err(1, "wait");
+
+ if (WIFEXITED(cstatus) == 0)
+ errx(1, "receiver exited abnormally");
+
+ if (WEXITSTATUS(cstatus) != 0)
+ errx(1, "receiver exited with status %d",
+ WEXITSTATUS(cstatus));
+
+ /*
+ * If we get here, the child has exited normally, and we should
+ * decrement the child count. If the child_count reaches 0, we
+ * should exit.
+ */
+
+ sun.buf = &s_ds;
+ if (semctl(sender_semid, 0, IPC_STAT, sun) == -1)
+ err(1, "semctl IPC_STAT");
+
+ print_semid_ds(&s_ds, 0600);
+
+ if (--child_count != 0) {
+ signal_was_sigchld = 1;
+ return;
+ }
+
+ exit(0);
+}
+
+void
+cleanup()
+{
+
+ /*
+ * If we're the sender, and it exists, remove the message queue.
+ */
+ if (child_pid != 0 && sender_semid != -1) {
+ if (semctl(sender_semid, 0, IPC_RMID) == -1)
+ warn("semctl IPC_RMID");
+ }
+}
+
+void
+print_semid_ds(struct semid_ds *sp, mode_t mode)
+{
+ uid_t uid = geteuid();
+ gid_t gid = getegid();
+
+ printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n",
+ sp->sem_perm.uid, sp->sem_perm.gid,
+ sp->sem_perm.cuid, sp->sem_perm.cgid,
+ sp->sem_perm.mode & 0777);
+
+ printf("nsems %u\n", sp->sem_nsems);
+
+ printf("otime: %s", ctime(&sp->sem_otime));
+ printf("ctime: %s", ctime(&sp->sem_ctime));
+
+ /*
+ * Sanity check a few things.
+ */
+
+ if (sp->sem_perm.uid != uid || sp->sem_perm.cuid != uid)
+ errx(1, "uid mismatch");
+
+ if (sp->sem_perm.gid != gid || sp->sem_perm.cgid != gid)
+ errx(1, "gid mismatch");
+
+ if ((sp->sem_perm.mode & 0777) != mode)
+ errx(1, "mode mismatch %o != %o",
+ (sp->sem_perm.mode & 0777), mode);
+}
+
+void
+usage()
+{
+
+ fprintf(stderr, "usage: %s keypath\n", getprogname());
+ exit(1);
+}
+
+void
+waiter()
+{
+ struct sembuf s;
+ int semid;
+
+ if ((semid = semget(semkey, 1, 0)) == -1)
+ err(1, "waiter: semget");
+
+ /*
+ * Attempt to acquire the semaphore.
+ */
+ s.sem_num = 0;
+ s.sem_op = -1;
+ s.sem_flg = SEM_UNDO;
+
+ if (semop(semid, &s, 1) == -1)
+ err(1, "waiter: semop -1");
+
+ printf("WOO! GOT THE SEMAPHORE!\n");
+ sleep(1);
+
+ /*
+ * Release the semaphore and exit.
+ */
+ s.sem_num = 0;
+ s.sem_op = 1;
+ s.sem_flg = SEM_UNDO;
+
+ if (semop(semid, &s, 1) == -1)
+ err(1, "waiter: semop +1");
+
+ exit(0);
+}
diff --git a/tools/regression/sysvshm/Makefile b/tools/regression/sysvshm/Makefile
new file mode 100644
index 0000000..9905385
--- /dev/null
+++ b/tools/regression/sysvshm/Makefile
@@ -0,0 +1,15 @@
+# $FreeBSD$
+# SysV Shared Memory Regression Utility
+# Obtained from: $NetBSD: Makefile,v 1.3 2002/03/05 21:57:00 thorpej Exp $
+
+PROG= shmtest
+NOMAN= yes
+
+regress:
+ @if ./shmtest ./shmtest; then \
+ echo "PASS"; \
+ else \
+ echo "FAIL"; \
+ fi
+
+.include <bsd.prog.mk>
diff --git a/tools/regression/sysvshm/README b/tools/regression/sysvshm/README
new file mode 100644
index 0000000..4e0125e
--- /dev/null
+++ b/tools/regression/sysvshm/README
@@ -0,0 +1,13 @@
+$FreeBSD$
+
+SysV IPC Shared Memory Regression Utility.
+
+This regression utility will test the SysV Shared Memory facility
+in FreeBSD. You can start the test by running ``make regress'', after
+running ``make''.
+
+Obtained from: The NetBSD Foundation.
+Date of port: 13 August 2002
+
+ -- Hiten Pandya
+ -- hiten@uk.FreeBSD.org
diff --git a/tools/regression/sysvshm/shmtest.c b/tools/regression/sysvshm/shmtest.c
new file mode 100644
index 0000000..22f626e
--- /dev/null
+++ b/tools/regression/sysvshm/shmtest.c
@@ -0,0 +1,297 @@
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Obtained from: $NetBSD: shmtest.c,v 1.3 2002/07/20 08:36:26 grant Exp $
+ * $FreeBSD$
+ */
+
+/*
+ * Test the SVID-compatible Shared Memory facility.
+ */
+
+#include <sys/param.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+int main __P((int, char *[]));
+void print_shmid_ds __P((struct shmid_ds *, mode_t));
+void sigsys_handler __P((int));
+void sigchld_handler __P((int));
+void cleanup __P((void));
+void receiver __P((void));
+void usage __P((void));
+
+const char *m_str = "The quick brown fox jumped over the lazy dog.";
+
+int sender_shmid = -1;
+pid_t child_pid;
+
+key_t shmkey;
+
+size_t pgsize;
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ struct sigaction sa;
+ struct shmid_ds s_ds;
+ sigset_t sigmask;
+ char *shm_buf;
+
+ if (argc != 2)
+ usage();
+
+ /*
+ * Install a SIGSYS handler so that we can exit gracefully if
+ * System V Shared Memory support isn't in the kernel.
+ */
+ sa.sa_handler = sigsys_handler;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction(SIGSYS, &sa, NULL) == -1)
+ err(1, "sigaction SIGSYS");
+
+ /*
+ * Install and SIGCHLD handler to deal with all possible exit
+ * conditions of the receiver.
+ */
+ sa.sa_handler = sigchld_handler;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction(SIGCHLD, &sa, NULL) == -1)
+ err(1, "sigaction SIGCHLD");
+
+ pgsize = sysconf(_SC_PAGESIZE);
+
+ shmkey = ftok(argv[1], 4160);
+
+ /*
+ * Initialize child_pid to ourselves to that the cleanup function
+ * works before we create the receiver.
+ */
+ child_pid = getpid();
+
+ /*
+ * Make sure that when the sender exits, the message queue is
+ * removed.
+ */
+ if (atexit(cleanup) == -1)
+ err(1, "atexit");
+
+ if ((sender_shmid = shmget(shmkey, pgsize, IPC_CREAT | 0640)) == -1)
+ err(1, "shmget");
+
+ if (shmctl(sender_shmid, IPC_STAT, &s_ds) == -1)
+ err(1, "shmctl IPC_STAT");
+
+ print_shmid_ds(&s_ds, 0640);
+
+ s_ds.shm_perm.mode = (s_ds.shm_perm.mode & ~0777) | 0600;
+
+ if (shmctl(sender_shmid, IPC_SET, &s_ds) == -1)
+ err(1, "shmctl IPC_SET");
+
+ memset(&s_ds, 0, sizeof(s_ds));
+
+ if (shmctl(sender_shmid, IPC_STAT, &s_ds) == -1)
+ err(1, "shmctl IPC_STAT");
+
+ if ((s_ds.shm_perm.mode & 0777) != 0600)
+ err(1, "IPC_SET of mode didn't hold");
+
+ print_shmid_ds(&s_ds, 0600);
+
+ if ((shm_buf = shmat(sender_shmid, NULL, 0)) == (void *) -1)
+ err(1, "sender: shmat");
+
+ /*
+ * Write the test pattern into the shared memory buffer.
+ */
+ strcpy(shm_buf, m_str);
+
+ switch ((child_pid = fork())) {
+ case -1:
+ err(1, "fork");
+ /* NOTREACHED */
+
+ case 0:
+ receiver();
+ break;
+
+ default:
+ break;
+ }
+
+ /*
+ * Suspend forever; when we get SIGCHLD, the handler will exit.
+ */
+ sigemptyset(&sigmask);
+ (void) sigsuspend(&sigmask);
+
+ /*
+ * ...and any other signal is an unexpected error.
+ */
+ errx(1, "sender: received unexpected signal");
+}
+
+void
+sigsys_handler(signo)
+ int signo;
+{
+
+ errx(1, "System V Shared Memory support is not present in the kernel");
+}
+
+void
+sigchld_handler(signo)
+ int signo;
+{
+ struct shmid_ds s_ds;
+ int cstatus;
+
+ /*
+ * Reap the child; if it exited successfully, then the test passed!
+ */
+ if (waitpid(child_pid, &cstatus, 0) != child_pid)
+ err(1, "waitpid");
+
+ if (WIFEXITED(cstatus) == 0)
+ errx(1, "receiver exited abnormally");
+
+ if (WEXITSTATUS(cstatus) != 0)
+ errx(1, "receiver exited with status %d",
+ WEXITSTATUS(cstatus));
+
+ /*
+ * If we get here, the child has exited normally, and thus
+ * we should exit normally too. First, tho, we print out
+ * the final stats for the message queue.
+ */
+
+ if (shmctl(sender_shmid, IPC_STAT, &s_ds) == -1)
+ err(1, "shmctl IPC_STAT");
+
+ print_shmid_ds(&s_ds, 0600);
+
+ exit(0);
+}
+
+void
+cleanup()
+{
+
+ /*
+ * If we're the sender, and it exists, remove the shared memory area.
+ */
+ if (child_pid != 0 && sender_shmid != -1) {
+ if (shmctl(sender_shmid, IPC_RMID, NULL) == -1)
+ warn("shmctl IPC_RMID");
+ }
+}
+
+void
+print_shmid_ds(sp, mode)
+ struct shmid_ds *sp;
+ mode_t mode;
+{
+ uid_t uid = geteuid();
+ gid_t gid = getegid();
+
+ printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n",
+ sp->shm_perm.uid, sp->shm_perm.gid,
+ sp->shm_perm.cuid, sp->shm_perm.cgid,
+ sp->shm_perm.mode & 0777);
+
+ printf("segsz %lu, lpid %d, cpid %d, nattch %u\n",
+ (u_long)sp->shm_segsz, sp->shm_lpid, sp->shm_cpid,
+ sp->shm_nattch);
+
+ printf("atime: %s", ctime(&sp->shm_atime));
+ printf("dtime: %s", ctime(&sp->shm_dtime));
+ printf("ctime: %s", ctime(&sp->shm_ctime));
+
+ /*
+ * Sanity check a few things.
+ */
+
+ if (sp->shm_perm.uid != uid || sp->shm_perm.cuid != uid)
+ errx(1, "uid mismatch");
+
+ if (sp->shm_perm.gid != gid || sp->shm_perm.cgid != gid)
+ errx(1, "gid mismatch");
+
+ if ((sp->shm_perm.mode & 0777) != mode)
+ errx(1, "mode mismatch");
+}
+
+void
+usage()
+{
+
+ fprintf(stderr, "usage: %s keypath\n", getprogname());
+ exit(1);
+}
+
+void
+receiver()
+{
+ int shmid;
+ void *shm_buf;
+
+ if ((shmid = shmget(shmkey, pgsize, 0)) == -1)
+ err(1, "receiver: shmget");
+
+ if ((shm_buf = shmat(shmid, NULL, 0)) == (void *) -1)
+ err(1, "receiver: shmat");
+
+ printf("%s\n", (const char *)shm_buf);
+ if (strcmp((const char *)shm_buf, m_str) != 0)
+ err(1, "receiver: data isn't correct");
+
+ exit(0);
+}
diff --git a/tools/regression/usr.bin/Makefile b/tools/regression/usr.bin/Makefile
new file mode 100644
index 0000000..acc6b66
--- /dev/null
+++ b/tools/regression/usr.bin/Makefile
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+SUBDIR= file2c join jot m4 make sed uudecode uuencode xargs
+
+.include <bsd.subdir.mk>
diff --git a/tools/regression/usr.bin/file2c/Makefile b/tools/regression/usr.bin/file2c/Makefile
new file mode 100644
index 0000000..b937d41
--- /dev/null
+++ b/tools/regression/usr.bin/file2c/Makefile
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+all:
+ @m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR}
diff --git a/tools/regression/usr.bin/file2c/regress.in b/tools/regression/usr.bin/file2c/regress.in
new file mode 100644
index 0000000..405465a
--- /dev/null
+++ b/tools/regression/usr.bin/file2c/regress.in
Binary files differ
diff --git a/tools/regression/usr.bin/file2c/regress.out b/tools/regression/usr.bin/file2c/regress.out
new file mode 100644
index 0000000..91f5e00
--- /dev/null
+++ b/tools/regression/usr.bin/file2c/regress.out
@@ -0,0 +1,104 @@
+const char data[] = {
+175,212,59,239,227,234,192,22,186,113,52,204,195,81,240,223,173,115,109,
+102,175,183,24,185,173,137,107,116,77,142,217,172,196,45,62,228,41,174,
+134,54,187,231,53,124,146,136,203,52,91,174,212,115,254,86,214,31,196,19,
+159,213,217,170,247,32,69,15,231,52,136,125,195,84,63,231,94,73,173,8,93,
+21,246,118,130,218,200,68,1,213,178,88,162,39,161,153,54,177,161,114,188,
+55,163,166,158,218,151,163,44,7,42,25,221,143,194,40,129,228,100,128,87,
+22,76,210,109,149,64,61,169,252,1,10,61,78,17,233,29,222,247,155,156,34,
+151,186,171,39,111,169,87,194,186,102,95,11,205,207,209,111,83,167,166,
+29,172,60,135,178,208,166,219,38,228,105,200,239,180,184,232,11,1,81,233,
+107,45,73,109,94,17,10,51,91,47,89,38,253,42,224,111,143,244,243,132,225,
+236,187,30,9,241,233,210,161,200,236,249,21,197,176,161,185,240,15,155,
+73,244,186,255,214,180,122,15,206,205,35,217,58,112,50,82,199,35,150,232,
+96,54,67,77,248,243,17,96,131,221,212,44,236,137,88,213,20,21,87,89,238,
+199,156,82,77,167,123,2,92,199,167,190,74,59,80,50,196,105,153,40,27,93,
+170,194,85,110,39,185,21,155,221,105,44,156,220,30,29,17,220,26,54,30,167,
+42,77,239,74,240,203,94,63,221,148,49,14,107,117,66,1,105,243,79,165,175,
+174,213,130,57,187,168,91,229,107,49,55,120,144,120,93,89,120,60,127,84,
+152,194,184,102,115,33,8,221,63,46,181,152,83,62,45,231,162,173,228,103,
+103,116,248,51,141,21,236,8,30,123,30,234,59,188,86,232,101,106,153,116,
+200,64,175,52,18,186,152,60,255,171,132,173,173,176,60,246,21,85,51,240,
+237,224,250,22,33,89,89,204,108,107,121,119,120,215,207,179,181,142,127,
+78,131,95,195,100,48,166,135,170,195,247,111,185,202,47,151,74,62,32,174,
+242,230,104,193,252,28,115,187,212,110,41,39,170,27,167,229,36,31,192,214,
+209,35,149,83,44,7,74,16,6,162,164,171,21,48,68,19,137,29,115,225,31,97,
+226,39,220,241,118,3,172,249,17,144,45,171,247,34,124,160,136,171,7,165,
+127,186,207,150,30,115,162,6,75,153,114,65,146,59,93,162,184,197,81,160,
+173,244,205,8,84,76,85,214,195,73,70,6,38,135,198,111,48,242,129,24,202,
+183,227,77,62,92,136,58,149,235,155,34,100,63,248,185,247,103,12,117,135,
+218,116,114,185,35,11,178,217,192,11,184,239,201,107,24,187,32,183,149,
+180,103,191,36,72,152,129,204,108,46,14,187,236,222,134,28,158,81,41,15,
+83,148,165,165,16,50,134,119,162,211,103,6,28,182,225,13,67,165,25,110,
+51,141,158,80,112,27,2,163,34,96,55,223,171,108,115,119,191,29,45,48,176,
+93,63,123,252,132,121,238,116,180,217,185,178,213,86,194,197,122,13,159,
+70,109,151,247,182,134,65,76,155,189,174,220,28,38,253,222,56,102,50,221,
+183,255,234,113,240,24,149,76,227,18,188,10,201,110,148,51,108,253,37,32,
+192,136,135,149,253,77,23,99,213,12,35,25,219,234,9,251,145,90,23,111,223,
+251,54,16,217,91,116,214,175,95,87,116,228,191,226,227,72,67,72,227,52,
+91,237,107,6,20,30,67,179,215,177,9,138,235,14,83,23,37,127,111,36,122,
+165,179,81,247,230,81,106,89,85,62,188,48,49,122,155,172,71,129,167,98,
+25,108,23,89,100,251,85,108,114,163,179,40,40,129,67,78,165,71,126,55,35,
+108,168,86,141,242,16,178,196,234,255,243,10,170,84,201,160,243,153,12,
+246,112,87,172,229,154,154,231,225,154,62,78,50,100,211,194,225,50,14,134,
+198,5,48,174,154,213,62,249,2,77,18,179,154,27,244,32,44,73,74,150,48,103,
+186,212,126,48,213,41,240,21,209,94,239,111,157,235,120,194,179,15,45,110,
+74,114,107,248,124,221,42,1,248,115,14,20,76,219,51,178,87,83,74,81,179,
+10,188,233,36,90,123,175,106,85,72,85,247,247,150,22,127,238,219,156,230,
+141,108,80,92,226,205,250,61,57,23,128,120,138,195,61,50,48,40,89,57,0,
+108,138,179,29,182,118,58,232,220,199,228,56,184,194,86,244,239,16,198,
+172,248,114,100,209,210,74,246,210,215,83,149,65,151,36,215,64,148,13,198,
+151,160,109,43,109,176,149,187,55,216,239,227,157,71,1,137,235,100,30,155,
+160,6,153,19,17,57,45,17,211,240,230,117,98,228,16,148,211,217,183,210,
+224,126,134,129,133,59,238,108,128,55,9,53,63,209,219,15,241,210,179,126,
+209,237,226,31,168,14,244,84,15,178,156,207,52,183,238,75,46,198,222,199,
+187,122,236,157,216,200,186,206,232,178,139,180,48,172,179,64,255,173,117,
+56,187,111,51,164,176,81,74,18,223,195,241,215,110,118,170,10,85,42,118,
+207,167,76,52,10,223,217,199,21,148,132,227,122,89,95,50,196,35,113,250,
+140,131,221,33,214,61,172,16,167,189,85,183,33,99,28,255,105,45,230,252,
+78,58,141,63,233,184,227,150,177,23,124,88,77,152,224,53,47,208,156,141,
+227,80,76,93,97,205,63,126,216,128,43,234,86,241,35,225,209,53,194,40,228,
+135,97,224,135,136,209,172,124,127,193,198,125,70,219,251,134,56,110,128,
+134,235,20,184,170,1,178,173,176,236,18,79,83,60,110,117,154,242,5,254,
+212,231,224,203,236,117,245,92,109,193,45,187,32,223,184,174,68,68,7,21,
+83,150,227,254,117,189,137,53,47,194,235,84,106,158,96,253,148,233,20,219,
+47,195,115,90,131,219,109,94,179,197,153,117,170,201,115,217,52,34,242,
+177,36,163,172,89,31,237,128,202,79,206,95,232,250,245,250,248,85,205,18,
+42,255,89,27,253,151,196,70,111,223,210,133,43,141,220,38,164,115,97,253,
+143,14,110,111,161,180,120,180,10,67,159,159,131,78,250,171,117,254,102,
+180,19,191,64,121,234,124,209,6,99,115,126,62,6,180,117,63,96,47,252,91,
+238,92,31,161,23,148,54,247,17,114,8,109,120,173,236,230,16,160,52,172,
+135,100,28,109,74,112,236,30,120,44,179,241,226,128,86,36,25,43,0,131,174,
+39,71,145,42,145,57,134,49,119,186,21,71,227,7,143,23,129,207,212,68,86,
+189,223,128,210,13,244,134,154,21,247,229,135,56,126,130,64,24,129,97,170,
+179,60,2,251,235,7,146,54,168,51,205,241,176,243,18,112,166,154,11,185,
+34,2,74,34,112,80,194,44,31,79,148,22,126,184,143,164,65,185,118,97,137,
+197,195,71,201,124,30,189,16,222,168,96,21,114,25,135,66,61,52,196,6,103,
+156,174,43,155,156,146,168,129,221,31,38,17,84,177,13,182,35,86,148,68,
+216,182,162,189,162,229,124,99,43,181,175,191,21,89,116,76,18,120,112,167,
+160,199,230,54,159,75,205,231,34,123,227,122,40,228,137,194,91,15,83,32,
+161,238,160,158,81,254,235,51,181,128,169,77,75,128,9,221,244,167,92,168,
+132,102,155,20,17,0,115,64,13,198,187,22,66,80,133,155,139,35,77,184,50,
+31,108,46,113,132,129,105,10,38,109,158,217,152,252,106,137,70,214,109,
+142,23,193,78,47,157,63,199,246,92,213,249,158,193,196,65,53,159,48,43,
+139,17,210,33,122,153,199,184,146,155,64,139,233,170,2,81,2,116,140,134,
+148,214,138,6,54,223,45,254,180,208,72,255,191,65,129,138,27,28,48,41,125,
+203,72,62,184,117,59,124,59,156,127,22,130,200,25,188,17,87,87,71,180,203,
+126,37,171,228,197,213,193,24,95,185,8,33,6,135,150,88,215,49,121,249,249,
+126,93,145,33,48,231,203,214,171,53,189,190,186,69,74,78,226,152,46,73,
+97,132,93,57,243,62,8,23,160,48,143,26,243,244,69,223,70,9,4,61,104,204,
+57,82,28,232,205,45,164,252,49,24,192,241,200,120,32,90,181,153,234,105,
+124,201,101,91,145,121,236,41,0,73,54,204,145,93,72,105,203,59,118,155,
+173,58,37,137,45,50,207,33,83,188,236,149,223,23,55,24,140,220,235,248,
+224,145,15,225,11,88,85,101,138,235,92,38,59,58,179,203,8,44,28,225,1,147,
+217,197,33,237,115,216,55,178,154,74,207,199,158,198,39,180,203,103,52,
+132,48,98,243,121,32,210,6,119,180,225,230,79,227,207,190,151,119,209,155,
+216,34,156,47,179,133,184,77,108,199,243,170,14,43,166,203,191,43,209,144,
+37,246,211,139,52,133,37,75,31,6,103,246,112,230,134,120,239,33,136,82,
+40,158,0,11,62,156,209,141,170,166,191,34,201,17,115,227,161,89,21,53,200,
+239,123,153,200,115,87,10,4,203,69,132,33,245,27,237,253,86,90,38,51,139,
+117,223,46,112,206,251,91,230,219,203,46,194,226,218,192,8,24,104,111,102,
+55,241,73,26,49,35,15,35,55,48,3,151,212,63,105,195,186,42,7,221,56,14,
+122,92,188,17,179,185,199,165,231,154,149,231,102,135,64,192,7,54,233,13,
+191,88,180,161,11,154,175
+, 0};
diff --git a/tools/regression/usr.bin/file2c/regress.sh b/tools/regression/usr.bin/file2c/regress.sh
new file mode 100644
index 0000000..7558529
--- /dev/null
+++ b/tools/regression/usr.bin/file2c/regress.sh
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+REGRESSION_START($1)
+
+REGRESSION_TEST_ONE(`file2c "const char data[] = {" ", 0};" < regress.in')
+
+REGRESSION_END()
diff --git a/tools/regression/usr.bin/join/Makefile b/tools/regression/usr.bin/join/Makefile
new file mode 100644
index 0000000..b937d41
--- /dev/null
+++ b/tools/regression/usr.bin/join/Makefile
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+all:
+ @m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR}
diff --git a/tools/regression/usr.bin/join/regress.1.in b/tools/regression/usr.bin/join/regress.1.in
new file mode 100644
index 0000000..975bbaf
--- /dev/null
+++ b/tools/regression/usr.bin/join/regress.1.in
@@ -0,0 +1,4 @@
+!Name,Data1
+Foo,1
+Bar,2
+Baz,3
diff --git a/tools/regression/usr.bin/join/regress.2.in b/tools/regression/usr.bin/join/regress.2.in
new file mode 100644
index 0000000..0206b49
--- /dev/null
+++ b/tools/regression/usr.bin/join/regress.2.in
@@ -0,0 +1,4 @@
+!Name,Data2
+Foo,Bar
+Baz,2
+Foobar,1
diff --git a/tools/regression/usr.bin/join/regress.out b/tools/regression/usr.bin/join/regress.out
new file mode 100644
index 0000000..fa75c88
--- /dev/null
+++ b/tools/regression/usr.bin/join/regress.out
@@ -0,0 +1,5 @@
+!Name,Data1,Data2
+Foo,1,Bar
+Bar,2,(unknown)
+Baz,3,2
+Foobar,(unknown),1
diff --git a/tools/regression/usr.bin/join/regress.sh b/tools/regression/usr.bin/join/regress.sh
new file mode 100644
index 0000000..ee041f2
--- /dev/null
+++ b/tools/regression/usr.bin/join/regress.sh
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+REGRESSION_START($1)
+
+REGRESSION_TEST_ONE(`join -t , -a1 -a2 -e "(unknown)" -o 0,1.2,2.2 regress.1.in regress.2.in')
+
+REGRESSION_END()
diff --git a/tools/regression/usr.bin/jot/Makefile b/tools/regression/usr.bin/jot/Makefile
new file mode 100644
index 0000000..b937d41
--- /dev/null
+++ b/tools/regression/usr.bin/jot/Makefile
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+all:
+ @m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR}
diff --git a/tools/regression/usr.bin/jot/regress.out b/tools/regression/usr.bin/jot/regress.out
new file mode 100644
index 0000000..b109793
--- /dev/null
+++ b/tools/regression/usr.bin/jot/regress.out
@@ -0,0 +1 @@
+1,3,5,7,9,B,D,F,11,13,15,17,19,1B,1D,1F,21,23,25,27,29,2B,2D,2F,31,33,35,37,39,3B,3D,3F,41,43,45,47,49,4B,4D,4F,51,53,55,57,59,5B,5D,5F,61,63,65,67,69,6B,6D,6F,71,73,75,77,79,7B,7D,7F,81,83,85,87,89,8B,8D,8F,91,93,95,97,99,9B,9D,9F,A1,A3,A5,A7,A9,AB,AD,AF,B1,B3,B5,B7,B9,BB,BD,BF,C1,C3,C5,C8
diff --git a/tools/regression/usr.bin/jot/regress.sh b/tools/regression/usr.bin/jot/regress.sh
new file mode 100644
index 0000000..5b7d43a
--- /dev/null
+++ b/tools/regression/usr.bin/jot/regress.sh
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+REGRESSION_START($1)
+
+REGRESSION_TEST_ONE(`jot -w "%X" -s , 100 1 200')
+
+REGRESSION_END()
diff --git a/tools/regression/usr.bin/m4/Makefile b/tools/regression/usr.bin/m4/Makefile
new file mode 100644
index 0000000..9903670
--- /dev/null
+++ b/tools/regression/usr.bin/m4/Makefile
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+all:
+ @sh ${.CURDIR}/regress.sh ${.CURDIR}
diff --git a/tools/regression/usr.bin/m4/regress.changecom.in b/tools/regression/usr.bin/m4/regress.changecom.in
new file mode 100644
index 0000000..843fa11
--- /dev/null
+++ b/tools/regression/usr.bin/m4/regress.changecom.in
@@ -0,0 +1,3 @@
+changecom
+# dnl BSD will show this in output.
+# dnl SYSV + GNU will not show this.
diff --git a/tools/regression/usr.bin/m4/regress.changecom.out b/tools/regression/usr.bin/m4/regress.changecom.out
new file mode 100644
index 0000000..128a18b
--- /dev/null
+++ b/tools/regression/usr.bin/m4/regress.changecom.out
@@ -0,0 +1,3 @@
+
+# dnl BSD will show this in output.
+# dnl SYSV + GNU will not show this.
diff --git a/tools/regression/usr.bin/m4/regress.gchangecom.out b/tools/regression/usr.bin/m4/regress.gchangecom.out
new file mode 100644
index 0000000..00aae57
--- /dev/null
+++ b/tools/regression/usr.bin/m4/regress.gchangecom.out
@@ -0,0 +1,2 @@
+
+# # \ No newline at end of file
diff --git a/tools/regression/usr.bin/m4/regress.sh b/tools/regression/usr.bin/m4/regress.sh
new file mode 100644
index 0000000..b73d410
--- /dev/null
+++ b/tools/regression/usr.bin/m4/regress.sh
@@ -0,0 +1,40 @@
+# $FreeBSD$
+
+# Go into the regression test directory, handed to us by make(1)
+TESTDIR=$1
+if [ -z "$TESTDIR" ]; then
+ TESTDIR=.
+fi
+cd $TESTDIR
+
+STATUS=0
+
+for test in GNU/changecom changecom; do
+ echo "Running test $test"
+ case "$test" in
+ GNU/*)
+ M4="m4 -g"
+ GNU="g"
+ test=`basename $test`
+ ;;
+ *)
+ M4="m4"
+ GNU=""
+ ;;
+ esac
+ case "$test" in
+ changecom)
+ $M4 < regress.$test.in | diff -u regress.$GNU$test.out -
+ ;;
+ esac
+ if [ $? -eq 0 ]; then
+ echo "PASS: Test $test detected no regression, output matches."
+ else
+ STATUS=$?
+ echo "FAIL: Test $test failed: regression detected. See above."
+ fi
+done
+
+exit $STATUS
+
+REGRESSION_END()
diff --git a/tools/regression/usr.bin/make/Makefile b/tools/regression/usr.bin/make/Makefile
new file mode 100644
index 0000000..0ae687e
--- /dev/null
+++ b/tools/regression/usr.bin/make/Makefile
@@ -0,0 +1,95 @@
+# $FreeBSD$
+
+# Test for broken LHS expansion.
+# This *must* cause make(1) to detect a recursive variable, and fail as such.
+.if make(lhs_expn)
+FOO= ${BAR}
+BAR${NIL}= ${FOO}
+FOO${BAR}= ${FOO}
+.endif
+
+DATA1= helllo
+DATA2:= ${DATA1}
+DATA3= ${DATA2:S/ll/rr/g}
+DATA4:= ${DATA2:S/ll/rr/g}
+DATA2?= allo
+DATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g}
+DATA2= yello
+DATA1:= ${DATA5:S/l/r/g}
+NIL=
+
+all:
+ @echo "Running test variables"
+ @echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \
+ diff -u ${.CURDIR}/regress.variables.out - || ${MAKE} failure
+ @echo "PASS: Test variables detected no regression, output matches."
+ @echo "Running test targets"
+ @${MAKE} double 2>/dev/null || ${MAKE} failure
+ @echo "PASS: Test targets detected no regression."
+ @echo "Running test sysvmatch"
+ @${MAKE} sysvmatch || ${MAKE} failure
+ @echo "PASS: Test sysvmatch detected no regression."
+ @echo "Running test lhs_expn"
+ @! ${MAKE} lhs_expn && true || ${MAKE} failure
+ @echo "PASS: Test lhs_expn detected no regression."
+ @echo "Running test notdef"
+ @${MAKE} notdef || ${MAKE} failure
+ @echo "PASS: Test notdef detected no regression."
+ @echo "Running test modifiers"
+ @${MAKE} modifiers || ${MAKE} failure
+ @echo "PASS: Test modifiers detected no regression."
+ @echo "Running test funny_targets"
+ @${MAKE} funny_targets || ${MAKE} failure
+ @echo "PASS: Test funny_targets detected no regression."
+
+.if make(double)
+# Doubly-defined targets. make(1) will warn, but use the "right" one. If it
+# switches to using the "non-right" one, it breaks things worse than a little
+# regression test.
+double:
+ @true
+
+double:
+ @false
+.endif
+
+.if make(sysvmatch)
+# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst.
+sysvmatch:
+ @echo EMPTY ${NIL:=foo} LHS | \
+ diff -u ${.CURDIR}/regress.sysvmatch.out - || false
+.endif
+
+# A bogus target for the lhs_expn test; If this is reached, then the make(1)
+# program has not errored out because of the recursion caused by not expanding
+# the left-hand-side's embedded variables above.
+lhs_expn:
+ @true
+
+.if make(notdef)
+# make(1) claims to only evaluate a conditional as far as is necessary
+# to determine its value; that was not always the case.
+.undef notdef
+notdef:
+.if defined(notdef) && ${notdef:U}
+.endif
+.endif
+
+.if make(modifiers)
+# See if make(1) supports the C modifier.
+modifiers:
+ @if ${MAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \
+ grep -q "Unknown modifier 'C'"; then \
+ false; \
+ fi
+.endif
+
+.if make(funny_targets)
+funny_targets: colons::target exclamation!target
+colons::target:
+exclamation!target:
+.endif
+
+failure:
+ @echo "FAIL: Test failed: regression detected. See above."
+ @false
diff --git a/tools/regression/usr.bin/make/regress.sysvmatch.out b/tools/regression/usr.bin/make/regress.sysvmatch.out
new file mode 100644
index 0000000..759859e
--- /dev/null
+++ b/tools/regression/usr.bin/make/regress.sysvmatch.out
@@ -0,0 +1 @@
+EMPTY LHS
diff --git a/tools/regression/usr.bin/make/regress.variables.out b/tools/regression/usr.bin/make/regress.variables.out
new file mode 100644
index 0000000..83528d5
--- /dev/null
+++ b/tools/regression/usr.bin/make/regress.variables.out
@@ -0,0 +1 @@
+1:heiiro herrro 2:yello 3:yerro 4:herrlo 5:heiilo herrlo
diff --git a/tools/regression/usr.bin/regress.m4 b/tools/regression/usr.bin/regress.m4
new file mode 100644
index 0000000..8a4551c
--- /dev/null
+++ b/tools/regression/usr.bin/regress.m4
@@ -0,0 +1,61 @@
+# $FreeBSD$
+
+dnl A library of routines for doing regression tests for userland utilities.
+
+dnl Start up. We initialise the exit status to 0 (no failure) and change
+dnl into the directory specified by our first argument, which is the
+dnl directory to run the tests inside.
+define(`REGRESSION_START',
+TESTDIR=$1
+if [ -z "$TESTDIR" ]; then
+ TESTDIR=.
+fi
+cd $TESTDIR
+
+STATUS=0)
+
+dnl Check $? to see if we passed or failed. The first parameter is the test
+dnl which passed or failed. It may be nil.
+define(`REGRESSION_PASSFAIL',
+if [ $? -eq 0 ]; then
+ echo "PASS: Test $1 detected no regression. (in $TESTDIR)"
+else
+ STATUS=$?
+ echo "FAIL: Test $1 failed: regression detected. See above. (in $TESTDIR)"
+fi)
+
+dnl An actual test. The first parameter is the test name. The second is the
+dnl command/commands to execute for the actual test. Their exit status is
+dnl checked. It is assumed that the test will output to stdout, and that the
+dnl output to be used to check for regression will be in regress.TESTNAME.out.
+define(`REGRESSION_TEST',
+echo "Running test $1"
+$2 | diff -u regress.$1.out -
+REGRESSION_PASSFAIL($1))
+
+dnl A freeform regression test. Only exit status is checked.
+define(`REGRESSION_TEST_FREEFORM',
+$2
+REGRESSION_PASSFAIL($1))
+
+dnl A regression test like REGRESSION_TEST, except only regress.out is used
+dnl for checking output differences. The first argument is the command, the
+dnl second argument (which may be empty) is the test name.
+define(`REGRESSION_TEST_ONE',
+echo "Running test $2"
+$1 | diff -u regress.out -
+REGRESSION_PASSFAIL($2))
+
+dnl A fatal error. This will exit with the given status (first argument) and
+dnl print the message (second argument) prefixed with the string "FATAL :" to
+dnl the error stream.
+define(`REGRESSION_FATAL',
+echo "FATAL: $2 (in $TESTDIR)" > /dev/stderr
+exit $1)
+
+dnl Cleanup. Exit with the status code of the last failure. Should probably
+dnl be the number of failed tests, but hey presto, this is what it does. This
+dnl could also clean up potential droppings, if some forms of regression tests
+dnl end up using mktemp(1) or such.
+define(`REGRESSION_END',
+exit $STATUS)
diff --git a/tools/regression/usr.bin/sed/Makefile b/tools/regression/usr.bin/sed/Makefile
new file mode 100644
index 0000000..b937d41
--- /dev/null
+++ b/tools/regression/usr.bin/sed/Makefile
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+all:
+ @m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR}
diff --git a/tools/regression/usr.bin/sed/hanoi.sed b/tools/regression/usr.bin/sed/hanoi.sed
new file mode 100644
index 0000000..6a45dea
--- /dev/null
+++ b/tools/regression/usr.bin/sed/hanoi.sed
@@ -0,0 +1,103 @@
+# Towers of Hanoi in sed.
+#
+# @(#)hanoi.sed 8.1 (Berkeley) 6/6/93
+# $FreeBSD$
+#
+#
+# Ex:
+# Run "sed -f hanoi.sed", and enter:
+#
+# :abcd: : :<CR>
+#
+# note -- TWO carriage returns were once required, this will output the
+# sequence of states involved in moving 4 rings, the largest called "a" and
+# the smallest called "d", from the first to the second of three towers, so
+# that the rings on any tower at any time are in descending order of size.
+# You can start with a different arrangement and a different number of rings,
+# say :ce:b:ax: and it will give the shortest procedure for moving them all
+# to the middle tower. The rules are: the names of the rings must all be
+# lower-case letters, they must be input within 3 fields (representing the
+# towers) and delimited by 4 colons, such that the letters within each field
+# are in alphabetical order (i.e. rings are in descending order of size).
+#
+# For the benefit of anyone who wants to figure out the script, an "internal"
+# line of the form
+# b:0abx:1a2b3 :2 :3x2
+# has the following meaning: the material after the three markers :1, :2,
+# and :3 represents the three towers; in this case the current set-up is
+# ":ab : :x :". The numbers after a, b and x in these fields indicate
+# that the next time it gets a chance, it will move a to tower 2, move b
+# to tower 3, and move x to tower 2. The string after :0 just keeps track
+# of the alphabetical order of the names of the rings. The b at the
+# beginning means that it is now dealing with ring b (either about to move
+# it, or re-evaluating where it should next be moved to).
+#
+# Although this version is "limited" to 26 rings because of the size of the
+# alphabet, one could write a script using the same idea in which the rings
+# were represented by arbitrary [strings][within][brackets], and in place of
+# the built-in line of the script giving the order of the letters of the
+# alphabet, it would accept from the user a line giving the ordering to be
+# assumed, e.g. [ucbvax][decvax][hplabs][foo][bar].
+#
+# George Bergman
+# Math, UC Berkeley 94720 USA
+
+# cleaning, diagnostics
+s/ *//g
+/^$/d
+/[^a-z:]/{a\
+Illegal characters: use only a-z and ":". Try again.
+d
+}
+/^:[a-z]*:[a-z]*:[a-z]*:$/!{a\
+Incorrect format: use\
+\ : string1 : string2 : string3 :<CR>\
+Try again.
+d
+}
+/\([a-z]\).*\1/{a\
+Repeated letters not allowed. Try again.
+d
+}
+# initial formatting
+h
+s/[a-z]/ /g
+G
+s/^:\( *\):\( *\):\( *\):\n:\([a-z]*\):\([a-z]*\):\([a-z]*\):$/:1\4\2\3:2\5\1\3:3\6\1\2:0/
+s/[a-z]/&2/g
+s/^/abcdefghijklmnopqrstuvwxyz/
+:a
+s/^\(.\).*\1.*/&\1/
+s/.//
+/^[^:]/ba
+s/\([^0]*\)\(:0.*\)/\2\1:/
+s/^[^0]*0\(.\)/\1&/
+:b
+# outputting current state without markers
+h
+s/.*:1/:/
+s/[123]//gp
+g
+:c
+# establishing destinations
+/^\(.\).*\1:1/td
+/^\(.\).*:1[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
+/^\(.\).*:1[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
+/^\(.\).*:1[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
+/^\(.\).*:2[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
+/^\(.\).*:2[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
+/^\(.\).*:2[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
+/^\(.\).*:3[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
+/^\(.\).*:3[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
+/^\(.\).*:3[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
+bc
+# iterate back to find smallest out-of-place ring
+:d
+s/^\(.\)\(:0[^:]*\([^:]\)\1.*:\([123]\)[^:]*\1\)\4/\3\2\4/
+td
+# move said ring (right, resp. left)
+s/^\(.\)\(.*\)\1\([23]\)\(.*:\3[^ ]*\) /\1\2 \4\1\3/
+s/^\(.\)\(.*:\([12]\)[^ ]*\) \(.*\)\1\3/\1\2\1\3\4 /
+tb
+s/.*/Done! Try another, or end with ^D./p
+d
diff --git a/tools/regression/usr.bin/sed/math.sed b/tools/regression/usr.bin/sed/math.sed
new file mode 100644
index 0000000..8e7bf51
--- /dev/null
+++ b/tools/regression/usr.bin/sed/math.sed
@@ -0,0 +1,163 @@
+#
+# @(#)math.sed 8.1 (Berkeley) 6/6/93
+#
+# Addition and multiplication in sed.
+# ++ for a limited time only do (expr) too!!!
+#
+# Kevin S Braunsdorf, PUCC UNIX Group, ksb@cc.purdue.edu.
+#
+# Ex:
+# echo "4+7*3" | sed -f %f
+
+# make sure the expression is well formed
+s/[ ]//g
+/[+*\/-]$/{
+ a\
+ poorly formed expression, operator on the end
+ q
+}
+/^[+*\/]/{
+ a\
+ poorly formed expression, leading operator
+ q
+}
+
+# fill hold space with done token
+x
+s/^.*/done/
+x
+
+# main loop, process operators (*, + and () )
+: loop
+/^\+/{
+ s///
+ b loop
+}
+/^\(.*\)(\([^)]*\))\(.*\)$/{
+ H
+ s//\2/
+ x
+ s/^\(.*\)\n\(.*\)(\([^()]*\))\(.*\)$/()\2@\4@\1/
+ x
+ b loop
+}
+/^[0-9]*\*/b mul
+/^\([0-9]*\)\+\([0-9+*]*\*[0-9]*\)$/{
+ s//\2+\1/
+ b loop
+}
+/^[0-9]*\+/{
+ s/$/=/
+ b add
+}
+x
+/^done$/{
+ x
+ p
+ d
+}
+/^()/{
+ s///
+ x
+ G
+ s/\(.*\)\n\([^@]*\)@\([^@]*\)@\(.*\)/\2\1\3/
+ x
+ s/[^@]*@[^@]*@\(.*\)/\1/
+ x
+ b loop
+}
+i\
+help, stack problem
+p
+x
+p
+q
+
+# turn mul into add until 1*x -> x
+: mul
+/^0*1\*/{
+ s///
+ b loop
+}
+/^\([0-9]*\)0\*/{
+ s/^\([0-9]*\)0\*\([0-9]*\)/\1*\20/
+ b mul
+}
+s/^\([0-9]*\)1\*/\10*/
+s/^\([0-9]*\)2\*/\11*/
+s/^\([0-9]*\)3\*/\12*/
+s/^\([0-9]*\)4\*/\13*/
+s/^\([0-9]*\)5\*/\14*/
+s/^\([0-9]*\)6\*/\15*/
+s/^\([0-9]*\)7\*/\16*/
+s/^\([0-9]*\)8\*/\17*/
+s/^\([0-9]*\)9\*/\18*/
+s/\*\([0-9*]*\)/*\1+\1/
+b mul
+
+# get rid of a plus term until 0+x -> x
+: add
+/^\+\([0-9+*]*\)=/{
+ s//\1/
+ b loop
+}
+/^\([0-9*]*\)\+=/{
+ s//\1/
+ b loop
+}
+/^\([0-9]*\)\+\([0-9*+]*\)\+=/{
+ s//\2+\1/
+ b loop
+}
+/^\([0-9]*\)0\+\([0-9]*\)\([0-9]\)=/{
+ s//\1+\2=\3/
+ b add
+}
+/^\([0-9]*\)\([0-9]\)\+\([0-9]*\)0=/{
+ s//\1+\3=\2/
+ b add
+}
+/^\([0-9]*\)0\+\([0-9*+]*\)\+\([0-9]*\)\([0-9]\)=/{
+ s//\1+\2+\3=\4/
+ b add
+}
+/^\([0-9]*\)\([0-9]\)\+\([0-9*+]*\)\+\([0-9]*\)0=/{
+ s//\1+\3+\4=\2/
+ b add
+}
+s/^\([0-9]*\)1\+/\10+/
+s/^\([0-9]*\)2\+/\11+/
+s/^\([0-9]*\)3\+/\12+/
+s/^\([0-9]*\)4\+/\13+/
+s/^\([0-9]*\)5\+/\14+/
+s/^\([0-9]*\)6\+/\15+/
+s/^\([0-9]*\)7\+/\16+/
+s/^\([0-9]*\)8\+/\17+/
+s/^\([0-9]*\)9\+/\18+/
+
+s/9=\([0-9]*\)$/_=\1/
+s/8=\([0-9]*\)$/9=\1/
+s/7=\([0-9]*\)$/8=\1/
+s/6=\([0-9]*\)$/7=\1/
+s/5=\([0-9]*\)$/6=\1/
+s/4=\([0-9]*\)$/5=\1/
+s/3=\([0-9]*\)$/4=\1/
+s/2=\([0-9]*\)$/3=\1/
+s/1=\([0-9]*\)$/2=\1/
+/_/{
+ s//_0/
+ : inc
+ s/9_/_0/
+ s/8_/9/
+ s/7_/8/
+ s/6_/7/
+ s/5_/6/
+ s/4_/5/
+ s/3_/4/
+ s/2_/3/
+ s/1_/2/
+ s/0_/1/
+ s/\+_/+1/
+ /_/b inc
+}
+b add
diff --git a/tools/regression/usr.bin/sed/multitest.t b/tools/regression/usr.bin/sed/multitest.t
new file mode 100644
index 0000000..71c7f20
--- /dev/null
+++ b/tools/regression/usr.bin/sed/multitest.t
@@ -0,0 +1,552 @@
+#!/bin/sh -
+#
+# Copyright (c) 1992 Diomidis Spinellis.
+# Copyright (c) 1992, 1993
+# The Regents of the University of California. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the University of
+# California, Berkeley and its contributors.
+# 4. Neither the name of the University nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# @(#)sed.test 8.1 (Berkeley) 6/6/93
+#
+
+# sed Regression Tests
+#
+# The following files are created:
+# lines[1-4], script1, script2
+# Two directories *.out contain the test results
+
+main()
+{
+ BASE=/usr/bin/sed
+ BASELOG=sed.out
+ TEST=`cd ..; make whereobj`/sed
+ TESTLOG=nsed.out
+ DICT=/usr/share/dict/words
+
+ test_error | more
+
+ awk 'END { for (i = 1; i < 15; i++) print "l1_" i}' </dev/null >lines1
+ awk 'END { for (i = 1; i < 10; i++) print "l2_" i}' </dev/null >lines2
+
+ exec 4>&1 5>&2
+
+ # Set these flags to get messages about known problems
+ BSD=1
+ GNU=0
+ SUN=0
+ tests $BASE $BASELOG
+
+ BSD=0
+ GNU=0
+ SUN=0
+ tests $TEST $TESTLOG
+ exec 1>&4 2>&5
+ diff -c $BASELOG $TESTLOG | more
+}
+
+tests()
+{
+ SED=$1
+ DIR=$2
+ rm -rf $DIR
+ mkdir $DIR
+ MARK=100
+
+ test_args
+ test_addr
+ echo Testing commands
+ test_group
+ test_acid
+ test_branch
+ test_pattern
+ test_print
+ test_subst
+}
+
+mark()
+{
+ MARK=`expr $MARK + 1`
+ exec 1>&4 2>&5
+ exec >"$DIR/${MARK}_$1"
+ echo "Test $1:$MARK"
+ # Uncomment this line to match tests with sed error messages
+ echo "Test $1:$MARK" >&5
+}
+
+test_args()
+{
+ mark '1.1'
+ echo Testing argument parsing
+ echo First type
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED 's/^/e1_/p' lines1
+ fi
+ mark '1.2' ; $SED -n 's/^/e1_/p' lines1
+ mark '1.3'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED 's/^/e1_/p' <lines1
+ fi
+ mark '1.4' ; $SED -n 's/^/e1_/p' <lines1
+ echo Second type
+ mark '1.4.1'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed fails this
+ fi
+ $SED -e '' <lines1
+ echo 's/^/s1_/p' >script1
+ echo 's/^/s2_/p' >script2
+ mark '1.5'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -f script1 lines1
+ fi
+ mark '1.6'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -f script1 <lines1
+ fi
+ mark '1.7'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -e 's/^/e1_/p' lines1
+ fi
+ mark '1.8'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -e 's/^/e1_/p' <lines1
+ fi
+ mark '1.9' ; $SED -n -f script1 lines1
+ mark '1.10' ; $SED -n -f script1 <lines1
+ mark '1.11' ; $SED -n -e 's/^/e1_/p' lines1
+ mark '1.12'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -n -e 's/^/e1_/p' <lines1
+ fi
+ mark '1.13'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -e 's/^/e1_/p' -e 's/^/e2_/p' lines1
+ fi
+ mark '1.14'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -f script1 -f script2 lines1
+ fi
+ mark '1.15'
+ if [ $GNU -eq 1 -o $SUN -eq 1 ] ; then
+ echo GNU and SunOS sed fail this following older POSIX draft
+ else
+ $SED -e 's/^/e1_/p' -f script1 lines1
+ fi
+ mark '1.16'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -e 's/^/e1_/p' lines1 lines1
+ fi
+ # POSIX D11.2:11251
+ mark '1.17' ; $SED p <lines1 lines1
+cat >script1 <<EOF
+#n
+# A comment
+
+p
+EOF
+ mark '1.18' ; $SED -f script1 <lines1 lines1
+}
+
+test_addr()
+{
+ echo Testing address ranges
+ mark '2.1' ; $SED -n -e '4p' lines1
+ mark '2.2' ; $SED -n -e '20p' lines1 lines2
+ mark '2.3' ; $SED -n -e '$p' lines1
+ mark '2.4' ; $SED -n -e '$p' lines1 lines2
+ mark '2.5' ; $SED -n -e '$a\
+hello' /dev/null
+ mark '2.6' ; $SED -n -e '$p' lines1 /dev/null lines2
+ # Should not print anything
+ mark '2.7' ; $SED -n -e '20p' lines1
+ mark '2.8' ; $SED -n -e '0p' lines1
+ mark '2.9' ; $SED -n '/l1_7/p' lines1
+ mark '2.10' ; $SED -n ' /l1_7/ p' lines1
+ mark '2.11'
+ if [ $BSD -eq 1 ] ; then
+ echo BSD sed fails this test
+ fi
+ if [ $GNU -eq 1 ] ; then
+ echo GNU sed fails this
+ fi
+ $SED -n '\_l1\_7_p' lines1
+ mark '2.12' ; $SED -n '1,4p' lines1
+ mark '2.13' ; $SED -n '1,$p' lines1 lines2
+ mark '2.14' ; $SED -n '1,/l2_9/p' lines1 lines2
+ mark '2.15' ; $SED -n '/4/,$p' lines1 lines2
+ mark '2.16' ; $SED -n '/4/,20p' lines1 lines2
+ mark '2.17' ; $SED -n '/4/,/10/p' lines1 lines2
+ mark '2.18' ; $SED -n '/l2_3/,/l1_8/p' lines1 lines2
+ mark '2.19'
+ if [ $GNU -eq 1 ] ; then
+ echo GNU sed fails this
+ fi
+ $SED -n '12,3p' lines1 lines2
+ mark '2.20'
+ if [ $GNU -eq 1 ] ; then
+ echo GNU sed fails this
+ fi
+ $SED -n '/l1_7/,3p' lines1 lines2
+}
+
+test_group()
+{
+ echo Brace and other grouping
+ mark '3.1' ; $SED -e '
+4,12 {
+ s/^/^/
+ s/$/$/
+ s/_/T/
+}' lines1
+ mark '3.2' ; $SED -e '
+4,12 {
+ s/^/^/
+ /6/,/10/ {
+ s/$/$/
+ /8/ s/_/T/
+ }
+}' lines1
+ mark '3.3' ; $SED -e '
+4,12 !{
+ s/^/^/
+ /6/,/10/ !{
+ s/$/$/
+ /8/ !s/_/T/
+ }
+}' lines1
+ mark '3.4' ; $SED -e '4,12!s/^/^/' lines1
+}
+
+test_acid()
+{
+ echo Testing a c d and i commands
+ mark '4.1' ; $SED -n -e '
+s/^/before_i/p
+20i\
+inserted
+s/^/after_i/p
+' lines1 lines2
+ mark '4.2' ; $SED -n -e '
+5,12s/^/5-12/
+s/^/before_a/p
+/5-12/a\
+appended
+s/^/after_a/p
+' lines1 lines2
+ mark '4.3'
+ if [ $GNU -eq 1 ] ; then
+ echo GNU sed fails this
+ fi
+ $SED -n -e '
+s/^/^/p
+/l1_/a\
+appended
+8,10N
+s/$/$/p
+' lines1 lines2
+ mark '4.4' ; $SED -n -e '
+c\
+hello
+' lines1
+ mark '4.5' ; $SED -n -e '
+8c\
+hello
+' lines1
+ mark '4.6' ; $SED -n -e '
+3,14c\
+hello
+' lines1
+# SunOS and GNU sed behave differently. We follow POSIX
+# mark '4.7' ; $SED -n -e '
+#8,3c\
+#hello
+#' lines1
+ mark '4.8' ; $SED d <lines1
+}
+
+test_branch()
+{
+ echo Testing labels and branching
+ mark '5.1' ; $SED -n -e '
+b label4
+:label3
+s/^/label3_/p
+b end
+:label4
+2,12b label1
+b label2
+:label1
+s/^/label1_/p
+b
+:label2
+s/^/label2_/p
+b label3
+:end
+' lines1
+ mark '5.2'
+ if [ $BSD -eq 1 ] ; then
+ echo BSD sed fails this test
+ fi
+ $SED -n -e '
+s/l1_/l2_/
+t ok
+b
+:ok
+s/^/tested /p
+' lines1 lines2
+# SunOS sed behaves differently here. Clarification needed.
+# mark '5.3' ; $SED -n -e '
+#5,8b inside
+#1,5 {
+# s/^/^/p
+# :inside
+# s/$/$/p
+#}
+#' lines1
+# Check that t clears the substitution done flag
+ mark '5.4' ; $SED -n -e '
+1,8s/^/^/
+t l1
+:l1
+t l2
+s/$/$/p
+b
+:l2
+s/^/ERROR/
+' lines1
+# Check that reading a line clears the substitution done flag
+ mark '5.5'
+ if [ $BSD -eq 1 ] ; then
+ echo BSD sed fails this test
+ fi
+ $SED -n -e '
+t l2
+1,8s/^/^/p
+2,7N
+b
+:l2
+s/^/ERROR/p
+' lines1
+ mark '5.6' ; $SED 5q lines1
+ mark '5.7' ; $SED -e '
+5i\
+hello
+5q' lines1
+# Branch across block boundary
+ mark '5.8' ; $SED -e '
+{
+:b
+}
+s/l/m/
+tb' lines1
+}
+
+test_pattern()
+{
+echo Pattern space commands
+# Check that the pattern space is deleted
+ mark '6.1' ; $SED -n -e '
+c\
+changed
+p
+' lines1
+ mark '6.2' ; $SED -n -e '
+4d
+p
+' lines1
+# SunOS sed refused to print here
+# mark '6.3' ; $SED -e '
+#N
+#N
+#N
+#D
+#P
+#4p
+#' lines1
+ mark '6.4' ; $SED -e '
+2h
+3H
+4g
+5G
+6x
+6p
+6x
+6p
+' lines1
+ mark '6.5' ; $SED -e '4n' lines1
+ mark '6.6' ; $SED -n -e '4n' lines1
+}
+
+test_print()
+{
+ echo Testing print and file routines
+ awk 'END {for (i = 1; i < 256; i++) printf("%c", i);print "\n"}' \
+ </dev/null >lines3
+ # GNU and SunOS sed behave differently here
+ mark '7.1'
+ if [ $BSD -eq 1 ] ; then
+ echo 'BSD sed drops core on this one; TEST SKIPPED'
+ else
+ $SED -n l lines3
+ fi
+ mark '7.2' ; $SED -e '/l2_/=' lines1 lines2
+ rm -f lines4
+ mark '7.3' ; $SED -e '3,12w lines4' lines1
+ echo w results
+ cat lines4
+ mark '7.4' ; $SED -e '4r lines2' lines1
+ mark '7.5' ; $SED -e '5r /dev/dds' lines1
+ mark '7.6' ; $SED -e '6r /dev/null' lines1
+ mark '7.7'
+ if [ $BSD -eq 1 -o $GNU -eq 1 -o $SUN -eq 1 ] ; then
+ echo BSD, GNU and SunOS cannot pass this one
+ else
+ sed '200q' $DICT | sed 's$.*$s/^/&/w tmpdir/&$' >script1
+ rm -rf tmpdir
+ mkdir tmpdir
+ $SED -f script1 lines1
+ cat tmpdir/*
+ rm -rf tmpdir
+ fi
+ mark '7.8'
+ if [ $BSD -eq 1 ] ; then
+ echo BSD sed cannot pass 7.7
+ else
+ echo line1 > lines3
+ echo "" >> lines3
+ $SED -n -e '$p' lines3 /dev/null
+ fi
+
+}
+
+test_subst()
+{
+ echo Testing substitution commands
+ mark '8.1' ; $SED -e 's/./X/g' lines1
+ mark '8.2' ; $SED -e 's,.,X,g' lines1
+# GNU and SunOS sed thinks we are escaping . as wildcard, not as separator
+# mark '8.3' ; $SED -e 's.\..X.g' lines1
+# POSIX does not say that this should work
+# mark '8.4' ; $SED -e 's/[/]/Q/' lines1
+ mark '8.4' ; $SED -e 's/[\/]/Q/' lines1
+ mark '8.5' ; $SED -e 's_\__X_' lines1
+ mark '8.6' ; $SED -e 's/./(&)/g' lines1
+ mark '8.7' ; $SED -e 's/./(\&)/g' lines1
+ mark '8.8' ; $SED -e 's/\(.\)\(.\)\(.\)/x\3x\2x\1/g' lines1
+ mark '8.9' ; $SED -e 's/_/u0\
+u1\
+u2/g' lines1
+ mark '8.10'
+ if [ $BSD -eq 1 -o $GNU -eq 1 ] ; then
+ echo 'BSD/GNU sed do not understand digit flags on s commands'
+ fi
+ $SED -e 's/./X/4' lines1
+ rm -f lines4
+ mark '8.11' ; $SED -e 's/1/X/w lines4' lines1
+ echo s wfile results
+ cat lines4
+ mark '8.12' ; $SED -e 's/[123]/X/g' lines1
+ mark '8.13' ; $SED -e 'y/0123456789/9876543210/' lines1
+ mark '8.14' ;
+ if [ $BSD -eq 1 -o $GNU -eq 1 -o $SUN -eq 1 ] ; then
+ echo BSD/GNU/SUN sed fail this test
+ else
+ $SED -e 'y10\123456789198765432\101' lines1
+ fi
+ mark '8.15' ; $SED -e '1N;2y/\n/X/' lines1
+ mark '8.16'
+ if [ $BSD -eq 1 ] ; then
+ echo 'BSD sed does not handle branch defined REs'
+ else
+ echo 'eeefff' | $SED -e 'p' -e 's/e/X/p' -e ':x' \
+ -e 's//Y/p' -e '/f/bx'
+ fi
+}
+
+test_error()
+{
+ exec 0>&3 4>&1 5>&2
+ exec 0</dev/null
+ exec 2>&1
+ set -x
+ $TEST -x && exit 1
+ $TEST -f && exit 1
+ $TEST -e && exit 1
+ $TEST -f /dev/dds && exit 1
+ $TEST p /dev/dds && exit 1
+ $TEST -f /bin/sh && exit 1
+ $TEST '{' && exit 1
+ $TEST '{' && exit 1
+ $TEST '/hello/' && exit 1
+ $TEST '1,/hello/' && exit 1
+ $TEST -e '-5p' && exit 1
+ $TEST '/jj' && exit 1
+ $TEST 'a hello' && exit 1
+ $TEST 'a \ hello' && exit 1
+ $TEST 'b foo' && exit 1
+ $TEST 'd hello' && exit 1
+ $TEST 's/aa' && exit 1
+ $TEST 's/aa/' && exit 1
+ $TEST 's/a/b' && exit 1
+ $TEST 's/a/b/c/d' && exit 1
+ $TEST 's/a/b/ 1 2' && exit 1
+ $TEST 's/a/b/ 1 g' && exit 1
+ $TEST 's/a/b/w' && exit 1
+ $TEST 'y/aa' && exit 1
+ $TEST 'y/aa/b/' && exit 1
+ $TEST 'y/aa/' && exit 1
+ $TEST 'y/a/b' && exit 1
+ $TEST 'y/a/b/c/d' && exit 1
+ $TEST '!' && exit 1
+ $TEST supercalifrangolisticexprialidociussupercalifrangolisticexcius
+ set +x
+ exec 0>&3 1>&4 2>&5
+}
+
+main
diff --git a/tools/regression/usr.bin/sed/regress.G.out b/tools/regression/usr.bin/sed/regress.G.out
new file mode 100644
index 0000000..49c277c
--- /dev/null
+++ b/tools/regression/usr.bin/sed/regress.G.out
@@ -0,0 +1,8 @@
+input
+
+data
+
+for validation
+
+of sed(1)
+
diff --git a/tools/regression/usr.bin/sed/regress.P.out b/tools/regression/usr.bin/sed/regress.P.out
new file mode 100644
index 0000000..4d3284f
--- /dev/null
+++ b/tools/regression/usr.bin/sed/regress.P.out
@@ -0,0 +1,8 @@
+input
+input
+data
+data
+for validation
+for validation
+of sed(1)
+of sed(1)
diff --git a/tools/regression/usr.bin/sed/regress.bcb.out b/tools/regression/usr.bin/sed/regress.bcb.out
new file mode 100644
index 0000000..2a26e6a
--- /dev/null
+++ b/tools/regression/usr.bin/sed/regress.bcb.out
@@ -0,0 +1,4 @@
+input
+data
+for validation
+of sed(1)
diff --git a/tools/regression/usr.bin/sed/regress.in b/tools/regression/usr.bin/sed/regress.in
new file mode 100644
index 0000000..2a26e6a
--- /dev/null
+++ b/tools/regression/usr.bin/sed/regress.in
@@ -0,0 +1,4 @@
+input
+data
+for validation
+of sed(1)
diff --git a/tools/regression/usr.bin/sed/regress.psl.out b/tools/regression/usr.bin/sed/regress.psl.out
new file mode 100644
index 0000000..8b38f4d
--- /dev/null
+++ b/tools/regression/usr.bin/sed/regress.psl.out
@@ -0,0 +1,4 @@
+
+
+
+of sed(1)
diff --git a/tools/regression/usr.bin/sed/regress.sh b/tools/regression/usr.bin/sed/regress.sh
new file mode 100644
index 0000000..15ab0e6
--- /dev/null
+++ b/tools/regression/usr.bin/sed/regress.sh
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+REGRESSION_START($1)
+
+REGRESSION_TEST(`G', `sed G < regress.in')
+REGRESSION_TEST(`P', `sed P < regress.in')
+REGRESSION_TEST(`psl', `sed \$!g\;P\;D < regress.in')
+REGRESSION_TEST(`bcb', `sed s/X/$(jot -n -bx -s "" 2043)\\\\zz/ < regress.in')
+REGRESSION_TEST(`y', `echo -n foo | sed y/o/O/')
+
+REGRESSION_END()
diff --git a/tools/regression/usr.bin/sed/regress.y.out b/tools/regression/usr.bin/sed/regress.y.out
new file mode 100644
index 0000000..22f4f05
--- /dev/null
+++ b/tools/regression/usr.bin/sed/regress.y.out
@@ -0,0 +1 @@
+fOO \ No newline at end of file
diff --git a/tools/regression/usr.bin/sed/sed.test b/tools/regression/usr.bin/sed/sed.test
new file mode 100644
index 0000000..71c7f20
--- /dev/null
+++ b/tools/regression/usr.bin/sed/sed.test
@@ -0,0 +1,552 @@
+#!/bin/sh -
+#
+# Copyright (c) 1992 Diomidis Spinellis.
+# Copyright (c) 1992, 1993
+# The Regents of the University of California. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the University of
+# California, Berkeley and its contributors.
+# 4. Neither the name of the University nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# @(#)sed.test 8.1 (Berkeley) 6/6/93
+#
+
+# sed Regression Tests
+#
+# The following files are created:
+# lines[1-4], script1, script2
+# Two directories *.out contain the test results
+
+main()
+{
+ BASE=/usr/bin/sed
+ BASELOG=sed.out
+ TEST=`cd ..; make whereobj`/sed
+ TESTLOG=nsed.out
+ DICT=/usr/share/dict/words
+
+ test_error | more
+
+ awk 'END { for (i = 1; i < 15; i++) print "l1_" i}' </dev/null >lines1
+ awk 'END { for (i = 1; i < 10; i++) print "l2_" i}' </dev/null >lines2
+
+ exec 4>&1 5>&2
+
+ # Set these flags to get messages about known problems
+ BSD=1
+ GNU=0
+ SUN=0
+ tests $BASE $BASELOG
+
+ BSD=0
+ GNU=0
+ SUN=0
+ tests $TEST $TESTLOG
+ exec 1>&4 2>&5
+ diff -c $BASELOG $TESTLOG | more
+}
+
+tests()
+{
+ SED=$1
+ DIR=$2
+ rm -rf $DIR
+ mkdir $DIR
+ MARK=100
+
+ test_args
+ test_addr
+ echo Testing commands
+ test_group
+ test_acid
+ test_branch
+ test_pattern
+ test_print
+ test_subst
+}
+
+mark()
+{
+ MARK=`expr $MARK + 1`
+ exec 1>&4 2>&5
+ exec >"$DIR/${MARK}_$1"
+ echo "Test $1:$MARK"
+ # Uncomment this line to match tests with sed error messages
+ echo "Test $1:$MARK" >&5
+}
+
+test_args()
+{
+ mark '1.1'
+ echo Testing argument parsing
+ echo First type
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED 's/^/e1_/p' lines1
+ fi
+ mark '1.2' ; $SED -n 's/^/e1_/p' lines1
+ mark '1.3'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED 's/^/e1_/p' <lines1
+ fi
+ mark '1.4' ; $SED -n 's/^/e1_/p' <lines1
+ echo Second type
+ mark '1.4.1'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed fails this
+ fi
+ $SED -e '' <lines1
+ echo 's/^/s1_/p' >script1
+ echo 's/^/s2_/p' >script2
+ mark '1.5'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -f script1 lines1
+ fi
+ mark '1.6'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -f script1 <lines1
+ fi
+ mark '1.7'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -e 's/^/e1_/p' lines1
+ fi
+ mark '1.8'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -e 's/^/e1_/p' <lines1
+ fi
+ mark '1.9' ; $SED -n -f script1 lines1
+ mark '1.10' ; $SED -n -f script1 <lines1
+ mark '1.11' ; $SED -n -e 's/^/e1_/p' lines1
+ mark '1.12'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -n -e 's/^/e1_/p' <lines1
+ fi
+ mark '1.13'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -e 's/^/e1_/p' -e 's/^/e2_/p' lines1
+ fi
+ mark '1.14'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -f script1 -f script2 lines1
+ fi
+ mark '1.15'
+ if [ $GNU -eq 1 -o $SUN -eq 1 ] ; then
+ echo GNU and SunOS sed fail this following older POSIX draft
+ else
+ $SED -e 's/^/e1_/p' -f script1 lines1
+ fi
+ mark '1.16'
+ if [ $SUN -eq 1 ] ; then
+ echo SunOS sed prints only with -n
+ else
+ $SED -e 's/^/e1_/p' lines1 lines1
+ fi
+ # POSIX D11.2:11251
+ mark '1.17' ; $SED p <lines1 lines1
+cat >script1 <<EOF
+#n
+# A comment
+
+p
+EOF
+ mark '1.18' ; $SED -f script1 <lines1 lines1
+}
+
+test_addr()
+{
+ echo Testing address ranges
+ mark '2.1' ; $SED -n -e '4p' lines1
+ mark '2.2' ; $SED -n -e '20p' lines1 lines2
+ mark '2.3' ; $SED -n -e '$p' lines1
+ mark '2.4' ; $SED -n -e '$p' lines1 lines2
+ mark '2.5' ; $SED -n -e '$a\
+hello' /dev/null
+ mark '2.6' ; $SED -n -e '$p' lines1 /dev/null lines2
+ # Should not print anything
+ mark '2.7' ; $SED -n -e '20p' lines1
+ mark '2.8' ; $SED -n -e '0p' lines1
+ mark '2.9' ; $SED -n '/l1_7/p' lines1
+ mark '2.10' ; $SED -n ' /l1_7/ p' lines1
+ mark '2.11'
+ if [ $BSD -eq 1 ] ; then
+ echo BSD sed fails this test
+ fi
+ if [ $GNU -eq 1 ] ; then
+ echo GNU sed fails this
+ fi
+ $SED -n '\_l1\_7_p' lines1
+ mark '2.12' ; $SED -n '1,4p' lines1
+ mark '2.13' ; $SED -n '1,$p' lines1 lines2
+ mark '2.14' ; $SED -n '1,/l2_9/p' lines1 lines2
+ mark '2.15' ; $SED -n '/4/,$p' lines1 lines2
+ mark '2.16' ; $SED -n '/4/,20p' lines1 lines2
+ mark '2.17' ; $SED -n '/4/,/10/p' lines1 lines2
+ mark '2.18' ; $SED -n '/l2_3/,/l1_8/p' lines1 lines2
+ mark '2.19'
+ if [ $GNU -eq 1 ] ; then
+ echo GNU sed fails this
+ fi
+ $SED -n '12,3p' lines1 lines2
+ mark '2.20'
+ if [ $GNU -eq 1 ] ; then
+ echo GNU sed fails this
+ fi
+ $SED -n '/l1_7/,3p' lines1 lines2
+}
+
+test_group()
+{
+ echo Brace and other grouping
+ mark '3.1' ; $SED -e '
+4,12 {
+ s/^/^/
+ s/$/$/
+ s/_/T/
+}' lines1
+ mark '3.2' ; $SED -e '
+4,12 {
+ s/^/^/
+ /6/,/10/ {
+ s/$/$/
+ /8/ s/_/T/
+ }
+}' lines1
+ mark '3.3' ; $SED -e '
+4,12 !{
+ s/^/^/
+ /6/,/10/ !{
+ s/$/$/
+ /8/ !s/_/T/
+ }
+}' lines1
+ mark '3.4' ; $SED -e '4,12!s/^/^/' lines1
+}
+
+test_acid()
+{
+ echo Testing a c d and i commands
+ mark '4.1' ; $SED -n -e '
+s/^/before_i/p
+20i\
+inserted
+s/^/after_i/p
+' lines1 lines2
+ mark '4.2' ; $SED -n -e '
+5,12s/^/5-12/
+s/^/before_a/p
+/5-12/a\
+appended
+s/^/after_a/p
+' lines1 lines2
+ mark '4.3'
+ if [ $GNU -eq 1 ] ; then
+ echo GNU sed fails this
+ fi
+ $SED -n -e '
+s/^/^/p
+/l1_/a\
+appended
+8,10N
+s/$/$/p
+' lines1 lines2
+ mark '4.4' ; $SED -n -e '
+c\
+hello
+' lines1
+ mark '4.5' ; $SED -n -e '
+8c\
+hello
+' lines1
+ mark '4.6' ; $SED -n -e '
+3,14c\
+hello
+' lines1
+# SunOS and GNU sed behave differently. We follow POSIX
+# mark '4.7' ; $SED -n -e '
+#8,3c\
+#hello
+#' lines1
+ mark '4.8' ; $SED d <lines1
+}
+
+test_branch()
+{
+ echo Testing labels and branching
+ mark '5.1' ; $SED -n -e '
+b label4
+:label3
+s/^/label3_/p
+b end
+:label4
+2,12b label1
+b label2
+:label1
+s/^/label1_/p
+b
+:label2
+s/^/label2_/p
+b label3
+:end
+' lines1
+ mark '5.2'
+ if [ $BSD -eq 1 ] ; then
+ echo BSD sed fails this test
+ fi
+ $SED -n -e '
+s/l1_/l2_/
+t ok
+b
+:ok
+s/^/tested /p
+' lines1 lines2
+# SunOS sed behaves differently here. Clarification needed.
+# mark '5.3' ; $SED -n -e '
+#5,8b inside
+#1,5 {
+# s/^/^/p
+# :inside
+# s/$/$/p
+#}
+#' lines1
+# Check that t clears the substitution done flag
+ mark '5.4' ; $SED -n -e '
+1,8s/^/^/
+t l1
+:l1
+t l2
+s/$/$/p
+b
+:l2
+s/^/ERROR/
+' lines1
+# Check that reading a line clears the substitution done flag
+ mark '5.5'
+ if [ $BSD -eq 1 ] ; then
+ echo BSD sed fails this test
+ fi
+ $SED -n -e '
+t l2
+1,8s/^/^/p
+2,7N
+b
+:l2
+s/^/ERROR/p
+' lines1
+ mark '5.6' ; $SED 5q lines1
+ mark '5.7' ; $SED -e '
+5i\
+hello
+5q' lines1
+# Branch across block boundary
+ mark '5.8' ; $SED -e '
+{
+:b
+}
+s/l/m/
+tb' lines1
+}
+
+test_pattern()
+{
+echo Pattern space commands
+# Check that the pattern space is deleted
+ mark '6.1' ; $SED -n -e '
+c\
+changed
+p
+' lines1
+ mark '6.2' ; $SED -n -e '
+4d
+p
+' lines1
+# SunOS sed refused to print here
+# mark '6.3' ; $SED -e '
+#N
+#N
+#N
+#D
+#P
+#4p
+#' lines1
+ mark '6.4' ; $SED -e '
+2h
+3H
+4g
+5G
+6x
+6p
+6x
+6p
+' lines1
+ mark '6.5' ; $SED -e '4n' lines1
+ mark '6.6' ; $SED -n -e '4n' lines1
+}
+
+test_print()
+{
+ echo Testing print and file routines
+ awk 'END {for (i = 1; i < 256; i++) printf("%c", i);print "\n"}' \
+ </dev/null >lines3
+ # GNU and SunOS sed behave differently here
+ mark '7.1'
+ if [ $BSD -eq 1 ] ; then
+ echo 'BSD sed drops core on this one; TEST SKIPPED'
+ else
+ $SED -n l lines3
+ fi
+ mark '7.2' ; $SED -e '/l2_/=' lines1 lines2
+ rm -f lines4
+ mark '7.3' ; $SED -e '3,12w lines4' lines1
+ echo w results
+ cat lines4
+ mark '7.4' ; $SED -e '4r lines2' lines1
+ mark '7.5' ; $SED -e '5r /dev/dds' lines1
+ mark '7.6' ; $SED -e '6r /dev/null' lines1
+ mark '7.7'
+ if [ $BSD -eq 1 -o $GNU -eq 1 -o $SUN -eq 1 ] ; then
+ echo BSD, GNU and SunOS cannot pass this one
+ else
+ sed '200q' $DICT | sed 's$.*$s/^/&/w tmpdir/&$' >script1
+ rm -rf tmpdir
+ mkdir tmpdir
+ $SED -f script1 lines1
+ cat tmpdir/*
+ rm -rf tmpdir
+ fi
+ mark '7.8'
+ if [ $BSD -eq 1 ] ; then
+ echo BSD sed cannot pass 7.7
+ else
+ echo line1 > lines3
+ echo "" >> lines3
+ $SED -n -e '$p' lines3 /dev/null
+ fi
+
+}
+
+test_subst()
+{
+ echo Testing substitution commands
+ mark '8.1' ; $SED -e 's/./X/g' lines1
+ mark '8.2' ; $SED -e 's,.,X,g' lines1
+# GNU and SunOS sed thinks we are escaping . as wildcard, not as separator
+# mark '8.3' ; $SED -e 's.\..X.g' lines1
+# POSIX does not say that this should work
+# mark '8.4' ; $SED -e 's/[/]/Q/' lines1
+ mark '8.4' ; $SED -e 's/[\/]/Q/' lines1
+ mark '8.5' ; $SED -e 's_\__X_' lines1
+ mark '8.6' ; $SED -e 's/./(&)/g' lines1
+ mark '8.7' ; $SED -e 's/./(\&)/g' lines1
+ mark '8.8' ; $SED -e 's/\(.\)\(.\)\(.\)/x\3x\2x\1/g' lines1
+ mark '8.9' ; $SED -e 's/_/u0\
+u1\
+u2/g' lines1
+ mark '8.10'
+ if [ $BSD -eq 1 -o $GNU -eq 1 ] ; then
+ echo 'BSD/GNU sed do not understand digit flags on s commands'
+ fi
+ $SED -e 's/./X/4' lines1
+ rm -f lines4
+ mark '8.11' ; $SED -e 's/1/X/w lines4' lines1
+ echo s wfile results
+ cat lines4
+ mark '8.12' ; $SED -e 's/[123]/X/g' lines1
+ mark '8.13' ; $SED -e 'y/0123456789/9876543210/' lines1
+ mark '8.14' ;
+ if [ $BSD -eq 1 -o $GNU -eq 1 -o $SUN -eq 1 ] ; then
+ echo BSD/GNU/SUN sed fail this test
+ else
+ $SED -e 'y10\123456789198765432\101' lines1
+ fi
+ mark '8.15' ; $SED -e '1N;2y/\n/X/' lines1
+ mark '8.16'
+ if [ $BSD -eq 1 ] ; then
+ echo 'BSD sed does not handle branch defined REs'
+ else
+ echo 'eeefff' | $SED -e 'p' -e 's/e/X/p' -e ':x' \
+ -e 's//Y/p' -e '/f/bx'
+ fi
+}
+
+test_error()
+{
+ exec 0>&3 4>&1 5>&2
+ exec 0</dev/null
+ exec 2>&1
+ set -x
+ $TEST -x && exit 1
+ $TEST -f && exit 1
+ $TEST -e && exit 1
+ $TEST -f /dev/dds && exit 1
+ $TEST p /dev/dds && exit 1
+ $TEST -f /bin/sh && exit 1
+ $TEST '{' && exit 1
+ $TEST '{' && exit 1
+ $TEST '/hello/' && exit 1
+ $TEST '1,/hello/' && exit 1
+ $TEST -e '-5p' && exit 1
+ $TEST '/jj' && exit 1
+ $TEST 'a hello' && exit 1
+ $TEST 'a \ hello' && exit 1
+ $TEST 'b foo' && exit 1
+ $TEST 'd hello' && exit 1
+ $TEST 's/aa' && exit 1
+ $TEST 's/aa/' && exit 1
+ $TEST 's/a/b' && exit 1
+ $TEST 's/a/b/c/d' && exit 1
+ $TEST 's/a/b/ 1 2' && exit 1
+ $TEST 's/a/b/ 1 g' && exit 1
+ $TEST 's/a/b/w' && exit 1
+ $TEST 'y/aa' && exit 1
+ $TEST 'y/aa/b/' && exit 1
+ $TEST 'y/aa/' && exit 1
+ $TEST 'y/a/b' && exit 1
+ $TEST 'y/a/b/c/d' && exit 1
+ $TEST '!' && exit 1
+ $TEST supercalifrangolisticexprialidociussupercalifrangolisticexcius
+ set +x
+ exec 0>&3 1>&4 2>&5
+}
+
+main
diff --git a/tools/regression/usr.bin/uudecode/Makefile b/tools/regression/usr.bin/uudecode/Makefile
new file mode 100644
index 0000000..b937d41
--- /dev/null
+++ b/tools/regression/usr.bin/uudecode/Makefile
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+all:
+ @m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR}
diff --git a/tools/regression/usr.bin/uudecode/regress.base64.in b/tools/regression/usr.bin/uudecode/regress.base64.in
new file mode 100644
index 0000000..3a8bfc2
--- /dev/null
+++ b/tools/regression/usr.bin/uudecode/regress.base64.in
@@ -0,0 +1,88 @@
+begin-base64 644 regress.out
+dB745nc7bs6q4W24dCU/WprFX3UkvTwO6wlHiV+L4U+QEH1p/P9WjgFZ0MSGI2lE
+TCIH+3j4oqf3JJA/uvQ2WnWzCjFXG17cZpBq8UQGMh/e8QLyahMOTrrHP9Cf2ZE9
+WtybokTG8E2Ft0QrfiTsIpcUPMd7VDRvCQGLD+t6bqJkPJKaGmXXCwLwLz2WpAOX
+RW+d4UhnCnB0aBs7IByd6beMYwQxIcM4XvyAnG1z3XK9gCwvIwzI6wYYzXCIAo/K
+pP90oNA6ijFYYNK3s/uttytzC5QfKn6gaVerwYcb1QQHqyrxoryOrjwgwgazSfwL
+hDK1fLejnpTXL1Uh2j9E+pM0WSftA0wX1tdyKxy7kUarWzEACH8htTSd3NDamR/2
+T66xNHPYZhW31cjeNTX0czIfpRWBbBQI3rc5yhWZlGA0j8X8zQR4puaGpQ6QNnbB
+QkSU4Ak+pveRT8JuFbJVQI6WHemB7H9LV5CSYVCoZ2iOFA/Z8PSM473XXjqBk/M1
+Zz4irDw8V1tBp519qNgXFt52fdrkbzJCa+71pfAuP2LsytpAd2LUJwhgiV7uj6cx
+4DjEfdd/QYdcJGDm435wfsniPoPnrghEJdqfgWIvaFNpuoQ9ByrznWacs50AQFxy
+ZpfAaLJnGNiPehTOosTT6dPOKp8x2ms6mdkr2neZ0I0leoNHxCBKvgUxC0uFieo6
+GLpussFEB8QeCsy1mjnXDI1qsC2Sp34PZTvR5apH29FB1eIeAPFZMkFxO2TTs0Y4
+q3yKDcPGHaAdPy8J64UpyBlO3rbcLyqEbKcuSHHd69iT/5mD4arbyYHMY6S7S7QP
+DHpH1x8Woo5xMo0MVkmBGbKc5Sy4J37T8xjj4h0pcKvEdCSanJ2A1E2jHzpfbe8u
+/NSxpB49+JGYGJ2nsgpsKzwTXabgKDZPydqcAIpNXnAdsQBNskmzBYb8959xCzws
+ybQ7+0g4a0DYyLDcnW2NH/OCYHvkOgyM72FQJAXGg61GnZZiAjSlrqsPX2NVUtXi
+vRrueFSG5rYnYJvO2OfhwgEfxTY8b7x8AFQntBvaKqG5rWC+a2d+4Xj0B2ODy+/M
+5Hppj0dNwpLPKHa8UH6IDd+m0Aql5u5oCbh+WIDovGtN2BpkyCq00M/kKErTbTT+
+qfuWSDow0ZjLeFdSErUtdi1tKhDh5oy5Ev+ShLywKPm4/NfJ3CLhbZSvhOWWxwzf
+KEgMCnHNd8uc3JIDNM7c3Dm5w0QrD0AObOUSBF8iouNBjMvdUviIBVFPeVkZ3xYs
+TciSRJm/fB5QNhrcYRMbZJ5iOVHuuOxFw+zPoEIjVBPO1wXZgsSwgFED20bKLcOv
+SnWGM3IyNZVKqdo3a4oh4H4Lv/y6rMrtSTr7kQJlwEvU6WiyvtQob/fMdHWIbc/W
+RPR47l6JDz4V3AUqPcF3Jy6RaNUKRvFi+7cOWYBKbNFRmE/jA6dyUuVkCYIMDuhu
+I7iQL0u4l//xbdGb9RWtf8WHs/N5nmWi1TLTPbaDz8GBPOMOecpeIfqDVoPqaheq
+GT4fJj3sVBhq6zayVfNpueaEdHb/XTGm9NHS4xsgpbfL/sJw6IVJj3/dgb0RfX90
+ZUgfDvwURsTNvxAVzKuuuH6wrE8AGOpBLgomMZ5UZcgWkeRNjTqcelCsl3JhBIuU
+mJMbYI2SMv/CK+nkIYcIE7zHRaCyF8ngNYosop/chz1o1gTP2Di6NTq4a/SX0h1z
+7fykkKt2pLJvSOA8nccRIUrix5/GTQwhJxMaoR5WQUDVUPHx0c8xRNTTI24bGeik
+G4qKq74bpmZvbZrnsSjQJyLiQiPtraGR8YiI2JwGZmHbama9DPjOKV3bBWT6LgR2
+LEEI0G7BZiSGP4lniTkpOR/FUgp8WmblvhOeZY+KDTamifrq0NhjYIUYWGbZEOUi
+6ImSbiVH/gm4tk+kyAT1uSuK4lTUCWK7XO5I6WLCY2g4v7nYTDNUv/nbJLzai1GQ
+PLz3p0biVq3QwkIf+rZSsTirEIHMTeAxjdfWICDIcPSsxRZgvurgnIAodzIR9RkA
+nsoe4cLvh9SxDNrmlyWDsczkUsc9eG9rr5HH73KOr6wx2CUFug/naqnDBSzEI3H+
+cz12m9X8ATzpH0BT8cFvDE/KKiou+qWWtgLWTwnRoRBmBZVgOHCmQghz5bVgzUyg
+xxQFnYCTD9D5S3d2ndwuHJL3IesR/a+Oq5M4ORktsLMaOGJ7x3obRM6gEtuwpJ1E
+wxfGr/cYrc/QsBFoQfL9LgrcvHLgmE6mazXdF9NfBWiPZhTjFurcB0wD3PqlCrhc
+vsVP9cugGxA1pQ96MywYL2G0yyM1GrRIbiWG4y7y82+0mQSL9xG6G0StzkfWp5rr
+L8psGo/CFPr/8CXz+6tP/pNUp40NqcMVlOicMozUEHalgUe+581gu0GUI+IritwO
+SPM2hc+woGvFQ6WvY3S77fT7gkpnVuRjiSBlvSkV+2Iujs6++ErDKcIjD9j88StJ
+8xySXDZr9vIDLkT+YZIxg+v/CcP4C0tSbwAQNjoS9kpbMQK4YucSAuXIzIZngJHz
+38iU+2I+mzhPKChNi5/MxP0TjK63RqjKsIuJC9OD3c84n7TGXnvC1QqDF4TKYR2z
+Es7UjlyQVOD3HrtixAJP8ubmUQOrbIY2imR9xqUf2SWl8sCYaM6b9E00Wnnj0x2x
+pfZKE+IvarSRiTRgNBp2S7K1u9NTtj+9A67xWPwpBCPcIsyDP4CItCzMoybyqbn3
+rM3RSiygpIj901FlNab/mUi+borZDvXZgcOlhZjUJnhUjiEhuMfpOxYG//hkj/dW
+d3Dg9gaLVriLVZOfl5wUZT1d8W6rN3RQ+jT42pm2hLhE4picD5GEOYOcTf4rolSx
+2IlgK4w4fb77Iqk35/7kC203b9OFzgzIN2MMfY1C50MRJQT5B7qmKva33MjEaPzb
+IxipHCd2wAMzTJHMCShK1qiQ60aki8suOO6RWDiDAdnpzzjnDFhMyL+if5pBgZct
+nfvKvvsxAEWlyOZHcwXBu/v+2Gg5cWFr8e5GtvxmQzK0CamIba1xl5UTiZDeb6bM
+0uKZewkY1okt5lYGVYDL/vdhH2FePzSHB42RbcetO/3J113wvGjPVWz0F5hgoO+H
+T0Rq31vpZ47oK83UvOdDzRTyudiMKyf3VCVEzhqunT/QfyPp5Q7UgSOu0fcY/iap
+wxwUtqeBLUfiDo4vHSeswfAb3b8dcPPpYdjLKU80trpChkV37UyXY0wVFSiAiVOe
+WgWSGa0ABkxF/pNr/OztK1Ms2omJxBulK/FhXHtrog6xFW/QcPcGM0TXILUHJ8Gp
+XTckydbsTCW7Itv59MrY5G/3ps62AOJmcojjQ3kNsJ2UA64/u06RtK8GaP8q3X1z
+eFmikqD+jEIQlpnx1oy/aSOc0P7U9DtWe5MrloS2hHovHkad/se3GiZkgmfFRfqr
+cC+6giz4cjwTj/yEjpto3VOXnXcPycmuXFPjUlDkLBI6RaegecWd+OaQhCe0iut+
+g64p+e6j2wNaDXa64XgU6HEaXwTgaHENJCQ3GNDl79k1umU0efn5PeFJiNDdg1UB
+foaob/WFuE+FT2Ns6rmLocAG9XeXNX8U2l3eIleCQHzkhfXluFFgLQnqFpPGay3W
+liEQrZ1/J2o5yx2YE/OJMi3bvnP3JB1mdMPbgd5ulrwcbCOCe0t/qjTxLQzunP5A
++S7uaweW4iBuDjGiSGPIDH7CPpYQRl+JAj1TYdP1rQ6LpG57cr+NsbyODFEN+DSu
+yOPiu0z5BmMqb1SQcZ3v2MWyYg+n3Lqai+CX96c0lpL8U2SG7ARnkbmMrQVzD5dw
+KxnZuk4yvkrSAX0y4kN7mpWuuMDKw/h5NbCXUM1OsgjZ3NW8gsj2FYt3f7RSgOeX
+/lpLuakHMlYgYDyzXnWL8VuwG7gEN/nJLoym7w2OhTFF/l7xilkflZJ3rcGvxbi9
+gJOsuCKz2oI1ujxJHR5fIX0HSkv7R4464jiK+GUNnbe7QmbBWLoo8Y524u70j5QJ
+sd9ZLcTkwAJdW/u/qUXOjbThd8TLsuwDSTMeQj210Lmq3eYy5Np8GRjxQkOXpp0J
+fkEHrkHb5+s1I9v2AhAxQ6RUOuvORLuEoid4RkpFM1kwTV1vQplg7VmLvPjpE1JZ
+3AbAvKdeqsPsJJVwU+q7Jbw3dVa8M0ZtqS4FCGk1C/4jlobxsakncIxP/haAz7oc
+0IeEFyMzNqu6xjHKqCh9WaqHQpXf1JgJrrV6e+j7Ygh3CsqlSzW6jbSDyxFeKlUx
+pMYHebEJSebLKOKE0mfubsGqizJFOKRPkYr1bQ1/u5P6FNEr0sGQ7lS7BEGRhchJ
+g17bXD9moD2CeJZ2QJYj+YMqjYHk/W6ufHVVHc0pF5jV6/lVMsIYeQ8l3YhI/1hB
++1An/yFOvVgNonYJVd8MohaVPCD+dZUV3M+S76YRiGVniidGQWl5Y6PYzlEqEuM5
+FWftt9dSLVYhXhbABzcfN7mzoCZjyZEv+ZgUv9ipeaSUW0SZ+6iFv/abw7FkZSl4
+5B88ETP2LqClT21/yd69ZyGfdp3FR9daqKrjVjvCFu98zyHTsdR+OF8bsaI280iz
+3WKdXum+iiuadf66GIsjtIyqUQqog74Ji+VKP/xIgOBAFB4ktVULAypA+NsRNwYA
+IBDEa7EMiDduUPQ/9uavMN/F9Jf1POW4MljbH7C66NisM+/3YJ4l4Um2iXQPq9yp
+G6c0AJjzgL6/XtWhFnki1jJYvEJ9IkWvlL650zgXzEvEEOWI6TaQSwrrSh2UTD6a
+fJPCRsymB1rBEWb1FRVsidkr+/rFFL7D3QsDr+EWFesj5ItbABOPNt5w0obx0mKg
+WoKuZaklnqJvJT7JUdVRZQ6ei4JksMnIs+muEl7ouM1OM/e2VM5JRI+2MO4/1Sy9
+brEj3xY0pRYfXJxzNZsIepyKB8T2NoWfvOomcCXlYNz3rIRRVPWgxsV6kqTJuFo+
+Ypu+A7Q8P2AWDfssP2vaHvphJmk5OwUAq4LljFbo6KlC932c6cljUhTRukRsFfz5
+JoYf1dcdgcPg5YGX4qpUuqCGiT99dSIQ/WhCL6n4gLV/IXb5BuMbrmHvx1xVVbiT
+h8S4MjNNqv6zpLumJr8qI7sFfPLDYhm7erthjGYmVnG3n7eEeAu/QU2CJl4kHMoS
+FoRanXJ+o4tprVlrRQ0whlADoNK8swogk2vGtYqqCfYAHuh/aGtETA/vqZI71/j9
+4nDd8YH1hVyf5GI/QvkuqZiLeZKUIrNj03jHio8oHWrim1mBlRhWo/947ac6xHOq
+FqBufMZIC1f2zvHvav1Cu7Y6kAoKsn4h4gTjKw25SImYWL4Lx8GUsVWKl+pm8rEJ
+3NTh6I2Q6vt1EmfP2Oot56oUci+u8WtQ8wvEaoYWWWqKghPp9piEsfHTETmievN5
+8OKlLHwxWbE7xE7teDcAZw==
+====
diff --git a/tools/regression/usr.bin/uudecode/regress.out b/tools/regression/usr.bin/uudecode/regress.out
new file mode 100644
index 0000000..fa0dd08
--- /dev/null
+++ b/tools/regression/usr.bin/uudecode/regress.out
Binary files differ
diff --git a/tools/regression/usr.bin/uudecode/regress.sh b/tools/regression/usr.bin/uudecode/regress.sh
new file mode 100644
index 0000000..f4f745a
--- /dev/null
+++ b/tools/regression/usr.bin/uudecode/regress.sh
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+REGRESSION_START($1)
+
+REGRESSION_TEST_ONE(`uudecode -p < regress.traditional.in', `traditional')
+REGRESSION_TEST_ONE(`uudecode -p < regress.base64.in', `base64')
+
+REGRESSION_END()
diff --git a/tools/regression/usr.bin/uudecode/regress.traditional.in b/tools/regression/usr.bin/uudecode/regress.traditional.in
new file mode 100644
index 0000000..da81415
--- /dev/null
+++ b/tools/regression/usr.bin/uudecode/regress.traditional.in
@@ -0,0 +1,95 @@
+begin 644 regress.out
+M=![XYG<[;LZJX6VX="4_6IK%7W4DO3P.ZPE'B5^+X4^0$'UI_/]6C@%9T,2&
+M(VE$3"('^WCXHJ?W))`_NO0V6G6S"C%7&U[<9I!J\40&,A_>\0+R:A,.3KK'
+M/]"?V9$]6MR;HD3&\$V%MT0K?B3L(I<4/,=[5#1O"0&+#^MZ;J)D/)*:&F77
+M"P+P+SV6I`.716^=X4AG"G!T:!L[(!R=Z;>,8P0Q(<,X7OR`G&USW7*]@"PO
+M(PS(ZP88S7"(`H_*I/]TH-`ZBC%88-*WL_NMMRMS"Y0?*GZ@:5>KP8<;U00'
+MJRKQHKR.KCP@P@:S2?P+A#*U?+>CGI37+U4AVC]$^I,T62?M`TP7UM=R*QR[
+MD4:K6S$`"'\AM32=W-#:F1_V3ZZQ-'/89A6WU<C>-37T<S(?I16!;!0(WK<Y
+MRA69E&`TC\7\S01XIN:&I0Z0-G;!0D24X`D^IO>13\)N%;)50(Z6'>F![']+
+M5Y"285"H9VB.%`_9\/2,X[W77CJ!D_,U9SXBK#P\5UM!IYU]J-@7%MYV?=KD
+M;S)":^[UI?`N/V+LRMI`=V+4)PA@B5[NCZ<QX#C$?==_08=<)&#FXWYP?LGB
+M/H/GK@A$)=J?@6(O:%-INH0]!RKSG6:<LYT`0%QR9I?`:+)G&-B/>A3.HL33
+MZ=/.*I\QVFLZF=DKVG>9T(TE>H-'Q"!*O@4Q"TN%B>HZ&+INLL%$!\0>"LRU
+MFCG7#(UJL"V2IWX/93O1Y:I'V]%!U>(>`/%9,D%Q.V33LT8XJWR*#</&':`=
+M/R\)ZX4IR!E.WK;<+RJ$;*<N2''=Z]B3_YF#X:K;R8',8Z2[2[0/#'I'UQ\6
+MHHYQ,HT,5DF!&;*<Y2RX)W[3\QCCXATI<*O$="2:G)V`U$VC'SI?;>\N_-2Q
+MI!X]^)&8&)VGL@IL*SP37:;@*#9/R=J<`(I-7G`=L0!-LDFS!8;\]Y]Q"SPL
+MR;0[^T@X:T#8R+#<G6V-'_."8'OD.@R,[V%0)`7&@ZU&G99B`C2EKJL/7V-5
+M4M7BO1KN>%2&YK8G8)O.V.?AP@$?Q38\;[Q\`%0GM!O:*J&YK6"^:V=^X7CT
+M!V.#R^_,Y'IICT=-PI+/*':\4'Z(#=^FT`JEYNYH";A^6(#HO&M-V!IDR"JT
+MT,_D*$K3;33^J?N62#HPT9C+>%=2$K4M=BUM*A#AYHRY$O^2A+RP*/FX_-?)
+MW"+A;92OA.66QPS?*$@,"G'-=\N<W)(#-,[<W#FYPT0K#T`.;.42!%\BHN-!
+MC,O=4OB(!5%/>5D9WQ8L3<B21)F_?!Y0-AK<81,;9)YB.5'NN.Q%P^S/H$(C
+M5!/.UP79@L2P@%$#VT;*+<.O2G6&,W(R-95*J=HW:XHAX'X+O_RZK,KM23K[
+MD0)EP$O4Z6BROM0H;_?,='6(;<_61/1X[EZ)#SX5W`4J/<%W)RZ1:-4*1O%B
+M^[<.68!*;-%1F$_C`Z=R4N5D"8(,#NAN([B0+TNXE__Q;=&;]16M?\6'L_-Y
+MGF6BU3+3/;:#S\&!/.,.><I>(?J#5H/J:A>J&3X?)CWL5!AJZS:R5?-IN>:$
+M=';_73&F]-'2XQL@I;?+_L)PZ(5)CW_=@;T1?7]T94@?#OP41L3-OQ`5S*NN
+MN'ZPK$\`&.I!+@HF,9Y49<@6D>1-C3J<>E"LEW)A!(N4F),;8(V2,O_"*^GD
+M(8<($[S'1:"R%\G@-8HLHI_<ASUHU@3/V#BZ-3JX:_27TAUS[?RDD*MVI+)O
+M2.`\G<<1(4KBQY_&30PA)Q,:H1Y604#54/'QT<\Q1-33(VX;&>BD&XJ*J[X;
+MIF9O;9KGL2C0)R+B0B/MK:&1\8B(V)P&9F';:F:]#/C.*5W;!63Z+@1V+$$(
+MT&[!9B2&/XEGB3DI.1_%4@I\6F;EOA.>98^*#3:FB?KJT-AC8(486&;9$.4B
+MZ(F2;B5'_@FXMD^DR`3UN2N*XE34"6*[7.Y(Z6+"8V@XO[G83#-4O_G;)+S:
+MBU&0/+SWIT;B5JW0PD(?^K92L3BK$(',3>`QC=?6("#(</2LQ19@ONK@G(`H
+M=S(1]1D`GLH>X<+OA]2Q#-KFER6#L<SD4L<]>&]KKY''[W*.KZPQV"4%N@_G
+M:JG#!2S$(W'^<SUVF]7\`3SI'T!3\<%O#$_**BHN^J66M@+63PG1H1!F!95@
+M.'"F0@ASY;5@S4R@QQ0%G8"3#]#Y2W=VG=PN')+W(>L1_:^.JY,X.1DML+,:
+M.&)[QWH;1,Z@$MNPI)U$PQ?&K_<8K<_0L!%H0?+]+@K<O'+@F$ZF:S7=%]-?
+M!6B/9A3C%NK<!TP#W/JE"KA<OL5/]<N@&Q`UI0]Z,RP8+V&TRR,U&K1(;B6&
+MXR[R\V^TF02+]Q&Z&T2MSD?6IYKK+\IL&H_"%/K_\"7S^ZM/_I-4IXT-J<,5
+ME.B<,HS4$':E@4>^Y\U@NT&4(^(KBMP.2/,VA<^PH&O%0Z6O8W2[[?3[@DIG
+M5N1CB2!EO2D5^V(NCLZ^^$K#*<(C#]C\\2M)\QR27#9K]O(#+D3^89(Q@^O_
+M"</X"TM2;P`0-CH2]DI;,0*X8N<2`N7(S(9G@)'SW\B4^V(^FSA/*"A-BY_,
+MQ/T3C*ZW1JC*L(N)"].#W<\XG[3&7GO"U0J#%X3*81VS$L[4CER05.#W'KMB
+MQ`)/\N;F40.K;(8VBF1]QJ4?V26E\L"8:,Z;]$TT6GGCTQVQI?9*$^(O:K21
+MB31@-!IV2[*UN]-3MC^]`Z[Q6/PI!"/<(LR#/X"(M"S,HR;RJ;GWK,W12BR@
+MI(C]TU%E-:;_F4B^;HK9#O79@<.EA9C4)GA4CB$AN,?I.Q8&__ADC_=6=W#@
+M]@:+5KB+59.?EYP493U=\6ZK-W10^C3XVIFVA+A$XIB<#Y&$.8.<3?XKHE2Q
+MV(E@*XPX?;[[(JDWY_[D"VTW;].%S@S(-V,,?8U"YT,1)03Y![JF*O:WW,C$
+M:/S;(QBI'"=VP`,S3)',"2A*UJB0ZT:DB\LN..Z16#B#`=GISSCG#%A,R+^B
+M?YI!@9<MG?O*OOLQ`$6ER.9'<P7!N_O^V&@Y<6%K\>Y&MOQF0S*T":F(;:UQ
+MEY43B9#>;Z;,TN*9>PD8UHDMYE8&58#+_O=A'V%>/S2'!XV1;<>M._W)UUWP
+MO&C/56ST%YA@H.^'3T1JWUOI9X[H*\W4O.=#S13RN=B,*R?W5"5$SAJNG3_0
+M?R/IY0[4@2.NT?<8_B:IPQP4MJ>!+4?B#HXO'2>LP?`;W;\=<//I8=C+*4\T
+MMKI"AD5W[4R78TP5%2B`B5.>6@62&:T`!DQ%_I-K_.SM*U,LVHF)Q!NE*_%A
+M7'MKH@ZQ%6_0</<&,T37(+4')\&I73<DR=;L3"6[(MOY],K8Y&_WILZV`.)F
+M<HCC0WD-L)V4`ZX_NTZ1M*\&:/\JW7US>%FBDJ#^C$(0EIGQUHR_:2.<T/[4
+M]#M6>Y,KEH2VA'HO'D:=_L>W&B9D@F?%1?JK<"^Z@BSX<CP3C_R$CIMHW5.7
+MG7</R<FN7%/C4E#D+!(Z1:>@><6=^.:0A">TBNM^@ZXI^>ZCVP-:#7:ZX7@4
+MZ'$:7P3@:'$-)"0W&-#E[]DUNF4T>?GY/>%)B-#=@U4!?H:H;_6%N$^%3V-L
+MZKF+H<`&]7>7-7\4VEW>(E>"0'SDA?7EN%%@+0GJ%I/&:RW6EB$0K9U_)VHY
+MRQV8$_.),BW;OG/W)!UF=,/;@=YNEKP<;".">TM_JC3Q+0SNG/Y`^2[N:P>6
+MXB!N#C&B2&/(#'["/I801E^)`CU38=/UK0Z+I&Y[<K^-L;R.#%$-^#2NR./B
+MNTSY!F,J;U20<9WOV,6R8@^GW+J:B^"7]Z<TEI+\4V2&[`1GD;F,K05S#Y=P
+M*QG9NDXRODK2`7TRXD-[FI6NN,#*P_AY-;"74,U.L@C9W-6\@LCV%8MW?[12
+M@.>7_EI+N:D',E8@8#RS7G6+\5NP&[@$-_G)+HRF[PV.A3%%_E[QBED?E9)W
+MK<&OQ;B]@).LN"*SVH(UNCQ)'1Y?(7T'2DO[1XXZXCB*^&4-G;>[0F;!6+HH
+M\8YVXN[TCY0)L=]9+<3DP`)=6_N_J47.C;3A=\3+LNP#23,>0CVUT+FJW>8R
+MY-I\&1CQ0D.7IIT)?D$'KD';Y^LU(]OV`A`Q0Z14.NO.1+N$HB=X1DI%,UDP
+M35UO0IE@[5F+O/CI$U)9W`;`O*=>JL/L))5P4^J[);PW=5:\,T9MJ2X%"&DU
+M"_XCEH;QL:DG<(Q/_A:`S[H<T(>$%R,S-JNZQC'*J"A]6:J'0I7?U)@)KK5Z
+M>^C[8@AW"LJE2S6ZC;2#RQ%>*E4QI,8'>;$)2>;+*.*$TF?N;L&JBS)%.*1/
+MD8KU;0U_NY/Z%-$KTL&0[E2[!$&1A<A)@U[;7#]FH#V">)9V0)8C^8,JC8'D
+M_6ZN?'55'<TI%YC5Z_E5,L(8>0\EW8A(_UA!^U`G_R%.O5@-HG8)5=\,HA:5
+M/"#^=945W,^2[Z81B&5GBB=&06EY8Z/8SE$J$N,Y%6?MM]=2+58A7A;`!S<?
+M-[FSH"9CR9$O^9@4O]BI>:246T29^ZB%O_:;P[%D92EXY!\\$3/V+J"E3VU_
+MR=Z]9R&?=IW%1]=:J*KC5CO"%N]\SR'3L=1^.%\;L:(V\TBSW6*=7NF^BBN:
+M=?ZZ&(LCM(RJ40JH@[X)B^5*/_Q(@.!`%!XDM54+`RI`^-L1-P8`(!#$:[$,
+MB#=N4/0_]N:O,-_%])?U/.6X,EC;'["ZZ-BL,^_W8)XEX4FVB70/J]RI&Z<T
+M`)CS@+Z_7M6A%GDBUC)8O$)](D6OE+ZYTS@7S$O$$.6(Z3:02PKK2AV43#Z:
+M?)/"1LRF!UK!$6;U%15LB=DK^_K%%+[#W0L#K^$6%>LCY(M;`!./-MYPTH;Q
+MTF*@6H*N9:DEGJ)O)3[)4=5190Z>BX)DL,G(L^FN$E[HN,U.,_>V5,Y)1(^V
+M,.X_U2R];K$CWQ8TI18?7)QS-9L(>IR*!\3V-H6?O.HF<"7E8-SWK(115/6@
+MQL5ZDJ3)N%H^8IN^`[0\/V`6#?LL/VO:'OIA)FDY.P4`JX+EC%;HZ*E"]WV<
+MZ<EC4A31ND1L%?SY)H8?U=<=@</@Y8&7XJI4NJ"&B3]]=2(0_6A"+ZGX@+5_
+M(7;Y!N,;KF'OQUQ55;B3A\2X,C--JOZSI+NF)K\J([L%?/+#8AF[>KMAC&8F
+M5G&WG[>$>`N_04V")EXD',H2%H1:G7)^HXMIK5EK10TPAE`#H-*\LPH@DVO&
+MM8JJ"?8`'NA_:&M$3`_OJ9([U_C]XG#=\8'UA5R?Y&(_0ODNJ9B+>9*4(K-C
+MTWC'BH\H'6KBFUF!E1A6H_]X[:<ZQ'.J%J!N?,9("U?VSO'O:OU"N[8ZD`H*
+MLGXAX@3C*PVY2(F86+X+Q\&4L56*E^IF\K$)W-3AZ(V0ZOMU$F?/V.HMYZH4
+M<B^N\6M0\PO$:H8666J*@A/I]IB$L?'3$3FB>O-Y\.*E+'PQ6;$[Q$[M>#<`
+!9P``
+`
+end
diff --git a/tools/regression/usr.bin/uuencode/Makefile b/tools/regression/usr.bin/uuencode/Makefile
new file mode 100644
index 0000000..b937d41
--- /dev/null
+++ b/tools/regression/usr.bin/uuencode/Makefile
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+all:
+ @m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR}
diff --git a/tools/regression/usr.bin/uuencode/regress.base64.out b/tools/regression/usr.bin/uuencode/regress.base64.out
new file mode 100644
index 0000000..046f6c5
--- /dev/null
+++ b/tools/regression/usr.bin/uuencode/regress.base64.out
@@ -0,0 +1,74 @@
+begin-base64 644 regress.in
+dB745nc7bs6q4W24dCU/WprFX3UkvTwO6wlHiV+L4U+QEH1p/P9WjgFZ0MSGI2lETCIH+3j4oqf3
+JJA/uvQ2WnWzCjFXG17cZpBq8UQGMh/e8QLyahMOTrrHP9Cf2ZE9WtybokTG8E2Ft0QrfiTsIpcU
+PMd7VDRvCQGLD+t6bqJkPJKaGmXXCwLwLz2WpAOXRW+d4UhnCnB0aBs7IByd6beMYwQxIcM4XvyA
+nG1z3XK9gCwvIwzI6wYYzXCIAo/KpP90oNA6ijFYYNK3s/uttytzC5QfKn6gaVerwYcb1QQHqyrx
+oryOrjwgwgazSfwLhDK1fLejnpTXL1Uh2j9E+pM0WSftA0wX1tdyKxy7kUarWzEACH8htTSd3NDa
+mR/2T66xNHPYZhW31cjeNTX0czIfpRWBbBQI3rc5yhWZlGA0j8X8zQR4puaGpQ6QNnbBQkSU4Ak+
+pveRT8JuFbJVQI6WHemB7H9LV5CSYVCoZ2iOFA/Z8PSM473XXjqBk/M1Zz4irDw8V1tBp519qNgX
+Ft52fdrkbzJCa+71pfAuP2LsytpAd2LUJwhgiV7uj6cx4DjEfdd/QYdcJGDm435wfsniPoPnrghE
+JdqfgWIvaFNpuoQ9ByrznWacs50AQFxyZpfAaLJnGNiPehTOosTT6dPOKp8x2ms6mdkr2neZ0I0l
+eoNHxCBKvgUxC0uFieo6GLpussFEB8QeCsy1mjnXDI1qsC2Sp34PZTvR5apH29FB1eIeAPFZMkFx
+O2TTs0Y4q3yKDcPGHaAdPy8J64UpyBlO3rbcLyqEbKcuSHHd69iT/5mD4arbyYHMY6S7S7QPDHpH
+1x8Woo5xMo0MVkmBGbKc5Sy4J37T8xjj4h0pcKvEdCSanJ2A1E2jHzpfbe8u/NSxpB49+JGYGJ2n
+sgpsKzwTXabgKDZPydqcAIpNXnAdsQBNskmzBYb8959xCzwsybQ7+0g4a0DYyLDcnW2NH/OCYHvk
+OgyM72FQJAXGg61GnZZiAjSlrqsPX2NVUtXivRrueFSG5rYnYJvO2OfhwgEfxTY8b7x8AFQntBva
+KqG5rWC+a2d+4Xj0B2ODy+/M5Hppj0dNwpLPKHa8UH6IDd+m0Aql5u5oCbh+WIDovGtN2BpkyCq0
+0M/kKErTbTT+qfuWSDow0ZjLeFdSErUtdi1tKhDh5oy5Ev+ShLywKPm4/NfJ3CLhbZSvhOWWxwzf
+KEgMCnHNd8uc3JIDNM7c3Dm5w0QrD0AObOUSBF8iouNBjMvdUviIBVFPeVkZ3xYsTciSRJm/fB5Q
+NhrcYRMbZJ5iOVHuuOxFw+zPoEIjVBPO1wXZgsSwgFED20bKLcOvSnWGM3IyNZVKqdo3a4oh4H4L
+v/y6rMrtSTr7kQJlwEvU6WiyvtQob/fMdHWIbc/WRPR47l6JDz4V3AUqPcF3Jy6RaNUKRvFi+7cO
+WYBKbNFRmE/jA6dyUuVkCYIMDuhuI7iQL0u4l//xbdGb9RWtf8WHs/N5nmWi1TLTPbaDz8GBPOMO
+ecpeIfqDVoPqaheqGT4fJj3sVBhq6zayVfNpueaEdHb/XTGm9NHS4xsgpbfL/sJw6IVJj3/dgb0R
+fX90ZUgfDvwURsTNvxAVzKuuuH6wrE8AGOpBLgomMZ5UZcgWkeRNjTqcelCsl3JhBIuUmJMbYI2S
+Mv/CK+nkIYcIE7zHRaCyF8ngNYosop/chz1o1gTP2Di6NTq4a/SX0h1z7fykkKt2pLJvSOA8nccR
+IUrix5/GTQwhJxMaoR5WQUDVUPHx0c8xRNTTI24bGeikG4qKq74bpmZvbZrnsSjQJyLiQiPtraGR
+8YiI2JwGZmHbama9DPjOKV3bBWT6LgR2LEEI0G7BZiSGP4lniTkpOR/FUgp8WmblvhOeZY+KDTam
+ifrq0NhjYIUYWGbZEOUi6ImSbiVH/gm4tk+kyAT1uSuK4lTUCWK7XO5I6WLCY2g4v7nYTDNUv/nb
+JLzai1GQPLz3p0biVq3QwkIf+rZSsTirEIHMTeAxjdfWICDIcPSsxRZgvurgnIAodzIR9RkAnsoe
+4cLvh9SxDNrmlyWDsczkUsc9eG9rr5HH73KOr6wx2CUFug/naqnDBSzEI3H+cz12m9X8ATzpH0BT
+8cFvDE/KKiou+qWWtgLWTwnRoRBmBZVgOHCmQghz5bVgzUygxxQFnYCTD9D5S3d2ndwuHJL3IesR
+/a+Oq5M4ORktsLMaOGJ7x3obRM6gEtuwpJ1EwxfGr/cYrc/QsBFoQfL9LgrcvHLgmE6mazXdF9Nf
+BWiPZhTjFurcB0wD3PqlCrhcvsVP9cugGxA1pQ96MywYL2G0yyM1GrRIbiWG4y7y82+0mQSL9xG6
+G0StzkfWp5rrL8psGo/CFPr/8CXz+6tP/pNUp40NqcMVlOicMozUEHalgUe+581gu0GUI+IritwO
+SPM2hc+woGvFQ6WvY3S77fT7gkpnVuRjiSBlvSkV+2Iujs6++ErDKcIjD9j88StJ8xySXDZr9vID
+LkT+YZIxg+v/CcP4C0tSbwAQNjoS9kpbMQK4YucSAuXIzIZngJHz38iU+2I+mzhPKChNi5/MxP0T
+jK63RqjKsIuJC9OD3c84n7TGXnvC1QqDF4TKYR2zEs7UjlyQVOD3HrtixAJP8ubmUQOrbIY2imR9
+xqUf2SWl8sCYaM6b9E00Wnnj0x2xpfZKE+IvarSRiTRgNBp2S7K1u9NTtj+9A67xWPwpBCPcIsyD
+P4CItCzMoybyqbn3rM3RSiygpIj901FlNab/mUi+borZDvXZgcOlhZjUJnhUjiEhuMfpOxYG//hk
+j/dWd3Dg9gaLVriLVZOfl5wUZT1d8W6rN3RQ+jT42pm2hLhE4picD5GEOYOcTf4rolSx2IlgK4w4
+fb77Iqk35/7kC203b9OFzgzIN2MMfY1C50MRJQT5B7qmKva33MjEaPzbIxipHCd2wAMzTJHMCShK
+1qiQ60aki8suOO6RWDiDAdnpzzjnDFhMyL+if5pBgZctnfvKvvsxAEWlyOZHcwXBu/v+2Gg5cWFr
+8e5GtvxmQzK0CamIba1xl5UTiZDeb6bM0uKZewkY1okt5lYGVYDL/vdhH2FePzSHB42RbcetO/3J
+113wvGjPVWz0F5hgoO+HT0Rq31vpZ47oK83UvOdDzRTyudiMKyf3VCVEzhqunT/QfyPp5Q7UgSOu
+0fcY/iapwxwUtqeBLUfiDo4vHSeswfAb3b8dcPPpYdjLKU80trpChkV37UyXY0wVFSiAiVOeWgWS
+Ga0ABkxF/pNr/OztK1Ms2omJxBulK/FhXHtrog6xFW/QcPcGM0TXILUHJ8GpXTckydbsTCW7Itv5
+9MrY5G/3ps62AOJmcojjQ3kNsJ2UA64/u06RtK8GaP8q3X1zeFmikqD+jEIQlpnx1oy/aSOc0P7U
+9DtWe5MrloS2hHovHkad/se3GiZkgmfFRfqrcC+6giz4cjwTj/yEjpto3VOXnXcPycmuXFPjUlDk
+LBI6RaegecWd+OaQhCe0iut+g64p+e6j2wNaDXa64XgU6HEaXwTgaHENJCQ3GNDl79k1umU0efn5
+PeFJiNDdg1UBfoaob/WFuE+FT2Ns6rmLocAG9XeXNX8U2l3eIleCQHzkhfXluFFgLQnqFpPGay3W
+liEQrZ1/J2o5yx2YE/OJMi3bvnP3JB1mdMPbgd5ulrwcbCOCe0t/qjTxLQzunP5A+S7uaweW4iBu
+DjGiSGPIDH7CPpYQRl+JAj1TYdP1rQ6LpG57cr+NsbyODFEN+DSuyOPiu0z5BmMqb1SQcZ3v2MWy
+Yg+n3Lqai+CX96c0lpL8U2SG7ARnkbmMrQVzD5dwKxnZuk4yvkrSAX0y4kN7mpWuuMDKw/h5NbCX
+UM1OsgjZ3NW8gsj2FYt3f7RSgOeX/lpLuakHMlYgYDyzXnWL8VuwG7gEN/nJLoym7w2OhTFF/l7x
+ilkflZJ3rcGvxbi9gJOsuCKz2oI1ujxJHR5fIX0HSkv7R4464jiK+GUNnbe7QmbBWLoo8Y524u70
+j5QJsd9ZLcTkwAJdW/u/qUXOjbThd8TLsuwDSTMeQj210Lmq3eYy5Np8GRjxQkOXpp0JfkEHrkHb
+5+s1I9v2AhAxQ6RUOuvORLuEoid4RkpFM1kwTV1vQplg7VmLvPjpE1JZ3AbAvKdeqsPsJJVwU+q7
+Jbw3dVa8M0ZtqS4FCGk1C/4jlobxsakncIxP/haAz7oc0IeEFyMzNqu6xjHKqCh9WaqHQpXf1JgJ
+rrV6e+j7Ygh3CsqlSzW6jbSDyxFeKlUxpMYHebEJSebLKOKE0mfubsGqizJFOKRPkYr1bQ1/u5P6
+FNEr0sGQ7lS7BEGRhchJg17bXD9moD2CeJZ2QJYj+YMqjYHk/W6ufHVVHc0pF5jV6/lVMsIYeQ8l
+3YhI/1hB+1An/yFOvVgNonYJVd8MohaVPCD+dZUV3M+S76YRiGVniidGQWl5Y6PYzlEqEuM5FWft
+t9dSLVYhXhbABzcfN7mzoCZjyZEv+ZgUv9ipeaSUW0SZ+6iFv/abw7FkZSl45B88ETP2LqClT21/
+yd69ZyGfdp3FR9daqKrjVjvCFu98zyHTsdR+OF8bsaI280iz3WKdXum+iiuadf66GIsjtIyqUQqo
+g74Ji+VKP/xIgOBAFB4ktVULAypA+NsRNwYAIBDEa7EMiDduUPQ/9uavMN/F9Jf1POW4MljbH7C6
+6NisM+/3YJ4l4Um2iXQPq9ypG6c0AJjzgL6/XtWhFnki1jJYvEJ9IkWvlL650zgXzEvEEOWI6TaQ
+SwrrSh2UTD6afJPCRsymB1rBEWb1FRVsidkr+/rFFL7D3QsDr+EWFesj5ItbABOPNt5w0obx0mKg
+WoKuZaklnqJvJT7JUdVRZQ6ei4JksMnIs+muEl7ouM1OM/e2VM5JRI+2MO4/1Sy9brEj3xY0pRYf
+XJxzNZsIepyKB8T2NoWfvOomcCXlYNz3rIRRVPWgxsV6kqTJuFo+Ypu+A7Q8P2AWDfssP2vaHvph
+Jmk5OwUAq4LljFbo6KlC932c6cljUhTRukRsFfz5JoYf1dcdgcPg5YGX4qpUuqCGiT99dSIQ/WhC
+L6n4gLV/IXb5BuMbrmHvx1xVVbiTh8S4MjNNqv6zpLumJr8qI7sFfPLDYhm7erthjGYmVnG3n7eE
+eAu/QU2CJl4kHMoSFoRanXJ+o4tprVlrRQ0whlADoNK8swogk2vGtYqqCfYAHuh/aGtETA/vqZI7
+1/j94nDd8YH1hVyf5GI/QvkuqZiLeZKUIrNj03jHio8oHWrim1mBlRhWo/947ac6xHOqFqBufMZI
+C1f2zvHvav1Cu7Y6kAoKsn4h4gTjKw25SImYWL4Lx8GUsVWKl+pm8rEJ3NTh6I2Q6vt1EmfP2Oot
+56oUci+u8WtQ8wvEaoYWWWqKghPp9piEsfHTETmievN58OKlLHwxWbE7xE7teDcAZw==
+====
diff --git a/tools/regression/usr.bin/uuencode/regress.in b/tools/regression/usr.bin/uuencode/regress.in
new file mode 100644
index 0000000..fa0dd08
--- /dev/null
+++ b/tools/regression/usr.bin/uuencode/regress.in
Binary files differ
diff --git a/tools/regression/usr.bin/uuencode/regress.sh b/tools/regression/usr.bin/uuencode/regress.sh
new file mode 100644
index 0000000..ec78286
--- /dev/null
+++ b/tools/regression/usr.bin/uuencode/regress.sh
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+REGRESSION_START($1)
+
+# To make sure we end up with matching headers.
+umask 022
+
+REGRESSION_TEST(`traditional', `uuencode regress.in < regress.in')
+REGRESSION_TEST(`base64', `uuencode -m regress.in < regress.in')
+
+REGRESSION_END()
diff --git a/tools/regression/usr.bin/uuencode/regress.traditional.out b/tools/regression/usr.bin/uuencode/regress.traditional.out
new file mode 100644
index 0000000..ee1352f
--- /dev/null
+++ b/tools/regression/usr.bin/uuencode/regress.traditional.out
@@ -0,0 +1,95 @@
+begin 644 regress.in
+M=![XYG<[;LZJX6VX="4_6IK%7W4DO3P.ZPE'B5^+X4^0$'UI_/]6C@%9T,2&
+M(VE$3"('^WCXHJ?W))`_NO0V6G6S"C%7&U[<9I!J\40&,A_>\0+R:A,.3KK'
+M/]"?V9$]6MR;HD3&\$V%MT0K?B3L(I<4/,=[5#1O"0&+#^MZ;J)D/)*:&F77
+M"P+P+SV6I`.716^=X4AG"G!T:!L[(!R=Z;>,8P0Q(<,X7OR`G&USW7*]@"PO
+M(PS(ZP88S7"(`H_*I/]TH-`ZBC%88-*WL_NMMRMS"Y0?*GZ@:5>KP8<;U00'
+MJRKQHKR.KCP@P@:S2?P+A#*U?+>CGI37+U4AVC]$^I,T62?M`TP7UM=R*QR[
+MD4:K6S$`"'\AM32=W-#:F1_V3ZZQ-'/89A6WU<C>-37T<S(?I16!;!0(WK<Y
+MRA69E&`TC\7\S01XIN:&I0Z0-G;!0D24X`D^IO>13\)N%;)50(Z6'>F![']+
+M5Y"285"H9VB.%`_9\/2,X[W77CJ!D_,U9SXBK#P\5UM!IYU]J-@7%MYV?=KD
+M;S)":^[UI?`N/V+LRMI`=V+4)PA@B5[NCZ<QX#C$?==_08=<)&#FXWYP?LGB
+M/H/GK@A$)=J?@6(O:%-INH0]!RKSG6:<LYT`0%QR9I?`:+)G&-B/>A3.HL33
+MZ=/.*I\QVFLZF=DKVG>9T(TE>H-'Q"!*O@4Q"TN%B>HZ&+INLL%$!\0>"LRU
+MFCG7#(UJL"V2IWX/93O1Y:I'V]%!U>(>`/%9,D%Q.V33LT8XJWR*#</&':`=
+M/R\)ZX4IR!E.WK;<+RJ$;*<N2''=Z]B3_YF#X:K;R8',8Z2[2[0/#'I'UQ\6
+MHHYQ,HT,5DF!&;*<Y2RX)W[3\QCCXATI<*O$="2:G)V`U$VC'SI?;>\N_-2Q
+MI!X]^)&8&)VGL@IL*SP37:;@*#9/R=J<`(I-7G`=L0!-LDFS!8;\]Y]Q"SPL
+MR;0[^T@X:T#8R+#<G6V-'_."8'OD.@R,[V%0)`7&@ZU&G99B`C2EKJL/7V-5
+M4M7BO1KN>%2&YK8G8)O.V.?AP@$?Q38\;[Q\`%0GM!O:*J&YK6"^:V=^X7CT
+M!V.#R^_,Y'IICT=-PI+/*':\4'Z(#=^FT`JEYNYH";A^6(#HO&M-V!IDR"JT
+MT,_D*$K3;33^J?N62#HPT9C+>%=2$K4M=BUM*A#AYHRY$O^2A+RP*/FX_-?)
+MW"+A;92OA.66QPS?*$@,"G'-=\N<W)(#-,[<W#FYPT0K#T`.;.42!%\BHN-!
+MC,O=4OB(!5%/>5D9WQ8L3<B21)F_?!Y0-AK<81,;9)YB.5'NN.Q%P^S/H$(C
+M5!/.UP79@L2P@%$#VT;*+<.O2G6&,W(R-95*J=HW:XHAX'X+O_RZK,KM23K[
+MD0)EP$O4Z6BROM0H;_?,='6(;<_61/1X[EZ)#SX5W`4J/<%W)RZ1:-4*1O%B
+M^[<.68!*;-%1F$_C`Z=R4N5D"8(,#NAN([B0+TNXE__Q;=&;]16M?\6'L_-Y
+MGF6BU3+3/;:#S\&!/.,.><I>(?J#5H/J:A>J&3X?)CWL5!AJZS:R5?-IN>:$
+M=';_73&F]-'2XQL@I;?+_L)PZ(5)CW_=@;T1?7]T94@?#OP41L3-OQ`5S*NN
+MN'ZPK$\`&.I!+@HF,9Y49<@6D>1-C3J<>E"LEW)A!(N4F),;8(V2,O_"*^GD
+M(8<($[S'1:"R%\G@-8HLHI_<ASUHU@3/V#BZ-3JX:_27TAUS[?RDD*MVI+)O
+M2.`\G<<1(4KBQY_&30PA)Q,:H1Y604#54/'QT<\Q1-33(VX;&>BD&XJ*J[X;
+MIF9O;9KGL2C0)R+B0B/MK:&1\8B(V)P&9F';:F:]#/C.*5W;!63Z+@1V+$$(
+MT&[!9B2&/XEGB3DI.1_%4@I\6F;EOA.>98^*#3:FB?KJT-AC8(486&;9$.4B
+MZ(F2;B5'_@FXMD^DR`3UN2N*XE34"6*[7.Y(Z6+"8V@XO[G83#-4O_G;)+S:
+MBU&0/+SWIT;B5JW0PD(?^K92L3BK$(',3>`QC=?6("#(</2LQ19@ONK@G(`H
+M=S(1]1D`GLH>X<+OA]2Q#-KFER6#L<SD4L<]>&]KKY''[W*.KZPQV"4%N@_G
+M:JG#!2S$(W'^<SUVF]7\`3SI'T!3\<%O#$_**BHN^J66M@+63PG1H1!F!95@
+M.'"F0@ASY;5@S4R@QQ0%G8"3#]#Y2W=VG=PN')+W(>L1_:^.JY,X.1DML+,:
+M.&)[QWH;1,Z@$MNPI)U$PQ?&K_<8K<_0L!%H0?+]+@K<O'+@F$ZF:S7=%]-?
+M!6B/9A3C%NK<!TP#W/JE"KA<OL5/]<N@&Q`UI0]Z,RP8+V&TRR,U&K1(;B6&
+MXR[R\V^TF02+]Q&Z&T2MSD?6IYKK+\IL&H_"%/K_\"7S^ZM/_I-4IXT-J<,5
+ME.B<,HS4$':E@4>^Y\U@NT&4(^(KBMP.2/,VA<^PH&O%0Z6O8W2[[?3[@DIG
+M5N1CB2!EO2D5^V(NCLZ^^$K#*<(C#]C\\2M)\QR27#9K]O(#+D3^89(Q@^O_
+M"</X"TM2;P`0-CH2]DI;,0*X8N<2`N7(S(9G@)'SW\B4^V(^FSA/*"A-BY_,
+MQ/T3C*ZW1JC*L(N)"].#W<\XG[3&7GO"U0J#%X3*81VS$L[4CER05.#W'KMB
+MQ`)/\N;F40.K;(8VBF1]QJ4?V26E\L"8:,Z;]$TT6GGCTQVQI?9*$^(O:K21
+MB31@-!IV2[*UN]-3MC^]`Z[Q6/PI!"/<(LR#/X"(M"S,HR;RJ;GWK,W12BR@
+MI(C]TU%E-:;_F4B^;HK9#O79@<.EA9C4)GA4CB$AN,?I.Q8&__ADC_=6=W#@
+M]@:+5KB+59.?EYP493U=\6ZK-W10^C3XVIFVA+A$XIB<#Y&$.8.<3?XKHE2Q
+MV(E@*XPX?;[[(JDWY_[D"VTW;].%S@S(-V,,?8U"YT,1)03Y![JF*O:WW,C$
+M:/S;(QBI'"=VP`,S3)',"2A*UJB0ZT:DB\LN..Z16#B#`=GISSCG#%A,R+^B
+M?YI!@9<MG?O*OOLQ`$6ER.9'<P7!N_O^V&@Y<6%K\>Y&MOQF0S*T":F(;:UQ
+MEY43B9#>;Z;,TN*9>PD8UHDMYE8&58#+_O=A'V%>/S2'!XV1;<>M._W)UUWP
+MO&C/56ST%YA@H.^'3T1JWUOI9X[H*\W4O.=#S13RN=B,*R?W5"5$SAJNG3_0
+M?R/IY0[4@2.NT?<8_B:IPQP4MJ>!+4?B#HXO'2>LP?`;W;\=<//I8=C+*4\T
+MMKI"AD5W[4R78TP5%2B`B5.>6@62&:T`!DQ%_I-K_.SM*U,LVHF)Q!NE*_%A
+M7'MKH@ZQ%6_0</<&,T37(+4')\&I73<DR=;L3"6[(MOY],K8Y&_WILZV`.)F
+M<HCC0WD-L)V4`ZX_NTZ1M*\&:/\JW7US>%FBDJ#^C$(0EIGQUHR_:2.<T/[4
+M]#M6>Y,KEH2VA'HO'D:=_L>W&B9D@F?%1?JK<"^Z@BSX<CP3C_R$CIMHW5.7
+MG7</R<FN7%/C4E#D+!(Z1:>@><6=^.:0A">TBNM^@ZXI^>ZCVP-:#7:ZX7@4
+MZ'$:7P3@:'$-)"0W&-#E[]DUNF4T>?GY/>%)B-#=@U4!?H:H;_6%N$^%3V-L
+MZKF+H<`&]7>7-7\4VEW>(E>"0'SDA?7EN%%@+0GJ%I/&:RW6EB$0K9U_)VHY
+MRQV8$_.),BW;OG/W)!UF=,/;@=YNEKP<;".">TM_JC3Q+0SNG/Y`^2[N:P>6
+MXB!N#C&B2&/(#'["/I801E^)`CU38=/UK0Z+I&Y[<K^-L;R.#%$-^#2NR./B
+MNTSY!F,J;U20<9WOV,6R8@^GW+J:B^"7]Z<TEI+\4V2&[`1GD;F,K05S#Y=P
+M*QG9NDXRODK2`7TRXD-[FI6NN,#*P_AY-;"74,U.L@C9W-6\@LCV%8MW?[12
+M@.>7_EI+N:D',E8@8#RS7G6+\5NP&[@$-_G)+HRF[PV.A3%%_E[QBED?E9)W
+MK<&OQ;B]@).LN"*SVH(UNCQ)'1Y?(7T'2DO[1XXZXCB*^&4-G;>[0F;!6+HH
+M\8YVXN[TCY0)L=]9+<3DP`)=6_N_J47.C;3A=\3+LNP#23,>0CVUT+FJW>8R
+MY-I\&1CQ0D.7IIT)?D$'KD';Y^LU(]OV`A`Q0Z14.NO.1+N$HB=X1DI%,UDP
+M35UO0IE@[5F+O/CI$U)9W`;`O*=>JL/L))5P4^J[);PW=5:\,T9MJ2X%"&DU
+M"_XCEH;QL:DG<(Q/_A:`S[H<T(>$%R,S-JNZQC'*J"A]6:J'0I7?U)@)KK5Z
+M>^C[8@AW"LJE2S6ZC;2#RQ%>*E4QI,8'>;$)2>;+*.*$TF?N;L&JBS)%.*1/
+MD8KU;0U_NY/Z%-$KTL&0[E2[!$&1A<A)@U[;7#]FH#V">)9V0)8C^8,JC8'D
+M_6ZN?'55'<TI%YC5Z_E5,L(8>0\EW8A(_UA!^U`G_R%.O5@-HG8)5=\,HA:5
+M/"#^=945W,^2[Z81B&5GBB=&06EY8Z/8SE$J$N,Y%6?MM]=2+58A7A;`!S<?
+M-[FSH"9CR9$O^9@4O]BI>:246T29^ZB%O_:;P[%D92EXY!\\$3/V+J"E3VU_
+MR=Z]9R&?=IW%1]=:J*KC5CO"%N]\SR'3L=1^.%\;L:(V\TBSW6*=7NF^BBN:
+M=?ZZ&(LCM(RJ40JH@[X)B^5*/_Q(@.!`%!XDM54+`RI`^-L1-P8`(!#$:[$,
+MB#=N4/0_]N:O,-_%])?U/.6X,EC;'["ZZ-BL,^_W8)XEX4FVB70/J]RI&Z<T
+M`)CS@+Z_7M6A%GDBUC)8O$)](D6OE+ZYTS@7S$O$$.6(Z3:02PKK2AV43#Z:
+M?)/"1LRF!UK!$6;U%15LB=DK^_K%%+[#W0L#K^$6%>LCY(M;`!./-MYPTH;Q
+MTF*@6H*N9:DEGJ)O)3[)4=5190Z>BX)DL,G(L^FN$E[HN,U.,_>V5,Y)1(^V
+M,.X_U2R];K$CWQ8TI18?7)QS-9L(>IR*!\3V-H6?O.HF<"7E8-SWK(115/6@
+MQL5ZDJ3)N%H^8IN^`[0\/V`6#?LL/VO:'OIA)FDY.P4`JX+EC%;HZ*E"]WV<
+MZ<EC4A31ND1L%?SY)H8?U=<=@</@Y8&7XJI4NJ"&B3]]=2(0_6A"+ZGX@+5_
+M(7;Y!N,;KF'OQUQ55;B3A\2X,C--JOZSI+NF)K\J([L%?/+#8AF[>KMAC&8F
+M5G&WG[>$>`N_04V")EXD',H2%H1:G7)^HXMIK5EK10TPAE`#H-*\LPH@DVO&
+MM8JJ"?8`'NA_:&M$3`_OJ9([U_C]XG#=\8'UA5R?Y&(_0ODNJ9B+>9*4(K-C
+MTWC'BH\H'6KBFUF!E1A6H_]X[:<ZQ'.J%J!N?,9("U?VSO'O:OU"N[8ZD`H*
+MLGXAX@3C*PVY2(F86+X+Q\&4L56*E^IF\K$)W-3AZ(V0ZOMU$F?/V.HMYZH4
+M<B^N\6M0\PO$:H8666J*@A/I]IB$L?'3$3FB>O-Y\.*E+'PQ6;$[Q$[M>#<`
+!9P``
+`
+end
diff --git a/tools/regression/usr.bin/xargs/Makefile b/tools/regression/usr.bin/xargs/Makefile
new file mode 100644
index 0000000..b937d41
--- /dev/null
+++ b/tools/regression/usr.bin/xargs/Makefile
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+all:
+ @m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR}
diff --git a/tools/regression/usr.bin/xargs/regress.I.out b/tools/regression/usr.bin/xargs/regress.I.out
new file mode 100644
index 0000000..f2a6a1e
--- /dev/null
+++ b/tools/regression/usr.bin/xargs/regress.I.out
@@ -0,0 +1,4 @@
+The quick brown quick brown quick brown quick brownquick brown quick brown %
+The fox jumped fox jumped fox jumped fox jumpedfox jumped fox jumped %
+The over the lazy over the lazy over the lazy over the lazyover the lazy over the lazy %
+The dog dog dog dogdog dog %
diff --git a/tools/regression/usr.bin/xargs/regress.J.out b/tools/regression/usr.bin/xargs/regress.J.out
new file mode 100644
index 0000000..b88a41e
--- /dev/null
+++ b/tools/regression/usr.bin/xargs/regress.J.out
@@ -0,0 +1 @@
+The quick brown fox jumped over the lazy dog again.
diff --git a/tools/regression/usr.bin/xargs/regress.L.out b/tools/regression/usr.bin/xargs/regress.L.out
new file mode 100644
index 0000000..7359dee
--- /dev/null
+++ b/tools/regression/usr.bin/xargs/regress.L.out
@@ -0,0 +1,2 @@
+quick brown fox jumped over the lazy
+dog
diff --git a/tools/regression/usr.bin/xargs/regress.R.out b/tools/regression/usr.bin/xargs/regress.R.out
new file mode 100644
index 0000000..6fe947f
--- /dev/null
+++ b/tools/regression/usr.bin/xargs/regress.R.out
@@ -0,0 +1,4 @@
+The quick brown % % %% % %
+The fox jumped % % %% % %
+The over the lazy % % %% % %
+The dog % % %% % %
diff --git a/tools/regression/usr.bin/xargs/regress.in b/tools/regression/usr.bin/xargs/regress.in
new file mode 100644
index 0000000..5252b48
--- /dev/null
+++ b/tools/regression/usr.bin/xargs/regress.in
@@ -0,0 +1,4 @@
+quick brown
+fox jumped
+over the lazy
+dog
diff --git a/tools/regression/usr.bin/xargs/regress.normal.out b/tools/regression/usr.bin/xargs/regress.normal.out
new file mode 100644
index 0000000..458d9cb
--- /dev/null
+++ b/tools/regression/usr.bin/xargs/regress.normal.out
@@ -0,0 +1 @@
+The quick brown fox jumped over the lazy dog
diff --git a/tools/regression/usr.bin/xargs/regress.sh b/tools/regression/usr.bin/xargs/regress.sh
new file mode 100644
index 0000000..dbf0ecc
--- /dev/null
+++ b/tools/regression/usr.bin/xargs/regress.sh
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+REGRESSION_START($1)
+
+REGRESSION_TEST(`normal', `xargs echo The < regress.in')
+REGRESSION_TEST(`I', `xargs -I% echo The % % % %% % % < regress.in')
+REGRESSION_TEST(`J', `xargs -J% echo The % again. < regress.in')
+REGRESSION_TEST(`L', `xargs -L3 echo < regress.in')
+REGRESSION_TEST(`R', `xargs -I% -R1 echo The % % % %% % % < regress.in')
+
+REGRESSION_END()
diff --git a/tools/test/README b/tools/test/README
new file mode 100644
index 0000000..aacc781
--- /dev/null
+++ b/tools/test/README
@@ -0,0 +1,12 @@
+$FreeBSD$
+
+This directory is for test programs.
+
+A test program is one that will exercise a particular bit of the system
+and try to break it and/or measuring performance on it.
+
+Please make a subdir per program, and add a brief description to this file.
+
+devrandom Programs to test /dev/*random.
+malloc A program to test and benchmark malloc().
+posixshm A program to test POSIX shared memory.
diff --git a/tools/test/devrandom/hammer.random b/tools/test/devrandom/hammer.random
new file mode 100644
index 0000000..ea4cb5f
--- /dev/null
+++ b/tools/test/devrandom/hammer.random
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+#
+# Test program for /dev/random
+# Read and display random numbers.
+# Try tapping shift/alt/ctrl to get more randomness.
+#
+# $FreeBSD$
+#
+
+for (;;) {
+ open(BIN, "/dev/random") || die "Cannot open /dev/random - $!\n";
+ $len = sysread(BIN, $a, 128);
+ close(BIN);
+ if ($len > 0) {
+ print "$len bytes read: ";
+ for ($j = 0; $j < $len; $j++) {
+ $k = unpack("C", substr($a, $j, 1));
+ printf("%.2X ", $k);
+ }
+ printf "\n";
+ }
+}
diff --git a/tools/test/devrandom/hammer.urandom b/tools/test/devrandom/hammer.urandom
new file mode 100644
index 0000000..d0b6aa8
--- /dev/null
+++ b/tools/test/devrandom/hammer.urandom
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+
+#
+# Test program for /dev/urandom
+# Read and display random numbers.
+# This also reads /dev/zero to make sure there is no brokenness there.
+#
+# $FreeBSD$
+#
+
+open(ZERO, "/dev/zero") || die "Cannot open /dev/zero - $!\n";
+
+for (;;) {
+ open(BIN, "/dev/urandom");
+ $len = sysread(BIN, $a, 20);
+ sysread(ZERO, $b, 20);
+ close(BIN);
+ if ($len > 0) {
+ for ($j = 0; $j < $len; $j += 2) {
+ $k = unpack("S", substr($a, $j, 2));
+ $z = unpack("S", substr($b, $j, 2));
+ $z == 0 || die "/dev/zero is returning non-zero!\n";
+ printf("%.4X ", $k);
+ }
+ printf "\n";
+ }
+}
diff --git a/tools/test/devrandom/stat.16bit b/tools/test/devrandom/stat.16bit
new file mode 100644
index 0000000..32a6a9c
--- /dev/null
+++ b/tools/test/devrandom/stat.16bit
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+#
+# Perform primitive binning into 16-bit bins (take 16bits of randomness
+# at a time) and see if the distribution is flat. The output should be
+# checked by eye - are all the numbers roughly the same?
+#
+# Redirect the output from this to a file - and go to the movies while
+# it runs. This program is a CPU Hog!
+#
+# $FreeBSD$
+#
+
+for ($i = 0; $i < (1024*64); $i++) {
+ open(BIN, "/dev/urandom") || die "Cannot open /dev/urandom - $!\n";
+ $len = sysread(BIN, $a, 512);
+ close(BIN);
+ if ($len > 0) {
+ for ($j = 0; $j < $len; $j += 2) {
+ $k = unpack("S", substr($a, $j, 2));
+ $bin[$k]++;
+ }
+ }
+}
+
+for ($i = 0; $i < 1024*64; $i++) {
+ printf("%.2X ", $bin[$i]);
+}
+printf "\n";
diff --git a/tools/test/devrandom/stat.8bit b/tools/test/devrandom/stat.8bit
new file mode 100644
index 0000000..03fdbdd
--- /dev/null
+++ b/tools/test/devrandom/stat.8bit
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+#
+# Perform primitive binning into 8-bit bins (take 8 bits of randomness
+# at a time) and see if the distribution is flat. The output should be
+# checked by eye - are all the numbers roughly the same?
+#
+# Redirect the output from this to a file - and make a cup of coffee while
+# it runs. This program is a CPU Hog!
+#
+# $FreeBSD$
+#
+
+for ($i = 0; $i < (1024*32); $i++) {
+ open(BIN, "/dev/urandom") || die "Cannot open /dev/urandom - $!\n";
+ $len = sysread(BIN, $a, 256);
+ close(BIN);
+ if ($len > 0) {
+ for ($j = 0; $j < $len; $j++) {
+ $k = unpack("C", substr($a, $j, 1));
+ $bin[$k]++;
+ }
+ }
+}
+
+for ($i = 0; $i < 256; $i++) {
+ printf("%.2X ", $bin[$i]);
+}
+printf "\n";
diff --git a/tools/test/malloc/Makefile b/tools/test/malloc/Makefile
new file mode 100644
index 0000000..6637ab1
--- /dev/null
+++ b/tools/test/malloc/Makefile
@@ -0,0 +1,15 @@
+# $FreeBSD$
+PROG= malloc
+SRCS= main.c
+.PATH: ${.CURDIR}/../../../lib/libc/stdlib
+
+NOMAN= sorry
+
+test: malloc
+ @echo
+ @csh -x -c "time ./malloc 500000 2000 8192"
+ @csh -x -c "time ./malloc 50000000 2000 8192"
+ @csh -x -c "time ./malloc 500000 14000 8192"
+ @csh -x -c "time ./malloc 20000000 20000 2048"
+
+.include <bsd.prog.mk>
diff --git a/tools/test/malloc/main.c b/tools/test/malloc/main.c
new file mode 100644
index 0000000..2a05029
--- /dev/null
+++ b/tools/test/malloc/main.c
@@ -0,0 +1,57 @@
+/* $FreeBSD$ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+u_long NBUCKETS = 2000;
+u_long NOPS = 200000;
+u_long NSIZE = (16*1024);
+
+char **foo;
+
+int
+main(int argc, char **argv)
+{
+ int i,j,k;
+
+ if (argc > 1) NOPS = strtoul(argv[1],0,0);
+ if (argc > 2) NBUCKETS = strtoul(argv[2],0,0);
+ if (argc > 3) NSIZE = strtoul(argv[3],0,0);
+ printf("BRK(0)=%x ",sbrk(0));
+ foo = malloc (sizeof *foo * NBUCKETS);
+ memset(foo,0,sizeof *foo * NBUCKETS);
+ for (i = 1; i <= 4096; i *= 2) {
+ for (j = 0 ; j < 40960/i && j < NBUCKETS; j++) {
+ foo[j] = malloc(i);
+ }
+ for (j = 0 ; j < 40960/i && j < NBUCKETS; j++) {
+ free(foo[j]);
+ foo[j] = 0;
+ }
+ }
+
+ for (i = 0 ; i < NOPS ; i++) {
+ j = random() % NBUCKETS;
+ k = random() % NSIZE;
+ foo[j] = realloc(foo[j], k & 1 ? 0 : k);
+ if (k & 1 || k == 0) {
+ /*
+ * Workaround because realloc return bogus pointer rather than
+ * NULL if passed zero length.
+ */
+ foo[j] = 0;
+ }
+ if (foo[j])
+ foo[j][0] = 1;
+ }
+ printf("BRK(1)=%x ",sbrk(0));
+ for (j = 0 ; j < NBUCKETS ; j++) {
+ if (foo[j]) {
+ free(foo[j]);
+ foo[j] = 0;
+ }
+ }
+ printf("BRK(2)=%x NOPS=%lu NBUCKETS=%lu NSIZE=%lu\n",
+ sbrk(0),NOPS,NBUCKETS,NSIZE);
+ return 0;
+}
diff --git a/tools/test/posixshm/README b/tools/test/posixshm/README
new file mode 100644
index 0000000..514e18b
--- /dev/null
+++ b/tools/test/posixshm/README
@@ -0,0 +1,4 @@
+$FreeBSD$
+
+This is a simple program to test/demonstrate the POSIX Shared Memory
+Objects feature set. `make shm_test' to build.
diff --git a/tools/test/posixshm/shm_test.c b/tools/test/posixshm/shm_test.c
new file mode 100644
index 0000000..6cee558
--- /dev/null
+++ b/tools/test/posixshm/shm_test.c
@@ -0,0 +1,144 @@
+/*
+ * Test the POSIX shared-memory API.
+ * Dedicated to tyhe public domain by Garrett A. Wollman, 2000.
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/*
+ * Signal handler which does nothing.
+ */
+static void
+ignoreit(int sig)
+{
+ ;
+}
+
+int
+main(int argc, char **argv)
+{
+ char buf[1024], *cp;
+ int desc, rv;
+ long scval;
+ sigset_t ss;
+ struct sigaction sa;
+ void *region;
+ size_t psize;
+
+#ifndef _POSIX_SHARED_MEMORY_OBJECTS
+ printf("_POSIX_SHARED_MEMORY_OBJECTS is undefined\n");
+#else
+ printf("_POSIX_SHARED_MEMORY_OBJECTS is defined as %ld\n",
+ (long)_POSIX_SHARED_MEMORY_OBJECTS - 0);
+ if (_POSIX_SHARED_MEMORY_OBJECTS - 0 == -1)
+ printf("***Indicates this feature may be unsupported!\n");
+#endif
+ errno = 0;
+ scval = sysconf(_SC_SHARED_MEMORY_OBJECTS);
+ if (scval == -1 && errno != 0) {
+ err(1, "sysconf(_SC_SHARED_MEMORY_OBJECTS)");
+ } else {
+ printf("sysconf(_SC_SHARED_MEMORY_OBJECTS) returns %ld\n",
+ scval);
+ if (scval == -1)
+ printf("***Indicates this feature is unsupported!\n");
+ }
+
+ errno = 0;
+ scval = sysconf(_SC_PAGESIZE);
+ if (scval == -1 && errno != 0) {
+ err(1, "sysconf(_SC_PAGESIZE)");
+ } else if (scval <= 0 || (size_t)psize != psize) {
+ warnx("bogus return from sysconf(_SC_PAGESIZE): %ld",
+ scval);
+ psize = 4096;
+ } else {
+ printf("sysconf(_SC_PAGESIZE) returns %ld\n", scval);
+ psize = scval;
+ }
+
+ argc--, argv++;
+
+ if (*argv) {
+ strncat(buf, *argv, (sizeof buf) - 1);
+ desc = shm_open(buf, O_EXCL | O_CREAT | O_RDWR, 0600);
+ } else {
+ do {
+ /*
+ * Can't use mkstemp for obvious reasons...
+ */
+ strcpy(buf, "/tmp/shmtest.XXXXXXXXXXXX");
+ mktemp(buf);
+ desc = shm_open(buf, O_EXCL | O_CREAT | O_RDWR, 0600);
+ } while (desc < 0 && errno == EEXIST);
+ }
+
+ if (desc < 0)
+ err(1, "shm_open");
+
+ if (shm_unlink(buf) < 0)
+ err(1, "shm_unlink");
+
+ if (ftruncate(desc, (off_t)psize) < 0)
+ err(1, "ftruncate");
+
+ region = mmap((void *)0, psize, PROT_READ | PROT_WRITE, MAP_SHARED,
+ desc, (off_t)0);
+ if (region == MAP_FAILED)
+ err(1, "mmap");
+ memset(region, '\377', psize);
+
+ sa.sa_flags = 0;
+ sa.sa_handler = ignoreit;
+ sigemptyset(&sa.sa_mask);
+ if (sigaction(SIGUSR1, &sa, (struct sigaction *)0) < 0)
+ err(1, "sigaction");
+
+ sigemptyset(&ss);
+ sigaddset(&ss, SIGUSR1);
+ if (sigprocmask(SIG_BLOCK, &ss, (sigset_t *)0) < 0)
+ err(1, "sigprocmask");
+
+ rv = fork();
+ if (rv < 0) {
+ err(1, "fork");
+ } else if (rv == 0) {
+ sigemptyset(&ss);
+ sigsuspend(&ss);
+
+ for (cp = region; cp < (char *)region + psize; cp++)
+ if (*cp != '\151')
+ _exit(1);
+ _exit(0);
+ } else {
+ int status;
+
+ memset(region, '\151', psize);
+ kill(rv, SIGUSR1);
+ waitpid(rv, &status, 0);
+
+ if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
+ printf("Functionality test successful\n");
+ exit(0);
+ } else if (WIFEXITED(status)) {
+ printf("Child process exited with status %d\n",
+ WEXITSTATUS(status));
+ } else {
+ printf("Child process terminated with %s\n",
+ strsignal(WTERMSIG(status)));
+ }
+ }
+ exit(1);
+}
diff --git a/tools/tools/README b/tools/tools/README
new file mode 100644
index 0000000..9de2553
--- /dev/null
+++ b/tools/tools/README
@@ -0,0 +1,38 @@
+# $FreeBSD$
+
+This directory is for tools.
+
+A tool is something which is sometimes useful, and doesn't fit any of
+the other categories.
+
+Please make a subdir per program, and add a brief description to this
+file.
+
+backout_commit A tool for reading in a commit message and generating
+ a script that will backout the commit.
+commitsdb A tool for reconstructing commit history using md5
+ checksums of the commit logs.
+crypto Exercise the crypto framework through /dev/crypto
+diffburst OBSOLETE: equivalent functionality is available via split -p.
+ For example: "split -p ^diff < patchfile". See split(1).
+editing Editor modes and the like to help editing FreeBSD code.
+epfe Extract printing filter examples from printing.sgml.
+find-sb Scan a disk for possible filesystem superblocks.
+html-mv Rename HTML generated filenames to human readable filenames.
+ifinfo Uses the interface MIB to print out all the information
+ an interface exports in an ugly form.
+kdrv KernelDriver; add/list/remove third-party kernel driver
+ source to/in/from a kernel source tree.
+kerncruft Shellscript to find orphaned *.c files in /sys
+kerninclude Shellscript to find unused #includes in the kernel.
+kernxref Shellscript to cross reference symbols in the LINT kernel.
+mid Create a Message-ID database for mailing lists.
+pciid Generate src/share/misc/pci_vendors.
+portsinfo Generate list of new ports for last two weeks.
+prstats Generate statistics about the PR database.
+scsi-defects Get at the primary or grown defect list of a SCSI disk.
+tinderbox Sample script for nightly test builds.
+upgrade Scripts used for upgrading an installed system.
+vop_table Generates a HTML document that shows all the VOP's in
+ the kernel.
+whereintheworld Summarizes "make world" output.
diff --git a/tools/tools/backout_commit/backout_commit.rb b/tools/tools/backout_commit/backout_commit.rb
new file mode 100644
index 0000000..264c271
--- /dev/null
+++ b/tools/tools/backout_commit/backout_commit.rb
@@ -0,0 +1,350 @@
+#!/usr/bin/env ruby -w
+
+# $FreeBSD$
+
+# Please note, that this utility must be kept in sync with
+# CVSROOT/log_accum.pl. If someone has a different output from their
+# mail client when saving e-mails as text files, feel free to hack it
+# in as an option.
+#
+# If someone would like to hack in the ability to generate diffs based
+# off of this script, by all means, be my guest.
+
+require 'getoptlong'
+
+$basedir = '/usr'
+$backout_script = "backout-#{Time.now.strftime("%Y-%m-%d-%H-%M")}.sh"
+$commit_authors = []
+$commit_dates = []
+$commit_file = nil
+$commit_message = nil
+$cvsbin = nil
+$cvs_path = '/usr/bin/cvs'
+$cvsrc_ignore = true
+$debug = 0
+$echo_path = '/usr/bin/echo'
+$echo_warnings = true
+$force_script_edit = false
+$force_remove = false
+$output = $stdout
+$quiet_script = false
+$shell_path = '/bin/sh'
+$shell_args = '--'
+
+def debug(level, *msgs)
+ if level <= $debug
+ if $debug > 1
+ $output.puts "DEBUG(#{level}): #{msgs.shift}"
+ else
+ $output.puts msgs.shift
+ end
+
+ for msg in msgs
+ $output.puts "\t #{msg}"
+ end
+ end
+end # def debug()
+
+
+def usage(msg, info = nil)
+ out = (msg.nil? ? $stdout : $stderr)
+ out.puts "#{File.basename($0)} usage:" << (msg.nil? ? '' : " #{msg}")
+ out.puts "#{info}" unless info.nil?
+ out.puts ""
+ out.puts " -s, --backout-script=<file> Specifies the filename of the script"
+ out.puts " -D, --basedir=<dir> Specifies the base directory [/usr]"
+ out.puts " -a, --commit-author=<uid> Forces a commit author"
+ out.puts " -d, --commit-date=<date> Forces a commit date"
+ out.puts " -m, --commit-file=<path> Specifies a commit message file"
+ out.puts " -M, --commit-message=<msg> Specifies a commit message"
+ out.puts " -c, --cvs-path=<path> Specifies the CVS binary to be used [cvs]"
+ out.puts " -C, --cvsrc-ignore=<bool> If true, will ignore options in ~/.cvsrc"
+ out.puts " -e, --echo-path=<path> Specifies the path to echo"
+ out.puts " -f, --force-remove=<bool> If true, removes new files [false]"
+ out.puts " -F, --force-edit=<bool> If true, add -C to the shell arguments in"
+ out.puts " the backout script if the shell is sh,"
+ out.puts " which forces an edit of the script"
+ out.puts " -O, --output=<stdio> Specifies what fd to direct the output to"
+ out.puts " -A, --shell-args=<string> Specifies the shell arguments to be used"
+ out.puts " -S, --shell-path=<path> Specifies the shell to be used [/bin/sh]"
+ out.puts " -W, --warnings=<bool> Turns on or off warnings [true]"
+ exit(msg.nil? ? 0 : 1)
+end
+
+
+OPTION_LIST = [
+ ['--backout-script','-s', GetoptLong::REQUIRED_ARGUMENT],
+ ['--basedir','-D', GetoptLong::REQUIRED_ARGUMENT],
+ ['--commit-author','-a', GetoptLong::REQUIRED_ARGUMENT],
+ ['--commit-date','-d', GetoptLong::REQUIRED_ARGUMENT],
+ ['--commit-file','-m', GetoptLong::REQUIRED_ARGUMENT],
+ ['--commit-message','-M', GetoptLong::REQUIRED_ARGUMENT],
+ ['--cvs-path','-c',GetoptLong::REQUIRED_ARGUMENT],
+ ['--cvsrc-ignore','-C',GetoptLong::REQUIRED_ARGUMENT],
+ ['--echo-path','-e',GetoptLong::REQUIRED_ARGUMENT],
+ ['--force-edit','-F',GetoptLong::REQUIRED_ARGUMENT],
+ ['--force-remove','-f',GetoptLong::REQUIRED_ARGUMENT],
+ ['--output', '-O', GetoptLong::REQUIRED_ARGUMENT],
+ ['--quiet-script','-q',GetoptLong::REQUIRED_ARGUMENT],
+ ['--shell-args','-A',GetoptLong::REQUIRED_ARGUMENT],
+ ['--shell-path','-S',GetoptLong::REQUIRED_ARGUMENT],
+ ['--warnings','-w', GetoptLong::REQUIRED_ARGUMENT],
+]
+
+opt_parser = GetoptLong.new(*OPTION_LIST)
+opt_parser.quiet = true
+
+begin
+ opt_parser.each do |opt,arg|
+ case opt
+ when '--backout-script'
+ debug(3, "backout script was #{$backout_script.inspect} : is #{arg.inspect}")
+ $backout_script = arg
+ when '--basedir'
+ debug(3, "base directory was #{$basedir.inspect} : is #{arg.inspect}")
+ $basedir = arg
+ when '--commit-author'
+ debug(3, "commit author #{arg.inspect} added to list")
+ $commit_authors.push(arg.dup)
+ when '--commit-date'
+ debug(3, "commit date #{arg.inspect} added to list")
+ $commit_date.push(arg.dup)
+ when '--commit-file'
+ debug(3, "commit file was #{$commit_file.inspect} : is #{arg.inspect}")
+ $commit_file = arg
+ when '--commit-message'
+ debug(3, "commit message was #{$commit_message.inspect} : is #{arg.inspect}")
+ $commit_message = arg
+ when '--cvs-path'
+ debug(3, "cvs path was #{$cvs_path.inspect} : is #{arg.inspect}")
+ $cvs_path = arg
+ when '--cvsrc-ignore'
+ if arg =~ /true|yes/i
+ $cvsrc_ignore = true
+ elsif arg =~ /false|no/i
+ $cvsrc_ignore = false
+ else
+ usage("#{opt}: unknown bool format \"#{arg}\"", "Valid options are \"true\", \"false\", \"yes\", or \"no\"")
+ end
+ debug(3, "ignoring of ~/.cvsrc is set to #{$cvsrc_ignore.inspect}")
+ when '--echo-path'
+ debug(3, "echo path was #{$echo_path.inspect} : is #{arg.inspect}")
+ $echo_path = arg
+ when '--force-edit'
+ if arg =~ /true|yes/i
+ $force_script_edit = true
+ elsif arg =~ /false|no/i
+ $force_script_edit = false
+ else
+ usage("#{opt}: unknown bool format \"#{arg}\"", "Valid options are \"true\", \"false\", \"yes\", or \"no\"")
+ end
+ debug(3, "force edit of backout script is set to #{$force_script_edit.inspect}")
+ when '--force-remove'
+ if arg =~ /true|yes/i
+ $force_remove = true
+ elsif arg =~ /false|no/i
+ $force_remove = false
+ else
+ usage("#{opt}: unknown bool format \"#{arg}\"", "Valid options are \"true\", \"false\", \"yes\", or \"no\"")
+ end
+ debug(3, "force removal of files is set to #{$force_remove.inspect}")
+ when '--output'
+ case arg
+ when 'stdout'
+ $output = $stdout
+ when 'stderr'
+ $output = $stderr
+ else
+ usage("#{opt}: unknown output format","Valid outputs are \"stdout\" and \"stderr\"")
+ end
+ debug(3, "output set to #{arg}")
+ when '--quiet-script'
+ if arg =~ /true|yes/i
+ $quiet_script = true
+ elsif arg =~ /false|no/i
+ $quiet_script = false
+ else
+ usage("#{opt}: unknown bool format \"#{arg}\"", "Valid options are \"true\", \"false\", \"yes\", or \"no\"")
+ end
+ debug(3, "quiet script is set to #{$quiet_script.inspect}")
+ when '--shell-args'
+ debug(3, "shell args were #{$shell_args.inspect} : is #{arg.inspect}")
+ $shell_args = arg
+ when '--shell-path'
+ debug(3, "shell path was #{$shell_path.inspect} : is #{arg.inspect}")
+ $shell_path = arg
+ when '--warnings'
+ if arg =~ /true|yes/i
+ $echo_warnings = true
+ elsif arg =~ /false|no/i
+ $echo_warnings = false
+ else
+ usage("#{opt}: unknown bool format \"#{arg}\"", "Valid options are \"true\", \"false\", \"yes\", or \"no\"")
+ end
+ debug(3, "warnings are set to #{$echo_warnings.inspect}")
+ end
+ end
+rescue GetoptLong::InvalidOption
+ usage("invalid argument")
+rescue GetoptLong::MissingArgument
+ usage("missing argument")
+rescue GetoptLong::NeedlessArgument => msg
+ usage("passed an extra argument: #{msg}")
+end
+
+debug(3, "Verbosity set to: #{$debug}")
+
+$cvsbin = $cvs_path
+$cvsbin << " -f" if $cvsrc_ignore
+
+if ARGV.length < 1
+ usage("require a commit message to parse")
+end
+
+$output.puts("Backout directory:\t#{$basedir}")
+$output.puts("Backout script:\t\t#{$backout_script}")
+$output.puts("")
+
+# Backout script - to be run by hand
+File.open($backout_script, "w+") do |f|
+ removals = []
+ updates = []
+ files = []
+
+ f.puts("#!#{$shell_path}#{($force_script_edit && $shell_path == '/bin/sh') ? ' -C' : ''} #{$shell_args}")
+ f.puts()
+ f.puts("# Generated at: #{Time.now()}")
+ f.puts("# Generated by: #{ENV['USER']}\@#{ENV['HOST']}")
+ f.puts()
+ f.puts("BASEDIR=#{$basedir}")
+ f.puts('if [ $BASEDIR != $PWD ]; then')
+ f.puts(' echo "Please change to $BASEDIR before running this shell script"')
+ f.puts(' exit 1')
+ f.puts('fi')
+ f.puts()
+
+ author_regexp = Regexp.new(/^([^\ ]+)\s+([\d]{4})\/([\d]{2})\/([\d]{2}) ([\d]{2}):([\d]{2}):([\d]{2}) ([A-Z]{3})$/)
+ file_regexp = Regexp.new(/^ ([\d\.]+)\s+\+([\d]+) \-([\d]+)\s+(.*?)$/)
+ newdead_regexp = Regexp.new(/^(.*?) \((new|dead)\)$/)
+ rev_regexp = Regexp.new(/^ Revision Changes Path$/)
+
+ for email_file in ARGV
+ File.open(email_file) do |e|
+ $output.print("Scanning through #{email_file}...")
+ found_files = false
+ for line in e
+ line.chomp!
+ if found_files == false
+ amd = author_regexp.match(line)
+ if !amd.nil?
+ $commit_authors.push(amd[1].dup)
+ $commit_dates.push(Time.local(*amd[2..7]).dup)
+ elsif rev_regexp.match(line)
+ found_files = true
+ end
+ else # if found_files
+ md = file_regexp.match(line)
+ next if md.nil?
+
+ filename = md[4]
+ ndmd = newdead_regexp.match(filename)
+ if !ndmd.nil?
+ filename = ndmd[1]
+ if ndmd[2] == 'new'
+ removals.push(filename)
+ f.puts("#{$force_remove ? '' : '# '}#{$echo_path} -n \"Removing #{filename}...\"") if !$quiet_script
+ f.puts("#{$force_remove ? '' : '# '}#{$cvsbin} rm -f #{filename}")
+ f.puts("#{$force_remove ? '' : '# '}#{$echo_path} \"done.\"") if !$quiet_script
+ f.puts()
+ files.push(filename)
+ next
+ end
+ end
+ f.puts("#{$echo_path} -n \"Updating #{filename} to #{md[1]}...\"") if !$quiet_script
+ f.puts("#{$cvsbin} up -p -r #{md[1]} #{filename} > #{filename}")
+ f.puts("#{$echo_path} \"done.\"") if !$quiet_script
+ f.puts()
+ files.push(filename)
+ end # if found_files
+ end # for line in..
+ $output.puts("done.")
+ end # File.open()
+ end # for email_file in ARGV...
+
+ if removals.length > 0 && $force_remove == false
+ f.puts("#{$echo_warnings ? '' : '# '}#{$echo_path} \"You may want to remove the following file#{removals.length > 1 ? 's' : ''}:\"")
+ for filename in removals
+ f.puts("#{$echo_warnings ? '' : '# '}#{$echo_path} \"\t#{filename}\"")
+ end
+ f.puts()
+ f.puts("#{$echo_warnings ? '' : '# '}#{$echo_path} \"There is code in #{$backout_script} to remove #{removals.length > 1 ? 'these files' : 'this file'} for you,\"")
+ f.puts("#{$echo_warnings ? '' : '# '}#{$echo_path} \"just uncomment them or pass the option --force-remove=true to #{$0}.\"")
+ end
+
+ f.puts()
+ f.puts("# # # Uncomment the following line to commit the backout.")
+ f.puts("# # #{$echo_path} -n \"Committing backout...\"") if !$quiet_script
+ if !$commit_message.nil?
+ if $commit_message.empty? or $commit_message =~ /^default|no|yes|true|false/i
+ $commit_message = "Backout of commit by #{$commit_authors.join(', ')} done on #{$commit_dates.join(', ')} because\n[___FILL_IN_THE_BLANK___]\n"
+ end
+
+ f.puts()
+ f.puts("# # # EDIT COMMIT MESSAGE HERE")
+ f.puts("CVSCOMMITMSG=<<DONTUSECVSMSG")
+ f.puts($commit_message)
+ f.puts('DONTUSECVSMSG')
+ f.puts()
+ elsif !$commit_file.nil?
+ f.puts("if [ ! -r #{$commit_file} ]; then")
+ f.puts(" #{$echo_path} \"The commit message file #{$commit_file} is not readable,\"")
+ f.puts(" #{$echo_path} \"please fix this and re-run the script.\"")
+ f.puts(" exit 1")
+ f.puts("fi")
+ f.puts()
+ end
+
+ f.print("# # #{$cvsbin} ci")
+ if !$commit_message.nil?
+ f.print(" -m \"$CVSCOMMITMSG\"")
+ elsif !$commit_file.nil?
+ f.print(" -F \"#{$commit_file}\"")
+ end
+ f.puts(" #{files.join(' ')}")
+
+ if !$quiet_script
+ if $commit_message.nil? and $commit_file.nil?
+ f.print("# # #{$echo_path} \"Commit complete. Backout should be complete. Please check to verify.\"")
+ else
+ f.puts("# # #{$echo_path} \"done.\"")
+ end
+ end
+end # File.open()
+
+$output.puts()
+$output.puts("Change to #{$basedir} and run this script. Please look through this script and")
+$output.puts("make changes as necessary. There are commented out commands available")
+$output.puts("in the script.")
+$output.puts()
+if !$commit_message.nil?
+ $output.puts("If you scroll to the bottom of #{$backout_script} you should be able to")
+ $output.puts("find a HERE document with your commit message, if you would like to make")
+ $output.puts("any further changes to your message.")
+ $output.puts()
+end
+if !$commit_file.nil?
+ begin
+ stat = File.stat($commit_file)
+ rescue Errno::ENOENT
+ $output.puts("The output file specified, \"#{$commit_file}\" DOES NOT EXIST!!! Please be sure to")
+ $output.puts("create/edit the file \"#{$commit_file}\" before you run this script")
+ $output.puts()
+ end
+end
+$output.puts("Example script usage:")
+$output.puts("\tmv #{$backout_script} #{$basedir}")
+$output.puts("\tcd #{$basedir}")
+$output.puts("\tless #{$backout_script}")
+$output.puts("\t#{$shell_path} #{$backout_script}")
+$output.puts("\trm -f #{$backout_script}")
+$output.puts()
diff --git a/tools/tools/commitsdb/make_commit_db b/tools/tools/commitsdb/make_commit_db
new file mode 100644
index 0000000..d33d4780
--- /dev/null
+++ b/tools/tools/commitsdb/make_commit_db
@@ -0,0 +1,105 @@
+#!/usr/bin/perl -w
+
+# $FreeBSD$
+
+# This script walks the tree from the current directory
+# and spits out a database generated by md5'ing the cvs log
+# messages of each revision of every file in the tree.
+
+use strict;
+use Digest::MD5 qw(md5_hex);
+
+my $dbname = "commitsdb";
+open DB, "> $dbname" or die "$!\n";
+
+# Extract all the logs for the current directory.
+my @dirs = ".";
+while (@dirs) {
+ my $dir = shift @dirs;
+ my %logs;
+
+ opendir DIR, $dir or die $!;
+ foreach my $f (grep { /[^\.]/ } readdir DIR) {
+ my $filename = "$dir/$f";
+ if (-f $filename) {
+ my %loghash = parse_log_message($filename);
+ next unless %loghash;
+
+ $logs{$filename} = {%loghash};
+ } elsif (-d $filename) {
+ next if $filename =~ /\/CVS$/;
+ push @dirs, $filename;
+ }
+ }
+ close DIR;
+
+ # Produce a database of the commits
+ foreach my $f (keys %logs) {
+ my $file = $logs{$f};
+ foreach my $rev (keys %$file) {
+ my $hash = $$file{$rev};
+
+ print DB "$f $rev $hash\n";
+ }
+ }
+
+ print "\r" . " " x 30 . "\r$dir";
+}
+print "\n";
+
+close DB;
+
+
+
+##################################################
+# Run a cvs log on a file and return a parse entry.
+##################################################
+sub parse_log_message {
+ my $file = shift;
+
+ # Get a log of the file.
+ open LOG, "cvs -R log $file 2>/dev/null |" or die $!;
+ my @log = <LOG>;
+ my $log = join "", @log;
+ close LOG;
+
+ # Split the log into revisions.
+ my @entries = split /----------------------------\n/, $log;
+
+ # Throw away the first entry.
+ shift @entries;
+
+ # Record the hash of the message against the revision.
+ my %loghash = ();
+ foreach my $e (@entries) {
+ # Get the revision number
+ $e =~ s/^revision\s*(\S*)\n//s;
+ my $rev = $1;
+
+ # Strip off any other headers.
+ my $user;
+ while ($e =~ s/^(date|branches):([^\n]*)\n//sg) {
+ my $sub = $2;
+ $user = $1 if $sub =~ /author: (.*?);/;
+ };
+
+ my $hash = string_to_hash($e);
+ $loghash{$rev} = "$user:$hash";
+ }
+
+ return %loghash;
+}
+
+
+##################################################
+# Convert a log message into an md5 checksum.
+##################################################
+sub string_to_hash {
+ my $logmsg = shift;
+
+ return md5_hex($logmsg);
+}
+
+
+
+#end
diff --git a/tools/tools/commitsdb/query_commit_db b/tools/tools/commitsdb/query_commit_db
new file mode 100644
index 0000000..e855efb
--- /dev/null
+++ b/tools/tools/commitsdb/query_commit_db
@@ -0,0 +1,93 @@
+#!/usr/bin/perl -w
+
+# $FreeBSD$
+
+# This script takes a filename and revision number as arguments
+# and spits out a list of other files and their revisions that share
+# the same log message. This is done by referring to the database
+# previously written by running make_commit_db.
+
+use strict;
+use Digest::MD5 qw(md5_hex);
+
+my $dbname = "commitsdb";
+
+# Take the filename and revision number from the command line.
+# Also take a flag to say whether to generate a patch or not.
+my ($file, $revision, $genpatch) = (shift, shift, shift);
+
+# Find the checksum of the named revision.
+my %possible_files;
+open DB, "< $dbname" or die "$!\n";
+my $cksum;
+while (<DB>) {
+ chomp;
+ my ($name, $rev, $hash) = split;
+ $name =~ s/^\.\///g;
+
+ $possible_files{$name} = 1 if $file !~ /\// && $name =~ /^.*\/$file/;
+
+ next unless $name eq $file and $rev eq $revision;
+ $cksum = $hash;
+}
+close DB;
+
+# Handle the fall-out if the file/revision wasn't matched.
+unless ($cksum) {
+ if (%possible_files) {
+ print "Couldn't find the file. Maybe you meant:\n";
+ foreach (sort keys %possible_files) {
+ print "\t$_\n";
+ }
+ }
+ die "Can't find $file rev $revision in database\n";
+}
+
+
+# Look for similar revisions.
+my @results;
+open DB, "< $dbname" or die "$!\n";
+while (<DB>) {
+ chomp;
+ my ($name, $rev, $hash) = split;
+
+ next unless $hash eq $cksum;
+
+ push @results, "$name $rev";
+}
+close DB;
+
+# May as well show the log message if we're producing a patch
+print `cvs log -r$revision $file` if $genpatch;
+
+# Show the commits that match, and their patches if required.
+foreach my $r (sort @results) {
+ print "$r\n";
+ next unless $genpatch;
+
+ my ($name, $rev) = split /\s/, $r, 2;
+ my $prevrev = previous_revision($rev);
+ print `cvs diff -u -r$prevrev -r$rev $name`;
+ print "\n\n";
+}
+
+#
+# Return the previous revision number.
+#
+sub previous_revision {
+ my $rev = shift;
+
+ $rev =~ /(?:(.*)\.)?([^\.]+)\.([^\.]+)$/;
+ my ($base, $r1, $r2) = ($1, $2, $3);
+
+ my $prevrev = "";
+ if ($r2 == 1) {
+ $prevrev = $base;
+ } else {
+ $prevrev = "$base." if $base;
+ $prevrev .= "$r1." . ($r2 - 1);
+ }
+ return $prevrev;
+}
+
+#end
diff --git a/tools/tools/crypto/Makefile b/tools/tools/crypto/Makefile
new file mode 100644
index 0000000..8dda355
--- /dev/null
+++ b/tools/tools/crypto/Makefile
@@ -0,0 +1,17 @@
+# $FreeBSD$
+
+ALL= cryptotest cryptokeytest cryptostats
+
+all: ${ALL}
+
+cryptotest: cryptotest.c
+ ${CC} -o cryptotest cryptotest.c
+
+cryptokeytest: cryptokeytest.c
+ ${CC} -o cryptokeytest cryptokeytest.c -lcrypto
+
+cryptostats: cryptostats.c
+ ${CC} -o cryptostats cryptostats.c
+
+clean:
+ rm -f ${ALL} core a.out
diff --git a/tools/tools/crypto/README b/tools/tools/crypto/README
new file mode 100644
index 0000000..16b6bdb
--- /dev/null
+++ b/tools/tools/crypto/README
@@ -0,0 +1,44 @@
+$FreeBSD$
+
+The cryptotest program repeatedly encrypts and decrypts a buffer
+with the built-in iv and key, using hardware crypto. At the end,
+it computes the data rate achieved. Operations are carried out by
+making ioctl calls to /dev/crypto.
+
+For a test of how fast a crypto card is, use something like:
+
+ cryptotest -z 1024
+
+This will run a series of tests using the available crypto/cipher
+algorithms over a variety of buffer sizes. The 1024 says to do
+1024 iterations. Extra arguments can be used to specify one or
+more buffer sizes to use in doing tests.
+
+A sample run is:
+
+ 0.129 sec, 2048 des crypts, 8 bytes, 127120 byte/sec, 1.0 Mb/sec
+ 0.129 sec, 2048 des crypts, 16 bytes, 253915 byte/sec, 1.9 Mb/sec
+ 0.129 sec, 2048 des crypts, 32 bytes, 508942 byte/sec, 3.9 Mb/sec
+ 0.128 sec, 2048 des crypts, 64 bytes, 1020135 byte/sec, 7.8 Mb/sec
+ 0.134 sec, 2048 des crypts, 128 bytes, 1954869 byte/sec, 14.9 Mb/sec
+ 0.142 sec, 2048 des crypts, 256 bytes, 3698107 byte/sec, 28.2 Mb/sec
+ 0.190 sec, 2048 des crypts, 1024 bytes, 11037700 byte/sec, 84.2 Mb/sec
+ 0.264 sec, 2048 des crypts, 2048 bytes, 15891127 byte/sec, 121.2 Mb/sec
+ 0.403 sec, 2048 des crypts, 4096 bytes, 20828998 byte/sec, 158.9 Mb/sec
+ 0.687 sec, 2048 des crypts, 8192 bytes, 24426602 byte/sec, 186.4 Mb/sec
+ 0.129 sec, 2048 3des crypts, 8 bytes, 127321 byte/sec, 1.0 Mb/sec
+ 0.131 sec, 2048 3des crypts, 16 bytes, 249773 byte/sec, 1.9 Mb/sec
+ 0.128 sec, 2048 3des crypts, 32 bytes, 512304 byte/sec, 3.9 Mb/sec
+ 0.128 sec, 2048 3des crypts, 64 bytes, 1021685 byte/sec, 7.8 Mb/sec
+ 0.132 sec, 2048 3des crypts, 128 bytes, 1986511 byte/sec, 15.2 Mb/sec
+ 0.142 sec, 2048 3des crypts, 256 bytes, 3695005 byte/sec, 28.2 Mb/sec
+ 0.190 sec, 2048 3des crypts, 1024 bytes, 11024876 byte/sec, 84.1 Mb/sec
+ 0.264 sec, 2048 3des crypts, 2048 bytes, 15887997 byte/sec, 121.2 Mb/sec
+ 0.402 sec, 2048 3des crypts, 4096 bytes, 20850846 byte/sec, 159.1 Mb/sec
+ 0.689 sec, 2048 3des crypts, 8192 bytes, 24333532 byte/sec, 185.7 Mb/sec
+
+Expect ~400 Mb/s for a Broadcom 582x for 16K buffers on a reasonable
+CPU. Hifn 7811 parts top out at ~120 Mb/s. Performance depends
+heavily on memory and bus performance.
+
+This code originally came from openbsd; give them all the credit.
diff --git a/tools/tools/crypto/cryptokeytest.c b/tools/tools/crypto/cryptokeytest.c
new file mode 100644
index 0000000..a031faf
--- /dev/null
+++ b/tools/tools/crypto/cryptokeytest.c
@@ -0,0 +1,224 @@
+/* $FreeBSD$ */
+/*
+ * The big num stuff is a bit broken at the moment and I've not yet fixed it.
+ * The symtom is that odd size big nums will fail. Test code below (it only
+ * uses modexp currently).
+ *
+ * --Jason L. Wright
+ */
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <machine/endian.h>
+#include <sys/time.h>
+#include <crypto/cryptodev.h>
+#include <openssl/bn.h>
+#include <fcntl.h>
+#include <err.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+static int crypto_fd = -1;
+
+/*
+ * Convert a little endian byte string in 'p' that
+ * is 'plen' bytes long to a BIGNUM. If 'dst' is NULL,
+ * a new BIGNUM is allocated. Returns NULL on failure.
+ *
+ * XXX there has got to be a more efficient way to do
+ * this, but I haven't figured out enough of the OpenSSL
+ * magic.
+ */
+BIGNUM *
+le_to_bignum(BIGNUM *dst, u_int8_t *p, int plen)
+{
+ u_int8_t *pd;
+ int i;
+
+ if (plen == 0)
+ return (NULL);
+
+ if ((pd = (u_int8_t *)malloc(plen)) == NULL)
+ return (NULL);
+
+ for (i = 0; i < plen; i++)
+ pd[i] = p[plen - i - 1];
+
+ dst = BN_bin2bn(pd, plen, dst);
+ free(pd);
+ return (dst);
+}
+
+/*
+ * Convert a BIGNUM to a little endian byte string.
+ * If 'rd' is NULL, allocate space for it, otherwise
+ * 'rd' is assumed to have room for BN_num_bytes(n)
+ * bytes. Returns NULL on failure.
+ */
+u_int8_t *
+bignum_to_le(BIGNUM *n, u_int8_t *rd)
+{
+ int i, j, k;
+ int blen = BN_num_bytes(n);
+
+ if (blen == 0)
+ return (NULL);
+ if (rd == NULL)
+ rd = (u_int8_t *)malloc(blen);
+ if (rd == NULL)
+ return (NULL);
+
+ for (i = 0, j = 0; i < n->top; i++) {
+ for (k = 0; k < BN_BITS2 / 8; k++) {
+ if ((j + k) >= blen)
+ goto out;
+ rd[j + k] = n->d[i] >> (k * 8);
+ }
+ j += BN_BITS2 / 8;
+ }
+out:
+ return (rd);
+}
+
+int
+UB_mod_exp(BIGNUM *res, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx)
+{
+ struct crypt_kop kop;
+ u_int8_t *ale, *ble, *cle;
+
+ if (crypto_fd == -1) {
+ int fd, fdc = open("/dev/crypto", O_RDONLY);
+
+ if (fdc == -1)
+ err(1, "/dev/crypto");
+ if (ioctl(fdc, CRIOGET, &fd) == -1)
+ err(1, "CRIOGET");
+ close(fdc);
+ crypto_fd = fd;
+ }
+
+ if ((ale = bignum_to_le(a, NULL)) == NULL)
+ err(1, "bignum_to_le, a");
+ if ((ble = bignum_to_le(b, NULL)) == NULL)
+ err(1, "bignum_to_le, b");
+ if ((cle = bignum_to_le(c, NULL)) == NULL)
+ err(1, "bignum_to_le, c");
+
+ bzero(&kop, sizeof(kop));
+ kop.crk_op = CRK_MOD_EXP;
+ kop.crk_iparams = 3;
+ kop.crk_oparams = 1;
+ kop.crk_param[0].crp_p = ale;
+ kop.crk_param[0].crp_nbits = BN_num_bytes(a) * 8;
+ kop.crk_param[1].crp_p = ble;
+ kop.crk_param[1].crp_nbits = BN_num_bytes(b) * 8;
+ kop.crk_param[2].crp_p = cle;
+ kop.crk_param[2].crp_nbits = BN_num_bytes(c) * 8;
+ kop.crk_param[3].crp_p = cle;
+ kop.crk_param[3].crp_nbits = BN_num_bytes(c) * 8;
+
+ if (ioctl(crypto_fd, CIOCKEY, &kop) == -1)
+ err(1, "CIOCKEY");
+
+ bzero(ale, BN_num_bytes(a));
+ free(ale);
+ bzero(ble, BN_num_bytes(b));
+ free(ble);
+
+ if (kop.crk_status != 0) {
+ printf("error %d\n", kop.crk_status);
+ bzero(cle, BN_num_bytes(c));
+ free(cle);
+ return (-1);
+ } else {
+ res = le_to_bignum(res, cle, BN_num_bytes(c));
+ bzero(cle, BN_num_bytes(c));
+ free(cle);
+ if (res == NULL)
+ err(1, "le_to_bignum");
+ return (0);
+ }
+ return (0);
+}
+
+void
+show_result(a, b, c, sw, hw)
+BIGNUM *a, *b, *c, *sw, *hw;
+{
+ printf("\n");
+
+ printf("A = ");
+ BN_print_fp(stdout, a);
+ printf("\n");
+
+ printf("B = ");
+ BN_print_fp(stdout, b);
+ printf("\n");
+
+ printf("C = ");
+ BN_print_fp(stdout, c);
+ printf("\n");
+
+ printf("sw= ");
+ BN_print_fp(stdout, sw);
+ printf("\n");
+
+ printf("hw= ");
+ BN_print_fp(stdout, hw);
+ printf("\n");
+
+ printf("\n");
+}
+
+void
+testit(void)
+{
+ BIGNUM *a, *b, *c, *r1, *r2;
+ BN_CTX *ctx;
+
+ ctx = BN_CTX_new();
+
+ a = BN_new();
+ b = BN_new();
+ c = BN_new();
+ r1 = BN_new();
+ r2 = BN_new();
+
+ BN_pseudo_rand(a, 1023, 0, 0);
+ BN_pseudo_rand(b, 1023, 0, 0);
+ BN_pseudo_rand(c, 1024, 0, 0);
+
+ if (BN_cmp(a, c) > 0) {
+ BIGNUM *rem = BN_new();
+
+ BN_mod(rem, a, c, ctx);
+ UB_mod_exp(r2, rem, b, c, ctx);
+ BN_free(rem);
+ } else {
+ UB_mod_exp(r2, a, b, c, ctx);
+ }
+ BN_mod_exp(r1, a, b, c, ctx);
+
+ if (BN_cmp(r1, r2) != 0) {
+ show_result(a, b, c, r1, r2);
+ }
+
+ BN_free(r2);
+ BN_free(r1);
+ BN_free(c);
+ BN_free(b);
+ BN_free(a);
+ BN_CTX_free(ctx);
+}
+
+int
+main()
+{
+ int i;
+
+ for (i = 0; i < 1000; i++) {
+ fprintf(stderr, "test %d\n", i);
+ testit();
+ }
+ return (0);
+}
diff --git a/tools/tools/crypto/cryptostats.c b/tools/tools/crypto/cryptostats.c
new file mode 100644
index 0000000..3e0c5c1
--- /dev/null
+++ b/tools/tools/crypto/cryptostats.c
@@ -0,0 +1,77 @@
+/* $FreeBSD$ */
+
+/*
+ * Little program to dump the crypto statistics block and, optionally,
+ * zero all the stats or just the timing stuff.
+ */
+#include <stdio.h>
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/time.h>
+#include <crypto/cryptodev.h>
+
+static void
+printt(const char* tag, struct cryptotstat *ts)
+{
+ uint64_t avg, min, max;
+
+ if (ts->count == 0)
+ return;
+ avg = (1000000000LL*ts->acc.tv_sec + ts->acc.tv_nsec) / ts->count;
+ min = 1000000000LL*ts->min.tv_sec + ts->min.tv_nsec;
+ max = 1000000000LL*ts->max.tv_sec + ts->max.tv_nsec;
+ printf("%16.16s: avg %6llu ns : min %6llu ns : max %7llu ns [%u samps]\n",
+ tag, avg, min, max, ts->count);
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct cryptostats stats;
+ size_t slen;
+
+ slen = sizeof (stats);
+ if (sysctlbyname("kern.crypto_stats", &stats, &slen, NULL, NULL) < 0)
+ err(1, "kern.cryptostats");
+
+ if (argc > 1 && strcmp(argv[1], "-z") == 0) {
+ bzero(&stats.cs_invoke, sizeof (stats.cs_invoke));
+ bzero(&stats.cs_done, sizeof (stats.cs_done));
+ bzero(&stats.cs_cb, sizeof (stats.cs_cb));
+ bzero(&stats.cs_finis, sizeof (stats.cs_finis));
+ stats.cs_invoke.min.tv_sec = 10000;
+ stats.cs_done.min.tv_sec = 10000;
+ stats.cs_cb.min.tv_sec = 10000;
+ stats.cs_finis.min.tv_sec = 10000;
+ if (sysctlbyname("kern.crypto_stats", NULL, NULL, &stats, sizeof (stats)) < 0)
+ err(1, "kern.cryptostats");
+ exit(0);
+ }
+ if (argc > 1 && strcmp(argv[1], "-Z") == 0) {
+ bzero(&stats, sizeof (stats));
+ stats.cs_invoke.min.tv_sec = 10000;
+ stats.cs_done.min.tv_sec = 10000;
+ stats.cs_cb.min.tv_sec = 10000;
+ stats.cs_finis.min.tv_sec = 10000;
+ if (sysctlbyname("kern.crypto_stats", NULL, NULL, &stats, sizeof (stats)) < 0)
+ err(1, "kern.cryptostats");
+ exit(0);
+ }
+
+
+ printf("%u symmetric crypto ops (%u errors, %u times driver blocked)\n"
+ , stats.cs_ops, stats.cs_errs, stats.cs_blocks);
+ printf("%u key ops (%u errors, %u times driver blocked)\n"
+ , stats.cs_kops, stats.cs_kerrs, stats.cs_kblocks);
+ printf("%u crypto dispatch thread activations\n", stats.cs_intrs);
+ printf("%u crypto return thread activations\n", stats.cs_rets);
+ if (stats.cs_invoke.count) {
+ printf("\n");
+ printt("dispatch->invoke", &stats.cs_invoke);
+ printt("invoke->done", &stats.cs_done);
+ printt("done->cb", &stats.cs_cb);
+ printt("cb->finis", &stats.cs_finis);
+ }
+ return 0;
+}
diff --git a/tools/tools/crypto/cryptotest.c b/tools/tools/crypto/cryptotest.c
new file mode 100644
index 0000000..7f1f951
--- /dev/null
+++ b/tools/tools/crypto/cryptotest.c
@@ -0,0 +1,424 @@
+/* $FreeBSD$ */
+
+/*
+ * This program repeatedly encrypts and decrypts a buffer with the built-in
+ * iv and key, using hardware crypto. At the end, it computes the data rate
+ * achieved. invoke with the number of times to encrypt and the buffer size.
+ *
+ * For a test of how fast a crypto card is, use something like:
+ * cryptotest -z 1024
+ * This will run a series of tests using the available crypto/cipher
+ * algorithms over a variety of buffer sizes. The 1024 says to do 1024
+ * iterations. Extra arguments can be used to specify one or more buffer
+ * sizes to use in doing tests.
+ *
+ * To fork multiple processes all doing the same work, specify -t X on the
+ * command line to get X "threads" running simultaneously. No effort is made
+ * synchronize the threads or otherwise maximize load.
+ *
+ * If the kernel crypto code is built with CRYPTO_TIMING and you run as root,
+ * then you can specify the -p option to get a "profile" of the time spent
+ * processing crypto operations. At present this data is only meaningful for
+ * symmetric operations. To get meaningful numbers you must run on an idle
+ * machine.
+ *
+ * Expect ~400 Mb/s for a Broadcom 582x for 8K buffers on a reasonable CPU
+ * (64-bit PCI helps). Hifn 7811 parts top out at ~110 Mb/s.
+ *
+ * This code originally came from openbsd; give them all the credit.
+ */
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <sys/mman.h>
+
+#include <sys/sysctl.h>
+#include <sys/time.h>
+#include <crypto/cryptodev.h>
+
+#define CHUNK 64 /* how much to display */
+#define N(a) (sizeof (a) / sizeof (a[0]))
+#define streq(a,b) (strcasecmp(a,b) == 0)
+
+void hexdump(char *, int);
+
+int cryptodev_fd;
+int fd;
+struct session_op session;
+struct crypt_op cryptop;
+char iv[8] = "00000000";
+int verbose = 0;
+int opflags = 0;
+
+struct alg {
+ const char* name;
+ int blocksize;
+ int minkeylen;
+ int maxkeylen;
+ int code;
+} algorithms[] = {
+#ifdef CRYPTO_NULL_CBC
+ { "null", 8, 1, 256, CRYPTO_NULL_CBC },
+#endif
+ { "des", 8, 8, 8, CRYPTO_DES_CBC },
+ { "3des", 8, 24, 24, CRYPTO_3DES_CBC },
+ { "blf", 8, 5, 56, CRYPTO_BLF_CBC },
+ { "cast", 8, 5, 16, CRYPTO_CAST_CBC },
+ { "skj", 8, 10, 10, CRYPTO_SKIPJACK_CBC },
+ { "aes", 16, 8, 32, CRYPTO_RIJNDAEL128_CBC },
+#ifdef notdef
+ { "arc4", 8, 1, 32, CRYPTO_ARC4 },
+#endif
+};
+
+static void
+usage(const char* cmd)
+{
+ printf("usage: %s [-z] [-s] [-v] [-a algorithm] [count] [size ...]\n",
+ cmd);
+ printf("where algorithm is one of:\n");
+ printf(" des 3des (default) blowfish cast skipjack\n");
+ printf(" rijndael arc4\n");
+ printf("count is the number of encrypt/decrypt ops to do\n");
+ printf("size is the number of bytes of text to encrypt+decrypt\n");
+ exit(-1);
+}
+
+static struct alg*
+getalgbycode(int cipher)
+{
+ int i;
+
+ for (i = 0; i < N(algorithms); i++)
+ if (cipher == algorithms[i].code)
+ return &algorithms[i];
+ return NULL;
+}
+
+static struct alg*
+getalgbyname(const char* name)
+{
+ int i;
+
+ for (i = 0; i < N(algorithms); i++)
+ if (streq(name, algorithms[i].name))
+ return &algorithms[i];
+ return NULL;
+}
+
+static void
+runtest(struct alg *alg, int count, int size, int cmd, struct timeval *tv)
+{
+ int i;
+ struct timeval start, stop, dt;
+ char *cleartext, *ciphertext;
+
+ if (ioctl(cryptodev_fd,CRIOGET,&fd) == -1)
+ err(1, "CRIOGET failed");
+
+ session.mac = 0;
+ session.keylen = (alg->minkeylen + alg->maxkeylen)/2;
+ session.key = (char *) malloc(session.keylen);
+ if (session.key == NULL)
+ err(1, "malloc (key)");
+ for (i = 0; i < session.keylen; i++)
+ session.key[i] = '0' + (i%10);
+ session.cipher = alg->code;
+ if (ioctl(fd, cmd, &session) == -1) {
+ if (cmd == CIOCGSESSION) {
+ close(fd);
+ /* hardware doesn't support algorithm; skip it */
+ return;
+ }
+ printf("cipher %s keylen %u\n", alg->name, session.keylen);
+ err(1, "CIOCGSESSION failed");
+ }
+
+ if ((cleartext = (char *)malloc(size)) == NULL)
+ err(1, "malloc (cleartext)");
+ if ((ciphertext = (char *)malloc(size)) == NULL)
+ err(1, "malloc (ciphertext)");
+ for (i = 0; i < size; i++)
+ cleartext[i] = 'a' + i%26;
+
+ if (verbose) {
+ printf("session = 0x%x\n", session.ses);
+ printf("count = %d, size = %d\n", count, size);
+ cryptop.ses = session.ses;
+ printf("iv:");
+ hexdump(iv, sizeof iv);
+ printf("cleartext:");
+ hexdump(cleartext, MIN(size, CHUNK));
+ }
+
+ gettimeofday(&start, NULL);
+ for (i = 0; i < count; i++) {
+ cryptop.op = COP_ENCRYPT;
+ cryptop.flags = opflags;
+ cryptop.len = size;
+ cryptop.src = cleartext;
+ cryptop.dst = ciphertext;
+ cryptop.mac = 0;
+ cryptop.iv = iv;
+
+ if (ioctl(fd, CIOCCRYPT, &cryptop) == -1)
+ err(1, "CIOCCRYPT failed");
+
+ memset(cleartext, 'x', MIN(size, CHUNK));
+ cryptop.op = COP_DECRYPT;
+ cryptop.flags = opflags;
+ cryptop.len = size;
+ cryptop.src = ciphertext;
+ cryptop.dst = cleartext;
+ cryptop.mac = 0;
+ cryptop.iv = iv;
+
+ if (ioctl(fd, CIOCCRYPT, &cryptop) == -1)
+ err(1, "CIOCCRYPT failed");
+ }
+ gettimeofday(&stop, NULL);
+
+ if (ioctl(fd, CIOCFSESSION, &session.ses) == -1)
+ perror("CIOCFSESSION");
+
+ if (verbose) {
+ printf("cleartext:");
+ hexdump(cleartext, MIN(size, CHUNK));
+ }
+ timersub(&stop, &start, tv);
+
+ free(ciphertext);
+ free(cleartext);
+
+ close(fd);
+}
+
+#ifdef __FreeBSD__
+static void
+resetstats()
+{
+ struct cryptostats stats;
+ size_t slen;
+
+ slen = sizeof (stats);
+ if (sysctlbyname("kern.crypto_stats", &stats, &slen, NULL, NULL) < 0) {
+ perror("kern.crypto_stats");
+ return;
+ }
+ bzero(&stats.cs_invoke, sizeof (stats.cs_invoke));
+ bzero(&stats.cs_done, sizeof (stats.cs_done));
+ bzero(&stats.cs_cb, sizeof (stats.cs_cb));
+ bzero(&stats.cs_finis, sizeof (stats.cs_finis));
+ stats.cs_invoke.min.tv_sec = 10000;
+ stats.cs_done.min.tv_sec = 10000;
+ stats.cs_cb.min.tv_sec = 10000;
+ stats.cs_finis.min.tv_sec = 10000;
+ if (sysctlbyname("kern.crypto_stats", NULL, NULL, &stats, sizeof (stats)) < 0)
+ perror("kern.cryptostats");
+}
+
+static void
+printt(const char* tag, struct cryptotstat *ts)
+{
+ uint64_t avg, min, max;
+
+ if (ts->count == 0)
+ return;
+ avg = (1000000000LL*ts->acc.tv_sec + ts->acc.tv_nsec) / ts->count;
+ min = 1000000000LL*ts->min.tv_sec + ts->min.tv_nsec;
+ max = 1000000000LL*ts->max.tv_sec + ts->max.tv_nsec;
+ printf("%16.16s: avg %6llu ns : min %6llu ns : max %7llu ns [%u samps]\n",
+ tag, avg, min, max, ts->count);
+}
+#endif
+
+static void
+runtests(struct alg *alg, int count, int size, int cmd, int threads, int profile)
+{
+ int i, status;
+ double t;
+ void *region;
+ struct timeval *tvp;
+ struct timeval total;
+ int otiming;
+
+ if (size % alg->blocksize) {
+ if (verbose)
+ printf("skipping blocksize %u 'cuz not a multiple of "
+ "%s blocksize %u\n",
+ size, alg->name, alg->blocksize);
+ return;
+ }
+
+ region = mmap(NULL, threads * sizeof (struct timeval),
+ PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
+ if (region == MAP_FAILED) {
+ perror("mmap");
+ return;
+ }
+ tvp = (struct timeval *) region;
+#ifdef __FreeBSD__
+ if (profile) {
+ size_t tlen = sizeof (otiming);
+ int timing = 1;
+
+ resetstats();
+ if (sysctlbyname("debug.crypto_timing", &otiming, &tlen,
+ &timing, sizeof (timing)) < 0)
+ perror("debug.crypto_timing");
+ }
+#endif
+
+ if (threads > 1) {
+ for (i = 0; i < threads; i++)
+ if (fork() == 0) {
+ runtest(alg, count, size, cmd, &tvp[i]);
+ exit(0);
+ }
+ while (waitpid(WAIT_MYPGRP, &status, 0) != -1)
+ ;
+ } else
+ runtest(alg, count, size, cmd, tvp);
+
+ t = 0;
+ for (i = 0; i < threads; i++)
+ t += (((double)tvp[i].tv_sec * 1000000 + tvp[i].tv_usec) / 1000000);
+ if (t) {
+ printf("%6.3lf sec, %7d %6s crypts, %7d bytes, %8.0lf byte/sec, %7.1lf Mb/sec\n",
+ t/threads, 2*count*threads, alg->name, size, (double)2*count*size*threads / t,
+ (double)2*count*size*threads / t * 8 / 1024 / 1024);
+ }
+#ifdef __FreeBSD__
+ if (profile) {
+ struct cryptostats stats;
+ size_t slen = sizeof (stats);
+
+ if (sysctlbyname("debug.crypto_timing", NULL, NULL,
+ &otiming, sizeof (otiming)) < 0)
+ perror("debug.crypto_timing");
+ if (sysctlbyname("kern.crypto_stats", &stats, &slen, NULL, NULL) < 0)
+ perror("kern.cryptostats");
+ if (stats.cs_invoke.count) {
+ printt("dispatch->invoke", &stats.cs_invoke);
+ printt("invoke->done", &stats.cs_done);
+ printt("done->cb", &stats.cs_cb);
+ printt("cb->finis", &stats.cs_finis);
+ }
+ }
+#endif
+ fflush(stdout);
+}
+
+int
+main(int argc, char **argv)
+{
+ struct alg *alg = NULL;
+ int count = 1;
+ int sizes[128], nsizes = 0;
+ int cmd = CIOCGSESSION;
+ int testall = 0;
+ int maxthreads = 1;
+ int profile = 0;
+ int i, ch;
+
+ while ((ch = getopt(argc, argv, "pzsva:bt:")) != -1) {
+ switch (ch) {
+#ifdef CIOCGSSESSION
+ case 's':
+ cmd = CIOCGSSESSION;
+ break;
+#endif
+ case 'v':
+ verbose++;
+ break;
+ case 'a':
+ alg = getalgbyname(optarg);
+ if (alg == NULL) {
+ if (streq(optarg, "rijndael"))
+ alg = getalgbyname("aes");
+ else
+ usage(argv[0]);
+ }
+ break;
+ case 't':
+ maxthreads = atoi(optarg);
+ break;
+ case 'z':
+ testall = 1;
+ break;
+ case 'p':
+ profile = 1;
+ break;
+ case 'b':
+ opflags |= COP_F_BATCH;
+ break;
+ default:
+ usage(argv[0]);
+ }
+ }
+ argc -= optind, argv += optind;
+ if (argc > 0)
+ count = atoi(argv[0]);
+ while (argc > 1) {
+ int s = atoi(argv[1]);
+ if (nsizes < N(sizes)) {
+ sizes[nsizes++] = s;
+ } else {
+ printf("Too many sizes, ignoring %u\n", s);
+ }
+ argc--, argv++;
+ }
+ if (nsizes == 0) {
+ sizes[nsizes++] = 8;
+ if (testall) {
+ while (sizes[nsizes-1] < 8*1024) {
+ sizes[nsizes] = sizes[nsizes-1]<<1;
+ nsizes++;
+ }
+ }
+ }
+
+ if ((cryptodev_fd = open("/dev/crypto",O_RDWR,0)) < 0)
+ err(1, "/dev/crypto");
+
+ if (testall) {
+ for (i = 0; i < N(algorithms); i++) {
+ int j;
+ alg = &algorithms[i];
+ for (j = 0; j < nsizes; j++)
+ runtests(alg, count, sizes[j], cmd, maxthreads, profile);
+ }
+ } else {
+ if (alg == NULL)
+ alg = getalgbycode(CRYPTO_3DES_CBC);
+ for (i = 0; i < nsizes; i++)
+ runtests(alg, count, sizes[i], cmd, maxthreads, profile);
+ }
+
+ return (0);
+}
+
+void hexdump(char *p, int n)
+{
+ int i;
+ for (i = 0; i < n; i++) {
+ if (i%16 == 0) {
+ if (i != 0) {
+ int j;
+ char *l = p-16;
+ printf(" |");
+ for (j = 0; j < 16; j++,l++)
+ printf("%c", (((*l)&0xff)>0x1f && ((*l)&0xff)<0x7f) ? (*l)&0xff : '.');
+ printf("|");
+ }
+ printf("\n%04x: ", i);
+ }
+ printf(" %02x", (int)(*p++)&0xff);
+ }
+ printf("\n");
+}
diff --git a/tools/tools/editing/freebsd.el b/tools/tools/editing/freebsd.el
new file mode 100644
index 0000000..63976b0
--- /dev/null
+++ b/tools/tools/editing/freebsd.el
@@ -0,0 +1,40 @@
+;;; This function switches C-mode so that it indents almost everything
+;;; as specified in FreeBSD's style(9). Tested with emacs-19.34 and
+;;; xemacs-20.4.
+;;;
+;;; Use "M-x bsd" in a C mode buffer to activate it.
+;;;
+;;; The only problem I found is top-level indenting:
+;;;
+;;; We want function definitions with the function name at the beginning
+;;; of a second line after the return type specification in the first:
+;;; > int
+;;; > foo(int bla)
+;;; But emacs c-mode can't treat this differently from other multiple-line
+;;; toplevel constructs:
+;;; > const char *const bar =
+;;; > "sometext";
+;;; which means the second line must be indented by hand.
+;;;
+;;; To make this the default, use a line like this, but you can't easily
+;;; switch back to default GNU style, since the old state isn't saved.
+;;; (add-hook 'c-mode-common-hook 'bsd)
+;;; As long as you don't have this in the c-mode hook you can edit GNU
+;;; and BSD style C sources within one emacs session with no problem.
+;;;
+;;; Please report problems and additions directly to cracauer@freebsd.org
+
+(defun bsd () (interactive)
+ (c-set-style "bsd")
+ (setq indent-tabs-mode t)
+ ;; Use C-c C-s at points of source code so see which
+ ;; c-set-offset is in effect for this situation
+ (c-set-offset 'defun-block-intro 8)
+ (c-set-offset 'statement-block-intro 8)
+ (c-set-offset 'statement-case-intro 8)
+ (c-set-offset 'substatement-open 4)
+ (c-set-offset 'substatement 8)
+ (c-set-offset 'arglist-cont-nonempty 4)
+ (c-set-offset 'inclass 8)
+ (c-set-offset 'knr-argdecl-intro 8)
+ )
diff --git a/tools/tools/epfe/epfe.pl b/tools/tools/epfe/epfe.pl
new file mode 100644
index 0000000..0aea2c2
--- /dev/null
+++ b/tools/tools/epfe/epfe.pl
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+# Copyright (c) 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
+#
+# epfe - extract printing filter examples from printing.sgml
+#
+# usage:
+# $ cd /usr/share/examples/printing
+# $ epfe < ../../doc/handbook/printing.sgml
+#
+# $FreeBSD$
+
+$in = 0; @a = ();
+sub Print { s/\&amp\;/&/g; push(@a,$_); }
+sub out {
+ local($name, *lines) = @_;
+ open(F, "> $name") || die "open $_[0]: $!\n";
+ print F @lines;
+ close F;
+}
+
+while(<>) {
+ if (/^<code>/) {
+ $in = 1;
+ } elsif (m%</code>% && $in > 0) {
+ if ($in > 1) {
+ $name = 'unknown' if !$name;
+ while(1) { if ($d{$name}) { $name .= 'X'; } else { last } }
+ &out("$name", *a);
+ $d{$name} = $name;
+ }
+ $in = 0; $name = ''; @a = ();
+ } elsif ($in == 1 && /^\#\s*!/) {
+ $in++; &Print;
+ } elsif ($in > 1) {
+ $name = $1 if (!$name && /^\#\s+(\S+)\s+-\s+/);
+ $in++; &Print;
+ }
+}
diff --git a/tools/tools/find-sb/Makefile b/tools/tools/find-sb/Makefile
new file mode 100644
index 0000000..26d4706
--- /dev/null
+++ b/tools/tools/find-sb/Makefile
@@ -0,0 +1,5 @@
+# $FreeBSD$
+PROG= find-sb
+NOMAN=
+
+.include <bsd.prog.mk>
diff --git a/tools/tools/find-sb/README b/tools/tools/find-sb/README
new file mode 100644
index 0000000..fae701c
--- /dev/null
+++ b/tools/tools/find-sb/README
@@ -0,0 +1,18 @@
+$FreeBSD$
+
+find-sb is a program which scans the input file you specify (normally a
+raw disk slice) for filesystems. It's not very smart, nor particularly
+efficient. All it does is read the input file one device block at a time,
+and when it reads a block that has a UFS superblock magic number in the
+right place, it tells you about it. It helped me find an important partition
+after the disklabel got somehow trashed. It might not work for you. After
+looking carefully at the output of this program and creating a new disklabel,
+you should use `fsck -n' or a tool like ffsinfo(8) to verify that there is
+in fact something vaguely sane located at that spot on the disk. (There are
+checks that fsck can do to verify the validity of the superblock which
+this program does not even attempt.)
+
+If you use this program and as a result trash what was left of your disk,
+well, too bad. You should have kept a backup anyway. If you read the source
+code and don't immediately understand how it works and what it's doing, then
+DON'T USE IT.
diff --git a/tools/tools/find-sb/find-sb.c b/tools/tools/find-sb/find-sb.c
new file mode 100644
index 0000000..72a5546
--- /dev/null
+++ b/tools/tools/find-sb/find-sb.c
@@ -0,0 +1,95 @@
+/*
+ * This program, created 2002-10-03 by Garrett A. Wollman
+ * <wollman@FreeBSD.org>, is in the public domain. Use at your own risk.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
+
+#include <err.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static union {
+ char buf[SBLOCKSIZE];
+ struct fs sblock;
+} u;
+
+int
+main(int argc, char **argv)
+{
+ off_t end, last;
+ size_t len;
+ ssize_t justread;
+ int fd;
+
+ if (argv[1] == NULL)
+ errx(1, "usage");
+
+ fd = open(argv[1], O_RDONLY, 0);
+ if (fd < 0)
+ err(1, "%s", argv[1]);
+
+ end = len = 0;
+ last = -1;
+ while (1) {
+ justread = read(fd, &u.buf[len], DEV_BSIZE);
+ if (justread != DEV_BSIZE) {
+ if (justread == 0) {
+ printf("reached end-of-file at %jd\n",
+ (intmax_t)end);
+ exit (0);
+ }
+ if (justread < 0)
+ err(1, "read");
+ errx(1, "short read %jd (wanted %d) at %jd",
+ (intmax_t)justread, DEV_BSIZE, (intmax_t)end);
+ }
+ len += DEV_BSIZE;
+ end += DEV_BSIZE;
+ if (len >= sizeof(struct fs)) {
+ intmax_t offset = end - len;
+
+ if (u.sblock.fs_magic == FS_UFS1_MAGIC) {
+ intmax_t fsbegin = offset - SBLOCK_UFS1;
+ printf("Found UFS1 superblock at offset %jd, "
+ "block %jd\n", offset,
+ offset / DEV_BSIZE);
+ printf("Filesystem might begin at offset %jd, "
+ "block %jd\n", fsbegin,
+ fsbegin / DEV_BSIZE);
+ if (last >= 0) {
+ printf("%jd blocks from last guess\n",
+ fsbegin / DEV_BSIZE - last);
+ }
+ last = fsbegin / DEV_BSIZE;
+ } else if (u.sblock.fs_magic == FS_UFS2_MAGIC) {
+ intmax_t fsbegin = offset - SBLOCK_UFS1;
+ printf("Found UFS2 superblock at offset %jd, "
+ "block %jd\n", offset,
+ offset / DEV_BSIZE);
+ printf("Filesystem might begin at offset %jd, "
+ "block %jd\n", fsbegin,
+ fsbegin / DEV_BSIZE);
+ if (last >= 0) {
+ printf("%jd blocks from last guess\n",
+ fsbegin / DEV_BSIZE - last);
+ }
+ last = fsbegin / DEV_BSIZE;
+ }
+ }
+ if (len >= SBLOCKSIZE) {
+ memmove(u.buf, &u.buf[DEV_BSIZE],
+ SBLOCKSIZE - DEV_BSIZE);
+ len -= DEV_BSIZE;
+ }
+ }
+}
diff --git a/tools/tools/html-mv/html-mv b/tools/tools/html-mv/html-mv
new file mode 100644
index 0000000..29ea1f2
--- /dev/null
+++ b/tools/tools/html-mv/html-mv
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+# Copyright (c) 1997 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
+# All rights reserved.
+#
+# rename sgml/html generated file names to human readable file names
+#
+# $ cd FAQ
+# $ make FORMATS=html
+# $ html-mv FAQ
+# $ ls
+# FAQ_ACKNOWLEDGMENTS.html
+# FAQ_Any_restrictions_on_how_I_divide_the_disk_up_.html
+# FAQ_Are_there_any_Database_systems_for_FreeBSD_.html
+# FAQ_Are_there_any_commercial_high-performance_X_servers_.html
+# FAQ_Books_on_FreeBSD.html
+# FAQ_Can_FreeBSD_handle_multiport_serial_cards_sharing_irqs_.html
+# [...]
+#
+# $FreeBSD$
+
+case $# in 0)
+ echo "usage `basename $0` file"
+ exit 1
+esac
+
+file=$1; export file
+
+if [ -f "$file.html" ]; then :
+else
+ echo "$file.html does not exist"
+ exit 1
+fi
+
+# search for title name
+egrep -i '^<title' $file[1-9]*.html |
+ perl -npe 's/<TITLE>[\*\s]*//; s%\s*</TITLE>.*%%;
+ s/[^a-zA-Z0-9\_\-\.:\n]/_/g' > .list
+
+# create sed commands
+awk -F: '{print "s/" $1 "/'$file'_" $2 ".html/g;"}' .list > .sed
+
+# create mv(1) shell script
+perl -ne 'chop;($a,$b)=split(/:/);
+ print qq[rename ("$a", "$ENV{'file'}_$b.html") || ] .
+ qq[die "rename $a $ENV{'file'}_$b.html:\$\!";\n]' .list > .mv
+
+# replace links
+if [ -f "$file.ln" ]; then
+ perl -i -p .sed $file.ln
+fi
+
+# replace links
+perl -i -p .sed $file*.html
+
+# rename file names
+perl .mv
+
+rm -f .mv .sed .list
diff --git a/tools/tools/ifinfo/Makefile b/tools/tools/ifinfo/Makefile
new file mode 100644
index 0000000..2fe0e83
--- /dev/null
+++ b/tools/tools/ifinfo/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= ifinfo
+SRCS= ifinfo.c rfc1650.c
+NOMAN=
+
+.include <bsd.prog.mk>
diff --git a/tools/tools/ifinfo/ifinfo.c b/tools/tools/ifinfo/ifinfo.c
new file mode 100644
index 0000000..54ca164
--- /dev/null
+++ b/tools/tools/ifinfo/ifinfo.c
@@ -0,0 +1,282 @@
+/*
+ * Copyright 1996 Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that both the above copyright notice and this
+ * permission notice appear in all copies, that both the above
+ * copyright notice and this permission notice appear in all
+ * supporting documentation, and that the name of M.I.T. not be used
+ * in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. M.I.T. makes
+ * no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
+ * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#include <sys/types.h>
+#include <sys/socket.h> /* for PF_LINK */
+#include <sys/sysctl.h>
+#include <sys/time.h>
+
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+#include <net/if.h>
+#include <net/if_types.h>
+#include <net/if_mib.h>
+
+#include "ifinfo.h"
+
+static void printit(const struct ifmibdata *);
+static const char *iftype(int);
+static const char *ifphys(int, int);
+static int isit(int, char **, const char *);
+static printfcn findlink(int);
+
+static void
+usage(const char *argv0)
+{
+ fprintf(stderr, "%s: usage:\n\t%s [-l]\n", argv0, argv0);
+ exit(EX_USAGE);
+}
+
+int
+main(int argc, char **argv)
+{
+ int i, maxifno, retval;
+ struct ifmibdata ifmd;
+ int name[6];
+ size_t len;
+ int c;
+ int dolink = 0;
+ void *linkmib;
+ size_t linkmiblen;
+ printfcn pf;
+
+ while ((c = getopt(argc, argv, "l")) != -1) {
+ switch(c) {
+ case 'l':
+ dolink = 1;
+ break;
+ default:
+ usage(argv[0]);
+ }
+ }
+
+ retval = 1;
+
+ name[0] = CTL_NET;
+ name[1] = PF_LINK;
+ name[2] = NETLINK_GENERIC;
+ name[3] = IFMIB_SYSTEM;
+ name[4] = IFMIB_IFCOUNT;
+
+ len = sizeof maxifno;
+ if (sysctl(name, 5, &maxifno, &len, 0, 0) < 0)
+ err(EX_OSERR, "sysctl(net.link.generic.system.ifcount)");
+
+ for (i = 1; i <= maxifno; i++) {
+ len = sizeof ifmd;
+ name[3] = IFMIB_IFDATA;
+ name[4] = i;
+ name[5] = IFDATA_GENERAL;
+ if (sysctl(name, 6, &ifmd, &len, 0, 0) < 0) {
+ if (errno == ENOENT)
+ continue;
+
+ err(EX_OSERR, "sysctl(net.link.ifdata.%d.general)",
+ i);
+ }
+
+ if (!isit(argc - optind, argv + optind, ifmd.ifmd_name))
+ continue;
+ printit(&ifmd);
+ if (dolink && (pf = findlink(ifmd.ifmd_data.ifi_type))) {
+ name[5] = IFDATA_LINKSPECIFIC;
+ if (sysctl(name, 6, 0, &linkmiblen, 0, 0) < 0)
+ err(EX_OSERR,
+ "sysctl(net.link.ifdata.%d.linkspec) size",
+ i);
+ linkmib = malloc(linkmiblen);
+ if (!linkmib)
+ err(EX_OSERR, "malloc(%lu)",
+ (u_long)linkmiblen);
+ if (sysctl(name, 6, linkmib, &linkmiblen, 0, 0) < 0)
+ err(EX_OSERR,
+ "sysctl(net.link.ifdata.%d.linkspec)",
+ i);
+ pf(linkmib, linkmiblen);
+ free(linkmib);
+ }
+ retval = 0;
+ }
+
+ return retval;
+}
+
+static void
+printit(const struct ifmibdata *ifmd)
+{
+ printf("Interface %.*s:\n", IFNAMSIZ, ifmd->ifmd_name);
+ printf("\tflags: %x\n", ifmd->ifmd_flags);
+ printf("\tpromiscuous listeners: %d\n", ifmd->ifmd_pcount);
+ printf("\tsend queue length: %d\n", ifmd->ifmd_snd_len);
+ printf("\tsend queue max length: %d\n", ifmd->ifmd_snd_maxlen);
+ printf("\tsend queue drops: %d\n", ifmd->ifmd_snd_drops);
+ printf("\ttype: %s\n", iftype(ifmd->ifmd_data.ifi_type));
+ printf("\tphysical: %s\n", ifphys(ifmd->ifmd_data.ifi_type,
+ ifmd->ifmd_data.ifi_physical));
+ printf("\taddress length: %d\n", ifmd->ifmd_data.ifi_addrlen);
+ printf("\theader length: %d\n", ifmd->ifmd_data.ifi_hdrlen);
+ printf("\treceive quota: %d\n", ifmd->ifmd_data.ifi_recvquota);
+ printf("\ttransmit quota: %d\n", ifmd->ifmd_data.ifi_xmitquota);
+ printf("\tmtu: %lu\n", ifmd->ifmd_data.ifi_mtu);
+ printf("\tmetric: %lu\n", ifmd->ifmd_data.ifi_metric);
+ printf("\tline rate: %lu bit/s\n", ifmd->ifmd_data.ifi_baudrate);
+ printf("\tpackets received: %lu\n", ifmd->ifmd_data.ifi_ipackets);
+ printf("\tinput errors: %lu\n", ifmd->ifmd_data.ifi_ierrors);
+ printf("\tpackets transmitted: %lu\n", ifmd->ifmd_data.ifi_opackets);
+ printf("\toutput errors: %lu\n", ifmd->ifmd_data.ifi_oerrors);
+ printf("\tcollisions: %lu\n", ifmd->ifmd_data.ifi_collisions);
+ printf("\tbytes received: %lu\n", ifmd->ifmd_data.ifi_ibytes);
+ printf("\tbytes transmitted: %lu\n", ifmd->ifmd_data.ifi_obytes);
+ printf("\tmulticasts received: %lu\n", ifmd->ifmd_data.ifi_imcasts);
+ printf("\tmulticasts transmitted: %lu\n", ifmd->ifmd_data.ifi_omcasts);
+ printf("\tinput queue drops: %lu\n", ifmd->ifmd_data.ifi_iqdrops);
+ printf("\tpackets for unknown protocol: %lu\n",
+ ifmd->ifmd_data.ifi_noproto);
+#ifdef notdef
+ printf("\treceive timing: %lu usec\n", ifmd->ifmd_data.ifi_recvtiming);
+ printf("\ttransmit timing: %lu usec\n",
+ ifmd->ifmd_data.ifi_xmittiming);
+#endif
+}
+
+static const char *const if_types[] = {
+ "reserved",
+ "other",
+ "BBN 1822",
+ "HDH 1822",
+ "X.25 DDN",
+ "X.25",
+ "Ethernet",
+ "ISO 8802-3 CSMA/CD",
+ "ISO 8802-4 Token Bus",
+ "ISO 8802-5 Token Ring",
+ "ISO 8802-6 DQDB MAN",
+ "StarLAN",
+ "Proteon proNET-10",
+ "Proteon proNET-80",
+ "HyperChannel",
+ "FDDI",
+ "LAP-B",
+ "SDLC",
+ "T-1",
+ "CEPT",
+ "Basic rate ISDN",
+ "Primary rate ISDN",
+ "Proprietary P2P",
+ "PPP",
+ "Loopback",
+ "ISO CLNP over IP",
+ "Experimental Ethernet",
+ "XNS over IP",
+ "SLIP",
+ "Ultra Technologies",
+ "DS-3",
+ "SMDS",
+ "Frame Relay",
+ "RS-232 serial",
+ "Parallel printer port",
+ "ARCNET",
+ "ARCNET+",
+ "ATM",
+ "MIOX25",
+ "SONET/SDH",
+ "X25PLE",
+ "ISO 8802-2 LLC",
+ "LocalTalk",
+ "SMDSDXI",
+ "Frame Relay DCE",
+ "V.35",
+ "HSSI",
+ "HIPPI",
+ "Generic Modem",
+ "ATM AAL5",
+ "SONETPATH",
+ "SONETVT",
+ "SMDS InterCarrier Interface",
+ "Proprietary virtual interface",
+ "Proprietary multiplexing",
+ "Generic tunnel interface",
+ "IPv6-to-IPv4 TCP relay capturing interface",
+ "6to4 tunnel interface"
+};
+#define NIFTYPES ((sizeof if_types)/(sizeof if_types[0]))
+
+static const char *
+iftype(int type)
+{
+ static char buf[256];
+
+ if (type <= 0 || type >= NIFTYPES) {
+ sprintf(buf, "unknown type %d", type);
+ return buf;
+ }
+
+ return if_types[type];
+}
+
+static const char *
+ifphys(int type, int phys)
+{
+ static char buf[256];
+
+ sprintf(buf, "unknown physical %d", phys);
+ return buf;
+}
+
+static int
+isit(int argc, char **argv, const char *name)
+{
+ if (argc == 0)
+ return 1;
+ for (argc = 0; argv[argc]; argc++) {
+ if (strncmp(argv[argc], name, IFNAMSIZ) == 0)
+ return 1;
+ }
+ return 0;
+}
+
+static printfcn
+findlink(int type)
+{
+ switch(type) {
+ case IFT_ETHER:
+ case IFT_ISO88023:
+ case IFT_STARLAN:
+ return print_1650;
+ }
+
+ return 0;
+}
diff --git a/tools/tools/ifinfo/ifinfo.h b/tools/tools/ifinfo/ifinfo.h
new file mode 100644
index 0000000..c05a8b8
--- /dev/null
+++ b/tools/tools/ifinfo/ifinfo.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 1996 Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that both the above copyright notice and this
+ * permission notice appear in all copies, that both the above
+ * copyright notice and this permission notice appear in all
+ * supporting documentation, and that the name of M.I.T. not be used
+ * in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. M.I.T. makes
+ * no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
+ * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef ifinfo_h
+#define ifinfo_h 1
+
+typedef void (*printfcn)(const void *, size_t);
+
+extern void print_1650(const void *, size_t);
+
+#endif /* ifinfo_h */
diff --git a/tools/tools/ifinfo/rfc1650.c b/tools/tools/ifinfo/rfc1650.c
new file mode 100644
index 0000000..5347871
--- /dev/null
+++ b/tools/tools/ifinfo/rfc1650.c
@@ -0,0 +1,124 @@
+#include <sys/types.h>
+#include <sys/socket.h> /* for PF_LINK */
+#include <sys/sysctl.h>
+#include <sys/time.h>
+
+#include <err.h>
+#include <stdio.h>
+#include <string.h>
+#include <sysexits.h>
+
+#include <net/if.h>
+#include <net/if_types.h>
+#include <net/if_mib.h>
+
+#include "ifinfo.h"
+
+#define print(msg, var) \
+ if (var) printf("\t" msg ": %lu\n", (u_long)var)
+
+static void identify_chipset(u_int32_t chipset);
+
+void
+print_1650(const void *xmd, size_t len)
+{
+ const struct ifmib_iso_8802_3 *md = xmd;
+
+ if (len != sizeof *md)
+ warnx("cannot interpret %lu bytes of MIB data", (u_long)len);
+
+ identify_chipset(md->dot3StatsEtherChipSet);
+ print("Alignment errors", md->dot3StatsAlignmentErrors);
+ print("FCS errors", md->dot3StatsFCSErrors);
+ print("Single-collision frames", md->dot3StatsSingleCollisionFrames);
+ print("Multiple-collision frames", md->dot3StatsMultipleCollisionFrames);
+ print("SQE (Heartbeat) test errors", md->dot3StatsSQETestErrors);
+ print("Deferred transmissions", md->dot3StatsDeferredTransmissions);
+ print("Late collisions", md->dot3StatsLateCollisions);
+ print("Excessive collisions", md->dot3StatsExcessiveCollisions);
+ print("Internal transmit errors", md->dot3StatsInternalMacTransmitErrors);
+ print("Carrier sense errors", md->dot3StatsCarrierSenseErrors);
+ print("Frame-too-long errors", md->dot3StatsFrameTooLongs);
+ print("Internal receive errors", md->dot3StatsInternalMacReceiveErrors);
+ print("Missed frames", md->dot3StatsMissedFrames);
+#define cprint(num) print("Packets with " #num " collisions", \
+ md->dot3StatsCollFrequencies[num - 1])
+ if (md->dot3Compliance >= DOT3COMPLIANCE_COLLS) {
+ cprint(1); cprint(2); cprint(3); cprint(4);
+ cprint(5); cprint(6); cprint(7); cprint(8);
+ cprint(9); cprint(10); cprint(11); cprint(12);
+ cprint(13); cprint(14); cprint(15); cprint(16);
+ }
+ switch(md->dot3Compliance) {
+ case DOT3COMPLIANCE_STATS:
+ printf("\tCompliance: statistics only\n");
+ break;
+ case DOT3COMPLIANCE_COLLS:
+ printf("\tCompliance: statistics and collisions\n");
+ break;
+ }
+}
+
+static const char *const amd[] = {
+ 0, "Am7990", "Am79900", "Am79C940"
+};
+
+static const char *const intel[] = {
+ 0, "82586", "82596", "82557"
+};
+
+static const char *const national[] = {
+ 0, "8390", "Sonic"
+};
+
+static const char *const fujitsu[] = {
+ 0, "86950"
+};
+
+static const char *const digital[] = {
+ 0, "DC21040", "DC21140", "DC21041", "DC21140A", "DC21142"
+};
+
+static const char *const westerndigital[] = {
+ 0, "83C690", "83C790"
+};
+
+#define vendor(name, sets) { name, sets, (sizeof sets)/(sizeof sets[0]) }
+static struct {
+ const char *name;
+ const char *const *chips;
+ size_t len;
+} chipset_names[] = {
+ { 0 },
+ vendor("AMD", amd),
+ vendor("Intel", intel),
+ { 0 },
+ vendor("National Semiconductor", national),
+ vendor("Fujitsu", fujitsu),
+ vendor("Digital", digital),
+ vendor("Western Digital", westerndigital)
+};
+
+static void
+identify_chipset(u_int32_t chipset)
+{
+ enum dot3Vendors vendor = DOT3CHIPSET_VENDOR(chipset);
+ u_int part = DOT3CHIPSET_PART(chipset);
+
+ printf("\tChipset: ");
+ if (vendor < 1
+ || vendor >= (sizeof chipset_names)/(sizeof chipset_names[0])
+ || !chipset_names[vendor].name) {
+ printf("unknown\n");
+ return;
+ }
+
+ printf("%s ", chipset_names[vendor].name);
+ if (part < 1 || part >= chipset_names[vendor].len) {
+ printf("unknown\n");
+ return;
+ }
+
+ printf("%s\n", chipset_names[vendor].chips[part]);
+}
+
diff --git a/tools/tools/kdrv/KernelDriver b/tools/tools/kdrv/KernelDriver
new file mode 100755
index 0000000..60f89d8
--- /dev/null
+++ b/tools/tools/kdrv/KernelDriver
@@ -0,0 +1,1081 @@
+#!/bin/sh
+# Tcl magic -*- tcl -*- \
+exec tclsh $0 $*
+################################################################################
+#
+# KernelDriver - FreeBSD driver source installer
+#
+################################################################################
+#
+# Copyright (C) 1997
+# Michael Smith. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the author nor the names of any co-contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY Michael Smith AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL Michael Smith OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+################################################################################
+#
+# KernelDriver provides a means for installing source-form drivers into FreeBSD
+# kernel source trees in an automated fashion. It can also remove drivers it
+# has installed.
+#
+# Driver information is read from a control file, with the following syntax :
+#
+# description {<text>} Driver description; used in comments inserted into
+# files.
+# driver <name> The name of the driver. (Note that this can't end in .drvinfo :)
+# filei386 <path> <name> The file <name> in the driver package is installed into
+# <path> in the kernel source tree. Files whose names
+# end in '.c' have an entry added to i386/conf/files.i386.
+# fileconf <path> <name> The file <name> in the driver package is installed into
+# <path> in the kernel source tree. Files whose names
+# end in '.c' have an entry added to conf/files.
+# optioni386 <name> <hdr> Adds an entry to i386/conf/options.i386, such that
+# the option <name> will be placed in the header <hdr>.
+# optionconf <name> <hdr> Adds an entry to conf/options, such that
+# the option <name> will be placed in the header <hdr>.
+# linttext Lines between this and a subsequent 'end' line are added
+# to the LINT file to provide configuration examples,
+# comments, etc.
+# end Ends a text region.
+#
+# Possible additions :
+#
+# patch <name> Applies the patch contained in <name>; patch is invoked
+# at the top level of the kernel source tree, and the
+# patch must apply cleanly (this is checked).
+#
+# option <name> <file> Adds an entry to i386/conf/options.i386
+#
+# Lines beginning with '#' or blanks are considered comments, except in
+# 'linttext' regions.
+#
+################################################################################
+#
+# $FreeBSD$
+#
+################################################################################
+
+################################################################################
+# findDrvFile
+#
+# Given (hint), use it to locate a driver information file.
+# (Possible extension; support drivers in gzipped tarballs...)
+#
+proc findDrvFile_try {hint} {
+
+ # points to something already
+ if {[file exists $hint]} {
+ # unwind symbolic links
+ while {[file type $hint] == "link"} {
+ set hint [file readlink $hint];
+ }
+ switch [file type $hint] {
+ file {
+ # run with it as it is
+ return $hint;
+ }
+ directory {
+ # look for a drvinfo file in the directory
+ set candidate [glob -nocomplain "$hint/*.drvinfo"];
+ switch [llength $candidate] {
+ 0 {
+ # nothing there
+ }
+ 1 {
+ return $candidate;
+ }
+ default {
+ error "multiple driver info files in directory : $hint";
+ }
+ }
+ }
+ default {
+ error "driver info file may be a typewriter : $hint";
+ }
+ }
+ }
+ # maybe we need an extension
+ if {[file exists $hint.drvinfo]} {
+ return $hint.drvinfo;
+ }
+ error "can't find a driver info file using '$hint'";
+}
+
+proc findDrvFile {hint} {
+
+ set result [findDrvFile_try $hint];
+ if {$result != ""} {
+ return $result;
+ }
+ set result [findDrvFile_try ${hint}.drvinfo];
+ if {$result != ""} {
+ return $result;
+ }
+ error "can't find driver information file using : $hint";
+}
+
+################################################################################
+# readDrvFile
+#
+# Reads the contents of (fname), which are expected to be in the format
+# described above, and fill in the global Drv array.
+#
+proc readDrvFile {fname} {
+
+ global Drv Options;
+
+ if {$Options(verbose)} {puts "+ read options from '$fname'";}
+ set fh [open $fname r];
+
+ # set defaults
+ set Drv(description) "";
+ set Drv(driver) "";
+ set Drv(filesi386) "";
+ set Drv(filesconf) "";
+ set Drv(optionsi386) "";
+ set Drv(optionsconf) "";
+ set Drv(patches) "";
+ set Drv(linttext) "";
+
+ while {[gets $fh line] >= 0} {
+
+ # blank lines/comments
+ if {([llength $line] == 0) ||
+ ([string index $line 0] == "\#")} {
+ continue ;
+ }
+
+ # get keyword, process
+ switch -- [lindex $line 0] {
+ description {
+ set Drv(description) [lindex $line 1];
+ }
+ driver {
+ set Drv(driver) [lindex $line 1];
+ }
+ filei386 {
+ set path [lindex $line 1];
+ set plast [expr [string length $path] -1];
+ if {[string index $path $plast] != "/"} {
+ append path "/";
+ }
+ set name [lindex $line 2];
+ set Drv(filei386:$name) $path;
+ lappend Drv(filesi386) $name;
+ }
+ fileconf {
+ set path [lindex $line 1];
+ set plast [expr [string length $path] -1];
+ if {[string index $path $plast] != "/"} {
+ append path "/";
+ }
+ set name [lindex $line 2];
+ set Drv(fileconf:$name) $path;
+ lappend Drv(filesconf) $name;
+ }
+ optioni386 {
+ set opt [lindex $line 1];
+ set hdr [lindex $line 2];
+ lappend Drv(optionsi386) $opt;
+ set Drv(optioni386:$opt) $hdr;
+ }
+ optionconf {
+ set opt [lindex $line 1];
+ set hdr [lindex $line 2];
+ lappend Drv(optionsconf) $opt;
+ set Drv(optionconf:$opt) $hdr;
+ }
+ patch {
+ lappend Drv(patches) [lindex $line 1];
+ }
+ linttext {
+ while {[gets $fh line] >= 0} {
+ if {$line == "end"} {
+ break ;
+ }
+ lappend Drv(linttext) $line;
+ }
+ }
+ }
+ }
+ close $fh;
+ if {$Options(verbose)} {
+ printDrv;
+ }
+}
+
+################################################################################
+# validateDrvPackage
+#
+# With the global Drv filled in, check that the files required are all in
+# (dir), and that the kernel config at (kpath) can be written.
+#
+proc validateDrvPackage {dir kpath} {
+
+ global Drv Options;
+
+ if {$Options(verbose)} {puts "+ checking driver package...";}
+ set missing "";
+ set unwritable "";
+
+ # check files, patches
+ foreach f $Drv(filesi386) {
+ if {![file readable $dir$f]} {
+ lappend missing $f;
+ }
+ }
+ foreach f $Drv(filesconf) {
+ if {![file readable $dir$f]} {
+ lappend missing $f;
+ }
+ }
+ foreach f $Drv(patches) {
+ if {![file readable $dir$f]} {
+ lappend missing $f;
+ }
+ }
+ if {$missing != ""} {
+ error "missing files : $missing";
+ }
+
+ # check writability
+ if {$Options(verbose)} {puts "+ checking kernel source writability...";}
+ foreach f $Drv(filesi386) {
+ set p $Drv(filei386:$f);
+ if {![file isdirectory $kpath$p]} {
+ lappend missing $p;
+ } else {
+ if {![file writable $kpath$p]} {
+ if {[lsearch -exact $unwritable $p] == -1} {
+ lappend unwritable $p;
+ }
+ }
+ }
+ }
+ foreach f $Drv(filesconf) {
+ set p $Drv(fileconf:$f);
+ if {![file isdirectory $kpath$p]} {
+ lappend missing $p;
+ } else {
+ if {![file writable $kpath$p]} {
+ if {[lsearch -exact $unwritable $p] == -1} {
+ lappend unwritable $p;
+ }
+ }
+ }
+ }
+ foreach f [list \
+ "conf/files" \
+ "i386/conf/files.i386" \
+ "i386/conf/options.i386" \
+ "i386/conf/LINT"] {
+ if {![file writable $kpath$f]} {
+ lappend unwritable $f;
+ }
+ }
+ if {$missing != ""} {
+ error "missing directories : $missing";
+ }
+ if {$unwritable != ""} {
+ error "can't write to : $unwritable";
+ }
+}
+
+################################################################################
+# installDrvFiles
+#
+# Install the files listed in the global Drv into (kpath) from (dir)
+#
+proc installDrvFiles {dir kpath} {
+
+ global Drv Options;
+
+ # clear 'installed' record
+ set Drv(installedi386) "";
+ set Drv(installedconf) "";
+ set failed "";
+
+ if {$Options(verbose)} {puts "+ installing driver files...";}
+ foreach f $Drv(filesi386) {
+ if {$Options(verbose)} {puts "$f -> $kpath$Drv(filei386:$f)";}
+ if {$Options(real)} {
+ if {[catch {exec cp $dir$f $kpath$Drv(filei386:$f)} msg]} {
+ lappend failed $f;
+ } else {
+ lappend Drv(installedi386) $f;
+ }
+ }
+ }
+ foreach f $Drv(filesconf) {
+ if {$Options(verbose)} {puts "$f -> $kpath$Drv(fileconf:$f)";}
+ if {$Options(real)} {
+ if {[catch {exec cp $dir$f $kpath$Drv(fileconf:$f)} msg]} {
+ lappend failed $f;
+ } else {
+ lappend Drv(installedconf) $f;
+ }
+ }
+ }
+ if {$failed != ""} {
+ error "failed to install files : $failed";
+ }
+}
+
+################################################################################
+# backoutDrvChanges
+#
+# Remove files from a failed installation in (kpath)
+#
+proc backoutDrvChanges {kpath} {
+
+ global Drv Options;
+
+ if {$Options(verbose)} {puts "+ backing out installed files...";}
+ # delete installed files
+ foreach f $Drv(installedi386) {
+ exec rm -f $kpath$Drv(filei386:$f)$f;
+ }
+ foreach f $Drv(installedconf) {
+ exec rm -f $kpath$Drv(fileconf:$f)$f;
+ }
+}
+
+################################################################################
+# registerDrvFiles
+#
+# Adds an entry to i386/conf/files.i386 and conf/files for the .c files in the driver.
+# (kpath) points to the kernel.
+#
+# A comment is added to the file preceding the new entries :
+#
+# ## driver: <drivername>
+# # <description>
+# # filei386: <path><file>
+# <file spec (.c files only)>
+# ## enddriver
+#
+# We only append to the end of the file.
+#
+# Add linttext to the LINT file.
+# Add options to i386/conf/options.i386 if any are specified
+#
+proc registerDrvFiles {kpath} {
+
+ global Drv Options;
+
+ if {$Options(verbose)} {puts "+ registering installed files...";}
+
+# Add stuff to LINT
+ if {$Drv(linttext) != ""} {
+
+ if {$Options(verbose)} {puts "+ updating LINT...";}
+ if {$Options(real)} {
+ set fname [format "%si386/conf/LINT" $kpath];
+ set fh [open $fname a];
+
+ # header
+ puts $fh "\#\# driver: $Drv(driver)";
+ puts $fh "\# $Drv(description)";
+ foreach l $Drv(linttext) {
+ puts $fh $l;
+ }
+ puts $fh "\#\# enddriver";
+ close $fh;
+ }
+ }
+
+# Do filesi386 stuff
+ if {$Options(real)} {
+ set fname [format "%si386/conf/files.i386" $kpath];
+ set fh [open $fname a];
+
+ # header
+ puts $fh "\#\# driver: $Drv(driver)";
+ puts $fh "\# $Drv(description)";
+ # file information
+ foreach f $Drv(filesi386) {
+ puts $fh "\# file: $Drv(filei386:$f)$f";
+ # is it a compilable object?
+ if {[string match "*.c" $f]} {
+ puts $fh "$Drv(filei386:$f)$f\t\toptional\t$Drv(driver)\tdevice-driver";
+ }
+ }
+ puts $fh "\#\# enddriver";
+ close $fh;
+ }
+ if {$Drv(optionsi386) != ""} {
+ if {$Options(verbose)} {puts "+ adding options...";}
+ if {$Options(real)} {
+ set fname [format "%si386/conf/options.i386" $kpath];
+ set fh [open $fname a];
+
+ # header
+ puts $fh "\#\# driver: $Drv(driver)";
+ puts $fh "\# $Drv(description)";
+ # options
+ foreach opt $Drv(optionsi386) {
+ puts $fh "$opt\t$Drv(optioni386:$opt)";
+ }
+ puts $fh "\#\# enddriver";
+ close $fh;
+ }
+ }
+
+# Do filesconf stuff
+ if {$Options(real)} {
+ set fname [format "%sconf/files" $kpath];
+ set fh [open $fname a];
+
+ # header
+ puts $fh "\#\# driver: $Drv(driver)";
+ puts $fh "\# $Drv(description)";
+ # file information
+ foreach f $Drv(filesconf) {
+ puts $fh "\# file: $Drv(fileconf:$f)$f";
+ # is it a compilable object?
+ if {[string match "*.c" $f]} {
+ puts $fh "$Drv(fileconf:$f)$f\t\toptional\t$Drv(driver)\tdevice-driver";
+ }
+ }
+ puts $fh "\#\# enddriver";
+ close $fh;
+ }
+ if {$Drv(optionsconf) != ""} {
+ if {$Options(verbose)} {puts "+ adding options...";}
+ if {$Options(real)} {
+ set fname [format "%sconf/options" $kpath];
+ set fh [open $fname a];
+
+ # header
+ puts $fh "\#\# driver: $Drv(driver)";
+ puts $fh "\# $Drv(description)";
+ # options
+ foreach opt $Drv(optionsconf) {
+ puts $fh "$opt\t$Drv(optionconf:$opt)";
+ }
+ puts $fh "\#\# enddriver";
+ close $fh;
+ }
+ }
+
+}
+
+################################################################################
+# listInstalledDrv
+#
+# List all drivers recorded as installed, in the kernel at (kpath)
+#
+# XXX : fix me so I understand conf/{options,files} stuff!
+proc listInstalledDrv {kpath} {
+
+ global Drv;
+
+ # pick up all the i386 options information first
+ set fname [format "%si386/conf/options.i386" $kpath];
+ if {![file readable $fname]} {
+ error "not a kernel directory";
+ }
+ set fh [open $fname r];
+
+ while {[gets $fh line] >= 0} {
+
+ # got a driver?
+ if {[scan $line "\#\# driver: %s" driver] == 1} {
+ # read driver details, ignore
+ gets $fh line;
+ # loop reading option details
+ while {[gets $fh line] >= 0} {
+ # end of driver info
+ if {$line == "\#\# enddriver"} {
+ break ;
+ }
+ # parse option/header tuple
+ if {[scan $line "%s %s" opt hdr] == 2} {
+ # remember that this driver uses this option
+ lappend drivers($driver:optionsi386) $opt;
+ # remember that this option goes in this header
+ set optionsi386($opt) $hdr;
+ }
+ }
+ }
+ }
+ close $fh;
+
+ # pick up all the conf options information first
+ set fname [format "%sconf/options" $kpath];
+ if {![file readable $fname]} {
+ error "not a kernel directory";
+ }
+ set fh [open $fname r];
+
+ while {[gets $fh line] >= 0} {
+
+ # got a driver?
+ if {[scan $line "\#\# driver: %s" driver] == 1} {
+ # read driver details, ignore
+ gets $fh line;
+ # loop reading option details
+ while {[gets $fh line] >= 0} {
+ # end of driver info
+ if {$line == "\#\# enddriver"} {
+ break ;
+ }
+ # parse option/header tuple
+ if {[scan $line "%s %s" opt hdr] == 2} {
+ # remember that this driver uses this option
+ lappend drivers($driver:optionsconf) $opt;
+ # remember that this option goes in this header
+ set optionsconf($opt) $hdr;
+ }
+ }
+ }
+ }
+ close $fh;
+
+ set fname [format "%si386/conf/files.i386" $kpath];
+ set fh [open $fname r];
+
+ while {[gets $fh line] >= 0} {
+
+ # got a driver?
+ if {[scan $line "\#\# driver: %s" driver] == 1} {
+ # clear global and reset
+ catch {unset Drv};
+ set Drv(driver) $driver;
+ # read driver details
+ gets $fh line;
+ set Drv(description) [string range $line 2 end];
+ set Drv(filesi386) "";
+ # options?
+ if {[info exists drivers($Drv(driver):optionsi386)]} {
+ set Drv(optionsi386) $drivers($Drv(driver):optionsi386);
+ # get pathnames
+ foreach opt $Drv(optionsi386) {
+ set Drv(optioni386:$opt) $optionsi386($opt);
+ }
+ }
+ # loop reading file details
+ while {[gets $fh line] >= 0} {
+ if {$line == "\#\# enddriver"} {
+ # print this driver and loop
+ printDrv;
+ break ;
+ }
+ if {[scan $line "\# filei386: %s" fpath] == 1} {
+ set f [file tail $fpath];
+ set Drv(filei386:$f) "[file dirname $fpath]/";
+ lappend Drv(filesi386) $f;
+ }
+ }
+ }
+ }
+ close $fh;
+
+ set fname [format "%sconf/files" $kpath];
+ set fh [open $fname r];
+
+ while {[gets $fh line] >= 0} {
+
+ # got a driver?
+ if {[scan $line "\#\# driver: %s" driver] == 1} {
+ # clear global and reset
+ catch {unset Drv};
+ set Drv(driver) $driver;
+ # read driver details
+ gets $fh line;
+ set Drv(description) [string range $line 2 end];
+ set Drv(filesconf) "";
+ # options?
+ if {[info exists drivers($Drv(driver):optionsconf)]} {
+ set Drv(optionsconf) $drivers($Drv(driver):optionsconf);
+ # get pathnames
+ foreach opt $Drv(optionsconf) {
+ set Drv(optionconf:$opt) $optionsconf($opt);
+ }
+ }
+ # loop reading file details
+ while {[gets $fh line] >= 0} {
+ if {$line == "\#\# enddriver"} {
+ # print this driver and loop
+ printDrv;
+ break ;
+ }
+ if {[scan $line "\# fileconf: %s" fpath] == 1} {
+ set f [file tail $fpath];
+ set Drv(fileconf:$f) "[file dirname $fpath]/";
+ lappend Drv(filesconf) $f;
+ }
+ }
+ }
+ }
+ close $fh;
+}
+
+################################################################################
+# printDrv
+#
+# Print the contents of the global Drv.
+#
+proc printDrv {} {
+
+ global Drv Options;
+
+ puts "$Drv(driver) : $Drv(description)";
+ if {$Options(verbose)} {
+ foreach f $Drv(filesi386) {
+ puts " $Drv(filei386:$f)$f"
+ }
+ foreach f $Drv(filesconf) {
+ puts " $Drv(fileconf:$f)$f"
+ }
+ if {[info exists Drv(optionsi386)]} {
+ foreach opt $Drv(optionsi386) {
+ puts " $opt in $Drv(optioni386:$opt)";
+ }
+ }
+ if {[info exists Drv(optionsconf)]} {
+ foreach opt $Drv(optionsconf) {
+ puts " $opt in $Drv(optionconf:$opt)";
+ }
+ }
+ }
+}
+
+################################################################################
+# findInstalledDrv
+#
+# Given a kernel tree at (kpath), get driver details about an installed
+# driver (drvname)
+#
+
+proc findInstalledDrvi386 {drvname kpath} {
+
+ global Drv;
+
+ set fname [format "%si386/conf/files.i386" $kpath];
+ set fh [open $fname r];
+
+ puts "checking i386/conf/files.i386";
+
+ while {[gets $fh line] >= 0} {
+ if {[scan $line "\#\# driver: %s" name] == 1} {
+ if {$name != $drvname} {
+ continue ; # not us
+ }
+ # read information
+ set Drv(driver) $drvname;
+ set line [gets $fh];
+ set Drv(description) [string range $line 2 end];
+ set Drv(filesi386) "";
+ # loop reading file details
+ while {[gets $fh line] >= 0} {
+ if {$line == "\#\# enddriver"} {
+ close $fh;
+ return 1; # all done
+ }
+ if {[scan $line "\# file: %s" fpath] == 1} {
+ set f [file tail $fpath];
+ set Drv(filei386:$f) "[file dirname $fpath]/";
+ lappend Drv(filesi386) $f;
+ }
+ }
+ close $fh;
+ error "unexpected EOF reading '$fname'";
+ }
+ }
+ close $fh
+
+ return 0;
+}
+
+proc findInstalledDrvconf {drvname kpath} {
+
+ global Drv;
+
+ set fname [format "%sconf/files" $kpath];
+ set fh [open $fname r];
+
+ puts "checking conf/files";
+
+ while {[gets $fh line] >= 0} {
+ if {[scan $line "\#\# driver: %s" name] == 1} {
+ if {$name != $drvname} {
+ continue ; # not us
+ }
+ # read information
+ set Drv(driver) $drvname;
+ set line [gets $fh];
+ set Drv(description) [string range $line 2 end];
+ set Drv(filesconf) "";
+ # loop reading file details
+ while {[gets $fh line] >= 0} {
+ if {$line == "\#\# enddriver"} {
+ close $fh;
+ return 1; # all done
+ }
+ if {[scan $line "\# file: %s" fpath] == 1} {
+ set f [file tail $fpath];
+ set Drv(fileconf:$f) "[file dirname $fpath]/";
+ lappend Drv(filesconf) $f;
+ }
+ }
+ close $fh;
+ error "unexpected EOF reading '$fname'";
+ }
+ }
+ close $fh
+
+ return 0;
+}
+
+proc findInstalledDrv {drvname kpath} {
+
+ global Drv Options;
+
+ if {$Options(verbose)} {puts "+ look for driver '$drvname' in '$kpath'";}
+
+# Whoops... won't work in a single if statement due to expression shortcircuiting
+ set a [findInstalledDrvi386 $drvname $kpath];
+ set b [findInstalledDrvconf $drvname $kpath];
+ if {$a || $b} {
+ return;
+ }
+
+ error "driver '$drvname' not recorded as installed";
+}
+
+################################################################################
+# validateDrvRemoval
+#
+# Verify that we can remove the driver described in the global Drv installed
+# at (kpath).
+#
+proc validateDrvRemoval {kpath} {
+
+ global Drv Options;
+
+ set missing "";
+ set unwritable "";
+
+ if {$Options(verbose)} {puts "+ checking for removabilty...";}
+
+ # admin files?
+ foreach f [list \
+ "i386/conf/files.i386" \
+ "i386/conf/options.i386" \
+ "i386/conf/LINT" \
+ "conf/files" \
+ "conf/options" ] {
+ if {![file exists $kpath$f]} {
+ lappend missing $kpath$f;
+ } else {
+ if {![file writable $kpath$f]} {
+ lappend unwritable $f;
+ }
+ }
+ }
+ # driver components?
+ foreach f $Drv(filesi386) {
+ set p $Drv(filei386:$f);
+ if {![file isdirectory $kpath$p]} {
+ lappend missing $p;
+ } else {
+ if {![file writable $kpath$p]} {
+ if {[lsearch -exact $unwritable $p] == -1} {
+ lappend unwritable $p;
+ }
+ }
+ }
+ }
+ foreach f $Drv(filesconf) {
+ set p $Drv(fileconf:$f);
+ if {![file isdirectory $kpath$p]} {
+ lappend missing $p;
+ } else {
+ if {![file writable $kpath$p]} {
+ if {[lsearch -exact $unwritable $p] == -1} {
+ lappend unwritable $p;
+ }
+ }
+ }
+ }
+ if {$missing != ""} {
+ error "files/directories missing : $missing";
+ }
+ if {$unwritable != ""} {
+ error "can't write to : $unwritable";
+ }
+}
+
+################################################################################
+# deleteDrvFiles
+#
+# Delete the files belonging to the driver devfined in the global Drv in
+# the kernel tree at (kpath)
+#
+proc deleteDrvFiles {kpath} {
+
+ global Drv Options;
+
+ if {$Options(verbose)} {puts "+ delete driver files...";}
+
+ # loop deleting files
+ foreach f $Drv(filesi386) {
+ if {$Options(verbose)} {puts "- $Drv(filei386:$f)$f";}
+ if {$Options(real)} {
+ exec rm $kpath$Drv(filei386:$f)$f;
+ }
+ }
+ foreach f $Drv(filesconf) {
+ if {$Options(verbose)} {puts "- $Drv(fileconf:$f)$f";}
+ if {$Options(real)} {
+ exec rm $kpath$Drv(fileconf:$f)$f;
+ }
+ }
+}
+
+################################################################################
+# unregisterDrvFiles
+#
+# Remove any mention of the current driver from the files.i386 and LINT
+# files in (ksrc)
+#
+proc unregisterDrvFiles {ksrc} {
+
+ global Drv Options;
+
+ if {$Options(verbose)} {puts "+ deregister driver files...";}
+
+ # don't really do it?
+ if {!$Options(real)} { return ; }
+
+ foreach f [list \
+ "i386/conf/files.i386" \
+ "i386/conf/options.i386" \
+ "i386/conf/LINT" \
+ "conf/files" \
+ "conf/options" ] {
+ set ifh [open $ksrc$f r];
+ set ofh [open $ksrc$f.new w];
+ set copying 1;
+
+ while {[gets $ifh line] >= 0} {
+
+ if {[scan $line "\#\# driver: %s" name] == 1} {
+ if {$name == $Drv(driver)} {
+ set copying 0; # don't copy this one
+ }
+ }
+ if {$copying} {
+ puts $ofh $line; # copy through
+ }
+ if {$line == "\#\# enddriver"} { # end of driver detail
+ set copying 1;
+ }
+ }
+ close $ifh;
+ close $ofh;
+ exec mv $ksrc$f.new $ksrc$f; # move new over old
+ }
+}
+
+################################################################################
+# usage
+#
+# Remind the user what goes where
+#
+proc usage {} {
+
+ global argv0;
+
+ set progname [file tail $argv0];
+
+ puts stderr "Usage is :";
+ puts stderr " $progname \[-v -n\] add <drvinfo> \[<kpath>\]";
+ puts stderr " $progname \[-v -n\] delete <drvname> \[<kpath>\]";
+ puts stderr " $progname \[-v\] list \[<kpath>\]";
+ puts stderr " <drvinfo> is a driver info file";
+ puts stderr " <drvname> is a driver name";
+ puts stderr " <kpath> is the path to the kernel source (default /sys/)";
+ puts stderr " -v be verbose";
+ puts stderr " -n don't actually do anything";
+ exit ;
+}
+
+################################################################################
+# getOptions
+#
+# Parse commandline options, return anything that doesn't look like an option
+#
+proc getOptions {} {
+
+ global argv Options;
+
+ set Options(real) 1;
+ set Options(verbose) 0;
+ set ret "";
+
+ for {set index 0} {$index < [llength $argv]} {incr index} {
+
+ switch -- [lindex $argv $index] {
+
+ -n {
+ set Options(real) 0; # 'do-nothing' mode
+ }
+ -v {
+ set Options(verbose) 1; # brag
+ }
+ default {
+ lappend ret [lindex $argv $index];
+ }
+ }
+ }
+ return $ret;
+}
+
+################################################################################
+# getKpath
+#
+# Given (hint), return the kernel path. If (hint) is empty, return /sys.
+# If the kernel path is not a directory, complain and dump the usage.
+#
+proc getKpath {hint} {
+
+ set kpath "";
+
+ # check the kernel path
+ if {$hint == ""} {
+ set kpath "/sys/";
+ } else {
+ set kpath $hint;
+ }
+ if {![file isdirectory $kpath]} {
+ puts "not a directory : $kpath";
+ usage ;
+ }
+ set plast [expr [string length $kpath] -1];
+ if {[string index $kpath $plast] != "/"} {
+ append kpath "/";
+ }
+ return $kpath;
+}
+
+################################################################################
+# main
+#
+# Start somewhere here.
+#
+proc main {} {
+
+ global Options;
+
+ # Work out what we're trying to do
+ set cmdline [getOptions];
+ set mode [lindex $cmdline 0];
+
+ # do stuff
+ switch -- $mode {
+ add {
+ set hint [lindex $cmdline 1];
+ set kpath [getKpath [lindex $cmdline 2]];
+
+ # check driver file argument
+ if {[catch {set drv [findDrvFile $hint]} msg]} {
+ puts stderr $msg;
+ usage ;
+ }
+ if {([file type $drv] != "file") ||
+ ![file readable $drv]} {
+ puts "can't read driver file : $drv";
+ usage ;
+ }
+ set drvdir "[file dirname $drv]/";
+
+ # read driver file
+ if {[catch {readDrvFile $drv} msg]} {
+ puts stderr $msg;
+ exit ;
+ }
+ # validate driver
+ if {[catch {validateDrvPackage $drvdir $kpath} msg]} {
+ puts stderr $msg;
+ exit ;
+ }
+ # install new files
+ if {[catch {installDrvFiles $drvdir $kpath} msg]} {
+ backoutDrvChanges $kpath; # oops, unwind
+ puts stderr $msg;
+ exit ;
+ }
+ # register files in config
+ if {[catch {registerDrvFiles $kpath} msg]} {
+ backoutDrvChanges $kpath; # oops, unwind
+ puts stderr $msg;
+ exit ;
+ }
+ }
+ delete {
+ set drv [lindex $cmdline 1];
+ set kpath [getKpath [lindex $cmdline 2]];
+
+ if {[string last ".drvinfo" $drv] != -1} {
+ set drv [string range $drv 0 [expr [string length $drv] - 9]];
+ puts "Driver name ends in .drvinfo, removing, is now $drv";
+ }
+
+ if {[catch {findInstalledDrv $drv $kpath} msg]} {
+ puts stderr $msg;
+ exit ;
+ }
+ if {[catch {validateDrvRemoval $kpath} msg]} {
+ puts stderr $msg;
+ exit ;
+ }
+ if {[catch {unregisterDrvFiles $kpath} msg]} {
+ puts stderr $msg;
+ exit ;
+ }
+ if {[catch {deleteDrvFiles $kpath} msg]} {
+ puts stderr $msg;
+ exit ;
+ }
+ }
+ list {
+ set kpath [getKpath [lindex $cmdline 1]];
+ if {[catch {listInstalledDrv $kpath} msg]} {
+ puts stderr "can't list drivers in '$kpath' : $msg";
+ }
+ }
+ default {
+ puts stderr "unknown command '$mode'";
+ usage ;
+ }
+ }
+}
+
+
+
+################################################################################
+main;
diff --git a/tools/tools/kdrv/sample.drvinfo b/tools/tools/kdrv/sample.drvinfo
new file mode 100644
index 0000000..4941b07
--- /dev/null
+++ b/tools/tools/kdrv/sample.drvinfo
@@ -0,0 +1,44 @@
+#
+# Sample driver information file for KernelDriver. See the top of
+# the KernelDriver script for a more exact definition of the syntax.
+#
+# $FreeBSD$
+
+# Device driver name
+#
+driver blorg
+
+# Description (must be in curly braces)
+#
+description {Snoofle roob wronkle bnar}
+
+# List of files to install for the driver.
+# The filei386 directive causes the *.c files to be added to i386/conf/file.i386
+# The fileconf directive causes the *.c files to be added to conf/file
+# Paths listed separately
+#
+filei386 i386/isa/ mdsio.c
+filei386 i386/include mdsio.h
+fileconf pci/ mdsio.c
+
+# List of options used by the driver, and the header into which
+# they should be written.
+# optioni386 causes them to be added to i386/conf/options.i386
+# optionconf causes them to be added to conf/options
+#
+optioni386 MDSIO_RXBUF opt_mdsio.h
+optioni386 MDSIO_TXBUF opt_mdsio.h
+optioni386 MDSIO_DEBUG opt_mdsio.h
+optionconf MDSIO_FOO opt_mdsio.h
+
+# Text to be added to LINT to provide configuration examples for the
+# user.
+#
+
+linttext
+#
+# This driver causes your system to emit occasional digestive noises.
+#
+device blorg0 at isa? port 0x123 irq 10 flags 0x10 drq 2
+device blorg1 at isa? port 0x234 irq 11 flags 0x10 drq 2
+end
diff --git a/tools/tools/kernelcruft/kernelcruft.sh b/tools/tools/kernelcruft/kernelcruft.sh
new file mode 100644
index 0000000..87288c5
--- /dev/null
+++ b/tools/tools/kernelcruft/kernelcruft.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# kernelcruft.sh
+#
+# Try to find *.c files in /sys which are orphaned
+#
+# $FreeBSD$
+
+cd /sys/conf
+cat files* | sed '
+/^[ ]*#/d
+s/[ ].*//
+/^$/d
+' | sort -u > /tmp/_0
+
+cd /sys
+find * -name '*.c' -print | sed '
+/\/compile\//d
+/^boot/d
+' | sort -u > /tmp/_1
+
+find * -name '*.[ch]' -print | xargs grep 'include.*c[>"]' > /tmp/_2
+
+find * -name 'Makefile*' -print | xargs cat | sed '
+/^ /d
+s/:.*//
+/^[ ]*$/d
+' > /tmp/_3
+
+comm -13 /tmp/_0 /tmp/_1 | while read f
+do
+ b=`basename $f`
+ if grep $b /tmp/_2 > /dev/null ; then
+ # echo "2 $f"
+ continue
+ fi
+ if grep $b /tmp/_3 > /dev/null ; then
+ # echo "3 $f"
+ continue
+ fi
+ echo $f
+done
+
diff --git a/tools/tools/kerninclude/kerninclude.sh b/tools/tools/kerninclude/kerninclude.sh
new file mode 100644
index 0000000..1efe4c2
--- /dev/null
+++ b/tools/tools/kerninclude/kerninclude.sh
@@ -0,0 +1,303 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# "THE BEER-WARE LICENSE" (Revision 42):
+# <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
+# can do whatever you want with this stuff. If we meet some day, and you think
+# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+# ----------------------------------------------------------------------------
+#
+# $FreeBSD$
+#
+# This script tries to find #include statements which are not needed in
+# the FreeBSD kernel tree.
+#
+
+set -e
+
+# Base of the kernel sources you want to work on
+cd /sys
+
+# Set to true to start from scratch, false to resume
+init=false
+
+# Which kernels you want to check
+kernels="LINT GENERIC GENERIC98"
+
+NO_MODULES=yes
+export NO_MODULES
+
+if $init ; then
+ (
+ echo "Cleaning modules"
+ cd modules
+ make clean > /dev/null 2>&1
+ make cleandir > /dev/null 2>&1
+ make cleandir > /dev/null 2>&1
+ make clean > /dev/null 2>&1
+ make clean > /dev/null 2>&1
+ )
+
+ (
+ echo "Cleaning compile"
+ cd compile
+ ls | grep -v CVS | xargs rm -rf
+ )
+fi
+
+(
+echo "Cleaning temp files"
+find . -name '*.h_' -print | xargs rm -f
+find . -name '::*' -print | xargs rm -f
+find . -name '*.o' -size 0 -print | xargs rm -f
+)
+
+echo "Configuring kernels"
+(
+ cd i386/conf
+ make LINT
+ if $init ; then
+ rm -rf ../../compile/LINT ../../compile/GENERIC
+ fi
+ config LINT
+ config GENERIC
+)
+(
+ cd pc98/conf
+ cp -f GENERIC GENERIC98
+ if $init ; then
+ rm -rf ../../compile/GENERIC98
+ fi
+ config GENERIC98
+)
+
+for i in $kernels
+do
+ (
+ echo "Compiling $i"
+ cd compile/$i
+ make > x.0 2>&1
+ tail -4 x.0
+ if [ ! -f kernel ] ; then
+ echo "Error: No $i kernel built"
+ exit 1
+ fi
+ )
+done
+
+(
+echo "Compiling modules"
+cd modules
+make > x.0 2>&1
+)
+
+# Generate the list of object files we want to check
+# you can put a convenient grep right before the sort
+# if you want just some specific subset of files checked
+(
+cd modules
+for i in *
+do
+ if [ -d $i -a $i != CVS ] ; then
+ ( cd $i ; ls *.o 2>/dev/null || true)
+ fi
+done
+cd ../compile
+for i in $kernels
+do
+ ( cd $i ; ls *.o 2>/dev/null )
+done
+) | sed '
+/aicasm/d
+/genassym/d
+/vers.o/d
+/setdef0.o/d
+/setdef1.o/d
+' | sort -u > _
+
+objlist=`cat _`
+
+
+for o in $objlist
+do
+ l=""
+ src=""
+ for k in $kernels
+ do
+ if [ ! -f compile/$k/$o ] ; then
+ continue;
+ fi
+ l="$l compile/$k"
+ if [ "x$src" = "x" ] ; then
+ cd compile/$k
+ mv $o ${o}_
+ make -n $o > _
+ mv ${o}_ $o
+ src=compile/$k/`awk '$1 == "cc" {print $NF}' _`
+ cd ../..
+ if expr "x$src" : 'x.*\.c$' > /dev/null ; then
+ true
+ else
+ echo NO SRC $o
+ src=""
+ fi
+ fi
+ done
+ for m in modules/*
+ do
+ if [ ! -d $m -o ! -f $m/$o ] ; then
+ continue;
+ fi
+ l="$l $m"
+ if [ "x$src" = "x" ] ; then
+ cd $m
+ mv $o ${o}_
+ make -n $o > _
+ mv ${o}_ $o
+ src=`awk '$1 == "cc" {print $NF}' _`
+ cd ../..
+ if expr "x$src" : 'x.*\.c$' > /dev/null ; then
+ if [ "`dirname $src`" = "." ] ; then
+ src="$m/$src"
+ fi
+ true
+ else
+ echo NO SRC $o
+ src=""
+ fi
+ fi
+ done
+ if [ "x$src" = "x" ] ; then
+ echo "NO SOURCE $o"
+ continue
+ fi
+ echo "OBJ $o"
+ echo " SRC $src"
+
+ grep -n '^[ ]*#[ ]*include' $src | sed '
+ s/^\([0-9]*\):[ ]*#[ ]*include[ ]*[<"]/\1 /
+ s/[">].*//
+ / opt_/d
+ ' | sort -rn | while read lin incl
+ do
+ S=""
+ echo " INCL $lin $incl"
+ cp $src ${src}_
+
+ # Check if we can compile without this #include line.
+
+ sed "${lin}s/.*//" ${src}_ > ${src}
+ for t in $l
+ do
+ cd $t
+ mv ${o} ${o}_
+ if make ${o} > _log 2>&1 ; then
+ if cmp -s ${o} ${o}_ ; then
+ echo " $t same object"
+ else
+ echo " $t changed object"
+ S=TAG
+ fi
+ else
+ echo " $t used"
+ S=TAG
+ fi
+ mv ${o}_ ${o}
+ cd ../..
+ if [ "x$S" != "x" ] ; then
+ break
+ fi
+ done
+ if [ "x$S" != "x" ] ; then
+ mv ${src}_ ${src}
+ continue
+ fi
+
+ # Check if this is because it is a nested #include
+ for t in $l
+ do
+ cd $t
+ rm -rf foo
+ mkdir -p foo/${incl}
+ rmdir foo/${incl}
+ touch foo/${incl}
+ mv ${o} ${o}_
+ if make INCLMAGIC=-Ifoo ${o} > _log2 2>&1 ; then
+ if cmp -s ${o} ${o}_ ; then
+ echo " $t still same object"
+ else
+ echo " $t changed object"
+ S=TAG
+ fi
+ else
+ echo " $t nested include"
+ S=TAG
+ fi
+ rm -rf foo
+ mv ${o}_ ${o}
+ cd ../..
+ if [ "x$S" != "x" ] ; then
+ break
+ fi
+ done
+ if [ "x$S" != "x" ] ; then
+ mv ${src}_ ${src}
+ continue
+ fi
+
+ # Check if this is because it is #ifdef'ed out
+
+ sed "${lin}s/.*/#error \"BARF\"/" ${src}_ > ${src}
+ for t in $l
+ do
+ cd $t
+ mv ${o} ${o}_
+ if make ${o} > /dev/null 2>&1 ; then
+ echo " $t line not read"
+ S=TAG
+ fi
+ mv ${o}_ ${o}
+ cd ../..
+ if [ "x$S" != "x" ] ; then
+ break
+ fi
+ done
+
+ mv ${src}_ ${src}
+ if [ "x$S" != "x" ] ; then
+ continue
+ fi
+
+ # Check if the warnings changed.
+
+ for t in $l
+ do
+ cd $t
+ mv ${o} ${o}_
+ if make ${o} > _ref 2>&1 ; then
+ if cmp -s _ref _log ; then
+ echo " $t same warnings"
+ else
+ echo " $t changed warnings"
+ S=TAG
+ fi
+ else
+ echo "ARGHH!!!"
+ exit 9
+ fi
+
+ mv ${o}_ ${o}
+ cd ../..
+ if [ "x$S" != "x" ] ; then
+ break
+ fi
+ done
+ if [ "x$S" != "x" ] ; then
+ continue
+ fi
+ cp $src ${src}_
+ sed "${lin}d" ${src}_ > ${src}
+ rm ${src}_
+ touch _again
+ echo "BINGO $src $lin $incl $obj $l"
+ done
+done
diff --git a/tools/tools/kernxref/kernxref.sh b/tools/tools/kernxref/kernxref.sh
new file mode 100644
index 0000000..439f385
--- /dev/null
+++ b/tools/tools/kernxref/kernxref.sh
@@ -0,0 +1,154 @@
+:
+#
+# ----------------------------------------------------------------------------
+# "THE BEER-WARE LICENSE" (Revision 42):
+# <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
+# can do whatever you want with this stuff. If we meet some day, and you think
+# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+# ----------------------------------------------------------------------------
+#
+# Sort options by "Matthew Emmerton" <matt@gsicomp.on.ca>
+#
+# $FreeBSD$
+#
+# This shell script will make a cross reference of the symbols of a kernel.
+#
+
+COMPILEDIR=/sys/`uname -m`/compile
+KERNELNAME=LINT
+SORTORDER=-k1
+
+args=`getopt h?k:s: $*`;
+if [ $? != 0 ]
+then
+ args="-h";
+fi
+set -- $args;
+for i
+do
+ case "$i"
+ in
+ -h|-\?)
+ echo "Usage: $0 [ -k <kernelname> ] [ -s [ 'symbol' | 'filename' ] ]";
+ exit 0;
+ ;;
+ -k)
+ KERNELNAME=$2
+ if [ -d ${COMPILEDIR}/${KERNELNAME} ];
+ then
+ shift; shift;
+ continue;
+ fi
+ echo "Kernel '$KERNELNAME' does not exist in ${COMPILEDIR}!";
+ exit 1;
+ ;;
+ -s)
+ if [ "x$2" = "xsymbol" ]
+ then
+ SORTORDER=-k1
+ shift; shift;
+ continue;
+ fi
+ if [ "x$2" = "xfilename" ]
+ then
+ SORTORDER=-k2
+ shift; shift;
+ continue;
+ fi
+ echo "Invalid selection for -s: $2";
+ exit 1;
+ ;;
+ --)
+ shift;
+ break;
+ ;;
+ esac
+done
+
+cd ${COMPILEDIR}/${KERNELNAME}
+
+MOD_OBJS=`find modules -name \*.ko`
+
+nm -gon `echo *.o $MOD_OBJS \
+ | tr ' ' '\012' \
+ | egrep -v '(aicasm|genassym)'` \
+ | tr : ' ' | awk '
+NF > 1 {
+ if (length($2) == 8) {
+ $2 = $3
+ $3 = $4
+ }
+ if ($2 == "t")
+ next
+ if ($2 == "F")
+ next
+ nm[$3]++
+ if ($2 == "U") {
+ ref[$3]=ref[$3]" "$1
+ } else if ($2 == "T" || $2 == "D" || $2 == "A" || $2 == "R") {
+ if (def[$3] != "")
+ def[$3]=def[$3]" "$1
+ else
+ def[$3]=$1
+ } else if ($2 == "?") {
+ if (def[$3] == "S")
+ i++
+ else if (def[$3] != "")
+ def[$3]=def[$3]",S"
+ else
+ def[$3]="S"
+ ref[$3]=ref[$3]" "$1
+ } else if ($2 == "C") {
+ if (def[$3] == $2)
+ i++
+ else if (def[$3] == "")
+ def[$3]=$1
+ else
+ ref[$3]=ref[$3]" "$1
+ } else {
+ print ">>>",$0
+ }
+ }
+END {
+ for (i in nm) {
+ printf "%s {%s} %s\n",i,def[i],ref[i]
+ }
+ }
+' | sort $SORTORDER | awk '
+ {
+ if ($2 == "{S}")
+ $2 = "<Linker set>"
+ if (length($3) == 0) {
+ printf "%-30s %3d %s\n\tUNREF\n",$1,0, $2
+ N1++
+ } else if ($2 == "{}") {
+ printf "%-30s %3d {UNDEF}\n",$1, NF-2
+ N2++
+ } else {
+ printf "%-30s %3d %s",$1,NF-2,$2
+ p = 80;
+ for (i = 3 ; i <= NF; i++) {
+ if (p+length ($i)+1 > 78) {
+ printf "\n\t%s", $i
+ p = 7;
+ } else {
+ printf " %s", $i
+ }
+ p += 1 + length ($i)
+ }
+ printf "\n"
+ N3++
+ if (NF-2 == 1)
+ N4++
+ if (NF-2 == 2)
+ N5++
+ }
+ }
+END {
+ printf "Total symbols: %5d\n",N1+N2+N3
+ printf "unref symbols: %5d\n",N1
+ printf "undef symbols: %5d\n",N2
+ printf "1 ref symbols: %5d\n",N4
+ printf "2 ref symbols: %5d\n",N5
+ }
+'
diff --git a/tools/tools/mid/mid-build b/tools/tools/mid/mid-build
new file mode 100755
index 0000000..0a2d448
--- /dev/null
+++ b/tools/tools/mid/mid-build
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# Copyright (c) March 1998 Wolfram Schneider <wosch@FreeBSD.org>
+#
+# create a Message-ID, In-Reply-To look(1) index database
+#
+# $FreeBSD$
+
+
+TMPDIR=/var/tmp; export TMPDIR
+home=/g/www/mid
+
+dbout=$home/index
+archive=$home/archive
+
+PATH=$home/bin:/bin:/usr/bin:/usr/local/bin; export PATH
+
+
+all ()
+{
+ ( cd $archive || exit 1
+ find text/* -type f | mid-master-index 4 mid-index $dbout/mid
+ )
+}
+
+current ()
+{
+ ( cd $archive || exit 1
+ find current/freebsd-* current/cvs-* -type f |
+ mid-master-index 1 mid-index $dbout/mid-current
+ )
+}
+
+if [ $# -le 0 ]; then
+ echo "usage mid-build {current|all}"
+ exit 1
+fi
+
+for db
+do
+ case $db in
+ current) current;;
+ all) all;;
+ *) echo "Huh? $db";;
+ esac
+done
diff --git a/tools/tools/mid/mid-index b/tools/tools/mid/mid-index
new file mode 100755
index 0000000..a5ec10b
--- /dev/null
+++ b/tools/tools/mid/mid-index
@@ -0,0 +1,83 @@
+#!/usr/local/bin/perl
+#
+# create message-id / in-reply-to database
+#
+# $FreeBSD$
+
+sub usage { die "usage: mid-index name < filelist"; }
+
+sub id {
+ local($name, @files) = @_;
+ local($bytes, $bytes2, $headlen, $file);
+ local($counter);
+ local($from,$from2);
+
+ $counter = 0;
+ open(MID, "| sort -u -o $name.mid") || die "open sort > $name.mid: $!\n";
+ open(IRT, "| sort -u -o $name.irt") || die "open sort > $name.irt: $!\n";
+
+ while(<>) {
+ local($/) = "\n\n";
+ chop;
+ $file = $_;
+
+ open(R, $file) || do {
+ warn "open $file:$!\n";
+ next;
+ };
+ $bytes = 0;
+
+ while(<R>) {
+ $headlen = length($_);
+ $from2 = substr($_, 0, 6);
+ $from = substr($from2, 0, 5);
+
+ # warn "xxx" . $from . "yyy\n";
+ if ($from eq "From " || $from2 eq "\nFrom ") {
+
+ if ($from eq "From ") {
+ $bytes2 = $bytes;
+ } else {
+ # One bytes more for "\nFrom "
+ $bytes2 = $bytes + 1;
+ }
+
+ $counter++;
+ s/\n[ \t]+/ /g;
+ if ($debug && $counter % $speedstep == 0) {
+ print STDERR sprintf("\r%7d", $counter);
+ }
+
+ foreach (split("\n")) {
+ if (/^Message-id:\s+\<([^$idsep]+)/oi) {
+ print MID "$1 $file $bytes2\n";
+ } elsif (/^Resent-Message-id:\s+\<([^$idsep]+)/oi) {
+ print MID "$1 $file $bytes2\n";
+ } elsif (/^References:\s+\<([^$idsep]+)/oi) {
+ print IRT "$1 $file $bytes2\n";
+ } elsif (/^In-Reply-to:\s+[^<]*\<([^$idsep]+)/oi) {
+ print IRT "$1 $file $bytes2\n";
+ }
+ }
+ }
+ $bytes += $headlen;
+ }
+ close R;
+ }
+ close MID || warn "close: MID\n";
+ close IRT || warn "close: IRT\n";
+ print STDERR sprintf("\r%7d", $counter)
+ if $debug && $counter % $speedstep != 0;
+ print STDERR "\n" if $debug;
+}
+
+$idsep = '>';
+$idsep = '>@\s';
+$debug = 0;
+$speedstep = 100;
+
+&usage if $#ARGV != 0;
+$name = $ARGV[0]; shift @ARGV;
+&id($name);
+
+
diff --git a/tools/tools/mid/mid-master b/tools/tools/mid/mid-master
new file mode 100755
index 0000000..5ee531a
--- /dev/null
+++ b/tools/tools/mid/mid-master
@@ -0,0 +1,33 @@
+#!/usr/local/bin/perl
+
+if ($#ARGV < 1) {
+ die "usage master counter command comandargs ... \n";
+}
+
+$count = $ARGV[0]; shift @ARGV;
+@command = @ARGV;
+$file = pop(@command);
+undef @ARGV;
+$debug = 0;
+
+for($i = 0; $i < $count; $i ++) {
+ @c = (@command, "$file.$i");
+ warn "Start process: $i @c\n" if $debug;
+ open("OUT$i", "| @c") || die "open @c\n";
+ select("OUT$i"); $| = 1;
+}
+select(STDOUT);
+
+$n = 0;
+while(<>) {
+ $o = 'OUT' . ($n % $count);
+ print $o $_;
+ warn "$o $_" if $debug;
+ $n++
+}
+
+for($i = 0; $i < $count; $i ++) {
+ warn "Close process $i\n" if $debug;
+ close("OUT$i") || warn "close OUT$i: $!\n";
+}
+
diff --git a/tools/tools/mid/mid-master-index b/tools/tools/mid/mid-master-index
new file mode 100755
index 0000000..8b32acd
--- /dev/null
+++ b/tools/tools/mid/mid-master-index
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+if [ $# -le 2 ]; then
+ echo "usage $0 parallel_processes command [comand_options]"
+ exit 1
+fi
+
+count=$1; shift
+command=$1; shift
+file=$1; shift
+filelistmid=`perl -e "for(0 .. $count -1) {print qq{$file.temp.\\$_.mid }}"`
+filelistirt=`perl -e "for(0 .. $count -1) {print qq{$file.temp.\\$_.irt }}"`
+
+if mid-master $count $command $file.temp; then
+ sort -u -m -o $file.temp.mid $filelistmid &&
+ rm -f $filelistmid && mv $file.temp.mid $file.mid || exit 1
+ sort -u -m -o $file.temp.irt $filelistirt &&
+ rm -f $filelistirt && mv $file.temp.irt $file.irt || exit 1
+else
+ exit 1
+fi
diff --git a/tools/tools/mtxstat/mtxstat.pl b/tools/tools/mtxstat/mtxstat.pl
new file mode 100644
index 0000000..59baaf4
--- /dev/null
+++ b/tools/tools/mtxstat/mtxstat.pl
@@ -0,0 +1,130 @@
+#!/usr/bin/perl -Tw
+#-
+# Copyright (c) 2002 Dag-Erling Coïdan Smørgrav
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer
+# in this position and unchanged.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+use strict;
+use Getopt::Std;
+
+sub usage() {
+
+ print(STDERR "usage: mtxstat [-gr] [-a|c|m|t] [-l limit]\n");
+ exit(1);
+}
+
+MAIN:{
+ my %opts; # Command-line options
+ my $key; # Sort key
+ my $limit; # Output limit
+ local *PIPE; # Pipe
+ my $header; # Header line
+ my @names; # Field names
+ my %data; # Mutex data
+ my @list; # List of entries
+
+ getopts("acgl:mrt", \%opts)
+ or usage();
+ if ($opts{'a'}) {
+ usage()
+ if ($opts{'c'} || $opts{'m'} || $opts{'t'});
+ $key = 'average';
+ } elsif ($opts{'c'}) {
+ usage()
+ if ($opts{'m'} || $opts{'t'});
+ $key = 'count';
+ } elsif ($opts{'m'}) {
+ usage()
+ if ($opts{'t'});
+ $key = 'max';
+ } elsif ($opts{'t'}) {
+ $key = 'total';
+ }
+ if ($opts{'l'}) {
+ if ($opts{'l'} !~ m/^\d+$/) {
+ usage();
+ }
+ $limit = $opts{'l'};
+ }
+ $ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin';
+ open(PIPE, "sysctl -n debug.mutex.prof.stats|")
+ or die("open(): $!\n");
+ $header = <PIPE>;
+ chomp($header);
+ @names = split(' ', $header);
+ if (defined($key) && !grep(/^$key$/, @names)) {
+ die("can't find sort key '$key' in header\n");
+ }
+ while (<PIPE>) {
+ chomp();
+ my @fields = split(' ', $_, @names);
+ next unless @fields;
+ my %entry;
+ foreach (@names) {
+ $entry{$_} = ($_ eq 'name') ? shift(@fields) : 0.0 + shift(@fields);
+ }
+ if ($opts{'g'}) {
+ $entry{'name'} =~ s/^(\S+)\s+\((.*)\)$/$2/;
+ }
+ my $name = $entry{'name'};
+ if ($data{$name}) {
+ if ($entry{'max'} > $data{$name}->{'max'}) {
+ $data{$name}->{'max'} = $entry{'max'};
+ }
+ $data{$name}->{'total'} += $entry{'total'};
+ $data{$name}->{'count'} += $entry{'count'};
+ $data{$name}->{'average'} =
+ $data{$name}->{'total'} / $data{$name}->{'count'};
+ } else {
+ $data{$name} = \%entry;
+ }
+ }
+ if (defined($key)) {
+ @list = sort({ $data{$a}->{$key} <=> $data{$b}->{$key} }
+ sort(keys(%data)));
+ } else {
+ @list = sort(keys(%data));
+ }
+ if ($opts{'r'}) {
+ @list = reverse(@list);
+ }
+ print("$header\n");
+ if ($limit) {
+ while (@list > $limit) {
+ pop(@list);
+ }
+ }
+ foreach (@list) {
+ printf("%12.0f %12.0f %12.0f %12.0f %s\n",
+ $data{$_}->{'max'},
+ $data{$_}->{'total'},
+ $data{$_}->{'count'},
+ $data{$_}->{'average'},
+ $data{$_}->{'name'});
+ }
+}
diff --git a/tools/tools/pciid/mk_pci_vendors.pl b/tools/tools/pciid/mk_pci_vendors.pl
new file mode 100644
index 0000000..1a812b3
--- /dev/null
+++ b/tools/tools/pciid/mk_pci_vendors.pl
@@ -0,0 +1,241 @@
+#!/usr/bin/perl -w
+#
+# Copyright (C) 2001 Sheldon Hearn. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+# usage: mk_pci_vendors [-lq] [-p pcidevs.txt] [-v vendors.txt]
+#
+# Generate src/share/misc/pci_vendors from the Hart and Boemler lists,
+# currently available at:
+#
+# Boemler: http://www.yourvote.com/pci/
+# Hart: http://members.hyperlink.com.au/~chart/pci.htm
+#
+# -l Where an entry is found in both input lists, use the entry with
+# the longest description. The default is for the Boemler file to
+# override the Hart file.
+# -q Do not print diagnostics.
+# -p Specify the pathname of the Hart file. (Default ./pcidevs.txt)
+# -v Specify the pathname of the Boemler file. (Default ./vendors.txt)
+#
+use strict;
+use Getopt::Std;
+
+my $PROGNAME = 'mk_pci_vendors';
+my $VENDORS_FILE = 'vendors.txt';
+my $PCIDEVS_FILE = 'pcidevs.txt';
+
+my $cur_vendor;
+my %opts;
+my %vendors;
+my ($descr, $existing, $id, $line, $rv, $winner, $optlused);
+
+my $IS_VENDOR = 1;
+my $IS_DEVICE = 2;
+my $V_DESCR = 0;
+my $V_DEVSL = 1;
+my $W_NOCONTEST = 0;
+my $W_VENDORS = 1;
+my $W_PCIDEVS = 2;
+
+sub clean_descr($);
+sub vendors_parse($\$\$);
+sub pcidevs_parse($\$\$);
+
+if (not getopts('lp:qv:', \%opts) or @ARGV > 0) {
+ print STDERR "usage: $PROGNAME [-lq] [-p pcidevs.txt] [-v vendors.txt]\n";
+ exit 1;
+}
+
+if (not defined($opts{p})) {
+ $opts{p} = $PCIDEVS_FILE;
+}
+if (not defined($opts{v})) {
+ $opts{v} = $VENDORS_FILE;
+}
+foreach (('l', 'q')) {
+ if (not exists($opts{$_})) {
+ $opts{$_} = 0;
+ } else {
+ $opts{$_} = 1;
+ }
+}
+
+open(VENDORS, "< $opts{v}") or
+ die "$PROGNAME: $opts{v}: $!\n";
+while ($line = <VENDORS>) {
+ chomp($line);
+ $rv = vendors_parse($line, $id, $descr);
+ if ($rv == $IS_VENDOR) {
+ if (exists($vendors{$id})) {
+ die "$PROGNAME: $id: duplicate vendor ID\n";
+ }
+ $vendors{$id} = [$descr, {}];
+ $cur_vendor = $id;
+ } elsif ($rv == $IS_DEVICE) {
+ ${$vendors{$cur_vendor}->[$V_DEVSL]}{$id} = $descr;
+ }
+}
+close(VENDORS);
+
+open(PCIDEVS, "< $opts{p}") or
+ die "$PROGNAME: $opts{p}: $!\n";
+while ($line = <PCIDEVS>) {
+ chomp($line);
+ $rv = pcidevs_parse($line, $id, $descr);
+ if ($rv == $IS_VENDOR) {
+ if (not exists($vendors{$id})) {
+ $vendors{$id} = [$descr, {}];
+ $winner = $W_NOCONTEST;
+ } elsif ($opts{l}) {
+ $existing = $vendors{$id}->[$V_DESCR];
+ if (length($existing) < length($descr)) {
+ $vendors{$id}->[$V_DESCR] = $descr;
+ $winner = $W_PCIDEVS;
+ } else {
+ $winner = $W_VENDORS;
+ }
+ } else {
+ $winner = $W_VENDORS;
+ }
+ $cur_vendor = $id;
+ if (not $opts{q} and $winner != $W_NOCONTEST) {
+ $existing = $vendors{$id}->[$V_DESCR];
+ print STDERR "$PROGNAME: ",
+ $winner == $W_VENDORS ? "Boemler" : "Hart",
+ " vendor wins: $id\t$existing\n";
+ }
+ } elsif ($rv == $IS_DEVICE) {
+ if (not exists(${$vendors{$cur_vendor}->[$V_DEVSL]}{$id})) {
+ ${$vendors{$cur_vendor}->[$V_DEVSL]}{$id} = $descr;
+ $winner = $W_NOCONTEST;
+ } elsif ($opts{l}) {
+ $existing = ${$vendors{$cur_vendor}->[$V_DEVSL]}{$id};
+ if (length($existing) < length($descr)) {
+ ${$vendors{$cur_vendor}->[$V_DEVSL]}{$id} =
+ $descr;
+ $winner = $W_PCIDEVS;
+ } else {
+ $winner = $W_VENDORS;
+ }
+ } else {
+ $winner = $W_VENDORS;
+ }
+ if (not $opts{q} and $winner != $W_NOCONTEST) {
+ $existing = ${$vendors{$cur_vendor}->[$V_DEVSL]}{$id};
+ print STDERR "$PROGNAME: ",
+ $winner == $W_VENDORS ? "Boemler" : "Hart",
+ " device wins: $id\t$existing\n";
+ }
+ }
+}
+close(PCIDEVS);
+
+$optlused = $opts{l} ? "with" : "without";
+print <<HEADER_END;
+; \$FreeBSD\$
+;
+; Automatically generated by src/tools/tools/pciid/mk_pci_vendors.pl
+; ($optlused the -l option), using the following source lists:
+;
+; http://www.yourvote.com/pci/vendors.txt
+; http://members.hyperlink.com.au/~chart/download/pcidevs.txt
+;
+; Manual edits on this file will be lost!
+;
+HEADER_END
+
+foreach $cur_vendor (sort keys %vendors) {
+ $id = $cur_vendor;
+ $descr = $vendors{$id}->[$V_DESCR];
+ print "$id\t$descr\n";
+ foreach $id (sort keys %{$vendors{$cur_vendor}->[$V_DEVSL]}) {
+ $descr = ${$vendors{$cur_vendor}->[$V_DEVSL]}{$id};
+ print "\t$id\t$descr\n";
+ }
+}
+exit 0;
+
+
+# Parse a line from the Boemler file and place the ID and description
+# in the scalars referenced by $id_ref and $descr_ref.
+#
+# On success, returns $IS_VENDOR if the line represents a vendor entity
+# or $IS_DEVICE if the line represents a device entity.
+#
+# Returns 0 on failure.
+#
+sub vendors_parse($\$\$)
+{
+ my ($line, $id_ref, $descr_ref) = @_;
+
+ if ($line =~ /^([A-Fa-f0-9]{4})\t([^\t].+?)\s*$/) {
+ ($$id_ref, $$descr_ref) = (uc($1), clean_descr($2));
+ return $IS_VENDOR;
+ } elsif ($line =~ /^\t([A-Fa-f0-9]{4})\t([^\t].+?)\s*$/) {
+ ($$id_ref, $$descr_ref) = (uc($1), clean_descr($2));
+ return $IS_DEVICE;
+ } elsif (not $opts{q} and
+ $line !~ /^\s*$/ and $line !~ /^;/) {
+ chomp($line);
+ print STDERR "$PROGNAME: ignored Boemler: $line\n";
+ }
+
+ return 0;
+}
+
+# Parse a line from the Hart file and place the ID and description
+# in the scalars referenced by $id_ref and $descr_ref.
+#
+# On success, returns $IS_VENDOR if the line represents a vendor entity
+# or $IS_DEVICE if the line represents a device entity.
+#
+# Returns 0 on failure.
+#
+sub pcidevs_parse($\$\$)
+{
+ my ($line, $id_ref, $descr_ref) = @_;
+ my $descr;
+
+ if ($line =~ /^V\t([A-Fa-f0-9]{4})\t([^\t].+?)\s*$/) {
+ ($$id_ref, $$descr_ref) = (uc($1), clean_descr($2));
+ return $IS_VENDOR;
+ } elsif ($line =~ /^D\t([A-Fa-f0-9]{4})\t([^\t].+?)\s*$/) {
+ ($$id_ref, $$descr_ref) = (uc($1), clean_descr($2));
+ return $IS_DEVICE;
+ } elsif (not $opts{q} and
+ $line !~ /^\s*$/ and $line !~ /^[;ORSX]/) {
+ print STDERR "$PROGNAME: ignored Hart: $line\n";
+ }
+
+ return 0;
+}
+
+sub clean_descr($)
+{
+ my ($descr) = @_;
+
+ return $descr;
+}
diff --git a/tools/tools/portsinfo/portsinfo.sh b/tools/tools/portsinfo/portsinfo.sh
new file mode 100644
index 0000000..f3dcf50
--- /dev/null
+++ b/tools/tools/portsinfo/portsinfo.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Copyright (c) April 1997 Wolfram Schneider <wosch@FreeBSD.org>, Berlin.
+#
+# portsinfo - Generate list of new ports for last two weeks.
+#
+# $FreeBSD$
+
+PATH=/bin:/usr/bin:/usr/local/bin:$PATH; export PATH
+
+host=http://www.freebsd.org
+url=$host/cgi/ports.cgi
+time='?type=new&time=2+week+ago&sektion=all'
+time2='?type=changed&time=2+week+ago&sektion=all'
+info=yes
+
+if [ x"$info" = xyes ]; then
+
+cat <<'EOF'
+Introduction
+------------
+
+The FreeBSD Ports Collection offers a simple way for users and
+administrators to install applications. Each "port" listed here
+contains any patches necessary to make the original application source
+code compile and run on FreeBSD. Installing an application is as
+simple as downloading the port, unpacking it and typing make in the
+port directory. The Makefile automatically fetches the application
+source code, either from a local disk or via ftp, unpacks it on your
+system, applies the patches, and compiles. If all goes well, simply
+type make install to install the application.
+
+For more information about using ports, see the ports collection
+
+ http://www.freebsd.org/handbook/ports.html
+and
+ http://www.freebsd.org/ports/
+
+EOF
+
+ lynx -dump $host/ports/ |
+ perl -ne '/^[ ]*There are currently/ && s/^\s+// && print && exit'
+
+cat <<EOF
+
+
+New ports added last two weeks
+------------------------------
+
+EOF
+
+
+fi
+
+
+lynx -nolist -dump -reload -nostatus "$url$time" |
+ grep -v "Description :" |
+perl -ne 'print if (/^\s*Category/ .. /__________________/)' |
+ grep -v ________ |
+perl -ne 'if (/^\s*Category/) {
+ print; for(1..50) {print "="}; print "\n";
+ } else { print}'
+
+cat <<EOF
+
+
+Updated ports last two weeks
+-----------------------------------
+
+EOF
+
+lynx -nolist -dump -reload -nostatus "$url$time2" |
+ grep -v "Description :" |
+perl -ne 's/\[INLINE\]\s*//g; print if (/Category/ .. /XXXXYYYYZZZZ/)' |
+perl -ne 'if (/^\s*Category/) {
+ print; for(1..50) {print "="}; print "\n";
+ } else { print}'
+
+cat <<EOF
+
+This information was produced by
+ $url
+
+EOF
+
diff --git a/tools/tools/prstats/prstats.pl b/tools/tools/prstats/prstats.pl
new file mode 100644
index 0000000..bb437a6
--- /dev/null
+++ b/tools/tools/prstats/prstats.pl
@@ -0,0 +1,357 @@
+#!/usr/bin/perl -w
+#-
+# Copyright (c) 2001 Dag-Erling Coïdan Smørgrav
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer
+# in this position and unchanged.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+use strict;
+use Data::Dumper;
+use Fcntl;
+use POSIX qw(isatty mktime strftime tzset);
+use vars qw($TTY $NOW %MONTH %PR @EVENTS @COUNT @AGE);
+use vars qw(%STATE %CATEGORY %OWNER %CLOSER);
+
+%MONTH = (
+ 'Jan' => 1,
+ 'Feb' => 2,
+ 'Mar' => 3,
+ 'Apr' => 4,
+ 'May' => 5,
+ 'Jun' => 6,
+ 'Jul' => 7,
+ 'Aug' => 8,
+ 'Sep' => 9,
+ 'Oct' => 10,
+ 'Nov' => 11,
+ 'Dec' => 12,
+);
+
+@AGE = (
+ [ 0, 7, 0 ], # Less than one week
+ [ 7, 30, 0 ], # One week to one month
+ [ 30, 90, 0 ], # One to three months
+ [ 90, 365, 0 ], # Three months to a year
+ [ 365, 1095, 0 ], # One to three years
+ [ 1095, 999999, 0 ], # More than three years
+);
+
+sub GNATS_DIR { "/home/gnats" }
+sub GNATS_TZ { "America/Los_Angeles" }
+sub DATFILE { "/tmp/prstats.dat.$$" }
+sub GNUPLOT { "|/usr/local/bin/gnuplot /dev/stdin" }
+sub TIMEFMT { "%Y-%m-%d/%H:%M:%S" }
+
+sub parse_date($) {
+ my $date = shift; # Date to parse
+
+ my $year;
+ my $month;
+ my $day;
+ my $hour;
+ my $minute;
+ my $second;
+
+ $date =~ s/\s+/ /g;
+ $date =~ s/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\w*\s*//;
+ if ($date =~ m/^(\w{3}) (\d\d?) (\d\d):(\d\d):(\d\d) [A-Z ]*(\d{4})$/) {
+ ($month, $day, $hour, $minute, $second, $year) =
+ ($1, $2, $3, $4, $5, $6);
+ } else {
+ die("Unrecognized date format: $date\n");
+ }
+ defined($month = $MONTH{$month})
+ or die("Invalid month: $month\n");
+ return mktime($second, $minute, $hour, $day, $month - 1, $year - 1900);
+}
+
+sub scan_pr($) {
+ my $fn = shift; # File name
+
+ local *FILE; # File handle
+ my $pr = {}; # PR hash
+ my $age; # PR age
+
+ sysopen(FILE, $fn, O_RDONLY)
+ or die("$fn: open(): $!\n");
+ while (<FILE>) {
+ if (m/^>([A-Za-z-]+):\s+(.*?)\s*$/o ||
+ m/^(Category|Responsible|State-Changed-[A-Za-z-]+):\s+(.*?)\s*$/o) {
+ $pr->{lc($1)} = $2;
+ }
+ }
+
+ exists($PR{$pr->{'number'}})
+ and die("$fn: PR $pr->{'number'} already exists\n");
+
+ if ($TTY) {
+ print(" "x40, "\r", scalar(keys(%PR)),
+ " $pr->{'category'}/$pr->{'number'} ");
+ }
+
+ foreach ('arrival-date', 'closed-date', 'last-modified',
+ 'state-changed-when') {
+ if (defined($pr->{$_}) && length($pr->{$_})) {
+ $pr->{$_} = parse_date($pr->{$_});
+ }
+ }
+
+ $pr->{'_created'} = $pr->{'arrival-date'};
+ if ($pr->{'state'} eq 'closed') {
+ $pr->{'_closed'} = $pr->{'closed-date'} || $pr->{'state-changed-when'};
+ $pr->{'_closed_by'} = $pr->{'state-changed-by'};
+ if (!defined($pr->{'_closed_by'})) {
+ warn("PR $pr->{'category'}/$pr->{'number'} is incomplete\n");
+ return;
+ }
+ ++$CLOSER{$pr->{'_closed_by'}};
+ } else {
+ $age = $pr->{'arrival-date'} / 86400;
+ foreach (@AGE) {
+ if ($age >= $_->[0] && $age < $_->[1]) {
+ ++$_->[2];
+ last;
+ }
+ }
+ ++$CATEGORY{$pr->{'category'}};
+ ++$OWNER{$pr->{'responsible'}};
+ }
+ ++$STATE{$pr->{'state'}};
+
+ $PR{$pr->{'number'}} = {
+ 'category' => $pr->{'category'},
+ #'number' => $pr->{'number'},
+ 'responsible' => $pr->{'responsible'},
+ 'created' => $pr->{'created'},
+ 'closed' => $pr->{'closed'},
+ 'closer' => $pr->{'_closed_by'},
+ };
+ push(@EVENTS, [ $pr->{'_created'}, +1 ]);
+ push(@EVENTS, [ $pr->{'_closed'}, -1 ])
+ if defined($pr->{'_closed'});
+}
+
+sub scan_recurse($);
+sub scan_recurse($) {
+ my $dn = shift; # Directory name
+
+ local *DIR; # Directory handle
+ my $entry; # Entry
+
+ opendir(DIR, $dn)
+ or die("$dn: opendir(): $!\n");
+ while ($entry = readdir(DIR)) {
+ next if ($entry eq '.' || $entry eq '..');
+ if (-d "$dn/$entry") {
+ scan_recurse("$dn/$entry");
+ } elsif ($entry =~ m/^\d+$/) {
+ eval {
+ scan_pr("$dn/$entry");
+ };
+ }
+ }
+ closedir(DIR);
+}
+
+sub count_prs() {
+
+ my $pr; # Iterator
+ my @events; # Creations or closures
+ my $event; # Iterator
+ my $count; # PR count
+
+ if ($TTY) {
+ print(int(@EVENTS), " events\n");
+ }
+ @COUNT = ( [ 0, 0 ] );
+ foreach $event (sort({ $a->[0] <=> $b->[0] } @EVENTS)) {
+ if ($event->[0] == $COUNT[-1]->[0]) {
+ $COUNT[-1]->[1] += $event->[1];
+ } else {
+ push(@COUNT, [ $event->[0], $COUNT[-1]->[1] + $event->[1] ]);
+ }
+ }
+ if (@COUNT > 1) {
+ $COUNT[0]->[0] = $COUNT[1]->[0] - 1;
+ unshift(@COUNT, [ 0, 0 ]);
+ }
+}
+
+sub gnuplot(@) {
+ my @commands = @_; # Commands
+
+ my $pid; # Child PID
+ local *PIPE; # Pipe
+
+ open(PIPE, &GNUPLOT)
+ or die("fork(): $!\n");
+ print(PIPE join("\n", @commands, ""));
+ close(PIPE);
+ if ($? & 0x7f) {
+ die("gnuplot caught a signal " . ($? & 0x7f) . "\n");
+ } elsif ($?) {
+ die("gunplot returned exit code " . ($? >> 8) . "\n");
+ }
+}
+
+sub write_dat_file($) {
+ my $fn = shift; # File name
+
+ local *FILE; # File handle
+ my $datum; # Iterator
+
+ sysopen(FILE, $fn, O_RDWR|O_CREAT|O_TRUNC, 0640)
+ or die("$fn: open(): $!\n");
+ foreach $datum (@COUNT) {
+ print(FILE strftime(&TIMEFMT, localtime($datum->[0])),
+ " ", $datum->[1],
+ " ", $COUNT[-1]->[1],
+ "\n");
+ }
+ close(FILE);
+}
+
+sub graph_open_prs($$$$$) {
+ my $datfn = shift; # Data file name
+ my $fn = shift; # File name
+ my $start = shift; # Starting date
+ my $end = shift; # Ending date
+ my $title = shift; # Title
+
+ my $tickfmt; # Tick format
+ my $timefmt; # Time format
+
+ if ($end - $start > 86400 * 30) {
+ $tickfmt = "%Y-%m-%d";
+ } else {
+ $tickfmt = "%m-%d";
+ }
+ $start = strftime(&TIMEFMT, localtime($start));
+ $end = strftime(&TIMEFMT, localtime($end));
+ $timefmt = &TIMEFMT;
+ gnuplot("
+set term png small color
+set xdata time
+set timefmt '$timefmt'
+set data style line
+set grid
+set output '$fn'
+set format x '$tickfmt'
+set xrange ['$start':'$end']
+set yrange [0:*]
+set title '$title'
+plot '$datfn' using 1:2 title 'Open PRs'
+");
+}
+
+sub pr_stat_summary() {
+
+ my $n; # Loop counter
+
+ # Overall stats
+ printf("Total PRs in database: %d\n", scalar(keys(%PR)));
+ printf("Open PRs: %d\n", scalar(keys(%PR)) - $STATE{'closed'});
+ print("\n");
+
+ # Category ranking
+ print("Number of PRs in each category:\n");
+ foreach (sort({ $CATEGORY{$b} <=> $CATEGORY{$a} } keys(%CATEGORY))) {
+ printf("%12s: %d\n", $_, $CATEGORY{$_});
+ }
+ print("\n");
+
+ # State ranking
+ print("Number of PRs in each state:\n");
+ foreach (sort({ $STATE{$b} <=> $STATE{$a} } keys(%STATE))) {
+ printf("%12s: %d\n", $_, $STATE{$_});
+ }
+ print("\n");
+
+ # Closer ranking
+ print("Top ten PR busters:\n");
+ $n = 0;
+ foreach (sort({ $CLOSER{$b} <=> $CLOSER{$a} } keys(%CLOSER))) {
+ printf(" %2d. %s (%d)\n", ++$n, $_, $CLOSER{$_});
+ last if ($n == 10);
+ }
+ print("\n");
+
+ # Owner ranking
+ print("Top ten owners of open PRs:\n");
+ $n = 0;
+ foreach (sort({ $OWNER{$b} <=> $OWNER{$a} } keys(%OWNER))) {
+ next if (m/^freebsd-(bugs|doc|ports)$/);
+ printf(" %2d. %s (%d)\n", ++$n, $_, $OWNER{$_});
+ last if ($n == 10);
+ }
+ print("\n");
+
+}
+
+MAIN:{
+ $| = 1;
+ $TTY = isatty(*STDOUT);
+
+ # Perl lacks strptime(), and its mktime() doesn't accept a
+ # timezone argument, so we set our local timezone to that of the
+ # FreeBSD cluster and use localtime() instead.
+ $ENV{'TZ'} = &GNATS_TZ;
+ tzset();
+ $NOW = time();
+
+ # Read and count PRs
+ if (@ARGV) {
+ foreach (@ARGV) {
+ scan_recurse(join('/', &GNATS_DIR, $_));
+ }
+ } else {
+ scan_recurse(&GNATS_DIR);
+ }
+ if ($TTY) {
+ print("\r", scalar(keys(%PR)), " problem reports scanned\n");
+ }
+
+ # Generate graphs
+ if (0) {
+ count_prs();
+ write_dat_file(&DATFILE);
+ graph_open_prs(&DATFILE, "week.png", $NOW - (86400 * 7) + 1, $NOW,
+ "Open FreeBSD problem reports (week view)");
+ graph_open_prs(&DATFILE, "month.png", $NOW - (86400 * 30) + 1, $NOW,
+ "Open FreeBSD problem reports (month view)");
+ graph_open_prs(&DATFILE, "year.png", $NOW - (86400 * 365) + 1, $NOW,
+ "Open FreeBSD problem reports (year view)");
+ graph_open_prs(&DATFILE, "ever.png", $COUNT[1]->[0], $NOW,
+ "Open FreeBSD problem reports (project history)");
+ graph_open_prs(&DATFILE, "drive.png", mktime(0, 0, 0, 29, 4, 101), $NOW,
+ "Open FreeBSD problem reports (drive progress)");
+ unlink(&DATFILE);
+ }
+
+ # Print summary
+ pr_stat_summary();
+}
diff --git a/tools/tools/scsi-defects/README b/tools/tools/scsi-defects/README
new file mode 100644
index 0000000..bca470a
--- /dev/null
+++ b/tools/tools/scsi-defects/README
@@ -0,0 +1,5 @@
+Peter Dufault's tools to extract the primary or grown defect list from
+a SCSI disk, wrapped into Perl (for easier decoding of the list) by
+Joerg Wunsch.
+
+This has not been ported CAM yet.
diff --git a/tools/tools/scsi-defects/scsi-defects.pl b/tools/tools/scsi-defects/scsi-defects.pl
new file mode 100755
index 0000000..0827182
--- /dev/null
+++ b/tools/tools/scsi-defects/scsi-defects.pl
@@ -0,0 +1,94 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 1997
+# Peter Dufault, Joerg Wunsch. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+#
+# Read and decode a SCSI disk's primary or grown defect list.
+#
+
+sub usage
+{
+ die "usage: scsi-defects raw-device-name [Glist|Plist]\n";
+}
+
+
+#
+# Main
+#
+
+&usage if $#ARGV < 0 || $#ARGV > 1;
+
+$ENV{'PATH'} = "/bin:/usr/bin:/sbin:/usr/sbin";
+
+$dev = $ARGV[0];
+
+# generic device name given?
+if ($dev =~ /^[so]d\d+$/) { $dev = "/dev/r${dev}.ctl"; }
+
+#
+# Select what you want to read. PList include the primary defect list
+# from the factory. GList is grown defects only.
+#
+if ($#ARGV > 0) {
+ if ($ARGV[1] =~ /^[Gg]/) { $glist = 1; $plist = 0; }
+ elsif ($ARGV[1] =~ /^[Pp]/) { $glist = 0; $plist = 1; }
+ else { &usage; }
+} else {
+ $glist = 1; $plist = 0;
+}
+
+open(PIPE, "scsi -f $dev " .
+ "-c '{ Op code} 37 0 0:3 v:1 v:1 5:3 0 0 0 0 4:i2 0' $plist $glist " .
+ "-i 4 '{ stuff } *i2 { Defect list length } i2' |") ||
+ die "Cannot pipe to scsi(8)\n";
+chop($amnt = <PIPE>);
+close(PIPE);
+
+if ($amnt == 0) {
+ print "There are no defects (in this list).\n";
+ exit 0;
+}
+
+print "There are " . $amnt / 8 . " defects in this list.\n";
+
+$amnt += 4;
+
+open(PIPE, "scsi -f $dev " .
+ "-c '{ Op code} 37 0 0:3 v:1 v:1 5:3 0 0 0 0 v:i2 0' $plist $glist " .
+ "$amnt -i $amnt - |") ||
+ die "Cannot pipe to scsi(8)\n";
+
+read(PIPE, $buf, 4); # defect list header
+
+print "cylinder head sector\n";
+
+while(read(PIPE, $buf, 8)) {
+ ($cylhi, $cyllo, $head, $sec) = unpack("CnCN", $buf);
+ printf "%8u %4u %6u\n", $cylhi*65536+$cyllo, $head, $sec;
+}
+close(PIPE);
diff --git a/tools/tools/tinderbox/Makefile b/tools/tools/tinderbox/Makefile
new file mode 100644
index 0000000..7a0a269
--- /dev/null
+++ b/tools/tools/tinderbox/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+BINDIR ?= ${HOME}/bin
+BINOWN ?= ${USER}
+BINGRP ?= ${USER}
+SCRIPTS = tbmaster.pl tinderbox.pl
+
+.include <bsd.prog.mk>
diff --git a/tools/tools/tinderbox/tbmaster.pl b/tools/tools/tinderbox/tbmaster.pl
new file mode 100644
index 0000000..4282d0d
--- /dev/null
+++ b/tools/tools/tinderbox/tbmaster.pl
@@ -0,0 +1,264 @@
+#!/usr/bin/perl -Tw
+#-
+# Copyright (c) 2003 Dag-Erling Coïdan Smørgrav
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer
+# in this position and unchanged.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+use strict;
+use POSIX qw(tzset);
+
+my %CONFIGS = (
+ # Global settings
+ 'global' => {
+ 'LOGDIR' => '/home/des/public_html',
+ 'OPTIONS' => [ '--update', '--verbose' ],
+ 'EMAIL' => 'des',
+ },
+ # 5-CURRENT tinderbox
+ 'cueball' => {
+ 'COMMENT' => "-CURRENT tinderbox",
+ 'BRANCHES' => [ 'CURRENT' ],
+ 'TARGETS' => [ 'world', 'generic', 'lint' ],
+ 'ARCHES' => {
+ 'alpha' => [ 'alpha' ],
+ 'i386' => [ 'i386', 'pc98' ],
+ 'ia64' => [ 'ia64' ],
+ 'sparc64' => [ 'sparc64' ],
+ },
+ },
+ # 4-STABLE tinderbox
+ 'triangle' => {
+ 'COMMENT' => "-STABLE tinderbox",
+ 'BRANCHES' => [ 'RELENG_4' ],
+ 'TARGETS' => [ 'world', 'generic' ],
+ 'ARCHES' => {
+ 'alpha' => [ 'alpha' ],
+ 'i386' => [ 'i386', 'pc98' ],
+ },
+ },
+ # Test setup
+ '9ball' => {
+ 'BRANCHES' => [ 'CURRENT' ],
+ 'TARGETS' => [ 'world', 'generic', 'lint' ],
+ 'ARCHES' => {
+ 'powerpc' => [ 'powerpc' ],
+ },
+ 'EMAIL' => 'des@ofug.org',
+ },
+);
+my %CONFIG = ();
+my $TINDERBOX;
+
+sub report($$$) {
+ my $recipient = shift;
+ my $subject = shift;
+ my $message = shift;
+
+ local *PIPE;
+ if (!open(PIPE, "|-", "/usr/bin/mail -s'$subject' $recipient") ||
+ !print(PIPE $message) || !close(PIPE)) {
+ print(STDERR "Subject: $subject\n\n");
+ print(STDERR "[failed to send report by email]\n\n");
+ print(STDERR $message);
+ } else {
+ print(STDERR "mailed report to $recipient\n");
+ }
+}
+
+sub tinderbox($$$) {
+ my $branch = shift;
+ my $arch = shift;
+ my $machine = shift;
+
+ # Open log files: one for the full log and one for the summary
+ my $logfile = "$CONFIG{'LOGDIR'}/tinderbox-$branch-$arch-$machine";
+ local (*FULL, *BRIEF);
+ if (!open(FULL, ">", "$logfile.full.$$")) {
+ warn("$logfile.full.$$: $!\n");
+ return undef;
+ }
+ select(FULL);
+ $| = 1;
+ select(STDOUT);
+ if (!open(BRIEF, ">", "$logfile.brief.$$")) {
+ warn("$logfile.brief.$$: $!\n");
+ return undef;
+ }
+ select(BRIEF);
+ $| = 1;
+ select(STDOUT);
+
+ # Open a pipe for the tinderbox process
+ local (*RPIPE, *WPIPE);
+ if (!pipe(RPIPE, WPIPE)) {
+ warn("pipe(): $!\n");
+ unlink("$logfile.brief.$$");
+ close(BRIEF);
+ unlink("$logfile.full.$$");
+ close(FULL);
+ return undef;
+ }
+
+ # Fork and start the tinderbox
+ my @args = @{$CONFIG{'OPTIONS'}};
+ push(@args, "--branch=$branch");
+ push(@args, "--arch=$arch");
+ push(@args, "--machine=$machine");
+ push(@args, @{$CONFIG{'TARGETS'}});
+ my $pid = fork();
+ if (!defined($pid)) {
+ warn("fork(): $!\n");
+ unlink("$logfile.brief.$$");
+ close(BRIEF);
+ unlink("$logfile.full.$$");
+ close(FULL);
+ return undef;
+ } elsif ($pid == 0) {
+ close(RPIPE);
+ open(STDOUT, ">&WPIPE");
+ open(STDERR, ">&WPIPE");
+ $| = 1;
+ exec($TINDERBOX, @args);
+ die("child: exec(): $!\n");
+ }
+
+ # Process the output
+ close(WPIPE);
+ my @lines = ();
+ my $error = 0;
+ my $summary = "";
+ while (<RPIPE>) {
+ print(FULL $_);
+ if (/^TB ---/ || /^>>> /) {
+ if ($error) {
+ $summary .= join('', @lines);
+ print(BRIEF join('', @lines));
+ @lines = ();
+ $error = 0;
+ }
+ $summary .= $_;
+ print(BRIEF $_);
+ @lines = ();
+ next;
+ }
+ if (/\bStop\b/) {
+ $error = 1;
+ }
+ if (@lines > 10 && !$error) {
+ shift(@lines);
+ $lines[0] = "[...]\n";
+ }
+ push(@lines, $_);
+ }
+ if ($error) {
+ $summary .= join('', @lines);
+ print(BRIEF join('', @lines));
+ }
+ close(BRIEF);
+ close(FULL);
+
+ # Done...
+ if (waitpid($pid, 0) == -1) {
+ warn("waitpid(): $!\n");
+ } elsif ($? & 0xff) {
+ warn("tinderbox caught signal ", $? & 0x7f, "\n");
+ $error = 1;
+ } elsif ($? >> 8) {
+ warn("tinderbox returned exit code ", $? >> 8, "\n");
+ $error = 1;
+ }
+
+ # Mail out error reports
+ if ($error) {
+ warn("$branch tinderbox failed for $arch/$machine\n");
+ my $recipient = $CONFIG{'EMAIL'};
+ $recipient =~ s/\%\%branch\%\%/$branch/gi;
+ $recipient =~ s/\%\%arch\%\%/$arch/gi;
+ $recipient =~ s/\%\%machine\%\%/$machine/gi;
+ report($recipient,
+ "$branch tinderbox failure on $arch/$machine",
+ $summary);
+ }
+
+ rename("$logfile.full.$$", "$logfile.full");
+ rename("$logfile.brief.$$", "$logfile.brief");
+}
+
+sub usage() {
+
+ my @configs = ();
+ foreach my $config (sort(keys(%CONFIGS))) {
+ push(@configs, $config)
+ unless ($config eq 'global');
+ }
+ print(STDERR "usage: tbmaster [", join('|', @configs), "]\n");
+ exit(1);
+}
+
+MAIN:{
+ usage()
+ unless (@ARGV >= 1);
+ my $config = lc(shift(@ARGV));
+ usage()
+ unless (exists($CONFIGS{$config}) && $config ne 'global');
+ %CONFIG = %{$CONFIGS{$config}};
+ foreach my $key (keys(%{$CONFIGS{'global'}})) {
+ $CONFIG{$key} = $CONFIGS{'global'}->{$key}
+ unless (exists($CONFIG{$key}));
+ }
+
+ $ENV{'TZ'} = "GMT";
+ tzset();
+ $ENV{'PATH'} = "";
+ $TINDERBOX = $0;
+ if ($TINDERBOX =~ m|(.*/)tbmaster(.*)$|) {
+ $TINDERBOX = "${1}tinderbox${2}";
+ }
+ if ($TINDERBOX eq $0 || ! -x $TINDERBOX) {
+ die("where is the tinderbox script?\n");
+ }
+
+ foreach my $branch (sort(@{$CONFIG{'BRANCHES'}})) {
+ if (@ARGV) {
+ foreach my $target (@ARGV) {
+ $target =~ m|^(\w+)(?:/(\w+))?$|
+ or die("invalid target specification: $target\n");
+ my ($arch, $machine) = ($1, $2);
+ $machine = $arch
+ unless defined($machine);
+ tinderbox($branch, $arch, $machine);
+ }
+ } else {
+ foreach my $arch (sort(keys(%{$CONFIG{'ARCHES'}}))) {
+ foreach my $machine (sort(@{$CONFIG{'ARCHES'}->{$arch}})) {
+ tinderbox($branch, $arch, $machine);
+ }
+ }
+ }
+ }
+}
diff --git a/tools/tools/tinderbox/tinderbox.pl b/tools/tools/tinderbox/tinderbox.pl
new file mode 100644
index 0000000..599640c
--- /dev/null
+++ b/tools/tools/tinderbox/tinderbox.pl
@@ -0,0 +1,441 @@
+#!/usr/bin/perl -Tw
+#-
+# Copyright (c) 2003 Dag-Erling Coïdan Smørgrav
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer
+# in this position and unchanged.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+use strict;
+use Fcntl qw(:DEFAULT :flock);
+use POSIX;
+use Getopt::Long;
+
+my $VERSION = "2.0";
+my $COPYRIGHT = "Copyright (c) 2003 Dag-Erling Smørgrav. " .
+ "All rights reserved.";
+
+my $arch; # Target architecture
+my $branch; # CVS branch to checkou
+my $clean; # Clean before building
+my $date; # Date of sources to check out
+my $jobs; # Number of paralell jobs
+my $logfile; # Path to log file
+my $machine; # Target machine
+my $repository; # Location of CVS repository
+my $sandbox; # Location of sandbox
+my $update; # Update sources before building
+my $verbose; # Verbose mode
+
+my %cmds = (
+ 'world' => 0,
+ 'generic' => 0,
+ 'lint' => 0
+);
+
+sub message(@) {
+
+ my $msg = join(' ', "TB ---", @_);
+ chomp($msg);
+ print("$msg\n");
+}
+
+sub warning(@) {
+
+ my $msg = join(' ', @_);
+ chomp($msg);
+ warn("$msg\n");
+ return undef;
+}
+
+sub error(@) {
+
+ my $msg = join(' ', "ERROR:", @_);
+ chomp($msg);
+ die("$msg\n");
+ return undef;
+}
+
+#
+# Open and lock a file reliably
+#
+sub open_locked($;$$) {
+ my $fn = shift; # File name
+ my $flags = shift; # Open flags
+ my $mode = shift; # File mode
+
+ local *FILE; # File handle
+ my (@sb1, @sb2); # File status
+
+ for (;; close(FILE)) {
+ sysopen(FILE, $fn, $flags || O_RDONLY, $mode || 0640)
+ or last;
+ if (!(@sb1 = stat(FILE))) {
+ # Huh? shouldn't happen
+ warning("$fn: stat(): $!");
+ last;
+ }
+ if (!flock(FILE, LOCK_EX|LOCK_NB)) {
+ # A failure here means the file can't be locked, or
+ # something really weird happened, so just give up.
+ warning("$fn: flock(): $!");
+ last;
+ }
+ if (!(@sb2 = stat($fn))) {
+ # File was pulled from under our feet, though it may
+ # reappear in the next pass
+ next;
+ }
+ if ($sb1[0] != $sb2[0] || $sb1[1] != $sb2[1]) {
+ # File changed under our feet, try again
+ next;
+ }
+ return *FILE{IO};
+ }
+ close(FILE);
+ return undef;
+}
+
+#
+# Remove a directory and all its subdirectories
+#
+sub remove_dir($);
+sub remove_dir($) {
+ my $dir = shift;
+
+ if (!-d $dir) {
+ message("removing $dir")
+ if ($verbose);
+ return (unlink($dir) || $! == ENOENT);
+ }
+
+ local *DIR;
+ opendir(DIR, $dir)
+ or return warning("$dir: $!");
+ foreach my $ent (readdir(DIR)) {
+ next if ($ent eq '.' || $ent eq '..');
+ $ent =~ m/(.*)/;
+ if (!remove_dir("$dir/$1")) {
+ closedir(DIR);
+ return undef;
+ }
+ }
+ closedir(DIR)
+ or return warning("$dir: $!");
+ message("rmdir $dir")
+ if ($verbose);
+ return rmdir($dir);
+}
+
+sub make_dir($);
+sub make_dir($) {
+ my $dir = shift;
+
+ if (!-d $dir && $dir =~ m|^(\S*)/([^\s/]+)$|) {
+ make_dir($1)
+ or return undef;
+ message("mkdir $dir");
+ mkdir("$dir")
+ or return undef;
+ }
+ return 1;
+}
+
+sub cd($) {
+ my $dir = shift;
+
+ message("cd $dir");
+ chdir($dir)
+ or error("$dir: $!");
+}
+
+#
+# Spawn a child and wait for it to finish
+#
+sub spawn($@) {
+ my $cmd = shift; # Command to run
+ my @args = @_; # Arguments
+
+ message($cmd, @args);
+ my $pid = fork();
+ if (!defined($pid)) {
+ return warning("fork(): $!");
+ } elsif ($pid == 0) {
+ exec($cmd, @args);
+ die("child: exec(): $!\n");
+ }
+ if (waitpid($pid, 0) == -1) {
+ return warning("waitpid(): $!\n");
+ } elsif ($? & 0xff) {
+ return warning("$cmd caught signal ", $? & 0x7f, "\n");
+ } elsif ($? >> 8) {
+ return warning("$cmd returned exit code ", $? >> 8, "\n");
+ }
+ return 1;
+}
+
+sub make($) {
+ my $target = shift;
+
+ return spawn('/usr/bin/make',
+ ($jobs > 1) ? "-j$jobs" : "-B",
+ $target);
+}
+
+sub logstage($) {
+ my $msg = shift;
+
+ chomp($msg);
+ print(STDERR strftime("TB --- %Y-%m-%d %H:%M:%S - $msg\n", localtime()));
+}
+
+sub sigwarn {
+
+ logstage(shift);
+}
+
+sub sigdie {
+
+ logstage(shift);
+ logstage("tinderbox aborted");
+ exit(1);
+}
+
+sub usage() {
+
+ print(STDERR "This is the FreeBSD tinderbox script, version $VERSION.
+$COPYRIGHT
+
+Usage:
+ $0 [options] [parameters] command [...]
+
+Options:
+ -c, --clean Clean sandbox before building
+ -u, --update Update sources before building
+ -v, --verbose Verbose mode
+
+Parameters:
+ -a, --arch=ARCH Target architecture
+ -b, --branch=BRANCH CVS branch to check out
+ -d, --date=DATE Date of sources to check out
+ -j, --jobs=NUM Maximum number of paralell jobs
+ -l, --logfile=FILE Path to log file
+ -r, --repository=DIR Location of CVS repository
+ -s, --sandbox=DIR Location of sandbox
+
+Commands:
+ world Build the world
+ generic Build the GENERIC kernel
+ lint Build the LINT kernel
+
+Report bugs to <des\@freebsd.org>.
+");
+ exit(1);
+}
+
+MAIN:{
+ $ENV{'PATH'} = '';
+ $ENV{'TZ'} = "GMT";
+ tzset();
+
+ # Set defaults
+ $arch = `/usr/bin/uname -m`;
+ chomp($arch);
+ $branch = "CURRENT";
+ $jobs = 0;
+ $repository = "/home/ncvs";
+ $sandbox = "$ENV{'HOME'}/tinderbox";
+
+ # Get options
+ {Getopt::Long::Configure("auto_abbrev", "bundling");}
+ GetOptions(
+ "a|arch=s" => \$arch,
+ "b|branch=s" => \$branch,
+ "c|clean" => \$clean,
+ "d|date=s" => \$date,
+ "j|jobs=i" => \$jobs,
+ "l|logfile=s" => \$logfile,
+ "m|machine=s" => \$machine,
+ "r|repository=s" => \$repository,
+ "s|sandbox=s" => \$sandbox,
+ "u|update" => \$update,
+ "v|verbose" => \$verbose,
+ ) or usage();
+
+ if ($jobs < 0) {
+ error("invalid number of jobs");
+ }
+ if ($branch !~ m|^(\w+)$|) {
+ error("invalid source branch");
+ }
+ $branch = $1;
+ if ($arch !~ m|^(\w+)$|) {
+ error("invalid target architecture");
+ }
+ $arch = $1;
+ if (!defined($machine)) {
+ $machine = $arch;
+ }
+ if ($machine !~ m|^(\w+)$|) {
+ error("invalid target machine");
+ }
+ $machine = $1;
+
+ if (!@ARGV) {
+ usage();
+ }
+
+ # Find out what we're expected to do
+ foreach my $cmd (@ARGV) {
+ if (!exists($cmds{$cmd})) {
+ error("unrecognized command: '$cmd'");
+ }
+ $cmds{$cmd} = 1;
+ }
+
+ # Take control of our sandbox
+ if ($sandbox !~ m|^(/[\w/-]+)$|) {
+ error("invalid sandbox directory");
+ }
+ $sandbox = "$1/$branch/$arch/$machine";
+ make_dir($sandbox)
+ or error("$sandbox: $!");
+ my $lockfile = open_locked("$sandbox/lock", O_RDWR|O_CREAT);
+ if (!defined($lockfile)) {
+ error("unable to lock sandbox");
+ }
+ truncate($lockfile, 0);
+ print($lockfile "$$\n");
+
+ # Open logfile
+ open(STDIN, '<', "/dev/null")
+ or error("/dev/null: $!\n");
+ if (defined($logfile)) {
+ if ($logfile !~ m|([\w./-]+)$|) {
+ error("invalid log file name");
+ }
+ $logfile = $1;
+ unlink($logfile);
+ open(STDOUT, '>', $logfile)
+ or error("$logfile: $!");
+ }
+ open(STDERR, ">&STDOUT");
+ $| = 1;
+ logstage("starting $branch tinderbox run for $arch/$machine");
+ $SIG{__DIE__} = \&sigdie;
+ $SIG{__WARN__} = \&sigwarn;
+
+ # Clean up remains from old runs
+ if ($clean) {
+ logstage("cleaning up sandbox");
+ remove_dir("$sandbox/src")
+ or error("unable to remove old source directory");
+ remove_dir("$sandbox/obj")
+ or error("unable to remove old object directory");
+ make_dir("$sandbox/obj")
+ or error("$sandbox/obj: $!");
+ }
+
+ # Check out new source tree
+ if ($update) {
+ cd("$sandbox");
+ logstage("checking out sources");
+ my @cvsargs = (
+ "-f",
+ "-R",
+ $verbose ? "-q" : "-Q",
+ "-d$repository",
+ );
+ if (-d "$sandbox/src") {
+ push(@cvsargs, "update", "-Pd");
+ } else {
+ push(@cvsargs, "checkout", "-P");
+ };
+ push(@cvsargs, ($branch eq 'CURRENT') ? "-A" : "-r$branch")
+ if defined($branch);
+ push(@cvsargs, "-D$date")
+ if defined($date);
+ push(@cvsargs, "src");
+ spawn('/usr/bin/cvs', @cvsargs)
+ or error("unable to check out the source tree");
+ }
+
+ # Prepare environment for make(1);
+ cd("$sandbox/src");
+ %ENV = (
+ 'TZ' => "GMT",
+ 'PATH' => "/usr/bin:/usr/sbin:/bin:/sbin",
+
+ '__MAKE_CONF' => "/dev/null",
+ 'MAKEOBJDIRPREFIX' => "$sandbox/obj",
+
+ 'TARGET' => $machine,
+ 'TARGET_ARCH' => $arch,
+ 'TARGET_MACHINE' => $machine,
+
+ 'CFLAGS' => "-O -pipe",
+ 'NO_CPU_CFLAGS' => "YES",
+ 'COPTFLAGS' => "-O -pipe",
+ 'NO_CPU_COPTFLAGS' => "YES",
+
+ 'MAKE_KERBEROS4' => "YES",
+ 'MAKE_KERBEROS5' => "YES",
+ 'BOOT2_UFS' => "UFS1_ONLY",
+ );
+
+ # Build the world
+ if ($cmds{'world'}) {
+ logstage("building world");
+ make('buildworld')
+ or error("failed to build world");
+ }
+
+ # Build GENERIC if requested
+ if ($cmds{'generic'}) {
+ logstage("building generic kernel");
+ spawn('/usr/bin/make', 'buildkernel', 'KERNCONF=GENERIC')
+ or error("failed to build generic kernel");
+ }
+
+ # Build LINT if requested
+ if ($cmds{'lint'} && ! -f "$sandbox/src/sys/$machine/conf/NOTES") {
+ logstage("no NOTES, skipping lint kernel");
+ $cmds{'lint'} = 0;
+ }
+ if ($cmds{'lint'}) {
+ logstage("building lint kernel");
+ cd("$sandbox/src/sys/$machine/conf");
+ make('LINT')
+ or error("failed to generate lint config");
+ cd("$sandbox/src");
+ spawn('/usr/bin/make', 'buildkernel', 'KERNCONF=LINT')
+ or error("failed to build lint kernel");
+ }
+
+ # Exiting releases the lock file
+ logstage("tinderbox run completed");
+ exit(0);
+}
diff --git a/tools/tools/upgrade/doupgrade.sh b/tools/tools/upgrade/doupgrade.sh
new file mode 100755
index 0000000..9fa73ec
--- /dev/null
+++ b/tools/tools/upgrade/doupgrade.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# Simple helper script for upgrade target.
+
+# Expects MACHINE to be passed in with the environment, the "pass number"
+# as the first argument the name of the file to leave its droppings in
+# as the second. CURDIR is also passed in the environment from ${.CURDIR}
+
+PASS=$1
+CONF=$2
+
+cd ${CURDIR}/sys/${MACHINE}/conf
+
+# Create kernel configuration file for pass #1
+if [ $PASS -eq 1 ]; then
+ echo "The following files are in ${CURDIR}/sys/${MACHINE}/conf:"; echo
+ ls -C
+ echo; echo -n "Which config file do you wish to use? [GENERIC] "
+ read answer
+ if [ -z "${answer}" ]; then
+ KERN=GENERIC
+ else
+ KERN="${answer}"
+ fi
+ if [ ! -f ${KERN} ]; then
+ KERN=GENERIC
+ fi
+ if ! grep -q atkbdc0 ${KERN}; then
+ if [ ! -f ${KERN}.bkup ]; then
+ cp ${KERN} ${KERN}.bkup
+ fi
+ sed -e 's/^device.*sc0.*$/ \
+controller atkbdc0 at isa? port IO_KBD tty \
+device atkbd0 at isa? tty irq 1 \
+device vga0 at isa? port ? conflicts \
+device sc0 at isa? tty \
+pseudo-device splash \
+/' -e 's/sd\([0-9]\)/da\1/' -e 's/st\([0-9]\)/sa\1/' < ${KERN}.bkup > ${KERN}
+ fi
+
+ ROOTDEV=`awk '$2~/\/$/{print substr($1, 6, 3)}' /etc/fstab`
+ echo -n "What is your boot device (e.g. wd0 or sd0)? [${ROOTDEV}] "
+ read answer
+ if [ -n "${answer}" ]; then
+ ROOTDEV="${answer}"
+ fi
+ echo "KERNEL=${KERN}" > ${CONF}
+ echo "ROOTDEV=${ROOTDEV}" >> ${CONF}
+ if ! file /kernel | grep -q ELF; then
+ echo "NEWBOOT=YES" >> ${CONF}
+ fi
+fi
+
+# Build and install kernel as pass #2
+if [ $PASS -eq 2 -a -f ${CONF} ]; then
+ . ${CONF}
+ if [ "x${NEWBOOT}" = "xYES" ]; then
+ echo "--------------------------------------------------------------"
+ echo " Installing new boot blocks"
+ echo "--------------------------------------------------------------"
+ if [ ! -f /boot/loader ]; then
+ (cd ${CURDIR}/lib/libstand; make obj; make -B depend all install)
+ (cd ${CURDIR}/sys/boot; make obj; make -B depend all install)
+ fi
+ if ! disklabel -B ${ROOTDEV}; then
+ echo "Installation of new boot blocks failed! Please correct"
+ echo "this manually BEFORE you reboot your system!"
+ exit 1
+ fi
+ fi
+ if ! file /kernel | grep -q ELF; then
+ echo "--------------------------------------------------------------"
+ echo " Building an elf kernel for ${KERNEL} using the new tools"
+ echo "--------------------------------------------------------------"
+ config -r ${KERNEL}
+ cd ${CURDIR}/sys/compile/${KERNEL} && make -B depend -DFORCE all install
+ fi
+fi
diff --git a/tools/tools/upgrade/getosreldate.sh b/tools/tools/upgrade/getosreldate.sh
new file mode 100755
index 0000000..3c95648
--- /dev/null
+++ b/tools/tools/upgrade/getosreldate.sh
@@ -0,0 +1,8 @@
+#! /bin/sh
+# $FreeBSD$
+
+RELDATE=`sysctl -n kern.osreldate 2>/dev/null`
+if [ "x$RELDATE" = x ]; then
+ RELDATE=200000 # assume something really old
+fi
+echo $RELDATE
diff --git a/tools/tools/upgrade/move_aout_libs.sh b/tools/tools/upgrade/move_aout_libs.sh
new file mode 100755
index 0000000..e525200
--- /dev/null
+++ b/tools/tools/upgrade/move_aout_libs.sh
@@ -0,0 +1,139 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+# Search for a.out libraries and move them to an aout subdirectory of
+# the elf library directory.
+#
+# The arguments are the directories to search.
+#
+libdirs="$*"
+
+# Create a temporary tool to get the timestamp of libraries. No, I don't
+# want to use perl or whatever.
+create_get_time_stamp ( )
+{
+ echo "#include <stdio.h>" > /tmp/get_time_stamp.c
+ echo "#include <sys/stat.h>" >> /tmp/get_time_stamp.c
+ echo "int main(int argc, char *argv[]) {" >> /tmp/get_time_stamp.c
+ echo "int ierr; struct stat fs;" >> /tmp/get_time_stamp.c
+ echo "if ((ierr = stat(argv[1],&fs)) == 0)" >> /tmp/get_time_stamp.c
+ echo "printf(\"%ld\n\",(long) fs.st_mtime);" >> /tmp/get_time_stamp.c
+ echo "return (ierr); }" >> /tmp/get_time_stamp.c
+ gcc -o /tmp/get_time_stamp /tmp/get_time_stamp.c
+ rm /tmp/get_time_stamp.c
+ return
+}
+
+# Move an a.out library to the aout subdirectory of the elf directory.
+move_file ( )
+{
+ if test -d $dir/aout; then
+ else
+ echo "Creating directory $dir/aout"
+ mkdir $dir/aout
+ ldconfig -m $dir/aout
+ fi
+ fname=${file#$dir/}
+ if test -f $dir/aout/$fname; then
+ if test -x /tmp/get_time_stamp; then
+ else
+ create_get_time_stamp
+ fi
+ t1=`/tmp/get_time_stamp $dir/aout/$fname`
+ t2=`/tmp/get_time_stamp $file`
+ if test $t1 -gt $t2; then
+ echo $file is older than $dir/aout/$fname
+ answer=""
+ while test "$answer" != "y" -a "$answer" != "n"; do
+ read -p "OK to delete the older file? (y/n) " answer
+ done
+ if test $answer = "y"; then
+ echo Deleting $file
+ chflags noschg $file
+ rm $file
+ else
+ echo "You need to move $file out of $dir because that's an elf directory"
+ fi
+ else
+ echo $dir/aout/$fname is older than $file
+ answer=""
+ while test "$answer" != "y" -a "$answer" != "n"; do
+ read -p "OK to overwrite the older file? (y/n) " answer
+ done
+ if test $answer = "y"; then
+ echo Overwriting $dir/aout/$fname with $file
+ chflags noschg $file
+ mv $file $dir/aout/$fname
+ ldconfig -R
+ else
+ echo "You need to move $file out of $dir because that's an elf directory"
+ fi
+ fi
+ else
+ echo Move $fname from $dir to $dir/aout
+ chflags noschg $file
+ mv $file $dir/aout/$fname
+ ldconfig -R
+ fi
+ return
+}
+
+# Given a list of files in a directory, find those that are a.out
+# libraries and move them.
+move_if_aout ( )
+{
+ # Check each library
+ for file in $files
+ do
+ # Don't touch symbolic links yet. It's not clear how
+ # they should be handled.
+ if test -L $file; then
+ else
+ # Check that this is a normal file.
+ if test -f $file; then
+ # Identify the file by magic
+ filemagic=`file $file`
+
+ # Check if the file is an a.out library
+ if expr "$filemagic" : ".*$aoutmagic"; then
+ # Move the a.out library
+ move_file
+ fi
+ fi
+ fi
+ done
+ return
+}
+
+# Only search the directories specified.
+for dir in $libdirs
+do
+ # Make sure the directory exists, or ldconfig will choke later.
+ mkdir -p $dir $dir/aout
+
+ echo "Searching library directory $dir for a.out libraries..."
+
+ # Get a list of archive libraries.
+ files=`ls $dir/*.a 2> /dev/null`
+
+ # a.out archive libraries look like this:
+ aoutmagic="current ar archive random library"
+
+ # Move each a.out archive library:
+ move_if_aout
+
+ # Get a list of shared libraries
+ files=`ls $dir/*.so.*.* 2> /dev/null`
+
+ # a.out shared libraries look like this:
+ aoutmagic="FreeBSD/i386 compact demand paged shared library"
+
+ # Move each a.out shared library:
+ move_if_aout
+done
+
+# If we created the time stamp program, delete it:
+if test -x /tmp/get_time_stamp; then
+ rm /tmp/get_time_stamp
+fi
diff --git a/tools/tools/vop_table/README b/tools/tools/vop_table/README
new file mode 100644
index 0000000..16cb1f7
--- /dev/null
+++ b/tools/tools/vop_table/README
@@ -0,0 +1,2 @@
+vop_table generates a HTML document that shows all the VOP's in
+the kernel.
diff --git a/tools/tools/vop_table/vop_table.tcl b/tools/tools/vop_table/vop_table.tcl
new file mode 100644
index 0000000..1b76d18
--- /dev/null
+++ b/tools/tools/vop_table/vop_table.tcl
@@ -0,0 +1,213 @@
+#!/usr/local/bin/tclsh8.3
+# $FreeBSD$
+
+set fo [open _.html w]
+
+proc do_file {file} {
+ global names ops op
+ set f [open $file]
+
+ set s 0
+
+ while {[gets $f a] >= 0} {
+ if {$s == 0} {
+ if {[regexp {struct[ ]*vnodeopv_entry_desc} "$a"]} {
+ regsub {.*vnodeopv_entry_desc[ ]*} $a {} a
+ regsub {\[.*} $a {} a
+ regsub {_entries} $a {} a
+ set name $a
+ set names($a) 0
+ set s 1
+ }
+ continue
+ }
+ if {$s == 1} {
+ if {[regexp {NULL} "$a"]} {
+ set s 0
+ continue
+ }
+ if {![regexp {vop.*_desc} "$a"]} continue
+ regsub -all {[,&]} $a " " a
+ regsub -all {\(vop_t \*\)} $a " " a
+ set b [lindex $a 0]
+ if {"$b" == "/*"} {
+ set s 0
+ continue
+ }
+ #puts "$name>> [lindex $b 0] >> [lindex $b 3]"
+ set o [lindex $b 0]
+ regsub {_desc} $o "" o
+ set ops($o) 0
+ set op([list $name $o]) [lindex $b 1]
+ continue
+ }
+ puts "$s>> $a"
+ }
+ close $f
+}
+
+set fi [open "|find /usr/src/sys -type f -name *.c -print | xargs grep VNODEOP_SET" ]
+while {[gets $fi a] >= 0} {
+ puts stderr $a
+ if {[regexp {#define} $a]} continue
+ if {[regexp {mallocfs} $a]} continue
+ do_file [lindex [split $a :] 0]
+}
+close $fi
+
+puts $fo {<HTML>
+<HEAD></HEAD><BODY>
+<TABLE BORDER WIDTH="100%" NOSAVE>
+}
+
+set opn [lsort [array names ops]]
+set a [lsort [array names names]]
+
+set tbn default_vnodeop
+foreach i $a {
+ if {$i == "default_vnodeop"} continue
+ lappend tbn $i
+}
+
+foreach i $opn {
+ if {$i == "vop_default"} continue
+ regsub "vop_" $i "" i
+ lappend fl [format "%12s" $i]
+}
+
+lappend fl [format "%12s" default]
+
+puts $fo {<TR>}
+puts $fo {<TD>}
+puts $fo {</TD>}
+puts $fo "<TR>"
+ puts $fo "<TD></TD>"
+ foreach j $fl {
+ puts $fo "<TD>"
+
+ for {set i 0} {$i < 12} {incr i} {
+ puts $fo "[string index $j $i]<BR>"
+ }
+ puts $fo "</TD>"
+ }
+puts $fo "</TR>"
+
+set fnames(vop_defaultop) *
+
+set fnames(vop_null) -
+set fnames(vop_ebadf) b
+set fnames(vop_einval) i
+set fnames(vop_enotty) t
+set fnames(vop_panic) !
+set fnames(vfs_cache_lookup) C
+set fnames(vop_eopnotsupp) *
+
+set fn 0
+set nop(aa) 0
+unset nop(aa)
+foreach i $tbn {
+ puts $fo {<TR>}
+ puts $fo "<TD>$i</TD>"
+ set pfx [lindex [split $i _] 0]
+ foreach j $opn {
+ if {$j == "vop_default"} continue
+ set sfx [lindex [split $j _] 1]
+ if {![info exists op([list $i $j])]} {
+ puts $fo "<TD BGCOLOR=\"#d0d0d0\"></TD>"
+ continue
+ }
+ set t $op([list $i $j])
+
+ set c "#00ddd0"
+ if {[info exists fnames($t)]} {
+ set t $fnames($t)
+ } elseif { $t == "${pfx}_${sfx}" } {
+ set t "F"
+ } elseif { $t == "vop_${sfx}" } {
+ set t "V"
+ } elseif { $t == "vop_no${sfx}" } {
+ set t "N"
+ } elseif { $t == "vop_std${sfx}" } {
+ set t "S"
+ } elseif { $sfx == "cachedlookup" && $t == "${pfx}_lookup" } {
+ set t "L"
+ } else {
+ if {![info exists nop($t)]} {
+ incr fn
+ set nop($t) $fn
+ set nfn($fn) $t
+ set use($fn) 0
+ }
+ incr use($nop($t))
+ set t "<FONT SIZE=-1>$nop($t)</FONT>"
+ set c "#ffff00"
+ }
+ puts $fo "<TD BGCOLOR=\"$c\">$t</TD>"
+ }
+ set j vop_default
+ if {![info exists op([list $i $j])]} {
+ puts $fo "<TD></TD>"
+ continue
+ }
+ puts $fo "<TD>$op([list $i $j])</TD>"
+
+ puts $fo "</TR>"
+}
+puts $fo "</TABLE>"
+puts $fo "<HR>"
+puts $fo {<PRE>}
+foreach i [lsort [array names fnames]] {
+ puts $fo [format "%-2s %s" $fnames($i) $i]
+}
+puts $fo [format "%-2s %s" "F" "<fs>_<vop>"]
+puts $fo [format "%-2s %s" "V" "vop_<vop>"]
+puts $fo [format "%-2s %s" "N" "vop_no<vop>"]
+puts $fo [format "%-2s %s" "S" "vop_std<vop>"]
+puts $fo [format "%-2s %s" "L" "<fs>_lookup"]
+puts $fo {
+</PRE>
+}
+puts $fo "<HR>"
+puts $fo {<TABLE BORDER NOSAVE>}
+set m 8
+for {set i 1} {$i <= $fn} {incr i $m} {
+ puts $fo "<TR>"
+ for {set j 0} {$j < $m} {incr j} {
+ set k [expr $i + $j]
+ if {$k <= $fn} {
+ #puts $fo "<TD>$k</TD><TD><FONT SIZE=-1>$nfn($k)/$use($k)</FONT></TD>"
+ puts $fo "<TD>$k</TD><TD><FONT SIZE=-1>$nfn($k)</FONT></TD>"
+ }
+ }
+ puts $fo "</TR>"
+}
+puts $fo "</TABLE>"
+
+puts $fo "</TABLE>"
+puts $fo "</BODY>"
+puts $fo "</HTML>"
+foreach i $tbn {
+ if {$i == "default_vnodeop"} {
+ continue
+ }
+ foreach j $opn {
+ set sfx [lindex [split $j _] 1]
+ if {![info exists op([list $i $j])]} {
+ continue
+ }
+ set v $op([list $i $j])
+ if {$v != "vop_std$sfx"} {
+ continue
+ }
+ if {![info exists op([list default_vnodeop $j])]} {
+ continue
+ }
+ if {$op([list default_vnodeop $j]) != $v} {
+ continue
+ }
+ if {$op([list $i vop_default]) != "vop_defaultop"} {
+ continue
+ }
+ puts "Suspect: uses explicit default, $i $j $v $op([list $i vop_default])"
+ }
+}
diff --git a/tools/tools/whereintheworld/Makefile b/tools/tools/whereintheworld/Makefile
new file mode 100644
index 0000000..876a318
--- /dev/null
+++ b/tools/tools/whereintheworld/Makefile
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+SCRIPTS= whereintheworld.pl
+
+.include <bsd.prog.mk>
diff --git a/tools/tools/whereintheworld/whereintheworld.pl b/tools/tools/whereintheworld/whereintheworld.pl
new file mode 100644
index 0000000..6a8e21e
--- /dev/null
+++ b/tools/tools/whereintheworld/whereintheworld.pl
@@ -0,0 +1,69 @@
+#!/usr/bin/perl -w
+#
+# whereintheworld
+# Parses "make world" output and summarize where it's been so far.
+#
+# Bill Fenner <fenner@freebsd.org> 11 January 2000
+# Dag-Erling Smørgrav <des@freebsd.org> 09 January 2003
+#
+# $Id: whereintheworld,v 1.3 2000/01/28 00:42:32 fenner Exp $
+# $FreeBSD$
+#
+
+use strict;
+
+my $line;
+my $inside = 0;
+my @lines = ();
+my $thresh = 10;
+my $lastwasdash = 0;
+my $width = $ENV{COLUMNS} || 80;
+my $error = 0;
+my $elided = 0;
+
+while ($line = <>) {
+ if ($line =~ /^------------/) {
+ $inside = !$inside;
+ print $line unless ($lastwasdash);
+ $lastwasdash = 1;
+ @lines = ();
+ next;
+ }
+ if ($inside && $line =~ /^>>>/) {
+ print $line;
+ $lastwasdash = 0;
+ next;
+ }
+ if ($line =~ /^TB /) {
+ print $line;
+ next;
+ }
+ if ($line =~ /^=+>/) {
+ @lines = ();
+ }
+ push(@lines, $line);
+ if ($line =~ /^\*\*\* Error/ && $line !~ /\(ignored\)/) {
+ $error = 1;
+ while ($line = <>) {
+ push(@lines, $line);
+ }
+ last;
+ }
+}
+
+if (@lines && !$error) {
+ print shift(@lines);
+ while (@lines > $thresh) {
+ shift(@lines);
+ ++$elided;
+ }
+ if ($elided > 0) {
+ print "[$elided lines elided]\n";
+ }
+}
+foreach $line (@lines) {
+ if (!$error && $line !~ m/^TB / && length($line) >= $width) {
+ substr($line, $width - 7) = " [...]\n";
+ }
+ print $line;
+}
OpenPOWER on IntegriCloud