From 5e1a84ab74d5e97582427f016f291a8c11e66f99 Mon Sep 17 00:00:00 2001 From: jutteau Date: Fri, 11 May 2007 18:10:19 +0000 Subject: Completion du script de mise à jour de la pc-104 : * Ajout des sources de busybox dans ./conf/busybox/ * Ajout d'un fichier réclamé par les script dans ./conf/busybox.links --- i/pc104/initrd/conf/busybox.links | 18 + i/pc104/initrd/conf/busybox/AUTHORS | 173 + i/pc104/initrd/conf/busybox/Config.in | 496 + i/pc104/initrd/conf/busybox/INSTALL | 125 + i/pc104/initrd/conf/busybox/LICENSE | 348 + i/pc104/initrd/conf/busybox/Makefile | 1280 ++ i/pc104/initrd/conf/busybox/Makefile.custom | 145 + i/pc104/initrd/conf/busybox/Makefile.flags | 61 + i/pc104/initrd/conf/busybox/Makefile.help | 42 + i/pc104/initrd/conf/busybox/README | 198 + i/pc104/initrd/conf/busybox/TODO | 320 + i/pc104/initrd/conf/busybox/applets/Kbuild | 22 + i/pc104/initrd/conf/busybox/applets/applets.c | 495 + i/pc104/initrd/conf/busybox/applets/busybox.c | 147 + i/pc104/initrd/conf/busybox/applets/busybox.mkll | 24 + i/pc104/initrd/conf/busybox/applets/individual.c | 27 + i/pc104/initrd/conf/busybox/applets/install.sh | 94 + i/pc104/initrd/conf/busybox/applets/usage.c | 17 + .../initrd/conf/busybox/applets/usage_compressed | 19 + i/pc104/initrd/conf/busybox/arch/i386/Makefile | 5 + i/pc104/initrd/conf/busybox/archival/Config.in | 300 + i/pc104/initrd/conf/busybox/archival/Kbuild | 22 + i/pc104/initrd/conf/busybox/archival/ar.c | 94 + i/pc104/initrd/conf/busybox/archival/bbunzip.c | 355 + i/pc104/initrd/conf/busybox/archival/cpio.c | 87 + i/pc104/initrd/conf/busybox/archival/dpkg.c | 1754 +++ i/pc104/initrd/conf/busybox/archival/dpkg_deb.c | 97 + i/pc104/initrd/conf/busybox/archival/gzip.c | 2085 +++ .../conf/busybox/archival/libunarchive/Kbuild | 59 + .../archival/libunarchive/archive_xread_all_eof.c | 20 + .../archival/libunarchive/check_header_gzip.c | 59 + .../busybox/archival/libunarchive/data_align.c | 17 + .../archival/libunarchive/data_extract_all.c | 127 + .../archival/libunarchive/data_extract_to_buffer.c | 17 + .../archival/libunarchive/data_extract_to_stdout.c | 13 + .../conf/busybox/archival/libunarchive/data_skip.c | 16 + .../archival/libunarchive/decompress_bunzip2.c | 731 + .../archival/libunarchive/decompress_uncompress.c | 308 + .../archival/libunarchive/decompress_unlzma.c | 497 + .../archival/libunarchive/decompress_unzip.c | 1104 ++ .../archival/libunarchive/filter_accept_all.c | 17 + .../archival/libunarchive/filter_accept_list.c | 19 + .../libunarchive/filter_accept_list_reassign.c | 44 + .../libunarchive/filter_accept_reject_list.c | 33 + .../archival/libunarchive/find_list_entry.c | 54 + .../busybox/archival/libunarchive/get_header_ar.c | 126 + .../archival/libunarchive/get_header_cpio.c | 160 + .../busybox/archival/libunarchive/get_header_tar.c | 284 + .../archival/libunarchive/get_header_tar_bz2.c | 20 + .../archival/libunarchive/get_header_tar_gz.c | 31 + .../archival/libunarchive/get_header_tar_lzma.c | 22 + .../busybox/archival/libunarchive/header_list.c | 11 + .../busybox/archival/libunarchive/header_skip.c | 10 + .../archival/libunarchive/header_verbose_list.c | 31 + .../busybox/archival/libunarchive/init_handle.c | 22 + .../archival/libunarchive/open_transformer.c | 44 + .../busybox/archival/libunarchive/seek_by_jump.c | 24 + .../busybox/archival/libunarchive/seek_by_read.c | 18 + .../archival/libunarchive/unpack_ar_archive.c | 22 + i/pc104/initrd/conf/busybox/archival/rpm.c | 367 + i/pc104/initrd/conf/busybox/archival/rpm2cpio.c | 90 + i/pc104/initrd/conf/busybox/archival/tar.c | 939 ++ i/pc104/initrd/conf/busybox/archival/unzip.c | 376 + i/pc104/initrd/conf/busybox/busybox | Bin 0 -> 573272 bytes i/pc104/initrd/conf/busybox/busybox.links | 18 + .../initrd/conf/busybox/console-tools/Config.in | 105 + i/pc104/initrd/conf/busybox/console-tools/Kbuild | 19 + i/pc104/initrd/conf/busybox/console-tools/chvt.c | 34 + i/pc104/initrd/conf/busybox/console-tools/clear.c | 22 + .../initrd/conf/busybox/console-tools/deallocvt.c | 38 + .../initrd/conf/busybox/console-tools/dumpkmap.c | 66 + .../initrd/conf/busybox/console-tools/loadfont.c | 194 + .../initrd/conf/busybox/console-tools/loadkmap.c | 62 + i/pc104/initrd/conf/busybox/console-tools/openvt.c | 43 + i/pc104/initrd/conf/busybox/console-tools/reset.c | 33 + i/pc104/initrd/conf/busybox/console-tools/resize.c | 70 + .../initrd/conf/busybox/console-tools/setconsole.c | 48 + .../conf/busybox/console-tools/setkeycodes.c | 50 + .../initrd/conf/busybox/console-tools/setlogcons.c | 32 + i/pc104/initrd/conf/busybox/coreutils/Config.in | 782 ++ i/pc104/initrd/conf/busybox/coreutils/Kbuild | 85 + i/pc104/initrd/conf/busybox/coreutils/basename.c | 51 + i/pc104/initrd/conf/busybox/coreutils/cal.c | 352 + i/pc104/initrd/conf/busybox/coreutils/cat.c | 43 + i/pc104/initrd/conf/busybox/coreutils/catv.c | 70 + i/pc104/initrd/conf/busybox/coreutils/chgrp.c | 28 + i/pc104/initrd/conf/busybox/coreutils/chmod.c | 159 + i/pc104/initrd/conf/busybox/coreutils/chown.c | 167 + i/pc104/initrd/conf/busybox/coreutils/chroot.c | 38 + i/pc104/initrd/conf/busybox/coreutils/cksum.c | 54 + i/pc104/initrd/conf/busybox/coreutils/cmp.c | 145 + i/pc104/initrd/conf/busybox/coreutils/comm.c | 127 + i/pc104/initrd/conf/busybox/coreutils/cp.c | 100 + i/pc104/initrd/conf/busybox/coreutils/cut.c | 287 + i/pc104/initrd/conf/busybox/coreutils/date.c | 241 + i/pc104/initrd/conf/busybox/coreutils/dd.c | 249 + i/pc104/initrd/conf/busybox/coreutils/df.c | 155 + i/pc104/initrd/conf/busybox/coreutils/diff.c | 1227 ++ i/pc104/initrd/conf/busybox/coreutils/dirname.c | 27 + i/pc104/initrd/conf/busybox/coreutils/dos2unix.c | 116 + i/pc104/initrd/conf/busybox/coreutils/du.c | 247 + i/pc104/initrd/conf/busybox/coreutils/echo.c | 159 + i/pc104/initrd/conf/busybox/coreutils/env.c | 128 + i/pc104/initrd/conf/busybox/coreutils/expr.c | 506 + i/pc104/initrd/conf/busybox/coreutils/false.c | 20 + i/pc104/initrd/conf/busybox/coreutils/fold.c | 155 + i/pc104/initrd/conf/busybox/coreutils/head.c | 140 + i/pc104/initrd/conf/busybox/coreutils/hostid.c | 26 + i/pc104/initrd/conf/busybox/coreutils/id.c | 130 + i/pc104/initrd/conf/busybox/coreutils/install.c | 202 + i/pc104/initrd/conf/busybox/coreutils/length.c | 20 + .../conf/busybox/coreutils/libcoreutils/Kbuild | 12 + .../busybox/coreutils/libcoreutils/coreutils.h | 16 + .../busybox/coreutils/libcoreutils/cp_mv_stat.c | 43 + .../coreutils/libcoreutils/getopt_mk_fifo_nod.c | 51 + i/pc104/initrd/conf/busybox/coreutils/ln.c | 105 + i/pc104/initrd/conf/busybox/coreutils/logname.c | 43 + i/pc104/initrd/conf/busybox/coreutils/ls.c | 957 ++ .../initrd/conf/busybox/coreutils/md5_sha1_sum.c | 185 + i/pc104/initrd/conf/busybox/coreutils/mkdir.c | 82 + i/pc104/initrd/conf/busybox/coreutils/mkfifo.c | 39 + i/pc104/initrd/conf/busybox/coreutils/mknod.c | 51 + i/pc104/initrd/conf/busybox/coreutils/mv.c | 137 + i/pc104/initrd/conf/busybox/coreutils/nice.c | 55 + i/pc104/initrd/conf/busybox/coreutils/nohup.c | 60 + i/pc104/initrd/conf/busybox/coreutils/od.c | 225 + i/pc104/initrd/conf/busybox/coreutils/od_bloaty.c | 1465 ++ i/pc104/initrd/conf/busybox/coreutils/printenv.c | 42 + i/pc104/initrd/conf/busybox/coreutils/printf.c | 313 + i/pc104/initrd/conf/busybox/coreutils/pwd.c | 26 + i/pc104/initrd/conf/busybox/coreutils/realpath.c | 47 + i/pc104/initrd/conf/busybox/coreutils/rm.c | 53 + i/pc104/initrd/conf/busybox/coreutils/rmdir.c | 61 + i/pc104/initrd/conf/busybox/coreutils/seq.c | 41 + i/pc104/initrd/conf/busybox/coreutils/sleep.c | 68 + i/pc104/initrd/conf/busybox/coreutils/sort.c | 401 + i/pc104/initrd/conf/busybox/coreutils/stat.c | 676 + i/pc104/initrd/conf/busybox/coreutils/stty.c | 1189 ++ i/pc104/initrd/conf/busybox/coreutils/sum.c | 100 + i/pc104/initrd/conf/busybox/coreutils/sync.c | 24 + i/pc104/initrd/conf/busybox/coreutils/tail.c | 278 + i/pc104/initrd/conf/busybox/coreutils/tee.c | 101 + i/pc104/initrd/conf/busybox/coreutils/test.c | 586 + i/pc104/initrd/conf/busybox/coreutils/touch.c | 62 + i/pc104/initrd/conf/busybox/coreutils/tr.c | 254 + i/pc104/initrd/conf/busybox/coreutils/true.c | 20 + i/pc104/initrd/conf/busybox/coreutils/tty.c | 44 + i/pc104/initrd/conf/busybox/coreutils/uname.c | 108 + i/pc104/initrd/conf/busybox/coreutils/uniq.c | 104 + i/pc104/initrd/conf/busybox/coreutils/usleep.c | 29 + i/pc104/initrd/conf/busybox/coreutils/uudecode.c | 181 + i/pc104/initrd/conf/busybox/coreutils/uuencode.c | 76 + i/pc104/initrd/conf/busybox/coreutils/watch.c | 80 + i/pc104/initrd/conf/busybox/coreutils/wc.c | 205 + i/pc104/initrd/conf/busybox/coreutils/who.c | 76 + i/pc104/initrd/conf/busybox/coreutils/whoami.c | 26 + i/pc104/initrd/conf/busybox/coreutils/yes.c | 42 + i/pc104/initrd/conf/busybox/debianutils/Config.in | 88 + i/pc104/initrd/conf/busybox/debianutils/Kbuild | 13 + i/pc104/initrd/conf/busybox/debianutils/mktemp.c | 49 + .../conf/busybox/debianutils/pipe_progress.c | 43 + i/pc104/initrd/conf/busybox/debianutils/readlink.c | 52 + .../initrd/conf/busybox/debianutils/run_parts.c | 192 + .../conf/busybox/debianutils/start_stop_daemon.c | 330 + i/pc104/initrd/conf/busybox/debianutils/which.c | 48 + i/pc104/initrd/conf/busybox/docs/autodocifier.pl | 303 + .../initrd/conf/busybox/docs/busybox.net/FAQ.html | 1108 ++ .../conf/busybox/docs/busybox.net/about.html | 24 + .../busybox/docs/busybox.net/busybox-growth.ps | 404 + .../conf/busybox/docs/busybox.net/copyright.txt | 30 + .../conf/busybox/docs/busybox.net/developer.html | 69 + .../conf/busybox/docs/busybox.net/download.html | 29 + .../conf/busybox/docs/busybox.net/footer.html | 47 + .../conf/busybox/docs/busybox.net/header.html | 96 + .../conf/busybox/docs/busybox.net/images/back.png | Bin 0 -> 322 bytes .../busybox/docs/busybox.net/images/busybox.jpeg | Bin 0 -> 9023 bytes .../busybox/docs/busybox.net/images/busybox.png | Bin 0 -> 34014 bytes .../busybox/docs/busybox.net/images/busybox1.png | Bin 0 -> 10913 bytes .../busybox/docs/busybox.net/images/busybox2.jpg | Bin 0 -> 8204 bytes .../busybox/docs/busybox.net/images/busybox3.jpg | Bin 0 -> 3292 bytes .../conf/busybox/docs/busybox.net/images/dir.png | Bin 0 -> 309 bytes .../busybox/docs/busybox.net/images/donate.png | Bin 0 -> 807 bytes .../busybox/docs/busybox.net/images/fm.mini.png | Bin 0 -> 7708 bytes .../docs/busybox.net/images/gfx_by_gimp.png | Bin 0 -> 3955 bytes .../busybox/docs/busybox.net/images/ltbutton2.png | Bin 0 -> 6798 bytes .../busybox/docs/busybox.net/images/osuosl.png | Bin 0 -> 8683 bytes .../busybox/docs/busybox.net/images/sdsmall.png | Bin 0 -> 1593 bytes .../conf/busybox/docs/busybox.net/images/text.png | Bin 0 -> 307 bytes .../docs/busybox.net/images/valid-html401.png | Bin 0 -> 1950 bytes .../conf/busybox/docs/busybox.net/images/vh40.gif | Bin 0 -> 906 bytes .../docs/busybox.net/images/written.in.vi.png | Bin 0 -> 4394 bytes .../conf/busybox/docs/busybox.net/index.html | 1 + .../conf/busybox/docs/busybox.net/license.html | 97 + .../conf/busybox/docs/busybox.net/links.html | 19 + .../conf/busybox/docs/busybox.net/lists.html | 46 + .../initrd/conf/busybox/docs/busybox.net/news.html | 252 + .../conf/busybox/docs/busybox.net/oldnews.html | 1140 ++ .../conf/busybox/docs/busybox.net/products.html | 170 + .../conf/busybox/docs/busybox.net/screenshot.html | 62 + .../conf/busybox/docs/busybox.net/shame.html | 82 + .../conf/busybox/docs/busybox.net/sponsors.html | 35 + .../conf/busybox/docs/busybox.net/subversion.html | 52 + .../conf/busybox/docs/busybox.net/tinyutils.html | 86 + .../initrd/conf/busybox/docs/busybox_footer.pod | 258 + .../initrd/conf/busybox/docs/busybox_header.pod | 82 + i/pc104/initrd/conf/busybox/docs/cgi/cl.html | 46 + i/pc104/initrd/conf/busybox/docs/cgi/env.html | 149 + i/pc104/initrd/conf/busybox/docs/cgi/in.html | 33 + .../initrd/conf/busybox/docs/cgi/interface.html | 29 + i/pc104/initrd/conf/busybox/docs/cgi/out.html | 126 + i/pc104/initrd/conf/busybox/docs/contributing.txt | 449 + .../busybox/docs/draft-coar-cgi-v11-03-clean.html | 2674 ++++ i/pc104/initrd/conf/busybox/docs/ipv4_ipv6.txt | 223 + .../initrd/conf/busybox/docs/keep_data_small.txt | 206 + i/pc104/initrd/conf/busybox/docs/mdev.txt | 68 + .../initrd/conf/busybox/docs/new-applet-HOWTO.txt | 151 + i/pc104/initrd/conf/busybox/docs/sigint.htm | 627 + i/pc104/initrd/conf/busybox/docs/style-guide.txt | 689 + i/pc104/initrd/conf/busybox/docs/tar_pax.txt | 239 + i/pc104/initrd/conf/busybox/e2fsprogs/Config.in | 67 + i/pc104/initrd/conf/busybox/e2fsprogs/Kbuild | 12 + i/pc104/initrd/conf/busybox/e2fsprogs/README | 12 + i/pc104/initrd/conf/busybox/e2fsprogs/chattr.c | 190 + i/pc104/initrd/conf/busybox/e2fsprogs/e2fs_defs.h | 561 + i/pc104/initrd/conf/busybox/e2fsprogs/e2fs_lib.c | 197 + i/pc104/initrd/conf/busybox/e2fsprogs/e2fs_lib.h | 30 + i/pc104/initrd/conf/busybox/e2fsprogs/fsck.c | 1243 ++ i/pc104/initrd/conf/busybox/e2fsprogs/lsattr.c | 115 + .../conf/busybox/e2fsprogs/old_e2fsprogs/Config.in | 67 + .../conf/busybox/e2fsprogs/old_e2fsprogs/Kbuild | 16 + .../conf/busybox/e2fsprogs/old_e2fsprogs/README | 3 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/Kbuild | 23 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/blkid.h | 105 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/blkidP.h | 187 + .../e2fsprogs/old_e2fsprogs/blkid/blkid_getsize.c | 179 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/cache.c | 126 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/dev.c | 214 + .../e2fsprogs/old_e2fsprogs/blkid/devname.c | 367 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/devno.c | 222 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/list.c | 110 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/list.h | 73 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/probe.c | 721 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/probe.h | 375 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/read.c | 461 + .../e2fsprogs/old_e2fsprogs/blkid/resolve.c | 139 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/save.c | 189 + .../busybox/e2fsprogs/old_e2fsprogs/blkid/tag.c | 432 + .../conf/busybox/e2fsprogs/old_e2fsprogs/chattr.c | 220 + .../conf/busybox/e2fsprogs/old_e2fsprogs/e2fsbb.h | 43 + .../conf/busybox/e2fsprogs/old_e2fsprogs/e2fsck.c | 13548 +++++++++++++++++++ .../conf/busybox/e2fsprogs/old_e2fsprogs/e2fsck.h | 640 + .../busybox/e2fsprogs/old_e2fsprogs/e2p/Kbuild | 15 + .../conf/busybox/e2fsprogs/old_e2fsprogs/e2p/e2p.h | 64 + .../busybox/e2fsprogs/old_e2fsprogs/e2p/feature.c | 187 + .../e2fsprogs/old_e2fsprogs/e2p/fgetsetflags.c | 70 + .../e2fsprogs/old_e2fsprogs/e2p/fgetsetversion.c | 70 + .../busybox/e2fsprogs/old_e2fsprogs/e2p/hashstr.c | 70 + .../conf/busybox/e2fsprogs/old_e2fsprogs/e2p/iod.c | 52 + .../conf/busybox/e2fsprogs/old_e2fsprogs/e2p/ls.c | 273 + .../busybox/e2fsprogs/old_e2fsprogs/e2p/mntopts.c | 134 + .../busybox/e2fsprogs/old_e2fsprogs/e2p/ostype.c | 74 + .../e2fsprogs/old_e2fsprogs/e2p/parse_num.c | 65 + .../conf/busybox/e2fsprogs/old_e2fsprogs/e2p/pe.c | 32 + .../conf/busybox/e2fsprogs/old_e2fsprogs/e2p/pf.c | 74 + .../conf/busybox/e2fsprogs/old_e2fsprogs/e2p/ps.c | 27 + .../busybox/e2fsprogs/old_e2fsprogs/e2p/uuid.c | 78 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/Kbuild | 23 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/alloc.c | 174 + .../e2fsprogs/old_e2fsprogs/ext2fs/alloc_sb.c | 58 + .../e2fsprogs/old_e2fsprogs/ext2fs/alloc_stats.c | 53 + .../e2fsprogs/old_e2fsprogs/ext2fs/alloc_tables.c | 118 + .../e2fsprogs/old_e2fsprogs/ext2fs/badblocks.c | 328 + .../e2fsprogs/old_e2fsprogs/ext2fs/bb_compat.c | 64 + .../e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c | 268 + .../e2fsprogs/old_e2fsprogs/ext2fs/bitmaps.c | 211 + .../e2fsprogs/old_e2fsprogs/ext2fs/bitops.c | 91 + .../e2fsprogs/old_e2fsprogs/ext2fs/bitops.h | 107 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/block.c | 438 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/bmap.c | 264 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/bmove.c | 156 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/brel.h | 87 + .../e2fsprogs/old_e2fsprogs/ext2fs/brel_ma.c | 196 + .../e2fsprogs/old_e2fsprogs/ext2fs/check_desc.c | 69 + .../e2fsprogs/old_e2fsprogs/ext2fs/closefs.c | 381 + .../e2fsprogs/old_e2fsprogs/ext2fs/cmp_bitmaps.c | 73 + .../e2fsprogs/old_e2fsprogs/ext2fs/dblist.c | 260 + .../e2fsprogs/old_e2fsprogs/ext2fs/dblist_dir.c | 76 + .../e2fsprogs/old_e2fsprogs/ext2fs/dir_iterate.c | 220 + .../e2fsprogs/old_e2fsprogs/ext2fs/dirblock.c | 133 + .../e2fsprogs/old_e2fsprogs/ext2fs/dirhash.c | 234 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/dupfs.c | 97 + .../e2fsprogs/old_e2fsprogs/ext2fs/e2image.h | 52 + .../e2fsprogs/old_e2fsprogs/ext2fs/expanddir.c | 127 + .../e2fsprogs/old_e2fsprogs/ext2fs/ext2_err.h | 116 + .../e2fsprogs/old_e2fsprogs/ext2fs/ext2_ext_attr.h | 53 + .../e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h | 570 + .../e2fsprogs/old_e2fsprogs/ext2fs/ext2_io.h | 114 + .../e2fsprogs/old_e2fsprogs/ext2fs/ext2_types.h | 2 + .../e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h | 923 ++ .../e2fsprogs/old_e2fsprogs/ext2fs/ext2fsP.h | 89 + .../e2fsprogs/old_e2fsprogs/ext2fs/ext2fs_inline.c | 367 + .../e2fsprogs/old_e2fsprogs/ext2fs/ext_attr.c | 101 + .../e2fsprogs/old_e2fsprogs/ext2fs/fileio.c | 377 + .../e2fsprogs/old_e2fsprogs/ext2fs/finddev.c | 199 + .../e2fsprogs/old_e2fsprogs/ext2fs/flushb.c | 83 + .../e2fsprogs/old_e2fsprogs/ext2fs/freefs.c | 128 + .../e2fsprogs/old_e2fsprogs/ext2fs/gen_bitmap.c | 49 + .../e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c | 157 + .../e2fsprogs/old_e2fsprogs/ext2fs/getsectsize.c | 58 + .../e2fsprogs/old_e2fsprogs/ext2fs/getsize.c | 291 + .../e2fsprogs/old_e2fsprogs/ext2fs/icount.c | 467 + .../e2fsprogs/old_e2fsprogs/ext2fs/imager.c | 377 + .../e2fsprogs/old_e2fsprogs/ext2fs/ind_block.c | 71 + .../e2fsprogs/old_e2fsprogs/ext2fs/initialize.c | 388 + .../e2fsprogs/old_e2fsprogs/ext2fs/inline.c | 33 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/inode.c | 767 ++ .../e2fsprogs/old_e2fsprogs/ext2fs/inode_io.c | 271 + .../e2fsprogs/old_e2fsprogs/ext2fs/io_manager.c | 70 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/irel.h | 115 + .../e2fsprogs/old_e2fsprogs/ext2fs/irel_ma.c | 367 + .../e2fsprogs/old_e2fsprogs/ext2fs/ismounted.c | 357 + .../e2fsprogs/old_e2fsprogs/ext2fs/jfs_dat.h | 65 + .../e2fsprogs/old_e2fsprogs/ext2fs/kernel-jbd.h | 236 + .../e2fsprogs/old_e2fsprogs/ext2fs/kernel-list.h | 113 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/link.c | 135 + .../e2fsprogs/old_e2fsprogs/ext2fs/lookup.c | 70 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/mkdir.c | 142 + .../e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c | 428 + .../busybox/e2fsprogs/old_e2fsprogs/ext2fs/namei.c | 205 + .../e2fsprogs/old_e2fsprogs/ext2fs/newdir.c | 73 + .../e2fsprogs/old_e2fsprogs/ext2fs/openfs.c | 330 + .../e2fsprogs/old_e2fsprogs/ext2fs/read_bb.c | 98 + .../e2fsprogs/old_e2fsprogs/ext2fs/read_bb_file.c | 98 + .../e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c | 221 + .../e2fsprogs/old_e2fsprogs/ext2fs/rs_bitmap.c | 107 + .../e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c | 296 + .../e2fsprogs/old_e2fsprogs/ext2fs/sparse.c | 79 + .../e2fsprogs/old_e2fsprogs/ext2fs/swapfs.c | 236 + .../e2fsprogs/old_e2fsprogs/ext2fs/test_io.c | 380 + .../e2fsprogs/old_e2fsprogs/ext2fs/unix_io.c | 703 + .../e2fsprogs/old_e2fsprogs/ext2fs/unlink.c | 100 + .../e2fsprogs/old_e2fsprogs/ext2fs/valid_blk.c | 57 + .../e2fsprogs/old_e2fsprogs/ext2fs/version.c | 51 + .../e2fsprogs/old_e2fsprogs/ext2fs/write_bb_file.c | 35 + .../conf/busybox/e2fsprogs/old_e2fsprogs/fsck.c | 1392 ++ .../conf/busybox/e2fsprogs/old_e2fsprogs/fsck.h | 16 + .../conf/busybox/e2fsprogs/old_e2fsprogs/lsattr.c | 129 + .../conf/busybox/e2fsprogs/old_e2fsprogs/mke2fs.c | 1336 ++ .../conf/busybox/e2fsprogs/old_e2fsprogs/tune2fs.c | 729 + .../conf/busybox/e2fsprogs/old_e2fsprogs/util.c | 267 + .../conf/busybox/e2fsprogs/old_e2fsprogs/util.h | 22 + .../busybox/e2fsprogs/old_e2fsprogs/uuid/Kbuild | 14 + .../busybox/e2fsprogs/old_e2fsprogs/uuid/compare.c | 55 + .../e2fsprogs/old_e2fsprogs/uuid/gen_uuid.c | 304 + .../busybox/e2fsprogs/old_e2fsprogs/uuid/pack.c | 69 + .../busybox/e2fsprogs/old_e2fsprogs/uuid/parse.c | 80 + .../busybox/e2fsprogs/old_e2fsprogs/uuid/unpack.c | 63 + .../busybox/e2fsprogs/old_e2fsprogs/uuid/unparse.c | 77 + .../busybox/e2fsprogs/old_e2fsprogs/uuid/uuid.h | 104 + .../busybox/e2fsprogs/old_e2fsprogs/uuid/uuidP.h | 60 + .../e2fsprogs/old_e2fsprogs/uuid/uuid_time.c | 161 + i/pc104/initrd/conf/busybox/editors/Config.in | 138 + i/pc104/initrd/conf/busybox/editors/Kbuild | 12 + i/pc104/initrd/conf/busybox/editors/awk.c | 2781 ++++ i/pc104/initrd/conf/busybox/editors/ed.c | 1232 ++ i/pc104/initrd/conf/busybox/editors/patch.c | 278 + i/pc104/initrd/conf/busybox/editors/sed.c | 1347 ++ i/pc104/initrd/conf/busybox/editors/vi.c | 3999 ++++++ .../busybox/examples/bootfloppy/bootfloppy.txt | 180 + .../conf/busybox/examples/bootfloppy/display.txt | 4 + .../conf/busybox/examples/bootfloppy/etc/fstab | 2 + .../busybox/examples/bootfloppy/etc/init.d/rcS | 3 + .../conf/busybox/examples/bootfloppy/etc/inittab | 5 + .../conf/busybox/examples/bootfloppy/etc/profile | 8 + .../conf/busybox/examples/bootfloppy/mkdevs.sh | 62 + .../conf/busybox/examples/bootfloppy/mkrootfs.sh | 105 + .../conf/busybox/examples/bootfloppy/mksyslinux.sh | 48 + .../busybox/examples/bootfloppy/quickstart.txt | 15 + .../conf/busybox/examples/bootfloppy/syslinux.cfg | 7 + i/pc104/initrd/conf/busybox/examples/busybox.spec | 44 + i/pc104/initrd/conf/busybox/examples/depmod.pl | 289 + i/pc104/initrd/conf/busybox/examples/devfsd.conf | 133 + i/pc104/initrd/conf/busybox/examples/dnsd.conf | 1 + i/pc104/initrd/conf/busybox/examples/inetd.conf | 73 + i/pc104/initrd/conf/busybox/examples/inittab | 90 + i/pc104/initrd/conf/busybox/examples/mk2knr.pl | 84 + .../conf/busybox/examples/udhcp/sample.bound | 31 + .../conf/busybox/examples/udhcp/sample.deconfig | 4 + .../initrd/conf/busybox/examples/udhcp/sample.nak | 4 + .../conf/busybox/examples/udhcp/sample.renew | 31 + .../conf/busybox/examples/udhcp/sample.script | 7 + .../conf/busybox/examples/udhcp/simple.script | 40 + .../initrd/conf/busybox/examples/udhcp/udhcpd.conf | 123 + i/pc104/initrd/conf/busybox/examples/undeb | 53 + i/pc104/initrd/conf/busybox/examples/unrpm | 48 + i/pc104/initrd/conf/busybox/examples/zcip.script | 38 + i/pc104/initrd/conf/busybox/findutils/Config.in | 175 + i/pc104/initrd/conf/busybox/findutils/Kbuild | 10 + i/pc104/initrd/conf/busybox/findutils/find.c | 645 + i/pc104/initrd/conf/busybox/findutils/grep.c | 507 + i/pc104/initrd/conf/busybox/findutils/xargs.c | 540 + i/pc104/initrd/conf/busybox/include/applets.h | 341 + i/pc104/initrd/conf/busybox/include/busybox.h | 39 + i/pc104/initrd/conf/busybox/include/dump.h | 50 + i/pc104/initrd/conf/busybox/include/grp_.h | 133 + i/pc104/initrd/conf/busybox/include/inet_common.h | 25 + i/pc104/initrd/conf/busybox/include/libbb.h | 902 ++ i/pc104/initrd/conf/busybox/include/platform.h | 311 + i/pc104/initrd/conf/busybox/include/pwd_.h | 122 + i/pc104/initrd/conf/busybox/include/shadow_.h | 114 + i/pc104/initrd/conf/busybox/include/unarchive.h | 118 + i/pc104/initrd/conf/busybox/include/usage.h | 3688 +++++ i/pc104/initrd/conf/busybox/include/xatonum.h | 157 + i/pc104/initrd/conf/busybox/include/xregex.h | 18 + i/pc104/initrd/conf/busybox/init/Config.in | 89 + i/pc104/initrd/conf/busybox/init/Kbuild | 10 + i/pc104/initrd/conf/busybox/init/halt.c | 59 + i/pc104/initrd/conf/busybox/init/init.c | 1043 ++ i/pc104/initrd/conf/busybox/init/mesg.c | 46 + i/pc104/initrd/conf/busybox/libbb/Config.in | 88 + i/pc104/initrd/conf/busybox/libbb/Kbuild | 120 + i/pc104/initrd/conf/busybox/libbb/README | 11 + .../initrd/conf/busybox/libbb/ask_confirmation.c | 36 + i/pc104/initrd/conf/busybox/libbb/bb_askpass.c | 75 + i/pc104/initrd/conf/busybox/libbb/bb_do_delay.c | 24 + i/pc104/initrd/conf/busybox/libbb/bb_pwd.c | 129 + i/pc104/initrd/conf/busybox/libbb/bb_strtonum.c | 156 + .../initrd/conf/busybox/libbb/change_identity.c | 51 + i/pc104/initrd/conf/busybox/libbb/chomp.c | 19 + .../conf/busybox/libbb/compare_string_array.c | 37 + .../initrd/conf/busybox/libbb/concat_path_file.c | 27 + .../conf/busybox/libbb/concat_subpath_file.c | 23 + i/pc104/initrd/conf/busybox/libbb/copy_file.c | 343 + i/pc104/initrd/conf/busybox/libbb/copyfd.c | 106 + .../initrd/conf/busybox/libbb/correct_password.c | 69 + i/pc104/initrd/conf/busybox/libbb/crc32.c | 39 + .../conf/busybox/libbb/create_icmp6_socket.c | 37 + .../initrd/conf/busybox/libbb/create_icmp_socket.c | 35 + .../conf/busybox/libbb/default_error_retval.c | 19 + i/pc104/initrd/conf/busybox/libbb/device_open.c | 30 + i/pc104/initrd/conf/busybox/libbb/dump.c | 805 ++ i/pc104/initrd/conf/busybox/libbb/error_msg.c | 23 + .../initrd/conf/busybox/libbb/error_msg_and_die.c | 33 + i/pc104/initrd/conf/busybox/libbb/execable.c | 71 + .../initrd/conf/busybox/libbb/fclose_nonstdin.c | 23 + .../conf/busybox/libbb/fflush_stdout_and_exit.c | 21 + i/pc104/initrd/conf/busybox/libbb/fgets_str.c | 53 + .../initrd/conf/busybox/libbb/find_mount_point.c | 53 + .../initrd/conf/busybox/libbb/find_pid_by_name.c | 55 + .../initrd/conf/busybox/libbb/find_root_device.c | 34 + i/pc104/initrd/conf/busybox/libbb/full_write.c | 36 + i/pc104/initrd/conf/busybox/libbb/get_console.c | 72 + .../conf/busybox/libbb/get_last_path_component.c | 32 + .../initrd/conf/busybox/libbb/get_line_from_file.c | 69 + i/pc104/initrd/conf/busybox/libbb/getopt32.c | 531 + i/pc104/initrd/conf/busybox/libbb/herror_msg.c | 22 + .../initrd/conf/busybox/libbb/herror_msg_and_die.c | 23 + i/pc104/initrd/conf/busybox/libbb/human_readable.c | 89 + i/pc104/initrd/conf/busybox/libbb/inet_common.c | 235 + i/pc104/initrd/conf/busybox/libbb/info_msg.c | 23 + i/pc104/initrd/conf/busybox/libbb/inode_hash.c | 90 + i/pc104/initrd/conf/busybox/libbb/isdirectory.c | 39 + i/pc104/initrd/conf/busybox/libbb/kernel_version.c | 37 + i/pc104/initrd/conf/busybox/libbb/last_char_is.c | 24 + i/pc104/initrd/conf/busybox/libbb/lineedit.c | 1801 +++ i/pc104/initrd/conf/busybox/libbb/llist.c | 108 + i/pc104/initrd/conf/busybox/libbb/login.c | 105 + i/pc104/initrd/conf/busybox/libbb/loop.c | 149 + i/pc104/initrd/conf/busybox/libbb/make_directory.c | 104 + i/pc104/initrd/conf/busybox/libbb/makedev.c | 23 + i/pc104/initrd/conf/busybox/libbb/md5.c | 450 + i/pc104/initrd/conf/busybox/libbb/messages.c | 61 + i/pc104/initrd/conf/busybox/libbb/mode_string.c | 128 + i/pc104/initrd/conf/busybox/libbb/mtab.c | 52 + i/pc104/initrd/conf/busybox/libbb/mtab_file.c | 17 + i/pc104/initrd/conf/busybox/libbb/obscure.c | 170 + i/pc104/initrd/conf/busybox/libbb/parse_mode.c | 148 + i/pc104/initrd/conf/busybox/libbb/perror_msg.c | 23 + .../initrd/conf/busybox/libbb/perror_msg_and_die.c | 24 + i/pc104/initrd/conf/busybox/libbb/perror_nomsg.c | 21 + .../conf/busybox/libbb/perror_nomsg_and_die.c | 21 + .../conf/busybox/libbb/process_escape_sequence.c | 89 + i/pc104/initrd/conf/busybox/libbb/procps.c | 249 + i/pc104/initrd/conf/busybox/libbb/pw_encrypt.c | 29 + i/pc104/initrd/conf/busybox/libbb/read.c | 137 + .../initrd/conf/busybox/libbb/recursive_action.c | 126 + i/pc104/initrd/conf/busybox/libbb/remove_file.c | 111 + .../initrd/conf/busybox/libbb/restricted_shell.c | 46 + i/pc104/initrd/conf/busybox/libbb/run_shell.c | 101 + i/pc104/initrd/conf/busybox/libbb/safe_strncpy.c | 21 + i/pc104/initrd/conf/busybox/libbb/safe_write.c | 26 + i/pc104/initrd/conf/busybox/libbb/selinux_common.c | 40 + .../initrd/conf/busybox/libbb/setup_environment.c | 83 + i/pc104/initrd/conf/busybox/libbb/sha1.c | 178 + i/pc104/initrd/conf/busybox/libbb/simplify_path.c | 50 + .../initrd/conf/busybox/libbb/skip_whitespace.c | 25 + i/pc104/initrd/conf/busybox/libbb/speed_table.c | 117 + i/pc104/initrd/conf/busybox/libbb/trim.c | 31 + i/pc104/initrd/conf/busybox/libbb/u_signal_names.c | 57 + i/pc104/initrd/conf/busybox/libbb/uuencode.c | 63 + i/pc104/initrd/conf/busybox/libbb/vdprintf.c | 21 + i/pc104/initrd/conf/busybox/libbb/verror_msg.c | 46 + .../initrd/conf/busybox/libbb/vfork_daemon_rexec.c | 63 + i/pc104/initrd/conf/busybox/libbb/vherror_msg.c | 15 + i/pc104/initrd/conf/busybox/libbb/vinfo_msg.c | 26 + i/pc104/initrd/conf/busybox/libbb/vperror_msg.c | 15 + .../initrd/conf/busybox/libbb/warn_ignoring_args.c | 17 + i/pc104/initrd/conf/busybox/libbb/wfopen.c | 20 + i/pc104/initrd/conf/busybox/libbb/wfopen_input.c | 31 + i/pc104/initrd/conf/busybox/libbb/xatonum.c | 70 + .../initrd/conf/busybox/libbb/xatonum_template.c | 185 + i/pc104/initrd/conf/busybox/libbb/xconnect.c | 330 + i/pc104/initrd/conf/busybox/libbb/xfuncs.c | 616 + i/pc104/initrd/conf/busybox/libbb/xgetcwd.c | 44 + i/pc104/initrd/conf/busybox/libbb/xgethostbyname.c | 19 + i/pc104/initrd/conf/busybox/libbb/xreadlink.c | 48 + i/pc104/initrd/conf/busybox/libbb/xregcomp.c | 32 + i/pc104/initrd/conf/busybox/libpwdgrp/Kbuild | 7 + i/pc104/initrd/conf/busybox/libpwdgrp/pwd_grp.c | 997 ++ .../conf/busybox/libpwdgrp/pwd_grp_internal.c | 62 + i/pc104/initrd/conf/busybox/libpwdgrp/uidgid_get.c | 133 + i/pc104/initrd/conf/busybox/loginutils/Config.in | 193 + i/pc104/initrd/conf/busybox/loginutils/Kbuild | 17 + i/pc104/initrd/conf/busybox/loginutils/addgroup.c | 111 + i/pc104/initrd/conf/busybox/loginutils/adduser.c | 196 + i/pc104/initrd/conf/busybox/loginutils/deluser.c | 83 + i/pc104/initrd/conf/busybox/loginutils/getty.c | 856 ++ i/pc104/initrd/conf/busybox/loginutils/login.c | 403 + i/pc104/initrd/conf/busybox/loginutils/passwd.c | 347 + i/pc104/initrd/conf/busybox/loginutils/su.c | 103 + i/pc104/initrd/conf/busybox/loginutils/sulogin.c | 126 + i/pc104/initrd/conf/busybox/loginutils/vlock.c | 119 + i/pc104/initrd/conf/busybox/miscutils/Config.in | 387 + i/pc104/initrd/conf/busybox/miscutils/Kbuild | 31 + i/pc104/initrd/conf/busybox/miscutils/adjtimex.c | 118 + i/pc104/initrd/conf/busybox/miscutils/bbconfig.c | 12 + i/pc104/initrd/conf/busybox/miscutils/chrt.c | 124 + i/pc104/initrd/conf/busybox/miscutils/crond.c | 1017 ++ i/pc104/initrd/conf/busybox/miscutils/crontab.c | 343 + i/pc104/initrd/conf/busybox/miscutils/dc.c | 232 + i/pc104/initrd/conf/busybox/miscutils/devfsd.c | 2030 +++ i/pc104/initrd/conf/busybox/miscutils/eject.c | 61 + i/pc104/initrd/conf/busybox/miscutils/hdparm.c | 2048 +++ i/pc104/initrd/conf/busybox/miscutils/last.c | 92 + i/pc104/initrd/conf/busybox/miscutils/less.c | 1296 ++ i/pc104/initrd/conf/busybox/miscutils/makedevs.c | 232 + i/pc104/initrd/conf/busybox/miscutils/mountpoint.c | 66 + i/pc104/initrd/conf/busybox/miscutils/mt.c | 121 + i/pc104/initrd/conf/busybox/miscutils/nmeter.c | 849 ++ .../initrd/conf/busybox/miscutils/raidautorun.c | 27 + i/pc104/initrd/conf/busybox/miscutils/readahead.c | 35 + i/pc104/initrd/conf/busybox/miscutils/runlevel.c | 43 + i/pc104/initrd/conf/busybox/miscutils/rx.c | 290 + i/pc104/initrd/conf/busybox/miscutils/setsid.c | 42 + i/pc104/initrd/conf/busybox/miscutils/strings.c | 89 + i/pc104/initrd/conf/busybox/miscutils/taskset.c | 99 + i/pc104/initrd/conf/busybox/miscutils/time.c | 474 + i/pc104/initrd/conf/busybox/miscutils/watchdog.c | 66 + i/pc104/initrd/conf/busybox/modutils/Config.in | 158 + i/pc104/initrd/conf/busybox/modutils/Kbuild | 11 + i/pc104/initrd/conf/busybox/modutils/insmod.c | 4315 ++++++ i/pc104/initrd/conf/busybox/modutils/lsmod.c | 192 + i/pc104/initrd/conf/busybox/modutils/modprobe.c | 896 ++ i/pc104/initrd/conf/busybox/modutils/rmmod.c | 97 + i/pc104/initrd/conf/busybox/networking/Config.in | 719 + i/pc104/initrd/conf/busybox/networking/Kbuild | 40 + i/pc104/initrd/conf/busybox/networking/arp.c | 496 + i/pc104/initrd/conf/busybox/networking/arping.c | 417 + i/pc104/initrd/conf/busybox/networking/dnsd.c | 426 + .../initrd/conf/busybox/networking/ether-wake.c | 284 + i/pc104/initrd/conf/busybox/networking/ftpgetput.c | 359 + i/pc104/initrd/conf/busybox/networking/hostname.c | 101 + i/pc104/initrd/conf/busybox/networking/httpd.c | 2049 +++ .../busybox/networking/httpd_index_cgi_example | 50 + i/pc104/initrd/conf/busybox/networking/ifconfig.c | 546 + i/pc104/initrd/conf/busybox/networking/ifupdown.c | 1273 ++ i/pc104/initrd/conf/busybox/networking/inetd.c | 1791 +++ i/pc104/initrd/conf/busybox/networking/interface.c | 1195 ++ i/pc104/initrd/conf/busybox/networking/ip.c | 50 + i/pc104/initrd/conf/busybox/networking/ipaddr.c | 26 + i/pc104/initrd/conf/busybox/networking/ipcalc.c | 195 + i/pc104/initrd/conf/busybox/networking/iplink.c | 26 + i/pc104/initrd/conf/busybox/networking/iproute.c | 26 + i/pc104/initrd/conf/busybox/networking/iprule.c | 26 + i/pc104/initrd/conf/busybox/networking/iptunnel.c | 26 + i/pc104/initrd/conf/busybox/networking/isrv.c | 352 + i/pc104/initrd/conf/busybox/networking/isrv.h | 33 + .../initrd/conf/busybox/networking/isrv_identd.c | 144 + .../conf/busybox/networking/libiproute/Kbuild | 66 + .../conf/busybox/networking/libiproute/ip_common.h | 35 + .../networking/libiproute/ip_parse_common_args.c | 79 + .../conf/busybox/networking/libiproute/ipaddress.c | 824 ++ .../conf/busybox/networking/libiproute/iplink.c | 350 + .../conf/busybox/networking/libiproute/iproute.c | 878 ++ .../conf/busybox/networking/libiproute/iprule.c | 334 + .../conf/busybox/networking/libiproute/iptunnel.c | 547 + .../busybox/networking/libiproute/libnetlink.c | 396 + .../busybox/networking/libiproute/libnetlink.h | 43 + .../conf/busybox/networking/libiproute/ll_addr.c | 85 + .../conf/busybox/networking/libiproute/ll_map.c | 186 + .../conf/busybox/networking/libiproute/ll_map.h | 13 + .../conf/busybox/networking/libiproute/ll_proto.c | 121 + .../conf/busybox/networking/libiproute/ll_types.c | 117 + .../conf/busybox/networking/libiproute/rt_names.c | 365 + .../conf/busybox/networking/libiproute/rt_names.h | 28 + .../conf/busybox/networking/libiproute/rtm_map.c | 110 + .../conf/busybox/networking/libiproute/rtm_map.h | 11 + .../conf/busybox/networking/libiproute/utils.c | 330 + .../conf/busybox/networking/libiproute/utils.h | 91 + i/pc104/initrd/conf/busybox/networking/nameif.c | 171 + i/pc104/initrd/conf/busybox/networking/nc.c | 197 + i/pc104/initrd/conf/busybox/networking/netstat.c | 596 + i/pc104/initrd/conf/busybox/networking/nslookup.c | 155 + i/pc104/initrd/conf/busybox/networking/ping.c | 752 + i/pc104/initrd/conf/busybox/networking/route.c | 697 + i/pc104/initrd/conf/busybox/networking/telnet.c | 665 + i/pc104/initrd/conf/busybox/networking/telnetd.c | 573 + i/pc104/initrd/conf/busybox/networking/tftp.c | 518 + .../initrd/conf/busybox/networking/traceroute.c | 1342 ++ .../initrd/conf/busybox/networking/udhcp/Config.in | 75 + .../initrd/conf/busybox/networking/udhcp/Kbuild | 19 + .../initrd/conf/busybox/networking/udhcp/arpping.c | 114 + .../conf/busybox/networking/udhcp/clientpacket.c | 224 + .../conf/busybox/networking/udhcp/clientsocket.c | 51 + .../initrd/conf/busybox/networking/udhcp/common.c | 61 + .../initrd/conf/busybox/networking/udhcp/common.h | 104 + .../initrd/conf/busybox/networking/udhcp/dhcpc.c | 509 + .../initrd/conf/busybox/networking/udhcp/dhcpc.h | 50 + .../initrd/conf/busybox/networking/udhcp/dhcpd.c | 223 + .../initrd/conf/busybox/networking/udhcp/dhcpd.h | 190 + .../conf/busybox/networking/udhcp/dhcprelay.c | 338 + .../conf/busybox/networking/udhcp/domain_codec.c | 205 + .../conf/busybox/networking/udhcp/dumpleases.c | 75 + .../initrd/conf/busybox/networking/udhcp/files.c | 426 + .../initrd/conf/busybox/networking/udhcp/leases.c | 145 + .../initrd/conf/busybox/networking/udhcp/options.c | 180 + .../initrd/conf/busybox/networking/udhcp/options.h | 44 + .../initrd/conf/busybox/networking/udhcp/packet.c | 211 + .../initrd/conf/busybox/networking/udhcp/pidfile.c | 60 + .../initrd/conf/busybox/networking/udhcp/script.c | 224 + .../conf/busybox/networking/udhcp/serverpacket.c | 261 + .../conf/busybox/networking/udhcp/signalpipe.c | 77 + .../initrd/conf/busybox/networking/udhcp/socket.c | 126 + .../conf/busybox/networking/udhcp/static_leases.c | 99 + i/pc104/initrd/conf/busybox/networking/vconfig.c | 165 + i/pc104/initrd/conf/busybox/networking/wget.c | 808 ++ i/pc104/initrd/conf/busybox/networking/zcip.c | 548 + i/pc104/initrd/conf/busybox/procps/Config.in | 121 + i/pc104/initrd/conf/busybox/procps/Kbuild | 16 + i/pc104/initrd/conf/busybox/procps/free.c | 69 + i/pc104/initrd/conf/busybox/procps/fuser.c | 368 + i/pc104/initrd/conf/busybox/procps/kill.c | 156 + i/pc104/initrd/conf/busybox/procps/pidof.c | 91 + i/pc104/initrd/conf/busybox/procps/ps.c | 388 + i/pc104/initrd/conf/busybox/procps/ps.posix | 175 + i/pc104/initrd/conf/busybox/procps/renice.c | 127 + i/pc104/initrd/conf/busybox/procps/sysctl.c | 327 + i/pc104/initrd/conf/busybox/procps/top.c | 570 + i/pc104/initrd/conf/busybox/procps/uptime.c | 60 + i/pc104/initrd/conf/busybox/runit/Config.in | 66 + i/pc104/initrd/conf/busybox/runit/Kbuild | 17 + i/pc104/initrd/conf/busybox/runit/chpst.c | 374 + i/pc104/initrd/conf/busybox/runit/runit_lib.c | 500 + i/pc104/initrd/conf/busybox/runit/runit_lib.h | 160 + i/pc104/initrd/conf/busybox/runit/runsv.c | 633 + i/pc104/initrd/conf/busybox/runit/runsvdir.c | 334 + i/pc104/initrd/conf/busybox/runit/sv.c | 590 + i/pc104/initrd/conf/busybox/runit/svlogd.c | 960 ++ i/pc104/initrd/conf/busybox/scripts/Kbuild | 7 + i/pc104/initrd/conf/busybox/scripts/Kbuild.include | 154 + i/pc104/initrd/conf/busybox/scripts/Makefile.IMA | 134 + i/pc104/initrd/conf/busybox/scripts/Makefile.build | 338 + i/pc104/initrd/conf/busybox/scripts/Makefile.clean | 102 + i/pc104/initrd/conf/busybox/scripts/Makefile.host | 156 + i/pc104/initrd/conf/busybox/scripts/Makefile.lib | 165 + i/pc104/initrd/conf/busybox/scripts/basic/Makefile | 18 + .../initrd/conf/busybox/scripts/basic/docproc.c | 398 + i/pc104/initrd/conf/busybox/scripts/basic/fixdep.c | 404 + .../conf/busybox/scripts/basic/split-include.c | 226 + i/pc104/initrd/conf/busybox/scripts/bloat-o-meter | 65 + i/pc104/initrd/conf/busybox/scripts/checkhelp.awk | 40 + i/pc104/initrd/conf/busybox/scripts/defconfig | 691 + i/pc104/initrd/conf/busybox/scripts/gcc-version.sh | 12 + i/pc104/initrd/conf/busybox/scripts/individual | 129 + .../initrd/conf/busybox/scripts/kconfig/Makefile | 254 + .../conf/busybox/scripts/kconfig/POTFILES.in | 5 + i/pc104/initrd/conf/busybox/scripts/kconfig/conf.c | 612 + .../initrd/conf/busybox/scripts/kconfig/confdata.c | 571 + i/pc104/initrd/conf/busybox/scripts/kconfig/expr.c | 1099 ++ i/pc104/initrd/conf/busybox/scripts/kconfig/expr.h | 194 + .../initrd/conf/busybox/scripts/kconfig/gconf.c | 1645 +++ .../conf/busybox/scripts/kconfig/gconf.glade | 648 + .../initrd/conf/busybox/scripts/kconfig/images.c | 326 + .../conf/busybox/scripts/kconfig/kconfig_load.c | 35 + .../conf/busybox/scripts/kconfig/kxgettext.c | 227 + .../busybox/scripts/kconfig/lex.zconf.c_shipped | 2317 ++++ i/pc104/initrd/conf/busybox/scripts/kconfig/lkc.h | 147 + .../conf/busybox/scripts/kconfig/lkc_proto.h | 41 + .../scripts/kconfig/lxdialog/BIG.FAT.WARNING | 4 + .../conf/busybox/scripts/kconfig/lxdialog/Makefile | 21 + .../scripts/kconfig/lxdialog/check-lxdialog.sh | 84 + .../busybox/scripts/kconfig/lxdialog/checklist.c | 333 + .../conf/busybox/scripts/kconfig/lxdialog/colors.h | 154 + .../conf/busybox/scripts/kconfig/lxdialog/dialog.h | 177 + .../busybox/scripts/kconfig/lxdialog/inputbox.c | 224 + .../busybox/scripts/kconfig/lxdialog/lxdialog.c | 204 + .../busybox/scripts/kconfig/lxdialog/menubox.c | 426 + .../conf/busybox/scripts/kconfig/lxdialog/msgbox.c | 71 + .../busybox/scripts/kconfig/lxdialog/textbox.c | 533 + .../conf/busybox/scripts/kconfig/lxdialog/util.c | 362 + .../conf/busybox/scripts/kconfig/lxdialog/yesno.c | 102 + .../initrd/conf/busybox/scripts/kconfig/mconf.c | 1098 ++ i/pc104/initrd/conf/busybox/scripts/kconfig/menu.c | 397 + .../initrd/conf/busybox/scripts/kconfig/qconf.cc | 1426 ++ .../initrd/conf/busybox/scripts/kconfig/qconf.h | 263 + .../initrd/conf/busybox/scripts/kconfig/symbol.c | 882 ++ i/pc104/initrd/conf/busybox/scripts/kconfig/util.c | 109 + .../conf/busybox/scripts/kconfig/zconf.gperf | 43 + .../busybox/scripts/kconfig/zconf.hash.c_shipped | 231 + .../initrd/conf/busybox/scripts/kconfig/zconf.l | 350 + .../busybox/scripts/kconfig/zconf.tab.c_shipped | 2173 +++ .../initrd/conf/busybox/scripts/kconfig/zconf.y | 681 + i/pc104/initrd/conf/busybox/scripts/mkconfigs | 52 + i/pc104/initrd/conf/busybox/scripts/mkmakefile | 36 + i/pc104/initrd/conf/busybox/scripts/objsizes | 19 + i/pc104/initrd/conf/busybox/scripts/showasm | 21 + i/pc104/initrd/conf/busybox/scripts/trylink | 18 + i/pc104/initrd/conf/busybox/selinux/Config.in | 75 + i/pc104/initrd/conf/busybox/selinux/Kbuild | 15 + i/pc104/initrd/conf/busybox/selinux/chcon.c | 175 + i/pc104/initrd/conf/busybox/selinux/getenforce.c | 34 + i/pc104/initrd/conf/busybox/selinux/getsebool.c | 66 + i/pc104/initrd/conf/busybox/selinux/matchpathcon.c | 86 + i/pc104/initrd/conf/busybox/selinux/runcon.c | 137 + .../initrd/conf/busybox/selinux/selinuxenabled.c | 14 + i/pc104/initrd/conf/busybox/selinux/setenforce.c | 42 + i/pc104/initrd/conf/busybox/shell/Config.in | 243 + i/pc104/initrd/conf/busybox/shell/Kbuild | 11 + i/pc104/initrd/conf/busybox/shell/ash.c | 13003 ++++++++++++++++++ .../busybox/shell/ash_test/ash-alias/alias.right | 4 + .../busybox/shell/ash_test/ash-alias/alias.tests | 37 + .../busybox/shell/ash_test/ash-arith/README.ash | 1 + .../shell/ash_test/ash-arith/arith-for.right | 74 + .../shell/ash_test/ash-arith/arith-for.testsx | 94 + .../busybox/shell/ash_test/ash-arith/arith.right | 138 + .../busybox/shell/ash_test/ash-arith/arith.tests | 302 + .../busybox/shell/ash_test/ash-arith/arith1.sub | 40 + .../busybox/shell/ash_test/ash-arith/arith2.sub | 57 + .../shell/ash_test/ash-heredoc/heredoc.right | 21 + .../shell/ash_test/ash-heredoc/heredoc.tests | 94 + .../busybox/shell/ash_test/ash-invert/invert.right | 10 + .../busybox/shell/ash_test/ash-invert/invert.tests | 19 + .../initrd/conf/busybox/shell/ash_test/printenv.c | 67 + i/pc104/initrd/conf/busybox/shell/ash_test/recho.c | 63 + i/pc104/initrd/conf/busybox/shell/ash_test/run-all | 62 + i/pc104/initrd/conf/busybox/shell/ash_test/zecho.c | 39 + i/pc104/initrd/conf/busybox/shell/bbsh.c | 223 + i/pc104/initrd/conf/busybox/shell/hush.c | 2928 ++++ i/pc104/initrd/conf/busybox/shell/lash.c | 1582 +++ i/pc104/initrd/conf/busybox/shell/msh.c | 5406 ++++++++ i/pc104/initrd/conf/busybox/sysklogd/Config.in | 111 + i/pc104/initrd/conf/busybox/sysklogd/Kbuild | 11 + i/pc104/initrd/conf/busybox/sysklogd/klogd.c | 123 + i/pc104/initrd/conf/busybox/sysklogd/logger.c | 168 + i/pc104/initrd/conf/busybox/sysklogd/logread.c | 144 + i/pc104/initrd/conf/busybox/sysklogd/syslogd.c | 654 + i/pc104/initrd/conf/busybox/testsuite/README | 34 + i/pc104/initrd/conf/busybox/testsuite/TODO | 26 + .../conf/busybox/testsuite/all_sourcecode.tests | 78 + .../basename-does-not-remove-identical-extension | 1 + .../conf/busybox/testsuite/basename/basename-works | 2 + .../initrd/conf/busybox/testsuite/bunzip2.tests | 84 + .../bunzip2/bunzip2-reads-from-standard-input | 2 + .../bunzip2/bunzip2-removes-compressed-file | 3 + .../bunzip2/bzcat-does-not-remove-compressed-file | 3 + .../initrd/conf/busybox/testsuite/busybox.tests | 46 + i/pc104/initrd/conf/busybox/testsuite/bzcat.tests | 49 + .../conf/busybox/testsuite/cat/cat-prints-a-file | 3 + .../cat/cat-prints-a-file-and-standard-input | 7 + .../busybox/testsuite/cmp/cmp-detects-difference | 9 + .../conf/busybox/testsuite/cp/cp-a-files-to-dir | 14 + .../conf/busybox/testsuite/cp/cp-a-preserves-links | 5 + .../conf/busybox/testsuite/cp/cp-copies-empty-file | 3 + .../conf/busybox/testsuite/cp/cp-copies-large-file | 3 + .../conf/busybox/testsuite/cp/cp-copies-small-file | 3 + .../conf/busybox/testsuite/cp/cp-d-files-to-dir | 11 + .../conf/busybox/testsuite/cp/cp-dir-create-dir | 4 + .../conf/busybox/testsuite/cp/cp-dir-existing-dir | 5 + .../testsuite/cp/cp-does-not-copy-unreadable-file | 6 + .../conf/busybox/testsuite/cp/cp-files-to-dir | 11 + .../conf/busybox/testsuite/cp/cp-follows-links | 4 + .../busybox/testsuite/cp/cp-preserves-hard-links | 6 + .../conf/busybox/testsuite/cp/cp-preserves-links | 5 + .../busybox/testsuite/cp/cp-preserves-source-file | 3 + .../busybox/testsuite/cut/cut-cuts-a-character | 1 + .../busybox/testsuite/cut/cut-cuts-a-closed-range | 1 + .../conf/busybox/testsuite/cut/cut-cuts-a-field | 1 + .../busybox/testsuite/cut/cut-cuts-an-open-range | 1 + .../testsuite/cut/cut-cuts-an-unclosed-range | 1 + .../conf/busybox/testsuite/date/date-R-works | 2 + .../conf/busybox/testsuite/date/date-format-works | 1 + .../conf/busybox/testsuite/date/date-u-works | 2 + .../initrd/conf/busybox/testsuite/date/date-works | 2 + .../initrd/conf/busybox/testsuite/dd/dd-accepts-if | 2 + .../initrd/conf/busybox/testsuite/dd/dd-accepts-of | 2 + ...d-copies-from-standard-input-to-standard-output | 1 + .../testsuite/dd/dd-prints-count-to-standard-error | 2 + .../dirname/dirname-handles-absolute-path | 1 + .../testsuite/dirname/dirname-handles-empty-path | 1 + .../dirname/dirname-handles-multiple-slashes | 1 + .../dirname/dirname-handles-relative-path | 1 + .../busybox/testsuite/dirname/dirname-handles-root | 1 + .../dirname/dirname-handles-single-component | 1 + .../conf/busybox/testsuite/dirname/dirname-works | 2 + .../initrd/conf/busybox/testsuite/du/du-h-works | 4 + .../initrd/conf/busybox/testsuite/du/du-k-works | 4 + .../initrd/conf/busybox/testsuite/du/du-l-works | 4 + .../initrd/conf/busybox/testsuite/du/du-m-works | 4 + .../initrd/conf/busybox/testsuite/du/du-s-works | 4 + i/pc104/initrd/conf/busybox/testsuite/du/du-works | 4 + .../testsuite/echo/echo-does-not-print-newline | 1 + .../busybox/testsuite/echo/echo-prints-argument | 1 + .../busybox/testsuite/echo/echo-prints-arguments | 1 + .../busybox/testsuite/echo/echo-prints-newline | 1 + .../initrd/conf/busybox/testsuite/expr/expr-works | 59 + .../conf/busybox/testsuite/false/false-is-silent | 1 + .../busybox/testsuite/false/false-returns-failure | 1 + .../testsuite/find/find-supports-minus-xdev | 1 + i/pc104/initrd/conf/busybox/testsuite/grep.tests | 84 + i/pc104/initrd/conf/busybox/testsuite/gunzip.tests | 3 + .../gunzip/gunzip-reads-from-standard-input | 2 + .../testsuite/gzip/gzip-accepts-multiple-files | 3 + .../testsuite/gzip/gzip-accepts-single-minus | 1 + .../testsuite/gzip/gzip-removes-original-file | 3 + .../conf/busybox/testsuite/head/head-n-works | 4 + .../initrd/conf/busybox/testsuite/head/head-works | 4 + .../conf/busybox/testsuite/hostid/hostid-works | 2 + .../busybox/testsuite/hostname/hostname-d-works | 2 + .../busybox/testsuite/hostname/hostname-i-works | 2 + .../busybox/testsuite/hostname/hostname-s-works | 1 + .../conf/busybox/testsuite/hostname/hostname-works | 1 + .../initrd/conf/busybox/testsuite/id/id-g-works | 1 + .../initrd/conf/busybox/testsuite/id/id-u-works | 1 + .../initrd/conf/busybox/testsuite/id/id-un-works | 1 + .../initrd/conf/busybox/testsuite/id/id-ur-works | 1 + .../busybox/testsuite/ln/ln-creates-hard-links | 4 + .../busybox/testsuite/ln/ln-creates-soft-links | 4 + .../testsuite/ln/ln-force-creates-hard-links | 5 + .../testsuite/ln/ln-force-creates-soft-links | 5 + .../busybox/testsuite/ln/ln-preserves-hard-links | 8 + .../busybox/testsuite/ln/ln-preserves-soft-links | 9 + .../initrd/conf/busybox/testsuite/ls/ls-1-works | 4 + .../initrd/conf/busybox/testsuite/ls/ls-h-works | 4 + .../initrd/conf/busybox/testsuite/ls/ls-l-works | 4 + .../initrd/conf/busybox/testsuite/ls/ls-s-works | 4 + .../md5sum/md5sum-verifies-non-binary-file | 3 + .../testsuite/mkdir/mkdir-makes-a-directory | 2 + .../testsuite/mkdir/mkdir-makes-parent-directories | 2 + .../initrd/conf/busybox/testsuite/mount.testroot | 183 + .../msh/msh-supports-underscores-in-variable-names | 1 + .../conf/busybox/testsuite/mv/mv-files-to-dir | 16 + .../conf/busybox/testsuite/mv/mv-follows-links | 4 + .../conf/busybox/testsuite/mv/mv-moves-empty-file | 4 + .../initrd/conf/busybox/testsuite/mv/mv-moves-file | 3 + .../conf/busybox/testsuite/mv/mv-moves-hardlinks | 4 + .../conf/busybox/testsuite/mv/mv-moves-large-file | 4 + .../conf/busybox/testsuite/mv/mv-moves-small-file | 4 + .../conf/busybox/testsuite/mv/mv-moves-symlinks | 6 + .../busybox/testsuite/mv/mv-moves-unreadable-files | 5 + .../busybox/testsuite/mv/mv-preserves-hard-links | 6 + .../conf/busybox/testsuite/mv/mv-preserves-links | 5 + .../testsuite/mv/mv-refuses-mv-dir-to-subdir | 23 + .../busybox/testsuite/mv/mv-removes-source-file | 4 + i/pc104/initrd/conf/busybox/testsuite/pidof.tests | 29 + .../testsuite/pwd/pwd-prints-working-directory | 1 + .../initrd/conf/busybox/testsuite/readlink.tests | 32 + .../conf/busybox/testsuite/rm/rm-removes-file | 3 + .../rmdir/rmdir-removes-parent-directories | 3 + i/pc104/initrd/conf/busybox/testsuite/runtest | 150 + i/pc104/initrd/conf/busybox/testsuite/sed.tests | 203 + i/pc104/initrd/conf/busybox/testsuite/seq.tests | 36 + i/pc104/initrd/conf/busybox/testsuite/sort.tests | 113 + .../testsuite/strings/strings-works-like-GNU | 9 + i/pc104/initrd/conf/busybox/testsuite/sum.tests | 24 + .../conf/busybox/testsuite/tail/tail-n-works | 4 + .../initrd/conf/busybox/testsuite/tail/tail-works | 4 + .../testsuite/tar/tar-archives-multiple-files | 6 + .../testsuite/tar/tar-complains-about-missing-file | 3 + .../testsuite/tar/tar-demands-at-least-one-ctx | 1 + .../testsuite/tar/tar-demands-at-most-one-ctx | 1 + .../busybox/testsuite/tar/tar-extracts-all-subdirs | 12 + .../conf/busybox/testsuite/tar/tar-extracts-file | 5 + .../testsuite/tar/tar-extracts-from-standard-input | 5 + .../testsuite/tar/tar-extracts-multiple-files | 6 + .../testsuite/tar/tar-extracts-to-standard-output | 3 + .../busybox/testsuite/tar/tar-handles-cz-options | 5 + ...andles-empty-include-and-non-empty-exclude-list | 6 + .../tar/tar-handles-exclude-and-extract-lists | 8 + .../testsuite/tar/tar-handles-multiple-X-options | 10 + .../testsuite/tar/tar-handles-nested-exclude | 9 + .../initrd/conf/busybox/testsuite/taskset.tests | 17 + .../conf/busybox/testsuite/tee/tee-appends-input | 5 + .../conf/busybox/testsuite/tee/tee-tees-input | 3 + i/pc104/initrd/conf/busybox/testsuite/testing.sh | 154 + .../busybox/testsuite/touch/touch-creates-file | 2 + .../testsuite/touch/touch-does-not-create-file | 2 + .../touch-touches-files-after-non-existent-file | 3 + .../initrd/conf/busybox/testsuite/tr/tr-d-works | 4 + .../initrd/conf/busybox/testsuite/tr/tr-non-gnu | 1 + i/pc104/initrd/conf/busybox/testsuite/tr/tr-works | 24 + .../conf/busybox/testsuite/true/true-is-silent | 1 + .../busybox/testsuite/true/true-returns-success | 1 + .../initrd/conf/busybox/testsuite/umlwrapper.sh | 20 + i/pc104/initrd/conf/busybox/testsuite/uniq.tests | 70 + i/pc104/initrd/conf/busybox/testsuite/unzip.tests | 38 + .../conf/busybox/testsuite/uptime/uptime-works | 2 + .../initrd/conf/busybox/testsuite/uuencode.tests | 28 + .../initrd/conf/busybox/testsuite/wc/wc-counts-all | 2 + .../conf/busybox/testsuite/wc/wc-counts-characters | 1 + .../conf/busybox/testsuite/wc/wc-counts-lines | 1 + .../conf/busybox/testsuite/wc/wc-counts-words | 1 + .../testsuite/wc/wc-prints-longest-line-length | 1 + .../busybox/testsuite/wget/wget--O-overrides--P | 3 + .../busybox/testsuite/wget/wget-handles-empty-path | 1 + .../testsuite/wget/wget-retrieves-google-index | 2 + .../conf/busybox/testsuite/wget/wget-supports--P | 3 + .../testsuite/which/which-uses-default-path | 4 + .../conf/busybox/testsuite/xargs/xargs-works | 4 + i/pc104/initrd/conf/busybox/util-linux/Config.in | 509 + i/pc104/initrd/conf/busybox/util-linux/Kbuild | 32 + i/pc104/initrd/conf/busybox/util-linux/dmesg.c | 54 + i/pc104/initrd/conf/busybox/util-linux/fbset.c | 408 + i/pc104/initrd/conf/busybox/util-linux/fdformat.c | 144 + i/pc104/initrd/conf/busybox/util-linux/fdisk.c | 3018 +++++ i/pc104/initrd/conf/busybox/util-linux/fdisk_aix.c | 73 + i/pc104/initrd/conf/busybox/util-linux/fdisk_osf.c | 1063 ++ i/pc104/initrd/conf/busybox/util-linux/fdisk_sgi.c | 891 ++ i/pc104/initrd/conf/busybox/util-linux/fdisk_sun.c | 730 + .../initrd/conf/busybox/util-linux/freeramdisk.c | 35 + .../initrd/conf/busybox/util-linux/fsck_minix.c | 1390 ++ i/pc104/initrd/conf/busybox/util-linux/getopt.c | 366 + i/pc104/initrd/conf/busybox/util-linux/hexdump.c | 102 + i/pc104/initrd/conf/busybox/util-linux/hwclock.c | 222 + i/pc104/initrd/conf/busybox/util-linux/ipcrm.c | 218 + i/pc104/initrd/conf/busybox/util-linux/ipcs.c | 631 + i/pc104/initrd/conf/busybox/util-linux/losetup.c | 65 + i/pc104/initrd/conf/busybox/util-linux/mdev.c | 270 + i/pc104/initrd/conf/busybox/util-linux/minix.h | 76 + .../initrd/conf/busybox/util-linux/mkfs_minix.c | 718 + i/pc104/initrd/conf/busybox/util-linux/mkswap.c | 48 + i/pc104/initrd/conf/busybox/util-linux/more.c | 173 + i/pc104/initrd/conf/busybox/util-linux/mount.c | 1742 +++ .../initrd/conf/busybox/util-linux/pivot_root.c | 27 + i/pc104/initrd/conf/busybox/util-linux/rdate.c | 71 + .../initrd/conf/busybox/util-linux/readprofile.c | 237 + i/pc104/initrd/conf/busybox/util-linux/setarch.c | 53 + i/pc104/initrd/conf/busybox/util-linux/swaponoff.c | 77 + .../initrd/conf/busybox/util-linux/switch_root.c | 123 + i/pc104/initrd/conf/busybox/util-linux/umount.c | 152 + 959 files changed, 231655 insertions(+) create mode 100644 i/pc104/initrd/conf/busybox.links create mode 100644 i/pc104/initrd/conf/busybox/AUTHORS create mode 100644 i/pc104/initrd/conf/busybox/Config.in create mode 100644 i/pc104/initrd/conf/busybox/INSTALL create mode 100644 i/pc104/initrd/conf/busybox/LICENSE create mode 100644 i/pc104/initrd/conf/busybox/Makefile create mode 100644 i/pc104/initrd/conf/busybox/Makefile.custom create mode 100644 i/pc104/initrd/conf/busybox/Makefile.flags create mode 100644 i/pc104/initrd/conf/busybox/Makefile.help create mode 100644 i/pc104/initrd/conf/busybox/README create mode 100644 i/pc104/initrd/conf/busybox/TODO create mode 100644 i/pc104/initrd/conf/busybox/applets/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/applets/applets.c create mode 100644 i/pc104/initrd/conf/busybox/applets/busybox.c create mode 100755 i/pc104/initrd/conf/busybox/applets/busybox.mkll create mode 100644 i/pc104/initrd/conf/busybox/applets/individual.c create mode 100755 i/pc104/initrd/conf/busybox/applets/install.sh create mode 100644 i/pc104/initrd/conf/busybox/applets/usage.c create mode 100755 i/pc104/initrd/conf/busybox/applets/usage_compressed create mode 100644 i/pc104/initrd/conf/busybox/arch/i386/Makefile create mode 100644 i/pc104/initrd/conf/busybox/archival/Config.in create mode 100644 i/pc104/initrd/conf/busybox/archival/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/archival/ar.c create mode 100644 i/pc104/initrd/conf/busybox/archival/bbunzip.c create mode 100644 i/pc104/initrd/conf/busybox/archival/cpio.c create mode 100644 i/pc104/initrd/conf/busybox/archival/dpkg.c create mode 100644 i/pc104/initrd/conf/busybox/archival/dpkg_deb.c create mode 100644 i/pc104/initrd/conf/busybox/archival/gzip.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/archive_xread_all_eof.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/check_header_gzip.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/data_align.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_all.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_to_buffer.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_to_stdout.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/data_skip.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_bunzip2.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_uncompress.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_unlzma.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_unzip.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_all.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_list.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_list_reassign.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_reject_list.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/find_list_entry.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_ar.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_cpio.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_bz2.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_gz.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_lzma.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/header_list.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/header_skip.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/header_verbose_list.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/init_handle.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/open_transformer.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/seek_by_jump.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/seek_by_read.c create mode 100644 i/pc104/initrd/conf/busybox/archival/libunarchive/unpack_ar_archive.c create mode 100644 i/pc104/initrd/conf/busybox/archival/rpm.c create mode 100644 i/pc104/initrd/conf/busybox/archival/rpm2cpio.c create mode 100644 i/pc104/initrd/conf/busybox/archival/tar.c create mode 100644 i/pc104/initrd/conf/busybox/archival/unzip.c create mode 100755 i/pc104/initrd/conf/busybox/busybox create mode 100644 i/pc104/initrd/conf/busybox/busybox.links create mode 100644 i/pc104/initrd/conf/busybox/console-tools/Config.in create mode 100644 i/pc104/initrd/conf/busybox/console-tools/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/console-tools/chvt.c create mode 100644 i/pc104/initrd/conf/busybox/console-tools/clear.c create mode 100644 i/pc104/initrd/conf/busybox/console-tools/deallocvt.c create mode 100644 i/pc104/initrd/conf/busybox/console-tools/dumpkmap.c create mode 100644 i/pc104/initrd/conf/busybox/console-tools/loadfont.c create mode 100644 i/pc104/initrd/conf/busybox/console-tools/loadkmap.c create mode 100644 i/pc104/initrd/conf/busybox/console-tools/openvt.c create mode 100644 i/pc104/initrd/conf/busybox/console-tools/reset.c create mode 100644 i/pc104/initrd/conf/busybox/console-tools/resize.c create mode 100644 i/pc104/initrd/conf/busybox/console-tools/setconsole.c create mode 100644 i/pc104/initrd/conf/busybox/console-tools/setkeycodes.c create mode 100644 i/pc104/initrd/conf/busybox/console-tools/setlogcons.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/Config.in create mode 100644 i/pc104/initrd/conf/busybox/coreutils/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/coreutils/basename.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/cal.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/cat.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/catv.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/chgrp.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/chmod.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/chown.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/chroot.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/cksum.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/cmp.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/comm.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/cp.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/cut.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/date.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/dd.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/df.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/diff.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/dirname.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/dos2unix.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/du.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/echo.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/env.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/expr.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/false.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/fold.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/head.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/hostid.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/id.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/install.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/length.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/libcoreutils/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/coreutils/libcoreutils/coreutils.h create mode 100644 i/pc104/initrd/conf/busybox/coreutils/libcoreutils/cp_mv_stat.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/libcoreutils/getopt_mk_fifo_nod.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/ln.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/logname.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/ls.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/md5_sha1_sum.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/mkdir.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/mkfifo.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/mknod.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/mv.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/nice.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/nohup.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/od.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/od_bloaty.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/printenv.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/printf.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/pwd.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/realpath.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/rm.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/rmdir.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/seq.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/sleep.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/sort.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/stat.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/stty.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/sum.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/sync.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/tail.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/tee.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/test.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/touch.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/tr.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/true.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/tty.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/uname.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/uniq.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/usleep.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/uudecode.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/uuencode.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/watch.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/wc.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/who.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/whoami.c create mode 100644 i/pc104/initrd/conf/busybox/coreutils/yes.c create mode 100644 i/pc104/initrd/conf/busybox/debianutils/Config.in create mode 100644 i/pc104/initrd/conf/busybox/debianutils/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/debianutils/mktemp.c create mode 100644 i/pc104/initrd/conf/busybox/debianutils/pipe_progress.c create mode 100644 i/pc104/initrd/conf/busybox/debianutils/readlink.c create mode 100644 i/pc104/initrd/conf/busybox/debianutils/run_parts.c create mode 100644 i/pc104/initrd/conf/busybox/debianutils/start_stop_daemon.c create mode 100644 i/pc104/initrd/conf/busybox/debianutils/which.c create mode 100755 i/pc104/initrd/conf/busybox/docs/autodocifier.pl create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/FAQ.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/about.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/busybox-growth.ps create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/copyright.txt create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/developer.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/download.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/footer.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/header.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/back.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/busybox.jpeg create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/busybox.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/busybox1.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/busybox2.jpg create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/busybox3.jpg create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/dir.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/donate.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/fm.mini.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/gfx_by_gimp.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/ltbutton2.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/osuosl.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/sdsmall.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/text.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/valid-html401.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/vh40.gif create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/images/written.in.vi.png create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/index.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/license.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/links.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/lists.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/news.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/oldnews.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/products.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/screenshot.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/shame.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/sponsors.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/subversion.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox.net/tinyutils.html create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox_footer.pod create mode 100644 i/pc104/initrd/conf/busybox/docs/busybox_header.pod create mode 100644 i/pc104/initrd/conf/busybox/docs/cgi/cl.html create mode 100644 i/pc104/initrd/conf/busybox/docs/cgi/env.html create mode 100644 i/pc104/initrd/conf/busybox/docs/cgi/in.html create mode 100644 i/pc104/initrd/conf/busybox/docs/cgi/interface.html create mode 100644 i/pc104/initrd/conf/busybox/docs/cgi/out.html create mode 100644 i/pc104/initrd/conf/busybox/docs/contributing.txt create mode 100644 i/pc104/initrd/conf/busybox/docs/draft-coar-cgi-v11-03-clean.html create mode 100644 i/pc104/initrd/conf/busybox/docs/ipv4_ipv6.txt create mode 100644 i/pc104/initrd/conf/busybox/docs/keep_data_small.txt create mode 100644 i/pc104/initrd/conf/busybox/docs/mdev.txt create mode 100644 i/pc104/initrd/conf/busybox/docs/new-applet-HOWTO.txt create mode 100644 i/pc104/initrd/conf/busybox/docs/sigint.htm create mode 100644 i/pc104/initrd/conf/busybox/docs/style-guide.txt create mode 100644 i/pc104/initrd/conf/busybox/docs/tar_pax.txt create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/Config.in create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/README create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/chattr.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/e2fs_defs.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/e2fs_lib.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/e2fs_lib.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/fsck.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/lsattr.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/Config.in create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/README create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/blkid.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/blkidP.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/blkid_getsize.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/cache.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/dev.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/devname.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/devno.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/list.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/list.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/probe.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/probe.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/read.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/resolve.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/save.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/blkid/tag.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/chattr.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2fsbb.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2fsck.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2fsck.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/e2p.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/feature.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/fgetsetflags.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/fgetsetversion.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/hashstr.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/iod.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/ls.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/mntopts.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/ostype.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/parse_num.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/pe.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/pf.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/ps.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/e2p/uuid.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/alloc.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/alloc_sb.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/alloc_stats.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/alloc_tables.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/badblocks.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/bb_compat.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/bitmaps.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/bitops.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/bitops.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/block.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/bmap.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/bmove.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/brel.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/brel_ma.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/check_desc.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/closefs.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/cmp_bitmaps.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/dblist.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/dblist_dir.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/dir_iterate.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/dirblock.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/dirhash.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/dupfs.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/e2image.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/expanddir.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2_err.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2_ext_attr.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2_io.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2_types.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2fsP.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs_inline.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext_attr.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/fileio.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/finddev.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/flushb.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/freefs.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/gen_bitmap.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/getsectsize.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/getsize.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/icount.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/imager.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/ind_block.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/inline.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/inode.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/inode_io.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/io_manager.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/irel.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/irel_ma.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/ismounted.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/jfs_dat.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/kernel-jbd.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/kernel-list.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/link.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/lookup.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/mkdir.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/namei.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/newdir.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/openfs.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/read_bb.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/read_bb_file.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/rs_bitmap.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/sparse.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/swapfs.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/test_io.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/unix_io.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/unlink.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/valid_blk.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/version.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/ext2fs/write_bb_file.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/fsck.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/fsck.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/lsattr.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/mke2fs.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/tune2fs.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/util.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/util.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/uuid/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/uuid/compare.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/uuid/gen_uuid.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/uuid/pack.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/uuid/parse.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/uuid/unpack.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/uuid/unparse.c create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/uuid/uuid.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/uuid/uuidP.h create mode 100644 i/pc104/initrd/conf/busybox/e2fsprogs/old_e2fsprogs/uuid/uuid_time.c create mode 100644 i/pc104/initrd/conf/busybox/editors/Config.in create mode 100644 i/pc104/initrd/conf/busybox/editors/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/editors/awk.c create mode 100644 i/pc104/initrd/conf/busybox/editors/ed.c create mode 100644 i/pc104/initrd/conf/busybox/editors/patch.c create mode 100644 i/pc104/initrd/conf/busybox/editors/sed.c create mode 100644 i/pc104/initrd/conf/busybox/editors/vi.c create mode 100644 i/pc104/initrd/conf/busybox/examples/bootfloppy/bootfloppy.txt create mode 100644 i/pc104/initrd/conf/busybox/examples/bootfloppy/display.txt create mode 100644 i/pc104/initrd/conf/busybox/examples/bootfloppy/etc/fstab create mode 100755 i/pc104/initrd/conf/busybox/examples/bootfloppy/etc/init.d/rcS create mode 100644 i/pc104/initrd/conf/busybox/examples/bootfloppy/etc/inittab create mode 100644 i/pc104/initrd/conf/busybox/examples/bootfloppy/etc/profile create mode 100755 i/pc104/initrd/conf/busybox/examples/bootfloppy/mkdevs.sh create mode 100755 i/pc104/initrd/conf/busybox/examples/bootfloppy/mkrootfs.sh create mode 100755 i/pc104/initrd/conf/busybox/examples/bootfloppy/mksyslinux.sh create mode 100644 i/pc104/initrd/conf/busybox/examples/bootfloppy/quickstart.txt create mode 100644 i/pc104/initrd/conf/busybox/examples/bootfloppy/syslinux.cfg create mode 100644 i/pc104/initrd/conf/busybox/examples/busybox.spec create mode 100755 i/pc104/initrd/conf/busybox/examples/depmod.pl create mode 100644 i/pc104/initrd/conf/busybox/examples/devfsd.conf create mode 100644 i/pc104/initrd/conf/busybox/examples/dnsd.conf create mode 100644 i/pc104/initrd/conf/busybox/examples/inetd.conf create mode 100644 i/pc104/initrd/conf/busybox/examples/inittab create mode 100755 i/pc104/initrd/conf/busybox/examples/mk2knr.pl create mode 100755 i/pc104/initrd/conf/busybox/examples/udhcp/sample.bound create mode 100755 i/pc104/initrd/conf/busybox/examples/udhcp/sample.deconfig create mode 100755 i/pc104/initrd/conf/busybox/examples/udhcp/sample.nak create mode 100755 i/pc104/initrd/conf/busybox/examples/udhcp/sample.renew create mode 100644 i/pc104/initrd/conf/busybox/examples/udhcp/sample.script create mode 100644 i/pc104/initrd/conf/busybox/examples/udhcp/simple.script create mode 100644 i/pc104/initrd/conf/busybox/examples/udhcp/udhcpd.conf create mode 100644 i/pc104/initrd/conf/busybox/examples/undeb create mode 100644 i/pc104/initrd/conf/busybox/examples/unrpm create mode 100644 i/pc104/initrd/conf/busybox/examples/zcip.script create mode 100644 i/pc104/initrd/conf/busybox/findutils/Config.in create mode 100644 i/pc104/initrd/conf/busybox/findutils/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/findutils/find.c create mode 100644 i/pc104/initrd/conf/busybox/findutils/grep.c create mode 100644 i/pc104/initrd/conf/busybox/findutils/xargs.c create mode 100644 i/pc104/initrd/conf/busybox/include/applets.h create mode 100644 i/pc104/initrd/conf/busybox/include/busybox.h create mode 100644 i/pc104/initrd/conf/busybox/include/dump.h create mode 100644 i/pc104/initrd/conf/busybox/include/grp_.h create mode 100644 i/pc104/initrd/conf/busybox/include/inet_common.h create mode 100644 i/pc104/initrd/conf/busybox/include/libbb.h create mode 100644 i/pc104/initrd/conf/busybox/include/platform.h create mode 100644 i/pc104/initrd/conf/busybox/include/pwd_.h create mode 100644 i/pc104/initrd/conf/busybox/include/shadow_.h create mode 100644 i/pc104/initrd/conf/busybox/include/unarchive.h create mode 100644 i/pc104/initrd/conf/busybox/include/usage.h create mode 100644 i/pc104/initrd/conf/busybox/include/xatonum.h create mode 100644 i/pc104/initrd/conf/busybox/include/xregex.h create mode 100644 i/pc104/initrd/conf/busybox/init/Config.in create mode 100644 i/pc104/initrd/conf/busybox/init/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/init/halt.c create mode 100644 i/pc104/initrd/conf/busybox/init/init.c create mode 100644 i/pc104/initrd/conf/busybox/init/mesg.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/Config.in create mode 100644 i/pc104/initrd/conf/busybox/libbb/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/libbb/README create mode 100644 i/pc104/initrd/conf/busybox/libbb/ask_confirmation.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/bb_askpass.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/bb_do_delay.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/bb_pwd.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/bb_strtonum.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/change_identity.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/chomp.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/compare_string_array.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/concat_path_file.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/concat_subpath_file.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/copy_file.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/copyfd.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/correct_password.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/crc32.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/create_icmp6_socket.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/create_icmp_socket.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/default_error_retval.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/device_open.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/dump.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/error_msg.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/error_msg_and_die.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/execable.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/fclose_nonstdin.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/fflush_stdout_and_exit.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/fgets_str.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/find_mount_point.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/find_pid_by_name.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/find_root_device.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/full_write.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/get_console.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/get_last_path_component.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/get_line_from_file.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/getopt32.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/herror_msg.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/herror_msg_and_die.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/human_readable.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/inet_common.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/info_msg.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/inode_hash.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/isdirectory.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/kernel_version.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/last_char_is.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/lineedit.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/llist.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/login.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/loop.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/make_directory.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/makedev.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/md5.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/messages.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/mode_string.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/mtab.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/mtab_file.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/obscure.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/parse_mode.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/perror_msg.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/perror_msg_and_die.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/perror_nomsg.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/perror_nomsg_and_die.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/process_escape_sequence.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/procps.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/pw_encrypt.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/read.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/recursive_action.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/remove_file.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/restricted_shell.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/run_shell.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/safe_strncpy.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/safe_write.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/selinux_common.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/setup_environment.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/sha1.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/simplify_path.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/skip_whitespace.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/speed_table.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/trim.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/u_signal_names.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/uuencode.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/vdprintf.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/verror_msg.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/vfork_daemon_rexec.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/vherror_msg.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/vinfo_msg.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/vperror_msg.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/warn_ignoring_args.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/wfopen.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/wfopen_input.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/xatonum.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/xatonum_template.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/xconnect.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/xfuncs.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/xgetcwd.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/xgethostbyname.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/xreadlink.c create mode 100644 i/pc104/initrd/conf/busybox/libbb/xregcomp.c create mode 100644 i/pc104/initrd/conf/busybox/libpwdgrp/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/libpwdgrp/pwd_grp.c create mode 100644 i/pc104/initrd/conf/busybox/libpwdgrp/pwd_grp_internal.c create mode 100644 i/pc104/initrd/conf/busybox/libpwdgrp/uidgid_get.c create mode 100644 i/pc104/initrd/conf/busybox/loginutils/Config.in create mode 100644 i/pc104/initrd/conf/busybox/loginutils/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/loginutils/addgroup.c create mode 100644 i/pc104/initrd/conf/busybox/loginutils/adduser.c create mode 100644 i/pc104/initrd/conf/busybox/loginutils/deluser.c create mode 100644 i/pc104/initrd/conf/busybox/loginutils/getty.c create mode 100644 i/pc104/initrd/conf/busybox/loginutils/login.c create mode 100644 i/pc104/initrd/conf/busybox/loginutils/passwd.c create mode 100644 i/pc104/initrd/conf/busybox/loginutils/su.c create mode 100644 i/pc104/initrd/conf/busybox/loginutils/sulogin.c create mode 100644 i/pc104/initrd/conf/busybox/loginutils/vlock.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/Config.in create mode 100644 i/pc104/initrd/conf/busybox/miscutils/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/miscutils/adjtimex.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/bbconfig.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/chrt.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/crond.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/crontab.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/dc.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/devfsd.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/eject.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/hdparm.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/last.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/less.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/makedevs.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/mountpoint.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/mt.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/nmeter.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/raidautorun.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/readahead.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/runlevel.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/rx.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/setsid.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/strings.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/taskset.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/time.c create mode 100644 i/pc104/initrd/conf/busybox/miscutils/watchdog.c create mode 100644 i/pc104/initrd/conf/busybox/modutils/Config.in create mode 100644 i/pc104/initrd/conf/busybox/modutils/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/modutils/insmod.c create mode 100644 i/pc104/initrd/conf/busybox/modutils/lsmod.c create mode 100644 i/pc104/initrd/conf/busybox/modutils/modprobe.c create mode 100644 i/pc104/initrd/conf/busybox/modutils/rmmod.c create mode 100644 i/pc104/initrd/conf/busybox/networking/Config.in create mode 100644 i/pc104/initrd/conf/busybox/networking/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/networking/arp.c create mode 100644 i/pc104/initrd/conf/busybox/networking/arping.c create mode 100644 i/pc104/initrd/conf/busybox/networking/dnsd.c create mode 100644 i/pc104/initrd/conf/busybox/networking/ether-wake.c create mode 100644 i/pc104/initrd/conf/busybox/networking/ftpgetput.c create mode 100644 i/pc104/initrd/conf/busybox/networking/hostname.c create mode 100644 i/pc104/initrd/conf/busybox/networking/httpd.c create mode 100644 i/pc104/initrd/conf/busybox/networking/httpd_index_cgi_example create mode 100644 i/pc104/initrd/conf/busybox/networking/ifconfig.c create mode 100644 i/pc104/initrd/conf/busybox/networking/ifupdown.c create mode 100644 i/pc104/initrd/conf/busybox/networking/inetd.c create mode 100644 i/pc104/initrd/conf/busybox/networking/interface.c create mode 100644 i/pc104/initrd/conf/busybox/networking/ip.c create mode 100644 i/pc104/initrd/conf/busybox/networking/ipaddr.c create mode 100644 i/pc104/initrd/conf/busybox/networking/ipcalc.c create mode 100644 i/pc104/initrd/conf/busybox/networking/iplink.c create mode 100644 i/pc104/initrd/conf/busybox/networking/iproute.c create mode 100644 i/pc104/initrd/conf/busybox/networking/iprule.c create mode 100644 i/pc104/initrd/conf/busybox/networking/iptunnel.c create mode 100644 i/pc104/initrd/conf/busybox/networking/isrv.c create mode 100644 i/pc104/initrd/conf/busybox/networking/isrv.h create mode 100644 i/pc104/initrd/conf/busybox/networking/isrv_identd.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/ip_common.h create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/ip_parse_common_args.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/ipaddress.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/iplink.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/iproute.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/iprule.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/iptunnel.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/libnetlink.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/libnetlink.h create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/ll_addr.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/ll_map.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/ll_map.h create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/ll_proto.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/ll_types.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/rt_names.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/rt_names.h create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/rtm_map.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/rtm_map.h create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/utils.c create mode 100644 i/pc104/initrd/conf/busybox/networking/libiproute/utils.h create mode 100644 i/pc104/initrd/conf/busybox/networking/nameif.c create mode 100644 i/pc104/initrd/conf/busybox/networking/nc.c create mode 100644 i/pc104/initrd/conf/busybox/networking/netstat.c create mode 100644 i/pc104/initrd/conf/busybox/networking/nslookup.c create mode 100644 i/pc104/initrd/conf/busybox/networking/ping.c create mode 100644 i/pc104/initrd/conf/busybox/networking/route.c create mode 100644 i/pc104/initrd/conf/busybox/networking/telnet.c create mode 100644 i/pc104/initrd/conf/busybox/networking/telnetd.c create mode 100644 i/pc104/initrd/conf/busybox/networking/tftp.c create mode 100644 i/pc104/initrd/conf/busybox/networking/traceroute.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/Config.in create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/arpping.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/clientpacket.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/clientsocket.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/common.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/common.h create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/dhcpc.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/dhcpc.h create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/dhcpd.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/dhcpd.h create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/dhcprelay.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/domain_codec.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/dumpleases.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/files.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/leases.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/options.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/options.h create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/packet.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/pidfile.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/script.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/serverpacket.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/signalpipe.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/socket.c create mode 100644 i/pc104/initrd/conf/busybox/networking/udhcp/static_leases.c create mode 100644 i/pc104/initrd/conf/busybox/networking/vconfig.c create mode 100644 i/pc104/initrd/conf/busybox/networking/wget.c create mode 100644 i/pc104/initrd/conf/busybox/networking/zcip.c create mode 100644 i/pc104/initrd/conf/busybox/procps/Config.in create mode 100644 i/pc104/initrd/conf/busybox/procps/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/procps/free.c create mode 100644 i/pc104/initrd/conf/busybox/procps/fuser.c create mode 100644 i/pc104/initrd/conf/busybox/procps/kill.c create mode 100644 i/pc104/initrd/conf/busybox/procps/pidof.c create mode 100644 i/pc104/initrd/conf/busybox/procps/ps.c create mode 100644 i/pc104/initrd/conf/busybox/procps/ps.posix create mode 100644 i/pc104/initrd/conf/busybox/procps/renice.c create mode 100644 i/pc104/initrd/conf/busybox/procps/sysctl.c create mode 100644 i/pc104/initrd/conf/busybox/procps/top.c create mode 100644 i/pc104/initrd/conf/busybox/procps/uptime.c create mode 100644 i/pc104/initrd/conf/busybox/runit/Config.in create mode 100644 i/pc104/initrd/conf/busybox/runit/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/runit/chpst.c create mode 100644 i/pc104/initrd/conf/busybox/runit/runit_lib.c create mode 100644 i/pc104/initrd/conf/busybox/runit/runit_lib.h create mode 100644 i/pc104/initrd/conf/busybox/runit/runsv.c create mode 100644 i/pc104/initrd/conf/busybox/runit/runsvdir.c create mode 100644 i/pc104/initrd/conf/busybox/runit/sv.c create mode 100644 i/pc104/initrd/conf/busybox/runit/svlogd.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/scripts/Kbuild.include create mode 100644 i/pc104/initrd/conf/busybox/scripts/Makefile.IMA create mode 100644 i/pc104/initrd/conf/busybox/scripts/Makefile.build create mode 100644 i/pc104/initrd/conf/busybox/scripts/Makefile.clean create mode 100644 i/pc104/initrd/conf/busybox/scripts/Makefile.host create mode 100644 i/pc104/initrd/conf/busybox/scripts/Makefile.lib create mode 100644 i/pc104/initrd/conf/busybox/scripts/basic/Makefile create mode 100644 i/pc104/initrd/conf/busybox/scripts/basic/docproc.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/basic/fixdep.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/basic/split-include.c create mode 100755 i/pc104/initrd/conf/busybox/scripts/bloat-o-meter create mode 100755 i/pc104/initrd/conf/busybox/scripts/checkhelp.awk create mode 100644 i/pc104/initrd/conf/busybox/scripts/defconfig create mode 100755 i/pc104/initrd/conf/busybox/scripts/gcc-version.sh create mode 100755 i/pc104/initrd/conf/busybox/scripts/individual create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/Makefile create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/POTFILES.in create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/conf.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/confdata.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/expr.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/expr.h create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/gconf.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/gconf.glade create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/images.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/kconfig_load.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/kxgettext.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lex.zconf.c_shipped create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lkc.h create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lkc_proto.h create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/BIG.FAT.WARNING create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/Makefile create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/check-lxdialog.sh create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/checklist.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/colors.h create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/dialog.h create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/inputbox.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/lxdialog.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/menubox.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/msgbox.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/textbox.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/util.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/lxdialog/yesno.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/mconf.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/menu.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/qconf.cc create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/qconf.h create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/symbol.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/util.c create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/zconf.gperf create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/zconf.hash.c_shipped create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/zconf.l create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/zconf.tab.c_shipped create mode 100644 i/pc104/initrd/conf/busybox/scripts/kconfig/zconf.y create mode 100755 i/pc104/initrd/conf/busybox/scripts/mkconfigs create mode 100755 i/pc104/initrd/conf/busybox/scripts/mkmakefile create mode 100755 i/pc104/initrd/conf/busybox/scripts/objsizes create mode 100755 i/pc104/initrd/conf/busybox/scripts/showasm create mode 100755 i/pc104/initrd/conf/busybox/scripts/trylink create mode 100644 i/pc104/initrd/conf/busybox/selinux/Config.in create mode 100644 i/pc104/initrd/conf/busybox/selinux/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/selinux/chcon.c create mode 100644 i/pc104/initrd/conf/busybox/selinux/getenforce.c create mode 100644 i/pc104/initrd/conf/busybox/selinux/getsebool.c create mode 100644 i/pc104/initrd/conf/busybox/selinux/matchpathcon.c create mode 100644 i/pc104/initrd/conf/busybox/selinux/runcon.c create mode 100644 i/pc104/initrd/conf/busybox/selinux/selinuxenabled.c create mode 100644 i/pc104/initrd/conf/busybox/selinux/setenforce.c create mode 100644 i/pc104/initrd/conf/busybox/shell/Config.in create mode 100644 i/pc104/initrd/conf/busybox/shell/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/shell/ash.c create mode 100644 i/pc104/initrd/conf/busybox/shell/ash_test/ash-alias/alias.right create mode 100755 i/pc104/initrd/conf/busybox/shell/ash_test/ash-alias/alias.tests create mode 100644 i/pc104/initrd/conf/busybox/shell/ash_test/ash-arith/README.ash create mode 100644 i/pc104/initrd/conf/busybox/shell/ash_test/ash-arith/arith-for.right create mode 100755 i/pc104/initrd/conf/busybox/shell/ash_test/ash-arith/arith-for.testsx create mode 100644 i/pc104/initrd/conf/busybox/shell/ash_test/ash-arith/arith.right create mode 100755 i/pc104/initrd/conf/busybox/shell/ash_test/ash-arith/arith.tests create mode 100755 i/pc104/initrd/conf/busybox/shell/ash_test/ash-arith/arith1.sub create mode 100755 i/pc104/initrd/conf/busybox/shell/ash_test/ash-arith/arith2.sub create mode 100644 i/pc104/initrd/conf/busybox/shell/ash_test/ash-heredoc/heredoc.right create mode 100755 i/pc104/initrd/conf/busybox/shell/ash_test/ash-heredoc/heredoc.tests create mode 100644 i/pc104/initrd/conf/busybox/shell/ash_test/ash-invert/invert.right create mode 100755 i/pc104/initrd/conf/busybox/shell/ash_test/ash-invert/invert.tests create mode 100644 i/pc104/initrd/conf/busybox/shell/ash_test/printenv.c create mode 100644 i/pc104/initrd/conf/busybox/shell/ash_test/recho.c create mode 100755 i/pc104/initrd/conf/busybox/shell/ash_test/run-all create mode 100644 i/pc104/initrd/conf/busybox/shell/ash_test/zecho.c create mode 100644 i/pc104/initrd/conf/busybox/shell/bbsh.c create mode 100644 i/pc104/initrd/conf/busybox/shell/hush.c create mode 100644 i/pc104/initrd/conf/busybox/shell/lash.c create mode 100644 i/pc104/initrd/conf/busybox/shell/msh.c create mode 100644 i/pc104/initrd/conf/busybox/sysklogd/Config.in create mode 100644 i/pc104/initrd/conf/busybox/sysklogd/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/sysklogd/klogd.c create mode 100644 i/pc104/initrd/conf/busybox/sysklogd/logger.c create mode 100644 i/pc104/initrd/conf/busybox/sysklogd/logread.c create mode 100644 i/pc104/initrd/conf/busybox/sysklogd/syslogd.c create mode 100644 i/pc104/initrd/conf/busybox/testsuite/README create mode 100644 i/pc104/initrd/conf/busybox/testsuite/TODO create mode 100755 i/pc104/initrd/conf/busybox/testsuite/all_sourcecode.tests create mode 100644 i/pc104/initrd/conf/busybox/testsuite/basename/basename-does-not-remove-identical-extension create mode 100644 i/pc104/initrd/conf/busybox/testsuite/basename/basename-works create mode 100755 i/pc104/initrd/conf/busybox/testsuite/bunzip2.tests create mode 100644 i/pc104/initrd/conf/busybox/testsuite/bunzip2/bunzip2-reads-from-standard-input create mode 100644 i/pc104/initrd/conf/busybox/testsuite/bunzip2/bunzip2-removes-compressed-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/bunzip2/bzcat-does-not-remove-compressed-file create mode 100755 i/pc104/initrd/conf/busybox/testsuite/busybox.tests create mode 100755 i/pc104/initrd/conf/busybox/testsuite/bzcat.tests create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cat/cat-prints-a-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cat/cat-prints-a-file-and-standard-input create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cmp/cmp-detects-difference create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-a-files-to-dir create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-a-preserves-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-copies-empty-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-copies-large-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-copies-small-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-d-files-to-dir create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-dir-create-dir create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-dir-existing-dir create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-does-not-copy-unreadable-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-files-to-dir create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-follows-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-preserves-hard-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-preserves-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cp/cp-preserves-source-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cut/cut-cuts-a-character create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cut/cut-cuts-a-closed-range create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cut/cut-cuts-a-field create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cut/cut-cuts-an-open-range create mode 100644 i/pc104/initrd/conf/busybox/testsuite/cut/cut-cuts-an-unclosed-range create mode 100644 i/pc104/initrd/conf/busybox/testsuite/date/date-R-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/date/date-format-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/date/date-u-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/date/date-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/dd/dd-accepts-if create mode 100644 i/pc104/initrd/conf/busybox/testsuite/dd/dd-accepts-of create mode 100644 i/pc104/initrd/conf/busybox/testsuite/dd/dd-copies-from-standard-input-to-standard-output create mode 100644 i/pc104/initrd/conf/busybox/testsuite/dd/dd-prints-count-to-standard-error create mode 100644 i/pc104/initrd/conf/busybox/testsuite/dirname/dirname-handles-absolute-path create mode 100644 i/pc104/initrd/conf/busybox/testsuite/dirname/dirname-handles-empty-path create mode 100644 i/pc104/initrd/conf/busybox/testsuite/dirname/dirname-handles-multiple-slashes create mode 100644 i/pc104/initrd/conf/busybox/testsuite/dirname/dirname-handles-relative-path create mode 100644 i/pc104/initrd/conf/busybox/testsuite/dirname/dirname-handles-root create mode 100644 i/pc104/initrd/conf/busybox/testsuite/dirname/dirname-handles-single-component create mode 100644 i/pc104/initrd/conf/busybox/testsuite/dirname/dirname-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/du/du-h-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/du/du-k-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/du/du-l-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/du/du-m-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/du/du-s-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/du/du-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/echo/echo-does-not-print-newline create mode 100644 i/pc104/initrd/conf/busybox/testsuite/echo/echo-prints-argument create mode 100644 i/pc104/initrd/conf/busybox/testsuite/echo/echo-prints-arguments create mode 100644 i/pc104/initrd/conf/busybox/testsuite/echo/echo-prints-newline create mode 100644 i/pc104/initrd/conf/busybox/testsuite/expr/expr-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/false/false-is-silent create mode 100644 i/pc104/initrd/conf/busybox/testsuite/false/false-returns-failure create mode 100644 i/pc104/initrd/conf/busybox/testsuite/find/find-supports-minus-xdev create mode 100755 i/pc104/initrd/conf/busybox/testsuite/grep.tests create mode 100755 i/pc104/initrd/conf/busybox/testsuite/gunzip.tests create mode 100644 i/pc104/initrd/conf/busybox/testsuite/gunzip/gunzip-reads-from-standard-input create mode 100644 i/pc104/initrd/conf/busybox/testsuite/gzip/gzip-accepts-multiple-files create mode 100644 i/pc104/initrd/conf/busybox/testsuite/gzip/gzip-accepts-single-minus create mode 100644 i/pc104/initrd/conf/busybox/testsuite/gzip/gzip-removes-original-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/head/head-n-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/head/head-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/hostid/hostid-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/hostname/hostname-d-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/hostname/hostname-i-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/hostname/hostname-s-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/hostname/hostname-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/id/id-g-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/id/id-u-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/id/id-un-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/id/id-ur-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/ln/ln-creates-hard-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/ln/ln-creates-soft-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/ln/ln-force-creates-hard-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/ln/ln-force-creates-soft-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/ln/ln-preserves-hard-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/ln/ln-preserves-soft-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/ls/ls-1-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/ls/ls-h-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/ls/ls-l-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/ls/ls-s-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/md5sum/md5sum-verifies-non-binary-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mkdir/mkdir-makes-a-directory create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mkdir/mkdir-makes-parent-directories create mode 100755 i/pc104/initrd/conf/busybox/testsuite/mount.testroot create mode 100644 i/pc104/initrd/conf/busybox/testsuite/msh/msh-supports-underscores-in-variable-names create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-files-to-dir create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-follows-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-moves-empty-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-moves-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-moves-hardlinks create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-moves-large-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-moves-small-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-moves-symlinks create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-moves-unreadable-files create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-preserves-hard-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-preserves-links create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-refuses-mv-dir-to-subdir create mode 100644 i/pc104/initrd/conf/busybox/testsuite/mv/mv-removes-source-file create mode 100755 i/pc104/initrd/conf/busybox/testsuite/pidof.tests create mode 100644 i/pc104/initrd/conf/busybox/testsuite/pwd/pwd-prints-working-directory create mode 100755 i/pc104/initrd/conf/busybox/testsuite/readlink.tests create mode 100644 i/pc104/initrd/conf/busybox/testsuite/rm/rm-removes-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/rmdir/rmdir-removes-parent-directories create mode 100755 i/pc104/initrd/conf/busybox/testsuite/runtest create mode 100755 i/pc104/initrd/conf/busybox/testsuite/sed.tests create mode 100755 i/pc104/initrd/conf/busybox/testsuite/seq.tests create mode 100755 i/pc104/initrd/conf/busybox/testsuite/sort.tests create mode 100644 i/pc104/initrd/conf/busybox/testsuite/strings/strings-works-like-GNU create mode 100755 i/pc104/initrd/conf/busybox/testsuite/sum.tests create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tail/tail-n-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tail/tail-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-archives-multiple-files create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-complains-about-missing-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-demands-at-least-one-ctx create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-demands-at-most-one-ctx create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-extracts-all-subdirs create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-extracts-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-extracts-from-standard-input create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-extracts-multiple-files create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-extracts-to-standard-output create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-handles-cz-options create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-handles-empty-include-and-non-empty-exclude-list create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-handles-exclude-and-extract-lists create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-handles-multiple-X-options create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tar/tar-handles-nested-exclude create mode 100755 i/pc104/initrd/conf/busybox/testsuite/taskset.tests create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tee/tee-appends-input create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tee/tee-tees-input create mode 100755 i/pc104/initrd/conf/busybox/testsuite/testing.sh create mode 100644 i/pc104/initrd/conf/busybox/testsuite/touch/touch-creates-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/touch/touch-does-not-create-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/touch/touch-touches-files-after-non-existent-file create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tr/tr-d-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tr/tr-non-gnu create mode 100644 i/pc104/initrd/conf/busybox/testsuite/tr/tr-works create mode 100644 i/pc104/initrd/conf/busybox/testsuite/true/true-is-silent create mode 100644 i/pc104/initrd/conf/busybox/testsuite/true/true-returns-success create mode 100755 i/pc104/initrd/conf/busybox/testsuite/umlwrapper.sh create mode 100755 i/pc104/initrd/conf/busybox/testsuite/uniq.tests create mode 100755 i/pc104/initrd/conf/busybox/testsuite/unzip.tests create mode 100644 i/pc104/initrd/conf/busybox/testsuite/uptime/uptime-works create mode 100755 i/pc104/initrd/conf/busybox/testsuite/uuencode.tests create mode 100644 i/pc104/initrd/conf/busybox/testsuite/wc/wc-counts-all create mode 100644 i/pc104/initrd/conf/busybox/testsuite/wc/wc-counts-characters create mode 100644 i/pc104/initrd/conf/busybox/testsuite/wc/wc-counts-lines create mode 100644 i/pc104/initrd/conf/busybox/testsuite/wc/wc-counts-words create mode 100644 i/pc104/initrd/conf/busybox/testsuite/wc/wc-prints-longest-line-length create mode 100644 i/pc104/initrd/conf/busybox/testsuite/wget/wget--O-overrides--P create mode 100644 i/pc104/initrd/conf/busybox/testsuite/wget/wget-handles-empty-path create mode 100644 i/pc104/initrd/conf/busybox/testsuite/wget/wget-retrieves-google-index create mode 100644 i/pc104/initrd/conf/busybox/testsuite/wget/wget-supports--P create mode 100644 i/pc104/initrd/conf/busybox/testsuite/which/which-uses-default-path create mode 100644 i/pc104/initrd/conf/busybox/testsuite/xargs/xargs-works create mode 100644 i/pc104/initrd/conf/busybox/util-linux/Config.in create mode 100644 i/pc104/initrd/conf/busybox/util-linux/Kbuild create mode 100644 i/pc104/initrd/conf/busybox/util-linux/dmesg.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/fbset.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/fdformat.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/fdisk.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/fdisk_aix.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/fdisk_osf.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/fdisk_sgi.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/fdisk_sun.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/freeramdisk.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/fsck_minix.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/getopt.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/hexdump.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/hwclock.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/ipcrm.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/ipcs.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/losetup.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/mdev.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/minix.h create mode 100644 i/pc104/initrd/conf/busybox/util-linux/mkfs_minix.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/mkswap.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/more.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/mount.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/pivot_root.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/rdate.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/readprofile.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/setarch.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/swaponoff.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/switch_root.c create mode 100644 i/pc104/initrd/conf/busybox/util-linux/umount.c (limited to 'i') diff --git a/i/pc104/initrd/conf/busybox.links b/i/pc104/initrd/conf/busybox.links new file mode 100644 index 0000000..de85a50 --- /dev/null +++ b/i/pc104/initrd/conf/busybox.links @@ -0,0 +1,18 @@ +/usr/bin/[ +/usr/bin/[[ +/bin/ash +/usr/sbin/chroot +/bin/echo +/sbin/halt +/bin/hostname +/sbin/insmod +/bin/mount +/usr/bin/nc +/sbin/pivot_root +/sbin/reboot +/bin/sh +/bin/sleep +/bin/sync +/usr/bin/test +/sbin/udhcpc +/bin/umount diff --git a/i/pc104/initrd/conf/busybox/AUTHORS b/i/pc104/initrd/conf/busybox/AUTHORS new file mode 100644 index 0000000..8f6498b --- /dev/null +++ b/i/pc104/initrd/conf/busybox/AUTHORS @@ -0,0 +1,173 @@ +List of the authors of code contained in BusyBox. + +If you have code in BusyBox, you should be listed here. If you should be +listed, or the description of what you have done needs more detail, or is +incorrect, _please_ let me know. + + -Erik + +----------- + +Peter Willis + eject + +Emanuele Aina + run-parts + +Erik Andersen + Tons of new stuff, major rewrite of most of the + core apps, tons of new apps as noted in header files. + Lots of tedious effort writing these boring docs that + nobody is going to actually read. + +Laurence Anderson + rpm2cpio, unzip, get_header_cpio, read_gz interface, rpm + +Jeff Angielski + ftpput, ftpget + +Enrik Berkhan + setconsole + +Jim Bauer + modprobe shell dependency + +Edward Betts + expr, hostid, logname, whoami + +John Beppu + du, nslookup, sort + +David Brownell + zcip + +Brian Candler + tiny-ls(ls) + +Randolph Chung + fbset, ping, hostname + +Dave Cinege + more(v2), makedevs, dutmp, modularization, auto links file, + various fixes, Linux Router Project maintenance + +Jordan Crouse + ipcalc + +Magnus Damm + tftp client + insmod powerpc support + +Larry Doolittle + pristine source directory compilation, lots of patches and fixes. + +Glenn Engel + httpd + +Gennady Feldman + Sysklogd (single threaded syslogd, IPC Circular buffer support, + logread), various fixes. + +Robert Griebl + modprobe, hwclock, suid/sgid handling, tinylogin integration + many bugfixes and enhancements + +Karl M. Hegbloom + cp_mv.c, the test suite, various fixes to utility.c, &c. + +Daniel Jacobowitz + mktemp.c + +Matt Kraai + documentation, bugfixes, test suite + +Rob Landley + Became busybox maintainer in 2006. + + sed (major rewrite in 2003, and I now maintain the thing) + bunzip2 (complete from-scratch rewrite, then mjn3 optimized the result) + sort (more or less from scratch rewrite in 2004, I now maintain it) + mount (rewrite in 2005, I maintain the new one) + +Stephan Linz + ipcalc, Red Hat equivalence + +John Lombardo + tr + +Glenn McGrath + Common unarchiving code and unarchiving applets, ifupdown, ftpgetput, + nameif, sed, patch, fold, install, uudecode. + Various bugfixes, review and apply numerous patches. + +Manuel Novoa III + cat, head, mkfifo, mknod, rmdir, sleep, tee, tty, uniq, usleep, wc, yes, + mesg, vconfig, nice, renice, + make_directory, parse_mode, dirname, mode_string, + get_last_path_component, simplify_path, and a number trivial libbb routines + + also bug fixes, partial rewrites, and size optimizations in + ash, basename, cal, cmp, cp, df, du, echo, env, ln, logname, md5sum, mkdir, + mv, realpath, rm, sort, tail, touch, uname, watch, arith, human_readable, + interface, dutmp, ifconfig, route + +Vladimir Oleynik + cmdedit; bb_mkdep, xargs(current), httpd(current); + ports: ash, crond, fdisk (initial, unmaintained now), inetd, stty, traceroute, + top; + locale, various fixes + and irreconcilable critic of everything not perfect. + +Bruce Perens + Original author of BusyBox in 1995, 1996. Some of his code can + still be found hiding here and there... + +Rodney Radford + ipcs, ipcrm + +Tim Riker + bug fixes, member of fan club + +Kent Robotti + reset, tons and tons of bug reports and patches. + +Chip Rosenthal , + wget - Contributed by permission of Covad Communications + +Pavel Roskin + Lots of bugs fixes and patches. + +Gyepi Sam + Remote logging feature for syslogd + +Rob Sullivan + comm + +Linus Torvalds + mkswap, fsck.minix, mkfs.minix + +Mark Whitley + grep, sed, cut, xargs(previous), + style-guide, new-applet-HOWTO, bug fixes, etc. + +Charles P. Wright + gzip, mini-netcat(nc) + +Enrique Zanardi + tarcat (since removed), loadkmap, various fixes, Debian maintenance + +Tito Ragusa + devfsd and size optimizations in strings, openvt, chvt, deallocvt, hdparm, + fdformat, lsattr, chattr, id and eject. + +Paul Fox + vi editing mode for ash, various other patches/fixes + +Roberto A. Foglietta + port: dnsd + +Bernhard Fischer + misc + +Mike Frysinger + initial e2fsprogs, printenv, setarch, sum, misc diff --git a/i/pc104/initrd/conf/busybox/Config.in b/i/pc104/initrd/conf/busybox/Config.in new file mode 100644 index 0000000..d15b267 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/Config.in @@ -0,0 +1,496 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/kbuild/config-language.txt. +# + +mainmenu "BusyBox Configuration" + +config HAVE_DOT_CONFIG + bool + default y + +menu "Busybox Settings" + +menu "General Configuration" + +config NITPICK + bool "See lots more (probably unnecessary) configuration options." + default n + help + Some BusyBox applets have more configuration options than anyone + will ever care about. To avoid drowining people in complexity, most + of the applet features that can be set to a sane default value are + hidden, unless you hit the above switch. + + This is better than to telling people to edit the busybox source + code, but not by much. + + See http://en.wikipedia.org/wiki/Fibber_McGee_and_Molly#The_Closet + + You have been warned. + +config DESKTOP + bool "Enable options for full-blown desktop systems" + default n + help + Enable options and features which are not essential. + Select this only if you plan to use busybox on full-blown + desktop machine with common Linux distro, not on an embedded box. + +choice + prompt "Buffer allocation policy" + default FEATURE_BUFFERS_USE_MALLOC + depends on NITPICK + help + There are 3 ways BusyBox can handle buffer allocations: + - Use malloc. This costs code size for the call to xmalloc. + - Put them on stack. For some very small machines with limited stack + space, this can be deadly. For most folks, this works just fine. + - Put them in BSS. This works beautifully for computers with a real + MMU (and OS support), but wastes runtime RAM for uCLinux. This + behavior was the only one available for BusyBox versions 0.48 and + earlier. + +config FEATURE_BUFFERS_USE_MALLOC + bool "Allocate with Malloc" + +config FEATURE_BUFFERS_GO_ON_STACK + bool "Allocate on the Stack" + +config FEATURE_BUFFERS_GO_IN_BSS + bool "Allocate in the .bss section" + +endchoice + +config SHOW_USAGE + bool "Show terse applet usage messages" + default y + help + All BusyBox applets will show help messages when invoked with + wrong arguments. You can turn off printing these terse usage + messages if you say no here. + This will save you up to 7k. + +config FEATURE_VERBOSE_USAGE + bool "Show verbose applet usage messages" + default n + select SHOW_USAGE + help + All BusyBox applets will show more verbose help messages when + busybox is invoked with --help. This will add a lot of text to the + busybox binary. In the default configuration, this will add about + 13k, but it can add much more depending on your configuration. + +config FEATURE_COMPRESS_USAGE + bool "Store applet usage messages in compressed form" + default y + depends on SHOW_USAGE + help + Store usage messages in compressed form, uncompress them on-the-fly + when --help is called. + + If you have a really tiny busybox with few applets enabled (and + bunzip2 isn't one of them), the overhead of the decompressor might + be noticeable. Also, if you run executables directly from ROM + and have very little memory, this might not be a win. Otherwise, + you probably want this. + +config FEATURE_INSTALLER + bool "Support --install [-s] to install applet links at runtime" + default n + help + Enable 'busybox --install [-s]' support. This will allow you to use + busybox at runtime to create hard links or symlinks for all the + applets that are compiled into busybox. This feature requires the + /proc filesystem. + +config LOCALE_SUPPORT + bool "Enable locale support (system needs locale for this to work)" + default n + help + Enable this if your system has locale support and you would like + busybox to support locale settings. + +config GETOPT_LONG + bool "Enable support for --long-options" + default y + help + Enable this if you want busybox applets to use the gnu --long-option + style, in addition to single character -a -b -c style options. + +config FEATURE_DEVPTS + bool "Use the devpts filesystem for Unix98 PTYs" + default y + help + Enable if you want BusyBox to use Unix98 PTY support. If enabled, + busybox will use /dev/ptmx for the master side of the pseudoterminal + and /dev/pts/ for the slave side. Otherwise, BSD style + /dev/ttyp will be used. To use this option, you should have + devpts mounted. + +config FEATURE_CLEAN_UP + bool "Clean up all memory before exiting (usually not needed)" + default n + depends on NITPICK + help + As a size optimization, busybox normally exits without explicitly + freeing dynamically allocated memory or closing files. This saves + space since the OS will clean up for us, but it can confuse debuggers + like valgrind, which report tons of memory and resource leaks. + + Don't enable this unless you have a really good reason to clean + things up manually. + +config FEATURE_SUID + bool "Support for SUID/SGID handling" + default n + help + With this option you can install the busybox binary belonging + to root with the suid bit set, and it'll and it'll automatically drop + priviledges for applets that don't need root access. + + If you're really paranoid and don't want to do this, build two + busybox binaries with different applets in them (and the appropriate + symlinks pointing to each binary), and only set the suid bit on the + one that needs it. The applets currently marked to need the suid bit + are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs, + and vlock. + +config FEATURE_SYSLOG + bool "Support for syslog" + default n + help + This option is auto-selected when you select any applet which may + send its output to syslog. You do not need to select it manually. + +config FEATURE_SUID_CONFIG + bool "Runtime SUID/SGID configuration via /etc/busybox.conf" + default n if FEATURE_SUID + depends on FEATURE_SUID + help + Allow the SUID / SGID state of an applet to be determined at runtime + by checking /etc/busybox.conf. (This is sort of a poor man's sudo.) + The format of this file is as follows: + + = [Ssx-][Ssx-][x-] (|).(|) + + An example might help: + + [SUID] + su = ssx root.0 # applet su can be run by anyone and runs with euid=0/egid=0 + su = ssx # exactly the same + + mount = sx- root.disk # applet mount can be run by root and members of group disk + # and runs with euid=0 + + cp = --- # disable applet cp for everyone + + The file has to be owned by user root, group root and has to be + writeable only by root: + (chown 0.0 /etc/busybox.conf; chmod 600 /etc/busybox.conf) + The busybox executable has to be owned by user root, group + root and has to be setuid root for this to work: + (chown 0.0 /bin/busybox; chmod 4755 /bin/busybox) + + Robert 'sandman' Griebl has more information here: + . + +config FEATURE_SUID_CONFIG_QUIET + bool "Suppress warning message if /etc/busybox.conf is not readable" + default y + depends on FEATURE_SUID_CONFIG + help + /etc/busybox.conf should be readable by the user needing the SUID, check + this option to avoid users to be notified about missing permissions. + +config FEATURE_HAVE_RPC + bool "RPC support" + default y + help + Select this if you have rpc support. + This automatically turns off all configuration options that rely + on RPC. + +config SELINUX + bool "Support NSA Security Enhanced Linux" + default n + help + Enable support for SELinux in applets ls, ps, and id. Also provide + the option of compiling in SELinux applets. + + If you do not have a complete SELinux userland installed, this stuff + will not compile. Go visit + http://www.nsa.gov/selinux/index.html + to download the necessary stuff to allow busybox to compile with + this option enabled. Specifially, libselinux 1.28 or better is + directly required by busybox. If the installation is located in a + non-standard directory, provide it by invoking make as follows: + CFLAGS=-I \ + LDFLAGS=-L \ + make + + Most people will leave this set to 'N'. + +config FEATURE_EXEC_PREFER_APPLETS + bool "exec prefers applets" + default n + help + This is an experimental option which directs applets about to + call 'exec' to try and find an applicable busybox applet before + searching the executable path for a binary or symlink to execute. + +config BUSYBOX_EXEC_PATH + string "Path to BusyBox executable" + default "/proc/self/exe" + help + When Busybox applets need to run other busybox applets, BusyBox + sometimes needs to exec() itself. When the /proc filesystem is + mounted, /proc/self/exe always points to the currently running + executable. If you haven't got /proc, set this to wherever you + want to run BusyBox from. + +endmenu + +menu 'Build Options' + +config STATIC + bool "Build BusyBox as a static binary (no shared libs)" + default n + help + If you want to build a static BusyBox binary, which does not + use or require any shared libraries, then enable this option. + This can cause BusyBox to be considerably larger, so you should + leave this option false unless you have a good reason (i.e. + your target platform does not support shared libraries, or + you are building an initrd which doesn't need anything but + BusyBox, etc). + + Most people will leave this set to 'N'. + +config BUILD_LIBBUSYBOX + bool "Build shared libbusybox" + default n + help + Build a shared library libbusybox.so which contains all + libraries used inside busybox. + + This is an experimental feature intended to support the upcoming + "make standalone" mode. Enabling it against the one big busybox + binary serves no purpose (and increases the size). You should + almost certainly say "no" to this right now. + +config FEATURE_FULL_LIBBUSYBOX + bool "Feature-complete libbusybox" + default n if !FEATURE_SHARED_BUSYBOX + depends on BUILD_LIBBUSYBOX + help + Build a libbusybox with the complete feature-set, disregarding + the actually selected config. + + Normally, libbusybox will only contain the features which are + used by busybox itself. If you plan to write a separate + standalone application which uses libbusybox say 'Y'. + + Note: libbusybox is GPL, not LGPL, and exports no stable API that + might act as a copyright barrier. We can and will modify the + exported function set between releases (even minor version number + changes), and happily break out-of-tree features. + + Say 'N' if in doubt. + +config FEATURE_SHARED_BUSYBOX + bool "Use shared libbusybox for busybox" + default y if BUILD_LIBBUSYBOX + depends on !STATIC && BUILD_LIBBUSYBOX + help + Use libbusybox.so also for busybox itself. + You need to have a working dynamic linker to use this variant. + +config LFS + bool "Build with Large File Support (for accessing files > 2 GB)" + default n + select FDISK_SUPPORT_LARGE_DISKS + help + If you want to build BusyBox with large file support, then enable + this option. This will have no effect if your kernel or your C + library lacks large file support for large files. Some of the + programs that can benefit from large file support include dd, gzip, + cp, mount, tar, and many others. If you want to access files larger + than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'. + +config BUILD_AT_ONCE + bool "Compile all sources at once" + default n + help + Normally each source-file is compiled with one invocation of + the compiler. + If you set this option, all sources are compiled at once. + This gives the compiler more opportunities to optimize which can + result in smaller and/or faster binaries. + + Setting this option will consume alot of memory, e.g. if you + enable all applets with all features, gcc uses more than 300MB + RAM during compilation of busybox. + + This option is most likely only beneficial for newer compilers + such as gcc-4.1 and above. + + Say 'N' unless you know what you are doing. + +endmenu + +menu 'Debugging Options' + +config DEBUG + bool "Build BusyBox with extra Debugging symbols" + default n + help + Say Y here if you wish to examine BusyBox internals while applets are + running. This increases the size of the binary considerably, and + should only be used when doing development. If you are doing + development and want to debug BusyBox, answer Y. + + Most people should answer N. + +config WERROR + bool "Abort compilation on any warning" + default n + help + Selecting this will add -Werror to gcc command line. + + Most people should answer N. + +# Seems to be unused +#config DEBUG_PESSIMIZE +# bool "Disable compiler optimizations." +# default n +# depends on DEBUG +# help +# The compiler's optimization of source code can eliminate and reorder +# code, resulting in an executable that's hard to understand when +# stepping through it with a debugger. This switches it off, resulting +# in a much bigger executable that more closely matches the source +# code. + +choice + prompt "Additional debugging library" + default NO_DEBUG_LIB + depends on DEBUG + help + Using an additional debugging library will make BusyBox become + considerable larger and will cause it to run more slowly. You + should always leave this option disabled for production use. + + dmalloc support: + ---------------- + This enables compiling with dmalloc ( http://dmalloc.com/ ) + which is an excellent public domain mem leak and malloc problem + detector. To enable dmalloc, before running busybox you will + want to properly set your environment, for example: + export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile + The 'debug=' value is generated using the following command + dmalloc -p log-stats -p log-non-free -p log-bad-space -p log-elapsed-time \ + -p check-fence -p check-heap -p check-lists -p check-blank \ + -p check-funcs -p realloc-copy -p allow-free-null + + Electric-fence support: + ----------------------- + This enables compiling with Electric-fence support. Electric + fence is another very useful malloc debugging library which uses + your computer's virtual memory hardware to detect illegal memory + accesses. This support will make BusyBox be considerable larger + and run slower, so you should leave this option disabled unless + you are hunting a hard to find memory problem. + + +config NO_DEBUG_LIB + bool "None" + +config DMALLOC + bool "Dmalloc" + +config EFENCE + bool "Electric-fence" + +endchoice + +config INCLUDE_SUSv2 + bool "Enable obsolete features removed before SUSv3?" + default y + help + This option will enable backwards compatibility with SuSv2, + specifically, old-style numeric options ('command -1 ') + will be supported in head, tail, and fold. (Note: should + affect renice too.) + +endmenu + +menu 'Installation Options' + +config INSTALL_NO_USR + bool "Don't use /usr" + default n + help + Disable use of /usr. Don't activate this option if you don't know + that you really want this behaviour. + +choice + prompt "Applets links" + default INSTALL_APPLET_SYMLINKS + help + Choose how you install applets links. + +config INSTALL_APPLET_SYMLINKS + bool "as soft-links" + help + Install applets as soft-links to the busybox binary. This needs some + free inodes on the filesystem, but might help with filesystem + generators that can't cope with hard-links. + +config INSTALL_APPLET_HARDLINKS + bool "as hard-links" + help + Install applets as hard-links to the busybox binary. This might count + on a filesystem with few inodes. + +config INSTALL_APPLET_DONT + bool "not installed" + depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE_SHELL || FEATURE_EXEC_PREFER_APPLETS + help + Do not install applet links. Useful when using the -install feature + or a standalone shell for rescue pruposes. + +endchoice + +config PREFIX + string "BusyBox installation prefix" + default "./_install" + help + Define your directory to install BusyBox files/subdirs in. + +endmenu + +source libbb/Config.in + +endmenu + +comment "Applets" + +source archival/Config.in +source coreutils/Config.in +source console-tools/Config.in +source debianutils/Config.in +source editors/Config.in +source findutils/Config.in +source init/Config.in +source loginutils/Config.in +source e2fsprogs/Config.in +source modutils/Config.in +source util-linux/Config.in +source miscutils/Config.in +source networking/Config.in +source procps/Config.in +source shell/Config.in +source sysklogd/Config.in +source runit/Config.in +source selinux/Config.in diff --git a/i/pc104/initrd/conf/busybox/INSTALL b/i/pc104/initrd/conf/busybox/INSTALL new file mode 100644 index 0000000..a7902ab --- /dev/null +++ b/i/pc104/initrd/conf/busybox/INSTALL @@ -0,0 +1,125 @@ +Building: +========= + +The BusyBox build process is similar to the Linux kernel build: + + make menuconfig # This creates a file called ".config" + make # This creates the "busybox" executable + make install # or make CONFIG_PREFIX=/path/from/root install + +The full list of configuration and install options is available by typing: + + make help + +Quick Start: +============ + +The easy way to try out BusyBox for the first time, without having to install +it, is to enable all features and then use "standalone shell" mode with a +blank command $PATH. + +To enable all features, use "make defconfig", which produces the largest +general-purpose configuration. (It's allyesconfig minus debugging options, +optional packaging choices, and a few special-purpose features requiring +extra configuration to use.) + + make defconfig + make + PATH= ./busybox ash + +Standalone shell mode causes busybox's built-in command shell to run +any built-in busybox applets directly, without looking for external +programs by that name. Supplying an empty command path (as above) means +the only commands busybox can find are the built-in ones. + +Note that the standalone shell requires CONFIG_BUSYBOX_EXEC_PATH +to be set appropriately, depending on whether or not /proc/self/exe is +available or not. If you do not have /proc, then point that config option +to the location of your busybox binary, usually /bin/busybox. + +Configuring Busybox: +==================== + +Busybox is optimized for size, but enabling the full set of functionality +still results in a fairly large executable -- more than 1 megabyte when +statically linked. To save space, busybox can be configured with only the +set of applets needed for each environment. The minimal configuration, with +all applets disabled, produces a 4k executable. (It's useless, but very small.) + +The manual configurator "make menuconfig" modifies the existing configuration. +(For systems without ncurses, try "make config" instead.) The two most +interesting starting configurations are "make allnoconfig" (to start with +everything disabled and add just what you need), and "make defconfig" (to +start with everything enabled and remove what you don't need). If menuconfig +is run without an existing configuration, make defconfig will run first to +create a known starting point. + +Other starting configurations (mostly used for testing purposes) include +"make allbareconfig" (enables all applets but disables all optional features), +"make allyesconfig" (enables absolutely everything including debug features), +and "make randconfig" (produce a random configuration). + +Configuring BusyBox produces a file ".config", which can be saved for future +use. Run "make oldconfig" to bring a .config file from an older version of +busybox up to date. + +Installing Busybox: +=================== + +Busybox is a single executable that can behave like many different commands, +and BusyBox uses the name it was invoked under to determine the desired +behavior. (Try "mv busybox ls" and then "./ls -l".) + +Installing busybox consists of creating symlinks (or hardlinks) to the busybox +binary for each applet enabled in busybox, and making sure these symlinks are +in the shell's command $PATH. Running "make install" creates these symlinks, +or "make install-hardlinks" creates hardlinks instead (useful on systems with +a limited number of inodes). This install process uses the file +"busybox.links" (created by make), which contains the list of enabled applets +and the path at which to install them. + +Installing links to busybox is not always necessary. The special applet name +"busybox" (or with any optional suffix, such as "busybox-static") uses the +first argument to determine which applet to behave as, for example +"./busybox cat LICENSE". (Running the busybox applet with no arguments gives +a list of all enabled applets.) The standalone shell can also call busybox +applets without links to busybox under other names in the filesystem. You can +also configure a standaone install capability into the busybox base applet, +and then install such links at runtime with one of "busybox --install" (for +hardlinks) or "busybox --install -s" (for symlinks). + +If you enabled the busybox shared library feature (libbusybox.so) and want +to run tests without installing, set your LD_LIBRARY_PATH accordingly when +running the executable: + + LD_LIBRARY_PATH=`pwd` ./busybox + +Building out-of-tree: +===================== + +By default, the BusyBox build puts its temporary files in the source tree. +Building from a read-only source tree, or building multiple configurations from +the same source directory, requires the ability to put the temporary files +somewhere else. + +To build out of tree, cd to an empty directory and configure busybox from there: + + make -f /path/to/source/Makefile defconfig + make + make install + +Alternately, use the O=$BUILDPATH option (with an absolute path) during the +configuration step, as in: + + make O=/some/empty/directory allyesconfig + cd /some/empty/directory + make + make CONFIG_PREFIX=. install + +More Information: +================= + +Se also the busybox FAQ, under the questions "How can I get started using +BusyBox" and "How do I build a BusyBox-based system?" The BusyBox FAQ is +available from http://www.busybox.net/FAQ.html or as the file +docs/busybox.net/FAQ.html in this tarball. diff --git a/i/pc104/initrd/conf/busybox/LICENSE b/i/pc104/initrd/conf/busybox/LICENSE new file mode 100644 index 0000000..9d9bdc7 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/LICENSE @@ -0,0 +1,348 @@ +--- A note on GPL versions + +BusyBox is distributed under version 2 of the General Public License (included +in its entirety, below). Version 2 is the only version of this license which +this version of BusyBox (or modified versions derived from this one) may be +distributed under. + +------------------------------------------------------------------------ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/i/pc104/initrd/conf/busybox/Makefile b/i/pc104/initrd/conf/busybox/Makefile new file mode 100644 index 0000000..b42e179 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/Makefile @@ -0,0 +1,1280 @@ +VERSION = 1 +PATCHLEVEL = 5 +SUBLEVEL = 0 +EXTRAVERSION = +NAME = Unnamed + +# *DOCUMENTATION* +# To see a list of typical targets execute "make help" +# More info can be located in ./README +# Comments in this file are targeted only to the developer, do not +# expect to learn how to build the kernel reading this file. + +# Do not print "Entering directory ..." +MAKEFLAGS += --no-print-directory + +# We are using a recursive build, so we need to do a little thinking +# to get the ordering right. +# +# Most importantly: sub-Makefiles should only ever modify files in +# their own directory. If in some directory we have a dependency on +# a file in another dir (which doesn't happen often, but it's often +# unavoidable when linking the built-in.o targets which finally +# turn into busybox), we will call a sub make in that other dir, and +# after that we are sure that everything which is in that other dir +# is now up to date. +# +# The only cases where we need to modify files which have global +# effects are thus separated out and done before the recursive +# descending is started. They are now explicitly listed as the +# prepare rule. + +# To put more focus on warnings, be less verbose as default +# Use 'make V=1' to see the full commands + +ifdef V + ifeq ("$(origin V)", "command line") + KBUILD_VERBOSE = $(V) + endif +endif +ifndef KBUILD_VERBOSE + KBUILD_VERBOSE = 0 +endif + +# Call sparse as part of compilation of C files +# Use 'make C=1' to enable sparse checking + +ifdef C + ifeq ("$(origin C)", "command line") + KBUILD_CHECKSRC = $(C) + endif +endif +ifndef KBUILD_CHECKSRC + KBUILD_CHECKSRC = 0 +endif + +# Use make M=dir to specify directory of external module to build +# Old syntax make ... SUBDIRS=$PWD is still supported +# Setting the environment variable KBUILD_EXTMOD take precedence +ifdef SUBDIRS + KBUILD_EXTMOD ?= $(SUBDIRS) +endif +ifdef M + ifeq ("$(origin M)", "command line") + KBUILD_EXTMOD := $(M) + endif +endif + + +# kbuild supports saving output files in a separate directory. +# To locate output files in a separate directory two syntaxes are supported. +# In both cases the working directory must be the root of the kernel src. +# 1) O= +# Use "make O=dir/to/store/output/files/" +# +# 2) Set KBUILD_OUTPUT +# Set the environment variable KBUILD_OUTPUT to point to the directory +# where the output files shall be placed. +# export KBUILD_OUTPUT=dir/to/store/output/files/ +# make +# +# The O= assignment takes precedence over the KBUILD_OUTPUT environment +# variable. + + +# KBUILD_SRC is set on invocation of make in OBJ directory +# KBUILD_SRC is not intended to be used by the regular user (for now) +ifeq ($(KBUILD_SRC),) + +# OK, Make called in directory where kernel src resides +# Do we want to locate output files in a separate directory? +ifdef O + ifeq ("$(origin O)", "command line") + KBUILD_OUTPUT := $(O) + endif +endif + +# That's our default target when none is given on the command line +PHONY := _all +_all: + +ifneq ($(KBUILD_OUTPUT),) +# Invoke a second make in the output directory, passing relevant variables +# check that the output directory actually exists +saved-output := $(KBUILD_OUTPUT) +KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) +$(if $(KBUILD_OUTPUT),, \ + $(error output directory "$(saved-output)" does not exist)) + +PHONY += $(MAKECMDGOALS) + +$(filter-out _all,$(MAKECMDGOALS)) _all: + $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ + KBUILD_SRC=$(CURDIR) \ + KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@ + +# Leave processing to above invocation of make +skip-makefile := 1 +endif # ifneq ($(KBUILD_OUTPUT),) +endif # ifeq ($(KBUILD_SRC),) + +# We process the rest of the Makefile if this is the final invocation of make +ifeq ($(skip-makefile),) + +# If building an external module we do not care about the all: rule +# but instead _all depend on modules +PHONY += all +ifeq ($(KBUILD_EXTMOD),) +_all: all +else +_all: modules +endif + +srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) +TOPDIR := $(srctree) +# FIXME - TOPDIR is obsolete, use srctree/objtree +objtree := $(CURDIR) +src := $(srctree) +obj := $(objtree) + +VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) + +export srctree objtree VPATH TOPDIR + + +# SUBARCH tells the usermode build what the underlying arch is. That is set +# first, and if a usermode build is happening, the "ARCH=um" on the command +# line overrides the setting of ARCH below. If a native build is happening, +# then ARCH is assigned, getting whatever value it gets normally, and +# SUBARCH is subsequently ignored. + +SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ ) + +# Cross compiling and selecting different set of gcc/bin-utils +# --------------------------------------------------------------------------- +# +# When performing cross compilation for other architectures ARCH shall be set +# to the target architecture. (See arch/* for the possibilities). +# ARCH can be set during invocation of make: +# make ARCH=ia64 +# Another way is to have ARCH set in the environment. +# The default ARCH is the host where make is executed. + +# CROSS_COMPILE specify the prefix used for all executables used +# during compilation. Only gcc and related bin-utils executables +# are prefixed with $(CROSS_COMPILE). +# CROSS_COMPILE can be set on the command line +# make CROSS_COMPILE=ia64-linux- +# Alternatively CROSS_COMPILE can be set in the environment. +# Default value for CROSS_COMPILE is not to prefix executables +# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile + +ARCH ?= $(SUBARCH) +CROSS_COMPILE ?= + +# Architecture as present in compile.h +UTS_MACHINE := $(ARCH) + +# SHELL used by kbuild +CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ + else if [ -x /bin/bash ]; then echo /bin/bash; \ + else echo sh; fi ; fi) + +HOSTCC = gcc +HOSTCXX = g++ +HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer +HOSTCXXFLAGS = -O2 + +# Decide whether to build built-in, modular, or both. +# Normally, just do built-in. + +KBUILD_MODULES := +KBUILD_BUILTIN := 1 + +# If we have only "make modules", don't compile built-in objects. +# When we're building modules with modversions, we need to consider +# the built-in objects during the descend as well, in order to +# make sure the checksums are uptodate before we record them. + +ifeq ($(MAKECMDGOALS),modules) + KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) +endif + +# If we have "make modules", compile modules +# in addition to whatever we do anyway. +# Just "make" or "make all" shall build modules as well + +ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) + KBUILD_MODULES := 1 +endif + +ifeq ($(MAKECMDGOALS),) + KBUILD_MODULES := 1 +endif + +export KBUILD_MODULES KBUILD_BUILTIN +export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD + +# Beautify output +# --------------------------------------------------------------------------- +# +# Normally, we echo the whole command before executing it. By making +# that echo $($(quiet)$(cmd)), we now have the possibility to set +# $(quiet) to choose other forms of output instead, e.g. +# +# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ +# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< +# +# If $(quiet) is empty, the whole command will be printed. +# If it is set to "quiet_", only the short version will be printed. +# If it is set to "silent_", nothing wil be printed at all, since +# the variable $(silent_cmd_cc_o_c) doesn't exist. +# +# A simple variant is to prefix commands with $(Q) - that's useful +# for commands that shall be hidden in non-verbose mode. +# +# $(Q)ln $@ :< +# +# If KBUILD_VERBOSE equals 0 then the above command will be hidden. +# If KBUILD_VERBOSE equals 1 then the above command is displayed. + +ifeq ($(KBUILD_VERBOSE),1) + quiet = + Q = +else + quiet=quiet_ + Q = @ +endif + +# If the user is running make -s (silent mode), suppress echoing of +# commands + +ifneq ($(findstring s,$(MAKEFLAGS)),) + quiet=silent_ +endif + +export quiet Q KBUILD_VERBOSE + + +# Look for make include files relative to root of kernel src +MAKEFLAGS += --include-dir=$(srctree) + +# We need some generic definitions +include $(srctree)/scripts/Kbuild.include + +# For maximum performance (+ possibly random breakage, uncomment +# the following) + +MAKEFLAGS += -rR + +# Make variables (CC, etc...) + +AS = $(CROSS_COMPILE)as +CC = $(CROSS_COMPILE)gcc +LD = $(CC) -nostdlib +CPP = $(CC) -E +AR = $(CROSS_COMPILE)ar +NM = $(CROSS_COMPILE)nm +STRIP = $(CROSS_COMPILE)strip +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump +AWK = awk +GENKSYMS = scripts/genksyms/genksyms +DEPMOD = /sbin/depmod +KALLSYMS = scripts/kallsyms +PERL = perl +CHECK = sparse + +CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF) +MODFLAGS = -DMODULE +CFLAGS_MODULE = $(MODFLAGS) +AFLAGS_MODULE = $(MODFLAGS) +LDFLAGS_MODULE = -r +CFLAGS_KERNEL = +AFLAGS_KERNEL = + + +# Use LINUXINCLUDE when you must reference the include/ directory. +# Needed to be compatible with the O= option +CFLAGS := $(CFLAGS) +CPPFLAGS := $(CPPFLAGS) +AFLAGS := $(AFLAGS) + +# Read KERNELRELEASE from .kernelrelease (if it exists) +KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null) +KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) + +export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \ + ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ + CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \ + HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS + +export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS +export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE +export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE + +# When compiling out-of-tree modules, put MODVERDIR in the module +# tree rather than in the kernel tree. The kernel tree might +# even be read-only. +export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions + +# Files to ignore in find ... statements + +RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o +export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git + +# =========================================================================== +# Rules shared between *config targets and build targets + +# Basic helpers built in scripts/ +PHONY += scripts_basic +scripts_basic: + $(Q)$(MAKE) $(build)=scripts/basic + +# To avoid any implicit rule to kick in, define an empty command. +scripts/basic/%: scripts_basic ; + +PHONY += outputmakefile +# outputmakefile generates a Makefile in the output directory, if using a +# separate output directory. This allows convenient use of make in the +# output directory. +outputmakefile: +ifneq ($(KBUILD_SRC),) + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ + $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) +endif + +# To make sure we do not include .config for any of the *config targets +# catch them early, and hand them over to scripts/kconfig/Makefile +# It is allowed to specify more targets when calling make, including +# mixing *config targets and build targets. +# For example 'make oldconfig all'. +# Detect when mixed targets is specified, and make a second invocation +# of make so .config is not included in this case either (for *config). + +no-dot-config-targets := clean mrproper distclean \ + cscope TAGS tags help %docs check% + +config-targets := 0 +mixed-targets := 0 +dot-config := 1 + +ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) + ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) + dot-config := 0 + endif +endif + +ifeq ($(KBUILD_EXTMOD),) + ifneq ($(filter config %config,$(MAKECMDGOALS)),) + config-targets := 1 + ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) + mixed-targets := 1 + endif + endif +endif + +ifeq ($(mixed-targets),1) +# =========================================================================== +# We're called with mixed targets (*config and build targets). +# Handle them one by one. + +%:: FORCE + $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@ + +else +ifeq ($(config-targets),1) +# =========================================================================== +# *config targets only - make sure prerequisites are updated, and descend +# in scripts/kconfig to make the *config target + +# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. +# KBUILD_DEFCONFIG may point out an alternative default configuration +# used for 'make defconfig' +-include $(srctree)/arch/$(ARCH)/Makefile +export KBUILD_DEFCONFIG + +config %config: scripts_basic outputmakefile FORCE + $(Q)mkdir -p include + $(Q)$(MAKE) $(build)=scripts/kconfig $@ + $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease + +else +# =========================================================================== +# Build targets only - this includes busybox, arch specific targets, clean +# targets and others. In general all targets except *config targets. + +ifeq ($(KBUILD_EXTMOD),) +# Additional helpers built in scripts/ +# Carefully list dependencies so we do not try to build scripts twice +# in parrallel +PHONY += scripts +scripts: scripts_basic include/config/MARKER + $(Q)$(MAKE) $(build)=$(@) + +scripts_basic: include/autoconf.h + +# Objects we will link into busybox / subdirs we need to visit +core-y := \ + applets/ \ + +libs-y := \ + archival/ \ + archival/libunarchive/ \ + console-tools/ \ + coreutils/ \ + coreutils/libcoreutils/ \ + debianutils/ \ + e2fsprogs/ \ + editors/ \ + findutils/ \ + init/ \ + libbb/ \ + libpwdgrp/ \ + loginutils/ \ + miscutils/ \ + modutils/ \ + networking/ \ + networking/libiproute/ \ + networking/udhcp/ \ + procps/ \ + runit/ \ + selinux/ \ + shell/ \ + sysklogd/ \ + util-linux/ \ + +endif # KBUILD_EXTMOD + +ifeq ($(dot-config),1) +# In this section, we need .config + +# Read in dependencies to all Kconfig* files, make sure to run +# oldconfig if changes are detected. +-include .kconfig.d + +-include .config + +# If .config needs to be updated, it will be done via the dependency +# that autoconf has on .config. +# To avoid any implicit rule to kick in, define an empty command +.config .kconfig.d: ; + +# Now we can define CFLAGS etc according to .config +include $(srctree)/Makefile.flags + +# If .config is newer than include/autoconf.h, someone tinkered +# with it and forgot to run make oldconfig. +# If kconfig.d is missing then we are probarly in a cleaned tree so +# we execute the config step to be sure to catch updated Kconfig files +include/autoconf.h: .kconfig.d .config + $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig + +else +# Dummy target needed, because used as prerequisite +include/autoconf.h: ; +endif + +# The all: target is the default when no target is given on the +# command line. +# This allow a user to issue only 'make' to build a kernel including modules +# Defaults busybox but it is usually overridden in the arch makefile +all: busybox + +-include $(srctree)/arch/$(ARCH)/Makefile + +# arch Makefile may override CC so keep this after arch Makefile is included +#bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) +CHECKFLAGS += $(NOSTDINC_FLAGS) + +# warn about C99 declaration after statement +CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) + +# disable pointer signedness warnings in gcc 4.0 +CFLAGS += $(call cc-option,-Wno-pointer-sign,) + +# Default kernel image to build when no specific target is given. +# KBUILD_IMAGE may be overruled on the commandline or +# set in the environment +# Also any assignments in arch/$(ARCH)/Makefile take precedence over +# this default value +export KBUILD_IMAGE ?= busybox + +# +# INSTALL_PATH specifies where to place the updated kernel and system map +# images. Default is /boot, but you can set it to other values +export INSTALL_PATH ?= /boot + +# +# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory +# relocations required by build roots. This is not defined in the +# makefile but the arguement can be passed to make if needed. +# + +MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) +export MODLIB + + +ifeq ($(KBUILD_EXTMOD),) +busybox-dirs := $(patsubst %/,%,$(filter %/, $(core-y) $(core-m) $(libs-y) $(libs-m))) + +busybox-alldirs := $(sort $(busybox-dirs) $(patsubst %/,%,$(filter %/, \ + $(core-n) $(core-) $(libs-n) $(libs-) \ + ))) + +core-y := $(patsubst %/, %/built-in.o, $(core-y)) +libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) +libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) +libs-y := $(libs-y1) $(libs-y2) + +# Build busybox +# --------------------------------------------------------------------------- +# busybox is build from the objects selected by $(busybox-init) and +# $(busybox-main). Most are built-in.o files from top-level directories +# in the kernel tree, others are specified in arch/$(ARCH)Makefile. +# Ordering when linking is important, and $(busybox-init) must be first. +# +# busybox +# ^ +# | +# +-< $(busybox-init) +# | +--< init/version.o + more +# | +# +--< $(busybox-main) +# | +--< driver/built-in.o mm/built-in.o + more +# | +# +-< kallsyms.o (see description in CONFIG_KALLSYMS section) +# +# busybox version (uname -v) cannot be updated during normal +# descending-into-subdirs phase since we do not yet know if we need to +# update busybox. +# Therefore this step is delayed until just before final link of busybox - +# except in the kallsyms case where it is done just before adding the +# symbols to the kernel. +# +# System.map is generated to document addresses of all kernel symbols + +busybox-all := $(core-y) $(libs-y) + +# Rule to link busybox - also used during CONFIG_KALLSYMS +# May be overridden by arch/$(ARCH)/Makefile +quiet_cmd_busybox__ ?= LINK $@ + cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) $(LDFLAGS) \ + -o $@ -Wl,-M \ + -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ + -Wl,--start-group $(busybox-all) -Wl,--end-group + +# Generate System.map +quiet_cmd_sysmap = SYSMAP + cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap + +# Link of busybox +# If CONFIG_KALLSYMS is set .version is already updated +# Generate System.map and verify that the content is consistent +# Use + in front of the busybox_version rule to silent warning with make -j2 +# First command is ':' to allow us to use + in front of the rule +define rule_busybox__ + : + $(call cmd,busybox__) + $(Q)echo 'cmd_$@ := $(cmd_busybox__)' > $(@D)/.$(@F).cmd +endef + + +ifdef CONFIG_KALLSYMS +# Generate section listing all symbols and add it into busybox $(kallsyms.o) +# It's a three stage process: +# o .tmp_busybox1 has all symbols and sections, but __kallsyms is +# empty +# Running kallsyms on that gives us .tmp_kallsyms1.o with +# the right size - busybox version (uname -v) is updated during this step +# o .tmp_busybox2 now has a __kallsyms section of the right size, +# but due to the added section, some addresses have shifted. +# From here, we generate a correct .tmp_kallsyms2.o +# o The correct .tmp_kallsyms2.o is linked into the final busybox. +# o Verify that the System.map from busybox matches the map from +# .tmp_busybox2, just in case we did not generate kallsyms correctly. +# o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using +# .tmp_busybox3 and .tmp_kallsyms3.o. This is only meant as a +# temporary bypass to allow the kernel to be built while the +# maintainers work out what went wrong with kallsyms. + +ifdef CONFIG_KALLSYMS_EXTRA_PASS +last_kallsyms := 3 +else +last_kallsyms := 2 +endif + +kallsyms.o := .tmp_kallsyms$(last_kallsyms).o + +define verify_kallsyms + $(Q)$(if $($(quiet)cmd_sysmap), \ + echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \ + $(cmd_sysmap) .tmp_busybox$(last_kallsyms) .tmp_System.map + $(Q)cmp -s System.map .tmp_System.map || \ + (echo Inconsistent kallsyms data; \ + echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \ + rm .tmp_kallsyms* ; /bin/false ) +endef + +# Update busybox version before link +# Use + in front of this rule to silent warning about make -j1 +# First command is ':' to allow us to use + in front of this rule +cmd_ksym_ld = $(cmd_busybox__) +define rule_ksym_ld + : + +$(call cmd,busybox_version) + $(call cmd,busybox__) + $(Q)echo 'cmd_$@ := $(cmd_busybox__)' > $(@D)/.$(@F).cmd +endef + +# Generate .S file with all kernel symbols +quiet_cmd_kallsyms = KSYM $@ + cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \ + $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@ + +.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE + $(call if_changed_dep,as_o_S) + +.tmp_kallsyms%.S: .tmp_busybox% $(KALLSYMS) + $(call cmd,kallsyms) + +# .tmp_busybox1 must be complete except kallsyms, so update busybox version +.tmp_busybox1: $(busybox-lds) $(busybox-all) FORCE + $(call if_changed_rule,ksym_ld) + +.tmp_busybox2: $(busybox-lds) $(busybox-all) .tmp_kallsyms1.o FORCE + $(call if_changed,busybox__) + +.tmp_busybox3: $(busybox-lds) $(busybox-all) .tmp_kallsyms2.o FORCE + $(call if_changed,busybox__) + +# Needs to visit scripts/ before $(KALLSYMS) can be used. +$(KALLSYMS): scripts ; + +# Generate some data for debugging strange kallsyms problems +debug_kallsyms: .tmp_map$(last_kallsyms) + +.tmp_map%: .tmp_busybox% FORCE + ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@ + +.tmp_map3: .tmp_map2 + +.tmp_map2: .tmp_map1 + +endif # ifdef CONFIG_KALLSYMS + +# busybox image - including updated kernel symbols +busybox_unstripped: $(busybox-all) FORCE + $(call if_changed_rule,busybox__) + $(Q)rm -f .old_version + +busybox: busybox_unstripped + $(Q)$(STRIP) -s --remove-section=.note --remove-section=.comment \ + busybox_unstripped -o $@ + +# The actual objects are generated when descending, +# make sure no implicit rule kicks in +$(sort $(busybox-all)): $(busybox-dirs) ; + +# Handle descending into subdirectories listed in $(busybox-dirs) +# Preset locale variables to speed up the build process. Limit locale +# tweaks to this spot to avoid wrong language settings when running +# make menuconfig etc. +# Error messages still appears in the original language + +PHONY += $(busybox-dirs) +$(busybox-dirs): prepare scripts + $(Q)$(MAKE) $(build)=$@ + +# Build the kernel release string +# The KERNELRELEASE is stored in a file named .kernelrelease +# to be used when executing for example make install or make modules_install +# +# Take the contents of any files called localversion* and the config +# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE. +# LOCALVERSION from the command line override all of this + +nullstring := +space := $(nullstring) # end of line + +___localver = $(objtree)/localversion* $(srctree)/localversion* +__localver = $(sort $(wildcard $(___localver))) +# skip backup files (containing '~') +_localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f))) + +localver = $(subst $(space),, \ + $(shell cat /dev/null $(_localver)) \ + $(patsubst "%",%,$(CONFIG_LOCALVERSION))) + +# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called +# and if the SCM is know a tag from the SCM is appended. +# The appended tag is determinded by the SCM used. +# +# Currently, only git is supported. +# Other SCMs can edit scripts/setlocalversion and add the appropriate +# checks as needed. +ifdef CONFIG_LOCALVERSION_AUTO + _localver-auto = $(shell $(CONFIG_SHELL) \ + $(srctree)/scripts/setlocalversion $(srctree)) + localver-auto = $(LOCALVERSION)$(_localver-auto) +endif + +localver-full = $(localver)$(localver-auto) + +# Store (new) KERNELRELASE string in .kernelrelease +kernelrelease = $(KERNELVERSION)$(localver-full) +.kernelrelease: FORCE + $(Q)rm -f $@ + $(Q)echo $(kernelrelease) > $@ + + +# Things we need to do before we recursively start building the kernel +# or the modules are listed in "prepare". +# A multi level approach is used. prepareN is processed before prepareN-1. +# archprepare is used in arch Makefiles and when processed asm symlink, +# version.h and scripts_basic is processed / created. + +# Listed in dependency order +PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 + +# prepare-all is deprecated, use prepare as valid replacement +PHONY += prepare-all + +# prepare3 is used to check if we are building in a separate output directory, +# and if so do: +# 1) Check that make has not been executed in the kernel src $(srctree) +# 2) Create the include2 directory, used for the second asm symlink +prepare3: .kernelrelease +ifneq ($(KBUILD_SRC),) + @echo ' Using $(srctree) as source for kernel' + $(Q)if [ -f $(srctree)/.config ]; then \ + echo " $(srctree) is not clean, please run 'make mrproper'";\ + echo " in the '$(srctree)' directory.";\ + /bin/false; \ + fi; + $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi; + $(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm +endif + +# prepare2 creates a makefile if using a separate output directory +prepare2: prepare3 outputmakefile + +prepare1: prepare2 include/config/MARKER +ifneq ($(KBUILD_MODULES),) + $(Q)mkdir -p $(MODVERDIR) + $(Q)rm -f $(MODVERDIR)/* +endif + +archprepare: prepare1 scripts_basic + +prepare0: archprepare FORCE + $(Q)$(MAKE) $(build)=. + +# All the preparing.. +prepare prepare-all: prepare0 + +# Leave this as default for preprocessing busybox.lds.S, which is now +# done in arch/$(ARCH)/kernel/Makefile + +export CPPFLAGS_busybox.lds += -P -C -U$(ARCH) + +# FIXME: The asm symlink changes when $(ARCH) changes. That's +# hard to detect, but I suppose "make mrproper" is a good idea +# before switching between archs anyway. + +#bbox# include/asm: +#bbox# @echo ' SYMLINK $@ -> include/asm-$(ARCH)' +#bbox# $(Q)if [ ! -d include ]; then mkdir -p include; fi; +#bbox# @ln -fsn asm-$(ARCH) $@ + +# Split autoconf.h into include/linux/config/* +quiet_cmd_gen_bbconfigopts = GEN include/bbconfigopts.h + cmd_gen_bbconfigopts = $(srctree)/scripts/mkconfigs > include/bbconfigopts.h +quiet_cmd_split_autoconf = SPLIT include/autoconf.h -> include/config/* + cmd_split_autoconf = scripts/basic/split-include include/autoconf.h include/config +#bbox# piggybacked generation of few .h files +include/config/MARKER: scripts/basic/split-include include/autoconf.h + $(call cmd,split_autoconf) + $(call cmd,gen_bbconfigopts) + @touch $@ + +# Generate some files +# --------------------------------------------------------------------------- + +# KERNELRELEASE can change from a few different places, meaning version.h +# needs to be updated, so this check is forced on all builds + +uts_len := 64 + +define filechk_version.h + if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ + echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ + exit 1; \ + fi; \ + (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \ + echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \ + echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \ + ) +endef + +# --------------------------------------------------------------------------- + +PHONY += depend dep +depend dep: + @echo '*** Warning: make $@ is unnecessary now.' + +# --------------------------------------------------------------------------- +# Modules + +ifdef CONFIG_MODULES + +# By default, build modules as well + +all: modules + +# Build modules + +PHONY += modules +modules: $(busybox-dirs) $(if $(KBUILD_BUILTIN),busybox) + @echo ' Building modules, stage 2.'; + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost + + +# Target to prepare building external modules +PHONY += modules_prepare +modules_prepare: prepare scripts + +# Target to install modules +PHONY += modules_install +modules_install: _modinst_ _modinst_post + +PHONY += _modinst_ +_modinst_: + @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ + echo "Warning: you may need to install module-init-tools"; \ + echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\ + sleep 1; \ + fi + @rm -rf $(MODLIB)/kernel + @rm -f $(MODLIB)/source + @mkdir -p $(MODLIB)/kernel + @ln -s $(srctree) $(MODLIB)/source + @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ + rm -f $(MODLIB)/build ; \ + ln -s $(objtree) $(MODLIB)/build ; \ + fi + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst + +# If System.map exists, run depmod. This deliberately does not have a +# dependency on System.map since that would run the dependency tree on +# busybox. This depmod is only for convenience to give the initial +# boot a modules.dep even before / is mounted read-write. However the +# boot script depmod is the master version. +ifeq "$(strip $(INSTALL_MOD_PATH))" "" +depmod_opts := +else +depmod_opts := -b $(INSTALL_MOD_PATH) -r +endif +PHONY += _modinst_post +_modinst_post: _modinst_ + if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi + +else # CONFIG_MODULES + +# Modules not configured +# --------------------------------------------------------------------------- + +modules modules_install: FORCE + @echo + @echo "The present busybox configuration has modules disabled." + @echo "Type 'make config' and enable loadable module support." + @echo "Then build a kernel with module support enabled." + @echo + @exit 1 + +endif # CONFIG_MODULES + +### +# Cleaning is done on three levels. +# make clean Delete most generated files +# Leave enough to build external modules +# make mrproper Delete the current configuration, and all generated files +# make distclean Remove editor backup files, patch leftover files and the like + +# Directories & files removed with 'make clean' +CLEAN_DIRS += $(MODVERDIR) +CLEAN_FILES += busybox* System.map .kernelrelease \ + .tmp_kallsyms* .tmp_version .tmp_busybox* .tmp_System.map + +# Directories & files removed with 'make mrproper' +MRPROPER_DIRS += include/config include2 +MRPROPER_FILES += .config .config.old include/asm .version .old_version \ + include/autoconf.h \ + include/bbconfigopts.h \ + include/usage_compressed.h \ + .kernelrelease Module.symvers tags TAGS cscope* + +# clean - Delete most, but leave enough to build external modules +# +clean: rm-dirs := $(CLEAN_DIRS) +clean: rm-files := $(CLEAN_FILES) +clean-dirs := $(addprefix _clean_,$(srctree) $(busybox-alldirs)) + +PHONY += $(clean-dirs) clean archclean +$(clean-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) + +clean: archclean $(clean-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + @find . $(RCS_FIND_IGNORE) \ + \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \ + -type f -print | xargs rm -f + +# mrproper - Delete all generated files, including .config +# +mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) +mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) +mrproper-dirs := $(addprefix _mrproper_,scripts) + +PHONY += $(mrproper-dirs) mrproper archmrproper +$(mrproper-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) + +mrproper: clean archmrproper $(mrproper-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + +# distclean +# +PHONY += distclean + +distclean: mrproper + @find $(srctree) $(RCS_FIND_IGNORE) \ + \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ + -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ + -o -name '.*.rej' -o -size 0 \ + -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ + -type f -print | xargs rm -f + + +# Packaging of the kernel to various formats +# --------------------------------------------------------------------------- +# rpm target kept for backward compatibility +package-dir := $(srctree)/scripts/package + +%pkg: FORCE + $(Q)$(MAKE) $(build)=$(package-dir) $@ +rpm: FORCE + $(Q)$(MAKE) $(build)=$(package-dir) $@ + + +# Brief documentation of the typical targets used +# --------------------------------------------------------------------------- + +boards := $(wildcard $(srctree)/arch/$(ARCH)/configs/*_defconfig) +boards := $(notdir $(boards)) + +-include $(srctree)/Makefile.help + +# Documentation targets +# --------------------------------------------------------------------------- +%docs: scripts_basic FORCE + $(Q)$(MAKE) $(build)=Documentation/DocBook $@ + +else # KBUILD_EXTMOD + +### +# External module support. +# When building external modules the kernel used as basis is considered +# read-only, and no consistency checks are made and the make +# system is not used on the basis kernel. If updates are required +# in the basis kernel ordinary make commands (without M=...) must +# be used. +# +# The following are the only valid targets when building external +# modules. +# make M=dir clean Delete all automatically generated files +# make M=dir modules Make all modules in specified dir +# make M=dir Same as 'make M=dir modules' +# make M=dir modules_install +# Install the modules build in the module directory +# Assumes install directory is already created + +# We are always building modules +KBUILD_MODULES := 1 +PHONY += crmodverdir +crmodverdir: + $(Q)mkdir -p $(MODVERDIR) + $(Q)rm -f $(MODVERDIR)/* + +PHONY += $(objtree)/Module.symvers +$(objtree)/Module.symvers: + @test -e $(objtree)/Module.symvers || ( \ + echo; \ + echo " WARNING: Symbol version dump $(objtree)/Module.symvers"; \ + echo " is missing; modules will have no dependencies and modversions."; \ + echo ) + +module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) +PHONY += $(module-dirs) modules +$(module-dirs): crmodverdir $(objtree)/Module.symvers + $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) + +modules: $(module-dirs) + @echo ' Building modules, stage 2.'; + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost + +PHONY += modules_install +modules_install: _emodinst_ _emodinst_post + +install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) +PHONY += _emodinst_ +_emodinst_: + $(Q)mkdir -p $(MODLIB)/$(install-dir) + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst + +# Run depmod only is we have System.map and depmod is executable +quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) + cmd_depmod = if [ -r System.map -a -x $(DEPMOD) ]; then \ + $(DEPMOD) -ae -F System.map \ + $(if $(strip $(INSTALL_MOD_PATH)), \ + -b $(INSTALL_MOD_PATH) -r) \ + $(KERNELRELEASE); \ + fi + +PHONY += _emodinst_post +_emodinst_post: _emodinst_ + $(call cmd,depmod) + +clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) + +PHONY += $(clean-dirs) clean +$(clean-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) + +clean: rm-dirs := $(MODVERDIR) +clean: $(clean-dirs) + $(call cmd,rmdirs) + @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \ + \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \ + -type f -print | xargs rm -f + +help: + @echo ' Building external modules.' + @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target' + @echo '' + @echo ' modules - default target, build the module(s)' + @echo ' modules_install - install the module' + @echo ' clean - remove generated files in module directory only' + @echo '' + +# Dummies... +PHONY += prepare scripts +prepare: ; +scripts: ; +endif # KBUILD_EXTMOD + +# Generate tags for editors +# --------------------------------------------------------------------------- + +#We want __srctree to totally vanish out when KBUILD_OUTPUT is not set +#(which is the most common case IMHO) to avoid unneeded clutter in the big tags file. +#Adding $(srctree) adds about 20M on i386 to the size of the output file! + +ifeq ($(src),$(obj)) +__srctree = +else +__srctree = $(srctree)/ +endif + +ifeq ($(ALLSOURCE_ARCHS),) +ifeq ($(ARCH),um) +ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH) +else +ALLINCLUDE_ARCHS := $(ARCH) +endif +else +#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour. +ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS) +endif + +ALLSOURCE_ARCHS := $(ARCH) + +define all-sources + ( find $(__srctree) $(RCS_FIND_IGNORE) \ + \( -name include -o -name arch \) -prune -o \ + -name '*.[chS]' -print; \ + for ARCH in $(ALLSOURCE_ARCHS) ; do \ + find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \ + -name '*.[chS]' -print; \ + done ; \ + find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \ + -name '*.[chS]' -print; \ + find $(__srctree)include $(RCS_FIND_IGNORE) \ + \( -name config -o -name 'asm-*' \) -prune \ + -o -name '*.[chS]' -print; \ + for ARCH in $(ALLINCLUDE_ARCHS) ; do \ + find $(__srctree)include/asm-$${ARCH} $(RCS_FIND_IGNORE) \ + -name '*.[chS]' -print; \ + done ; \ + find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ + -name '*.[chS]' -print ) +endef + +quiet_cmd_cscope-file = FILELST cscope.files + cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files + +quiet_cmd_cscope = MAKE cscope.out + cmd_cscope = cscope -b + +cscope: FORCE + $(call cmd,cscope-file) + $(call cmd,cscope) + +quiet_cmd_TAGS = MAKE $@ +define cmd_TAGS + rm -f $@; \ + ETAGSF=`etags --version | grep -i exuberant >/dev/null && \ + echo "-I __initdata,__exitdata,__acquires,__releases \ + -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ + --extra=+f --c-kinds=+px"`; \ + $(all-sources) | xargs etags $$ETAGSF -a +endef + +TAGS: FORCE + $(call cmd,TAGS) + + +quiet_cmd_tags = MAKE $@ +define cmd_tags + rm -f $@; \ + CTAGSF=`ctags --version | grep -i exuberant >/dev/null && \ + echo "-I __initdata,__exitdata,__acquires,__releases \ + -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ + --extra=+f --c-kinds=+px"`; \ + $(all-sources) | xargs ctags $$CTAGSF -a +endef + +tags: FORCE + $(call cmd,tags) + + +# Scripts to check various things for consistency +# --------------------------------------------------------------------------- + +includecheck: + find * $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w scripts/checkincludes.pl + +versioncheck: + find * $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w scripts/checkversion.pl + +namespacecheck: + $(PERL) $(srctree)/scripts/namespace.pl + +endif #ifeq ($(config-targets),1) +endif #ifeq ($(mixed-targets),1) + +PHONY += checkstack +checkstack: + $(OBJDUMP) -d busybox $$(find . -name '*.ko') | \ + $(PERL) $(src)/scripts/checkstack.pl $(ARCH) + +kernelrelease: + $(if $(wildcard .kernelrelease), $(Q)echo $(KERNELRELEASE), \ + $(error kernelrelease not valid - run 'make *config' to update it)) +kernelversion: + @echo $(KERNELVERSION) + +# Single targets +# --------------------------------------------------------------------------- +# Single targets are compatible with: +# - build whith mixed source and output +# - build with separate output dir 'make O=...' +# - external modules +# +# target-dir => where to store outputfile +# build-dir => directory in kernel source tree to use + +ifeq ($(KBUILD_EXTMOD),) + build-dir = $(patsubst %/,%,$(dir $@)) + target-dir = $(dir $@) +else + zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) + build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) + target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) +endif + +%.s: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.i: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.o: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.lst: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.s: %.S prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.o: %.S prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) + +# Modules +/ %/: prepare scripts FORCE + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(build-dir) +%.ko: prepare scripts FORCE + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(build-dir) $(@:.ko=.o) + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost + +# FIXME Should go into a make.lib or something +# =========================================================================== + +quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) + cmd_rmdirs = rm -rf $(rm-dirs) + +quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) + cmd_rmfiles = rm -f $(rm-files) + + +a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \ + $(NOSTDINC_FLAGS) $(CPPFLAGS) \ + $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) + +quiet_cmd_as_o_S = AS $@ +cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< + +# read all saved command lines + +targets := $(wildcard $(sort $(targets))) +cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) + +ifneq ($(cmd_files),) + $(cmd_files): ; # Do not try to update included dependency files + include $(cmd_files) +endif + +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir +# Usage: +# $(Q)$(MAKE) $(clean)=dir +clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj + +endif # skip-makefile + +PHONY += FORCE +FORCE: + +-include $(srctree)/Makefile.custom + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. +.PHONY: $(PHONY) diff --git a/i/pc104/initrd/conf/busybox/Makefile.custom b/i/pc104/initrd/conf/busybox/Makefile.custom new file mode 100644 index 0000000..0cc40a6 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/Makefile.custom @@ -0,0 +1,145 @@ +# ========================================================================== +# Build system +# ========================================================================== + +%.bflt: %_unstripped + $(CROSS_COMPILE)elf2flt $(ELF2FLTFLAGS) $< -o $@ + +busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/include/applets.h + $(Q)-$(SHELL) $^ >$@ + +.PHONY: install +ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y) +INSTALL_OPTS:= --symlinks +endif +ifeq ($(CONFIG_INSTALL_APPLET_HARDLINKS),y) +INSTALL_OPTS:= --hardlinks +endif +install: $(srctree)/applets/install.sh busybox busybox.links + $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \ + $(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS) +ifeq ($(strip $(CONFIG_FEATURE_SUID)),y) + @echo + @echo + @echo -------------------------------------------------- + @echo You will probably need to make your busybox binary + @echo setuid root to ensure all configured applets will + @echo work properly. + @echo -------------------------------------------------- + @echo +endif + +uninstall: busybox.links + rm -f $(CONFIG_PREFIX)/bin/busybox + for i in `cat busybox.links` ; do rm -f $(CONFIG_PREFIX)$$i; done +ifneq ($(strip $(DO_INSTALL_LIBS)),n) + for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \ + rm -f $(CONFIG_PREFIX)$$i; \ + done +endif + +check test: busybox busybox.links + bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \ + $(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v) + +.PHONY: release +release: distclean + cd ..; \ + rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \ + cp -a busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \ + find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \ + -name .svn \ + -print \ + -exec rm -r -f {} \; ; \ + find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \ + -name .\#* \ + -print \ + -exec rm -f {} \; ; \ + tar -czf busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION).tar.gz \ + busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ ; } + +.PHONY: checkhelp +checkhelp: + $(Q)$(srctree)/scripts/checkhelp.awk \ + $(patsubst %,$(srctree)/%,$(wildcard $(patsubst %,%/Config.in,$(busybox-dirs) ./))) + +.PHONY: sizes +sizes: busybox_unstripped + $(NM) --size-sort $(<) + +.PHONY: bloatcheck +bloatcheck: busybox_old busybox_unstripped + @$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped + +.PHONY: baseline +baseline: busybox_unstripped + @mv busybox_unstripped busybox_old + +.PHONY: objsizes +objsizes: busybox_unstripped + $(srctree)/scripts/objsizes + +.PHONY: bigdata +bigdata: busybox_unstripped + nm --size-sort busybox_unstripped | grep -vi ' [tr] ' | tail -20 + +# Documentation Targets +.PHONY: doc +doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html + +docs/busybox.pod: $(srctree)/docs/busybox_header.pod \ + $(srctree)/include/usage.h \ + $(srctree)/docs/busybox_footer.pod \ + $(srctree)/docs/autodocifier.pl + $(disp_doc) + $(Q)-mkdir -p docs + $(Q)-( cat $(srctree)/docs/busybox_header.pod ; \ + $(srctree)/docs/autodocifier.pl $(srctree)/include/usage.h ; \ + cat $(srctree)/docs/busybox_footer.pod ; ) > docs/busybox.pod + +docs/BusyBox.txt: docs/busybox.pod + $(disp_doc) + $(Q)-mkdir -p docs + $(Q)-pod2text $< > $@ + +docs/BusyBox.1: docs/busybox.pod + $(disp_doc) + $(Q)-mkdir -p docs + $(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \ + $< > $@ + +docs/BusyBox.html: docs/busybox.net/BusyBox.html + $(disp_doc) + $(Q)-mkdir -p docs + $(Q)-rm -f docs/BusyBox.html + $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html + +docs/busybox.net/BusyBox.html: docs/busybox.pod + $(Q)-mkdir -p docs/busybox.net + $(Q)-pod2html --noindex $< > \ + docs/busybox.net/BusyBox.html + $(Q)-rm -f pod2htm* + +# documentation, cross-reference +# Modern distributions already ship synopsis packages (e.g. debian) +# If you have an old distribution go to http://synopsis.fresco.org/ +syn_tgt = $(wildcard $(patsubst %,%/*.c,$(busybox-alldirs))) +syn = $(patsubst %.c, %.syn, $(syn_tgt)) + +comma:= , +brace_open:= ( +brace_close:= ) + +SYN_CPPFLAGS := $(strip $(CPPFLAGS) $(EXTRA_CPPFLAGS)) +SYN_CPPFLAGS := $(subst $(brace_open),\$(brace_open),$(SYN_CPPFLAGS)) +SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS)) +#SYN_CPPFLAGS := $(subst ",\",$(SYN_CPPFLAGS)) +#") +#SYN_CPPFLAGS := [$(patsubst %,'%'$(comma),$(SYN_CPPFLAGS))''] + +%.syn: %.c + synopsis -p C -l Comments.SSDFilter,Comments.Previous -Wp,preprocess=True,cppflags="'$(SYN_CPPFLAGS)'" -o $@ $< + +.PHONY: html +html: $(syn) + synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^ diff --git a/i/pc104/initrd/conf/busybox/Makefile.flags b/i/pc104/initrd/conf/busybox/Makefile.flags new file mode 100644 index 0000000..b7711f6 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/Makefile.flags @@ -0,0 +1,61 @@ +# ========================================================================== +# Build system +# ========================================================================== + +BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) + +# -std=gnu99 needed for [U]LLONG_MAX on some systems +CPPFLAGS += $(call cc-option,-std=gnu99,) + +CPPFLAGS += \ + -Iinclude -Ilibbb \ + $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \ + -include include/autoconf.h \ + -D_GNU_SOURCE -DNDEBUG \ + $(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \ + -D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP + +# flag checks are grouped together to speed the checks up a bit.. +CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,) +CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,) +# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above +# (or anything else for that matter) make sure that it is still possible +# to build bbox without warnings. Current offender: find.c:alloc_action(). +# Looks more like gcc bug: gcc will warn on it with or without prototype. +# But still, warning-free compile is a must, or else we will drown +# in warnings pretty soon. + +ifeq ($(CONFIG_WERROR),y) +CFLAGS += $(call cc-option,-Werror,) +endif +# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action() +CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition) + +# gcc emits bogus "no prev proto" warning on find.c:alloc_action() +ifneq ($(CONFIG_WERROR),y) +CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,) +endif + +CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,) +# -fno-guess-branch-probability: prohibit pseudo-random guessing +# of branch probabilities (hopefully makes bloatcheck more stable): +CFLAGS += $(call cc-option,-fno-guess-branch-probability,) +CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,) +CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,) + +# FIXME: These warnings are at least partially to be concerned about and should +# be fixed.. +#CFLAGS+=$(call cc-option,-Wconversion,) + +ifeq ($(CONFIG_DEBUG),y) +CFLAGS += $(call cc-option,-g) +endif + +ifeq ($(CONFIG_STATIC),y) +LDFLAGS += -static +endif + +ifeq ($(CONFIG_SELINUX),y) +LDFLAGS += -lselinux -lsepol +endif +#LDFLAGS += -nostdlib diff --git a/i/pc104/initrd/conf/busybox/Makefile.help b/i/pc104/initrd/conf/busybox/Makefile.help new file mode 100644 index 0000000..fc661b1 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/Makefile.help @@ -0,0 +1,42 @@ +# ========================================================================== +# Build system +# ========================================================================== + +help: + @echo 'Cleaning:' + @echo ' clean - delete temporary files created by build' + @echo ' distclean - delete all non-source files (including .config)' + @echo + @echo 'Build:' + @echo ' all - Executable and documentation' + @echo ' busybox - the swiss-army executable' + @echo ' doc - docs/BusyBox.{txt,html,1}' + @echo ' html - create html-based cross-reference' + @echo + @echo 'Configuration:' + @echo ' allnoconfig - disable all symbols in .config' + @echo ' allyesconfig - enable all symbols in .config (see defconfig)' + @echo ' allbareconfig - enable all applets without any sub-features' + @echo ' config - text based configurator (of last resort)' + @echo ' defconfig - set .config to largest generic configuration' + @echo ' menuconfig - interactive curses-based configurator' + @echo ' oldconfig - resolve any unresolved symbols in .config' + @echo ' hosttools - build sed for the host.' + @echo ' You can use these commands if the commands on the host' + @echo ' is unusable. Afterwards use it like:' + @echo ' make SED="$(objtree)/sed"' + @echo + @echo 'Installation:' + @echo ' install - install busybox into $(CONFIG_PREFIX)' + @echo ' uninstall' + @echo + @echo 'Development:' + @echo ' baseline - create busybox_old for bloatcheck.' + @echo ' bloatcheck - show size difference between old and new versions' + @echo ' check - run the test suite for all applets' + @echo ' checkhelp - check for missing help-entries in Config.in' + @echo ' randconfig - generate a random configuration' + @echo ' release - create a distribution tarball' + @echo ' sizes - show size of all enabled busybox symbols' + @echo ' objsizes - show size of each .o object built' + @echo diff --git a/i/pc104/initrd/conf/busybox/README b/i/pc104/initrd/conf/busybox/README new file mode 100644 index 0000000..96ca0bb --- /dev/null +++ b/i/pc104/initrd/conf/busybox/README @@ -0,0 +1,198 @@ +Please see the LICENSE file for details on copying and usage. +Please refer to the INSTALL file for instructions on how to build. + +What is busybox: + + BusyBox combines tiny versions of many common UNIX utilities into a single + small executable. It provides minimalist replacements for most of the + utilities you usually find in bzip2, coreutils, dhcp, diffutils, e2fsprogs, + file, findutils, gawk, grep, inetutils, less, modutils, net-tools, procps, + sed, shadow, sysklogd, sysvinit, tar, util-linux, and vim. The utilities + in BusyBox often have fewer options than their full-featured cousins; + however, the options that are included provide the expected functionality + and behave very much like their larger counterparts. + + BusyBox has been written with size-optimization and limited resources in + mind, both to produce small binaries and to reduce run-time memory usage. + Busybox is also extremely modular so you can easily include or exclude + commands (or features) at compile time. This makes it easy to customize + embedded systems; to create a working system, just add /dev, /etc, and a + Linux kernel. Busybox (usually together with uClibc) has also been used as + a component of "thin client" desktop systems, live-CD distributions, rescue + disks, installers, and so on. + + BusyBox provides a fairly complete POSIX environment for any small system, + both embedded environments and more full featured systems concerned about + space. Busybox is slowly working towards implementing the full Single Unix + Specification V3 (http://www.opengroup.org/onlinepubs/009695399/), but isn't + there yet (and for size reasons will probably support at most UTF-8 for + internationalization). We are also interested in passing the Linux Test + Project (http://ltp.sourceforge.net). + +---------------- + +Using busybox: + + BusyBox is extremely configurable. This allows you to include only the + components and options you need, thereby reducing binary size. Run 'make + config' or 'make menuconfig' to select the functionality that you wish to + enable. (See 'make help' for more commands.) + + The behavior of busybox is determined by the name it's called under: as + "cp" it behaves like cp, as "sed" it behaves like sed, and so on. Called + as "busybox" it takes the second argument as the name of the applet to + run (I.E. "./busybox ls -l /proc"). + + The "standalone shell" mode is an easy way to try out busybox; this is a + command shell that calls the builtin applets without needing them to be + installed in the path. (Note that this requires /proc to be mounted, if + testing from a boot floppy or in a chroot environment.) + + The build automatically generates a file "busybox.links", which is used by + 'make install' to create symlinks to the BusyBox binary for all compiled in + commands. This uses the CONFIG_PREFIX environment variable to specify + where to install, and installs hardlinks or symlinks depending + on the configuration preferences. (You can also manually run + the install script at "applets/install.sh"). + +---------------- + +Downloading the current source code: + + Source for the latest released version, as well as daily snapshots, can always + be downloaded from + + http://busybox.net/downloads/ + + You can browse the up to the minute source code and change history online. + + http://www.busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/ + + Anonymous SVN access is available. For instructions, check out: + + http://busybox.net/subversion.html + + For those that are actively contributing and would like to check files in, + see: + + http://busybox.net/developer.html + + The developers also have a bug and patch tracking system + (http://bugs.busybox.net) although posting a bug/patch to the mailing list + is generally a faster way of getting it fixed, and the complete archive of + what happened is the subversion changelog. + +---------------- + +getting help: + + when you find you need help, you can check out the busybox mailing list + archives at http://busybox.net/lists/busybox/ or even join + the mailing list if you are interested. + +---------------- + +bugs: + + if you find bugs, please submit a detailed bug report to the busybox mailing + list at busybox@busybox.net. a well-written bug report should include a + transcript of a shell session that demonstrates the bad behavior and enables + anyone else to duplicate the bug on their own machine. the following is such + an example: + + to: busybox@busybox.net + from: diligent@testing.linux.org + subject: /bin/date doesn't work + + package: busybox + version: 1.00 + + when i execute busybox 'date' it produces unexpected results. + with gnu date i get the following output: + + $ date + fri oct 8 14:19:41 mdt 2004 + + but when i use busybox date i get this instead: + + $ date + illegal instruction + + i am using debian unstable, kernel version 2.4.25-vrs2 on a netwinder, + and the latest uclibc from cvs. thanks for the wonderful program! + + -diligent + + note the careful description and use of examples showing not only what + busybox does, but also a counter example showing what an equivalent app + does (or pointing to the text of a relevant standard). Bug reports lacking + such detail may never be fixed... Thanks for understanding. + +---------------- + +Portability: + + Busybox is developed and tested on Linux 2.4 and 2.6 kernels, compiled + with gcc (the unit-at-a-time optimizations in version 3.4 and later are + worth upgrading to get, but older versions should work), and linked against + uClibc (0.9.27 or greater) or glibc (2.2 or greater). In such an + environment, the full set of busybox features should work, and if + anything doesn't we want to know about it so we can fix it. + + There are many other environments out there, in which busybox may build + and run just fine. We just don't test them. Since busybox consists of a + large number of more or less independent applets, portability is a question + of which features work where. Some busybox applets (such as cat and rm) are + highly portable and likely to work just about anywhere, while others (such as + insmod and losetup) require recent Linux kernels with recent C libraries. + + Earlier versions of Linux and glibc may or may not work, for any given + configuration. Linux 2.2 or earlier should mostly work (there's still + some support code in things like mount.c) but this is no longer regularly + tested, and inherently won't support certain features (such as long files + and --bind mounts). The same is true for glibc 2.0 and 2.1: expect a higher + testing and debugging burden using such old infrastructure. (The busybox + developers are not very interested in supporting these older versions, but + will probably accept small self-contained patches to fix simple problems.) + + Some environments are not recommended. Early versions of uClibc were buggy + and missing many features: upgrade. Linking against libc5 or dietlibc is + not supported and not interesting to the busybox developers. (The first is + obsolete and has no known size or feature advantages over uClibc, the second + has known bugs that its developers have actively refused to fix.) Ancient + Linux kernels (2.0.x and earlier) are similarly uninteresting. + + In theory it's possible to use Busybox under other operating systems (such as + MacOS X, Solaris, Cygwin, or the BSD Fork Du Jour). This generally involves + a different kernel and a different C library at the same time. While it + should be possible to port the majority of the code to work in one of + these environments, don't be suprised if it doesn't work out of the box. If + you're into that sort of thing, start small (selecting just a few applets) + and work your way up. + + Shaun Jackman has recently (2005) ported busybox to a combination of newlib + and libgloss, and some of his patches have been integrated. This platform + may join glibc/uclibc and Linux as a supported combination with the 1.1 + release, but is not supported in 1.0. + +Supported hardware: + + BusyBox in general will build on any architecture supported by gcc. We + support both 32 and 64 bit platforms, and both big and little endian + systems. + + Under 2.4 Linux kernels, kernel module loading was implemented in a + platform-specific manner. Busybox's insmod utility has been reported to + work under ARM, CRIS, H8/300, x86, ia64, x86_64, m68k, MIPS, PowerPC, S390, + SH3/4/5, Sparc, v850e, and x86_64. Anything else probably won't work. + + The module loading mechanism for the 2.6 kernel is much more generic, and + we believe 2.6.x kernel module loading support should work on all + architectures supported by the kernel. + +---------------- + +Please feed suggestions, bug reports, insults, and bribes back to the busybox +maintainer: + Denis Vlasenko + diff --git a/i/pc104/initrd/conf/busybox/TODO b/i/pc104/initrd/conf/busybox/TODO new file mode 100644 index 0000000..1896928 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/TODO @@ -0,0 +1,320 @@ +Busybox TODO + +Stuff that needs to be done. This is organized by who plans to get around to +doing it eventually, but that doesn't mean they "own" the item. If you want to +do one of these bounce an email off the person it's listed under to see if they +have any suggestions how they plan to go about it, and to minimize conflicts +between your work and theirs. But otherwise, all of these are fair game. + +Rob Landley : + Add BB_NOMMU to platform.h and migrate __uClinux__ tests to that. + #if defined __UCLIBC__ && !defined __ARCH_USE_MMU__ + Add a libbb/platform.c + Implement fdprintf() for platforms that haven't got one. + Implement bb_realpath() that can handle NULL on non-glibc. + Cleanup bb_asprintf() + + Migrate calloc() and bb_calloc() occurrences to bb_xzalloc(). + Remove obsolete _() wrapper crud for internationalization we don't do. + Figure out where we need utf8 support, and add it. + + sh + The command shell situation is a big mess. We have three or four different + shells that don't really share any code, and the "standalone shell" doesn't + work all that well (especially not in a chroot environment), due to apps not + being reentrant. I'm writing a new shell (bbsh) to unify the various + shells and configurably add the minimal set of bash features people + actually use. The hardest part is it has to configure down as small as + lash while providing lash's features. The rest is easy in comparison. + bzip2 + Compression-side support. + init + General cleanup (should use ENABLE_FEATURE_INIT_SYSLOG and ENABLE_FEATURE_INIT_DEBUG). + depmod + busybox lacks a way to update module deps when running from firmware without the + use of the depmod.pl (perl is to bloated for most embedded setups) and or orig + modutils. The orig depmod is rather pointless to have to add to a firmware image + in when we already have a insmod/rmmod and friends. + Unify base64 handling. + There's base64 encoding and decoding going on in: + networking/wget.c:base64enc() + coreutils/uudecode.c:read_base64() + coreutils/uuencode.c:tbl_base64[] + networking/httpd.c:decodeBase64() + And probably elsewhere. That needs to be unified into libbb functions. + Do a SUSv3 audit + Look at the full Single Unix Specification version 3 (available online at + "http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and + figure out which of our apps are compliant, and what we're missing that + we might actually care about. + + Even better would be some kind of automated compliance test harness that + exercises each command line option and the various corner cases. + Internationalization + How much internationalization should we do? + + The low hanging fruit is UTF-8 character set support. We should do this. + (Vodz pointed out the shell's cmdedit as needing work here. What else?) + + We also have lots of hardwired english text messages. Consolidating this + into some kind of message table not only makes translation easier, but + also allows us to consolidate redundant (or close) strings. + + We probably don't want to be bloated with locale support. (Not unless we + can cleanly export it from our underlying C library without having to + concern ourselves with it directly. Perhaps a few specific things like a + config option for "date" are low hanging fruit here?) + + What level should things happen at? How much do we care about + internationalizing the text console when X11 and xterms are so much better + at it? (There's some infrastructure here we don't implement: The + "unicode_start" and "unicode_stop" shell scripts need "vt-is-UTF8" and a + --unicode option to loadkeys. That implies a real loadkeys/dumpkeys + implementation to replace loadkmap/dumpkmap. Plus messing with console font + loading. Is it worth it, or do we just say "use X"?) + + Individual compilation of applets. + It would be nice if busybox had the option to compile to individual applets, + for people who want an alternate implementation less bloated than the gnu + utils (or simply with less political baggage), but without it being one big + executable. + + Turning libbb into a real dll is another possibility, especially if libbb + could export some of the other library interfaces we've already more or less + got the code for (like zlib). + buildroot - Make a "dogfood" option + Busybox 1.1 will be capable of replacing most gnu packages for real world + use, such as developing software or in a live CD. It needs wider testing. + + Busybox should now be able to replace bzip2, coreutils, e2fsprogs, file, + findutils, gawk, grep, inetutils, less, modutils, net-tools, patch, procps, + sed, shadow, sysklogd, sysvinit, tar, util-linux, and vim. The resulting + system should be self-hosting (I.E. able to rebuild itself from source + code). This means it would need (at least) binutils, gcc, and make, or + equivalents. + + It would be a good "eating our own dogfood" test if buildroot had the option + of using a "make allyesconfig" busybox instead of the all of the above + packages. Anything that's wrong with the resulting system, we can fix. (It + would be nice to be able to upgrade busybox to be able to replace bash and + diffutils as well, but we're not there yet.) + + One example of an existing system that does this already is Firmware Linux: + http://www.landley.net/code/firmware + initramfs + Busybox should have a sample initramfs build script. This depends on + bbsh, mdev, and switch_root. + mkdep + Write a mkdep that doesn't segfault if there's a directory it doesn't + have permission to read, isn't based on manually editing the output of + lexx and yacc, doesn't make such a mess under include/config, etc. + Group globals into unions of structures. + Go through and turn all the global and static variables into structures, + and have all those structures be in a big union shared between processes, + so busybox uses less bss. (This is a big win on nommu machines.) See + sed.c and mdev.c for examples. + Go through bugs.busybox.net and close out all of that somehow. + This one's open to everybody, but I'll wind up doing it... + + +Bernhard Fischer suggests to look at these: + New debug options: + -Wlarger-than-127 + Cleanup any big users + -Wunused-parameter + Facilitate applet PROTOTYPES to provide means for having applets that + do a) not take any arguments b) need only one of argc or argv c) need + both argc and argv. All of these three options should go for the most + feature complete denominator. + Collate BUFSIZ IOBUF_SIZE MY_BUF_SIZE PIPE_PROGRESS_SIZE BUFSIZE PIPESIZE + make bb_common_bufsiz1 configurable, size wise. + make pipesize configurable, size wise. + Use bb_common_bufsiz1 throughout applets! + +As yet unclaimed: + +---- +find + doesn't understand (), lots of susv3 stuff. +---- +diff + Make sure we handle empty files properly: + From the patch man page: + + you can remove a file by sending out a context diff that compares + the file to be deleted with an empty file dated the Epoch. The + file will be removed unless patch is conforming to POSIX and the + -E or --remove-empty-files option is not given. +--- +patch + Should have simple fuzz factor support to apply patches at an offset which + shouldn't take up too much space. + + And while we're at it, a new patch filename quoting format is apparently + coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2 +--- +ps / top + Add support for both RSS and VSIZE rather than just one or the other. + Or make it a build option. +--- +man + It would be nice to have a man command. Not one that handles troff or + anything, just one that can handle preformatted ascii man pages, possibly + compressed. This could probably be a script in the extras directory that + calls cat/zcat/bzcat | less + + (How doclifter might work into this is anybody's guess.) +--- +ar + Write support? +---- +stty / catv + stty's visible() function and catv's guts are identical. Merge them into + an appropriate libbb function. +---- +struct suffix_mult + Several duplicate users of: grep -r "1024\*1024" * -B2 -A1 + Merge to a single size_suffixes[] in libbb. + Users: head tail od_bloaty hexdump and (partially as it wouldn't hurt) svlogd + +Architectural issues: + +bb_close() with fsync() + We should have a bb_close() in place of normal close, with a CONFIG_ option + to not just check the return value of close() for an error, but fsync(). + Close can't reliably report anything useful because if write() accepted the + data then it either went out to the network or it's in cache or a pipe + buffer. Either way, there's no guarantee it'll make it to its final + destination before close() gets called, so there's no guarantee that any + error will be reported. + + You need to call fsync() if you care about errors that occur after write(), + but that can have a big performance impact. So make it a config option. +--- +Unify archivers + Lots of archivers have the same general infrastructure. The directory + traversal code should be factored out, and the guts of each archiver could + be some setup code and a series of callbacks for "add this file", + "add this directory", "add this symlink" and so on. + + This could clean up tar and zip, and make it cheaper to add cpio and ar + write support, and possibly even cheaply add things like mkisofs or + mksquashfs someday, if they become relevant. +--- +Text buffer support. + Several existing applets (sort, vi, less...) read + a whole file into memory and act on it. There might be an opportunity + for shared code in there that could be moved into libbb... +--- +Memory Allocation + We have a CONFIG_BUFFER mechanism that lets us select whether to do memory + allocation on the stack or the heap. Unfortunately, we're not using it much. + We need to audit our memory allocations and turn a lot of malloc/free calls + into RESERVE_CONFIG_BUFFER/RELEASE_CONFIG_BUFFER. + For a start, see e.g. make EXTRA_CFLAGS=-Wlarger-than-64 + + And while we're at it, many of the CONFIG_FEATURE_CLEAN_UP #ifdefs will be + optimized out by the compiler in the stack allocation case (since there's no + free for an alloca()), and this means that various cleanup loops that just + call free might also be optimized out by the compiler if written right, so + we can yank those #ifdefs too, and generally clean up the code. +--- +Switch CONFIG_SYMBOLS to ENABLE_SYMBOLS + + In busybox 1.0 and earlier, configuration was done by CONFIG_SYMBOLS + that were either defined or undefined to indicate whether the symbol was + selected in the .config file. They were used with #ifdefs, ala: + + #ifdef CONFIG_SYMBOL + if (other_test) { + do_code(); + } + #endif + + In 1.1, we have new ENABLE_SYMBOLS which are always defined (as 0 or 1), + meaning you can still use them for preprocessor tests by replacing + "#ifdef CONFIG_SYMBOL" with "#if ENABLE_SYMBOL". But more importantly, we + can use them as a true or false test in normal C code: + + if (ENABLE_SYMBOL && other_test) { + do_code(); + } + + (Optimizing away if() statements that resolve to a constant value + is known as "dead code elimination", an optimization so old and simple that + Turbo Pascal for DOS did it twenty years ago. Even modern mini-compilers + like the Tiny C Compiler (tcc) and the Small Device C Compiler (SDCC) + perform dead code elimination.) + + Right now, busybox.h is #including both "config.h" (defining the + CONFIG_SYMBOLS) and "bb_config.h" (defining the ENABLE_SYMBOLS). At some + point in the future, it would be nice to wean ourselves off of the + CONFIG versions. (Among other things, some defective build environments + leak the Linux kernel's CONFIG_SYMBOLS into the system's standard #include + files. We've experienced collisions before.) +--- +FEATURE_CLEAN_UP + This is more an unresolved issue than a to-do item. More thought is needed. + + Normally we rely on exit() to free memory, close files, and unmap segments + for us. This makes most calls to free(), close(), and unmap() optional in + busybox applets that don't intend to run for very long, and optional stuff + can be omitted to save size. + + The idea was raised that we could simulate fork/exit with setjmp/longjmp + for _really_ brainless embedded systems, or speed up the standalone shell + by not forking. Doing so would require a reliable FEATURE_CLEAN_UP. + Unfortunately, this isn't as easy as it sounds. + + The problem is, lots of things exit(), sometimes unexpectedly (xmalloc()) + and sometimes reliably (bb_perror_msg_and_die() or show_usage()). This + jumps out of the normal flow control and bypasses any cleanup code we + put at the end of our applets. + + It's possible to add hooks to libbb functions like xmalloc() and xopen() + to add their entries to a linked list, which could be traversed and + freed/closed automatically. (This would need to be able to free just the + entries after a checkpoint to be usable for a forkless standalone shell. + You don't want to free the shell's own resources.) + + Right now, FEATURE_CLEAN_UP is more or less a debugging aid, to make things + like valgrind happy. It's also documentation of _what_ we're trusting + exit() to clean up for us. But new infrastructure to auto-free stuff would + render the existing FEATURE_CLEAN_UP code redundant. + + For right now, exit() handles it just fine. + + + +Minor stuff: + watchdog.c could autodetect the timer duration via: + if(!ioctl (fd, WDIOC_GETTIMEOUT, &tmo)) timer_duration = 1 + (tmo / 2); + Unfortunately, that needs linux/watchdog.h and that contains unfiltered + kernel types on some distros, which breaks the build. +--- + use bb_error_msg where appropriate: See + egrep "(printf.*\([[:space:]]*(stderr|2)|[^_]write.*\([[:space:]]*(stderr|2))" +--- + use bb_perror_msg where appropriate: See + egrep "[^_]perror" +--- + Remove superfluous fmt occurances: e.g. + fprintf(stderr, "%s: %s not found\n", "unalias", *argptr); + -> fprintf(stderr, "unalias: %s not found\n", *argptr); +--- + possible code duplication ingroup() and is_a_group_member() +--- + Move __get_hz() to a better place and (re)use it in route.c, ash.c, msh.c +--- + + +Code cleanup: + +Replace deprecated functions. + +bzero() -> memset() +--- +sigblock(), siggetmask(), sigsetmask(), sigmask() -> sigprocmask et al +--- +vdprintf() -> similar sized functionality +--- diff --git a/i/pc104/initrd/conf/busybox/applets/Kbuild b/i/pc104/initrd/conf/busybox/applets/Kbuild new file mode 100644 index 0000000..4323e85 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/applets/Kbuild @@ -0,0 +1,22 @@ +# Makefile for busybox +# +# Copyright (C) 1999-2005 by Erik Andersen +# +# Licensed under the GPL v2, see the file LICENSE in this tarball. + +obj-y:= +obj-y += applets.o +obj-y += busybox.o + +# Generated file needs additional love + +applets/applets.o: .config include/usage_compressed.h + +hostprogs-y += usage +always := $(hostprogs-y) +HOSTCFLAGS_usage.o = -I$(srctree)/include + +quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h + cmd_gen_usage_compressed = $(srctree)/applets/usage_compressed include/usage_compressed.h applets +include/usage_compressed.h: .config $(srctree)/include/usage.h applets/usage + $(call cmd,gen_usage_compressed) diff --git a/i/pc104/initrd/conf/busybox/applets/applets.c b/i/pc104/initrd/conf/busybox/applets/applets.c new file mode 100644 index 0000000..7245ece --- /dev/null +++ b/i/pc104/initrd/conf/busybox/applets/applets.c @@ -0,0 +1,495 @@ +/* vi: set sw=4 ts=4: */ +/* + * Utility routines. + * + * Copyright (C) tons of folks. Tracking down who wrote what + * isn't something I'm going to worry about... If you wrote something + * here, please feel free to acknowledge your work. + * + * Based in part on code from sash, Copyright (c) 1999 by David I. Bell + * Permission has been granted to redistribute this code under the GPL. + * + * Licensed under GPLv2 or later, see file License in this tarball for details. + */ + +#include +#include "busybox.h" + +#define PROTOTYPES +#include "applets.h" +#undef PROTOTYPES + + +/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */ +#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__) +#warning Static linking against glibc produces buggy executables +#warning (glibc does not cope well with ld --gc-sections). +#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400 +#warning Note that glibc is unsuitable for static linking anyway. +#warning If you still want to do it, remove -Wl,--gc-sections +#warning from top-level Makefile and remove this warning. +#endif + +#if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE +static const char usage_messages[] = +#define MAKE_USAGE +#include "usage.h" +#include "applets.h" +; +#undef MAKE_USAGE +#else +#define usage_messages 0 +#endif /* ENABLE_SHOW_USAGE */ + +#undef APPLET +#undef APPLET_NOUSAGE +#undef PROTOTYPES +#include "applets.h" + +static struct BB_applet *applet_using; + +/* The -1 arises because of the {0,NULL,0,-1} entry above. */ +const unsigned short NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1); + + +#ifdef CONFIG_FEATURE_SUID_CONFIG + +#include + +#define CONFIG_FILE "/etc/busybox.conf" + +/* applets [] is const, so we have to define this "override" structure */ +static struct BB_suid_config +{ + struct BB_applet *m_applet; + + uid_t m_uid; + gid_t m_gid; + mode_t m_mode; + + struct BB_suid_config *m_next; +} *suid_config; + +static int suid_cfg_readable; + +/* check if u is member of group g */ +static int ingroup(uid_t u, gid_t g) +{ + struct group *grp = getgrgid(g); + + if (grp) { + char **mem; + + for (mem = grp->gr_mem; *mem; mem++) { + struct passwd *pwd = getpwnam(*mem); + + if (pwd && (pwd->pw_uid == u)) + return 1; + } + } + return 0; +} + +/* This should probably be a libbb routine. In that case, + * I'd probably rename it to something like bb_trimmed_slice. + */ +static char *get_trimmed_slice(char *s, char *e) +{ + /* First, consider the value at e to be nul and back up until we + * reach a non-space char. Set the char after that (possibly at + * the original e) to nul. */ + while (e-- > s) { + if (!isspace(*e)) { + break; + } + } + e[1] = 0; + + /* Next, advance past all leading space and return a ptr to the + * first non-space char; possibly the terminating nul. */ + return skip_whitespace(s); +} + + +#define parse_error(x) do { errmsg = x; goto pe_label; } while(0) + +/* Don't depend on the tools to combine strings. */ +static const char config_file[] = CONFIG_FILE; + +/* There are 4 chars + 1 nul for each of user/group/other. */ +static const char mode_chars[] = "Ssx-\0Ssx-\0Ttx-"; + +/* We don't supply a value for the nul, so an index adjustment is + * necessary below. Also, we use unsigned short here to save some + * space even though these are really mode_t values. */ +static const unsigned short mode_mask[] = { + /* SST sst xxx --- */ + S_ISUID, S_ISUID|S_IXUSR, S_IXUSR, 0, /* user */ + S_ISGID, S_ISGID|S_IXGRP, S_IXGRP, 0, /* group */ + 0, S_IXOTH, S_IXOTH, 0 /* other */ +}; + +static void parse_config_file(void) +{ + struct BB_suid_config *sct_head; + struct BB_suid_config *sct; + struct BB_applet *applet; + FILE *f; + const char *errmsg; + char *s; + char *e; + int i, lc, section; + char buffer[256]; + struct stat st; + + assert(!suid_config); /* Should be set to NULL by bss init. */ + + if ((stat(config_file, &st) != 0) /* No config file? */ + || !S_ISREG(st.st_mode) /* Not a regular file? */ + || (st.st_uid != 0) /* Not owned by root? */ + || (st.st_mode & (S_IWGRP | S_IWOTH)) /* Writable by non-root? */ + || !(f = fopen(config_file, "r")) /* Cannot open? */ + ) { + return; + } + + suid_cfg_readable = 1; + sct_head = NULL; + section = lc = 0; + + do { + s = buffer; + + if (!fgets(s, sizeof(buffer), f)) { /* Are we done? */ + if (ferror(f)) { /* Make sure it wasn't a read error. */ + parse_error("reading"); + } + fclose(f); + suid_config = sct_head; /* Success, so set the pointer. */ + return; + } + + lc++; /* Got a (partial) line. */ + + /* If a line is too long for our buffer, we consider it an error. + * The following test does mistreat one corner case though. + * If the final line of the file does not end with a newline and + * yet exactly fills the buffer, it will be treated as too long + * even though there isn't really a problem. But it isn't really + * worth adding code to deal with such an unlikely situation, and + * we do err on the side of caution. Besides, the line would be + * too long if it did end with a newline. */ + if (!strchr(s, '\n') && !feof(f)) { + parse_error("line too long"); + } + + /* Trim leading and trailing whitespace, ignoring comments, and + * check if the resulting string is empty. */ + if (!*(s = get_trimmed_slice(s, strchrnul(s, '#')))) { + continue; + } + + /* Check for a section header. */ + + if (*s == '[') { + /* Unlike the old code, we ignore leading and trailing + * whitespace for the section name. We also require that + * there are no stray characters after the closing bracket. */ + if (!(e = strchr(s, ']')) /* Missing right bracket? */ + || e[1] /* Trailing characters? */ + || !*(s = get_trimmed_slice(s+1, e)) /* Missing name? */ + ) { + parse_error("section header"); + } + /* Right now we only have one section so just check it. + * If more sections are added in the future, please don't + * resort to cascading ifs with multiple strcasecmp calls. + * That kind of bloated code is all too common. A loop + * and a string table would be a better choice unless the + * number of sections is very small. */ + if (strcasecmp(s, "SUID") == 0) { + section = 1; + continue; + } + section = -1; /* Unknown section so set to skip. */ + continue; + } + + /* Process sections. */ + + if (section == 1) { /* SUID */ + /* Since we trimmed leading and trailing space above, we're + * now looking for strings of the form + * [::space::]*=[::space::]* + * where both key and value could contain inner whitespace. */ + + /* First get the key (an applet name in our case). */ + if (!!(e = strchr(s, '='))) { + s = get_trimmed_slice(s, e); + } + if (!e || !*s) { /* Missing '=' or empty key. */ + parse_error("keyword"); + } + + /* Ok, we have an applet name. Process the rhs if this + * applet is currently built in and ignore it otherwise. + * Note: This can hide config file bugs which only pop + * up when the busybox configuration is changed. */ + if ((applet = find_applet_by_name(s))) { + /* Note: We currently don't check for duplicates! + * The last config line for each applet will be the + * one used since we insert at the head of the list. + * I suppose this could be considered a feature. */ + sct = xmalloc(sizeof(struct BB_suid_config)); + sct->m_applet = applet; + sct->m_mode = 0; + sct->m_next = sct_head; + sct_head = sct; + + /* Get the specified mode. */ + + e = skip_whitespace(e+1); + + for (i=0 ; i < 3 ; i++) { + const char *q; + if (!*(q = strchrnul(mode_chars + 5*i, *e++))) { + parse_error("mode"); + } + /* Adjust by -i to account for nul. */ + sct->m_mode |= mode_mask[(q - mode_chars) - i]; + } + + /* Now get the the user/group info. */ + + s = skip_whitespace(e); + + /* Note: We require whitespace between the mode and the + * user/group info. */ + if ((s == e) || !(e = strchr(s, '.'))) { + parse_error("."); + } + *e++ = 0; + + /* We can't use get_ug_id here since it would exit() + * if a uid or gid was not found. Oh well... */ + { + char *e2; + + sct->m_uid = strtoul(s, &e2, 10); + if (*e2 || (s == e2)) { + struct passwd *pwd = getpwnam(s); + if (!pwd) { + parse_error("user"); + } + sct->m_uid = pwd->pw_uid; + } + + sct->m_gid = strtoul(e, &e2, 10); + if (*e2 || (e == e2)) { + struct group *grp; + if (!(grp = getgrnam(e))) { + parse_error("group"); + } + sct->m_gid = grp->gr_gid; + } + } + } + continue; + } + + /* Unknown sections are ignored. */ + + /* Encountering configuration lines prior to seeing a + * section header is treated as an error. This is how + * the old code worked, but it may not be desirable. + * We may want to simply ignore such lines in case they + * are used in some future version of busybox. */ + if (!section) { + parse_error("keyword outside section"); + } + + } while (1); + + pe_label: + fprintf(stderr, "Parse error in %s, line %d: %s\n", + config_file, lc, errmsg); + + fclose(f); + /* Release any allocated memory before returning. */ + while (sct_head) { + sct = sct_head->m_next; + free(sct_head); + sct_head = sct; + } +} + +#else +#define parse_config_file() ((void)0) +#endif /* CONFIG_FEATURE_SUID_CONFIG */ + +#ifdef CONFIG_FEATURE_SUID +static void check_suid(struct BB_applet *applet) +{ + uid_t ruid = getuid(); /* real [ug]id */ + uid_t rgid = getgid(); + +#ifdef CONFIG_FEATURE_SUID_CONFIG + if (suid_cfg_readable) { + struct BB_suid_config *sct; + + for (sct = suid_config; sct; sct = sct->m_next) { + if (sct->m_applet == applet) + break; + } + if (sct) { + mode_t m = sct->m_mode; + + if (sct->m_uid == ruid) + /* same uid */ + m >>= 6; + else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid)) + /* same group / in group */ + m >>= 3; + + if (!(m & S_IXOTH)) /* is x bit not set ? */ + bb_error_msg_and_die("you have no permission to run this applet!"); + + if (sct->m_gid != 0) { + /* _both_ have to be set for sgid */ + if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { + xsetgid(sct->m_gid); + } else xsetgid(rgid); /* no sgid -> drop */ + } + if (sct->m_uid != 0) { + if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid); + else xsetuid(ruid); /* no suid -> drop */ + } + } else { + /* default: drop all privileges */ + xsetgid(rgid); + xsetuid(ruid); + } + return; + } else { +#ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET + static int onetime = 0; + + if (!onetime) { + onetime = 1; + fprintf(stderr, "Using fallback suid method\n"); + } +#endif + } +#endif + + if (applet->need_suid == _BB_SUID_ALWAYS) { + if (geteuid()) bb_error_msg_and_die("applet requires root privileges!"); + } else if (applet->need_suid == _BB_SUID_NEVER) { + xsetgid(rgid); /* drop all privileges */ + xsetuid(ruid); + } +} +#else +#define check_suid(x) +#endif /* CONFIG_FEATURE_SUID */ + + + +#ifdef CONFIG_FEATURE_COMPRESS_USAGE + +#include "usage_compressed.h" +#include "unarchive.h" + +static const char *unpack_usage_messages(void) +{ + int input[2], output[2], pid; + char *buf; + + if(pipe(input) < 0 || pipe(output) < 0) + exit(1); + + pid = fork(); + switch (pid) { + case -1: /* error */ + exit(1); + case 0: /* child */ + close(input[1]); + close(output[0]); + uncompressStream(input[0], output[1]); + exit(0); + } + /* parent */ + + close(input[0]); + close(output[1]); + pid = fork(); + switch (pid) { + case -1: /* error */ + exit(1); + case 0: /* child */ + full_write(input[1], packed_usage, sizeof(packed_usage)); + exit(0); + } + /* parent */ + close(input[1]); + + buf = xmalloc(SIZEOF_usage_messages); + full_read(output[0], buf, SIZEOF_usage_messages); + return buf; +} + +#else +#define unpack_usage_messages() usage_messages +#endif /* ENABLE_FEATURE_COMPRESS_USAGE */ + +void bb_show_usage(void) +{ + if (ENABLE_SHOW_USAGE) { + const char *format_string; + const char *usage_string = unpack_usage_messages(); + int i; + + for (i = applet_using - applets; i > 0;) + if (!*usage_string++) --i; + + format_string = "%s\n\nUsage: %s %s\n\n"; + if (*usage_string == '\b') + format_string = "%s\n\nNo help available.\n\n"; + fprintf(stderr, format_string, bb_msg_full_version, + applet_using->name, usage_string); + } + + exit(xfunc_error_retval); +} + +static int applet_name_compare(const void *name, const void *vapplet) +{ + const struct BB_applet *applet = vapplet; + + return strcmp(name, applet->name); +} + +struct BB_applet *find_applet_by_name(const char *name) +{ + return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet), + applet_name_compare); +} + +void run_applet_by_name(const char *name, int argc, char **argv) +{ + if (ENABLE_FEATURE_SUID_CONFIG) + parse_config_file(); + + if (!strncmp(name, "busybox", 7)) + exit(busybox_main(argc, argv)); + /* Do a binary search to find the applet entry given the name. */ + applet_using = find_applet_by_name(name); + if (applet_using) { + applet_name = applet_using->name; + if (argc == 2 && !strcmp(argv[1], "--help")) + bb_show_usage(); + if (ENABLE_FEATURE_SUID) + check_suid(applet_using); + exit(applet_using->main(argc, argv)); + } +} diff --git a/i/pc104/initrd/conf/busybox/applets/busybox.c b/i/pc104/initrd/conf/busybox/applets/busybox.c new file mode 100644 index 0000000..0387d79 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/applets/busybox.c @@ -0,0 +1,147 @@ +/* vi: set sw=4 ts=4: */ +/* + * BusyBox' main applet dispatcher. + * + * Licensed under GPLv2, see file LICENSE in this tarball for details. + */ +#include "busybox.h" + +const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE; + +#ifdef CONFIG_FEATURE_INSTALLER +/* + * directory table + * this should be consistent w/ the enum, busybox.h::Location, + * or else... + */ +static const char usr_bin [] = "/usr/bin"; +static const char usr_sbin[] = "/usr/sbin"; + +static const char* const install_dir[] = { + &usr_bin [8], /* "", equivalent to "/" for concat_path_file() */ + &usr_bin [4], /* "/bin" */ + &usr_sbin[4], /* "/sbin" */ + usr_bin, + usr_sbin +}; + +/* abstract link() */ +typedef int (*link_func)(const char *, const char *); + +/* create (sym)links for each applet */ +static void install_links(const char *busybox, int use_symbolic_links) +{ + link_func lf = link; + char *fpc; + int i; + int rc; + + if (use_symbolic_links) + lf = symlink; + + for (i = 0; applets[i].name != NULL; i++) { + fpc = concat_path_file( + install_dir[applets[i].location], + applets[i].name); + rc = lf(busybox, fpc); + if (rc != 0 && errno != EEXIST) { + bb_perror_msg("%s", fpc); + } + free(fpc); + } +} + +#else +#define install_links(x,y) +#endif /* CONFIG_FEATURE_INSTALLER */ + +int main(int argc, char **argv) +{ + const char *s; + + applet_name = argv[0]; + if (*applet_name == '-') + applet_name++; + while ((s = strchr(applet_name, '/'))) + applet_name = s + 1; + + /* Set locale for everybody except 'init' */ + if (ENABLE_LOCALE_SUPPORT && getpid() != 1) + setlocale(LC_ALL, ""); + + run_applet_by_name(applet_name, argc, argv); + bb_error_msg_and_die("applet not found"); +} + +int busybox_main(int argc, char **argv); +int busybox_main(int argc, char **argv) +{ + /* + * This style of argument parsing doesn't scale well + * in the event that busybox starts wanting more --options. + * If someone has a cleaner approach, by all means implement it. + */ + if (ENABLE_FEATURE_INSTALLER && argc > 1 && !strcmp(argv[1], "--install")) { + int use_symbolic_links = 0; + char *busybox; + + /* to use symlinks, or not to use symlinks... */ + if (argc > 2) + if (strcmp(argv[2], "-s") == 0) + use_symbolic_links = 1; + + /* link */ +// XXX: FIXME: this is broken. Why not just use argv[0] ? + busybox = xmalloc_readlink_or_warn("/proc/self/exe"); + if (!busybox) + return 1; + install_links(busybox, use_symbolic_links); + if (ENABLE_FEATURE_CLEAN_UP) + free(busybox); + return 0; + } + + /* Deal with --help. (Also print help when called with no arguments) */ + + if (argc == 1 || !strcmp(argv[1], "--help") ) { + if (argc > 2) { + applet_name = argv[2]; + run_applet_by_name(applet_name, 2, argv); + } else { + const struct BB_applet *a; + int col, output_width; + + output_width = 80 - sizeof("start-stop-daemon, ") - 8; + if (ENABLE_FEATURE_AUTOWIDTH) { + /* Obtain the terminal width. */ + get_terminal_width_height(0, &output_width, NULL); + /* leading tab and room to wrap */ + output_width -= sizeof("start-stop-daemon, ") + 8; + } + + printf("%s\n" + "Copyright (C) 1998-2006  Erik Andersen, Rob Landley, and others.\n" + "Licensed under GPLv2.  See source distribution for full notice.\n\n" + "Usage: busybox [function] [arguments]...\n" + " or: [function] [arguments]...\n\n" + "\tBusyBox is a multi-call binary that combines many common Unix\n" + "\tutilities into a single executable. Most people will create a\n" + "\tlink to busybox for each function they wish to use and BusyBox\n" + "\twill act like whatever it was invoked as!\n" + "\nCurrently defined functions:\n", bb_msg_full_version); + col = 0; + for (a = applets; a->name;) { + col += printf("%s%s", (col ? ", " : "\t"), a->name); + a++; + if (col > output_width && a->name) { + puts(","); + col = 0; + } + } + puts("\n"); + return 0; + } + } else run_applet_by_name(argv[1], argc - 1, argv + 1); + + bb_error_msg_and_die("applet not found"); +} diff --git a/i/pc104/initrd/conf/busybox/applets/busybox.mkll b/i/pc104/initrd/conf/busybox/applets/busybox.mkll new file mode 100755 index 0000000..6d61f7e --- /dev/null +++ b/i/pc104/initrd/conf/busybox/applets/busybox.mkll @@ -0,0 +1,24 @@ +#!/bin/sh +# Make busybox links list file. + +# input $1: full path to Config.h +# input $2: full path to applets.h +# output (stdout): list of pathnames that should be linked to busybox + +# Maintainer: Larry Doolittle + +export LC_ALL=POSIX +export LC_CTYPE=POSIX + +CONFIG_H=${1:-include/autoconf.h} +APPLETS_H=${2:-include/applets.h} +$HOSTCC -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H | + awk '/^[ \t]*LINK/{ + dir=substr($2,8) + gsub("_","/",dir) + if(dir=="/ROOT") dir="" + file=$3 + gsub("\"","",file) + if (file=="busybox") next + print tolower(dir) "/" file + }' diff --git a/i/pc104/initrd/conf/busybox/applets/individual.c b/i/pc104/initrd/conf/busybox/applets/individual.c new file mode 100644 index 0000000..0721683 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/applets/individual.c @@ -0,0 +1,27 @@ +/* Minimal wrapper to build an individual busybox applet. + * + * Copyright 2005 Rob Landley +#include +//Ok to remove? #include "bb_config.h" +#include "usage.h" + +int main(int argc, char *argv[]) +{ + applet_name=argv[0]; + + return APPLET_main(argc,argv); +} + +void bb_show_usage(void) +{ + printf(APPLET_full_usage "\n"); + + exit(1); +} diff --git a/i/pc104/initrd/conf/busybox/applets/install.sh b/i/pc104/initrd/conf/busybox/applets/install.sh new file mode 100755 index 0000000..4ec96c2 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/applets/install.sh @@ -0,0 +1,94 @@ +#!/bin/sh + +export LC_ALL=POSIX +export LC_CTYPE=POSIX + +prefix=${1} +if [ -z "$prefix" ]; then + echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]" + exit 1; +fi +h=`sort busybox.links | uniq` +cleanup="0" +noclobber="0" +case "$2" in + --hardlinks) linkopts="-f";; + --symlinks) linkopts="-fs";; + --cleanup) cleanup="1";; + --noclobber) noclobber="1";; + "") h="";; + *) echo "Unknown install option: $2"; exit 1;; +esac + +if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then + # get the target dir for the libs + # assume it starts with lib + libdir=$($CC -print-file-name=libc.so | \ + sed -n 's%^.*\(/lib[^\/]*\)/libc.so%\1%p') + if test -z "$libdir"; then + libdir=/lib + fi + + mkdir -p $prefix/$libdir || exit 1 + for i in $DO_INSTALL_LIBS; do + rm -f $prefix/$libdir/$i || exit 1 + if [ -f $i ]; then + cp -a $i $prefix/$libdir/ || exit 1 + chmod 0644 $prefix/$libdir/$i || exit 1 + fi + done +fi + +if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then + inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'` + sub_shell_it=` + cd "$prefix" + for d in usr/sbin usr/bin sbin bin ; do + pd=$PWD + if [ -d "$d" ]; then + cd $d + ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f + fi + cd "$pd" + done + ` +fi + +rm -f $prefix/bin/busybox || exit 1 +mkdir -p $prefix/bin || exit 1 +install -m 755 busybox $prefix/bin/busybox || exit 1 + +for i in $h ; do + appdir=`dirname $i` + mkdir -p $prefix/$appdir || exit 1 + if [ "$2" = "--hardlinks" ]; then + bb_path="$prefix/bin/busybox" + else + case "$appdir" in + /) + bb_path="bin/busybox" + ;; + /bin) + bb_path="busybox" + ;; + /sbin) + bb_path="../bin/busybox" + ;; + /usr/bin|/usr/sbin) + bb_path="../../bin/busybox" + ;; + *) + echo "Unknown installation directory: $appdir" + exit 1 + ;; + esac + fi + if [ "$noclobber" = "0" ] || [ ! -e "$prefix$i" ]; then + echo " $prefix$i -> $bb_path" + ln $linkopts $bb_path $prefix$i || exit 1 + else + echo " $prefix$i already exists" + fi +done + +exit 0 diff --git a/i/pc104/initrd/conf/busybox/applets/usage.c b/i/pc104/initrd/conf/busybox/applets/usage.c new file mode 100644 index 0000000..bb7ca82 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/applets/usage.c @@ -0,0 +1,17 @@ +/* vi: set sw=4 ts=4: */ +#include + +#include "../include/autoconf.h" +#include "../include/busybox.h" + +static const char usage_messages[] = "" +#define MAKE_USAGE +#include "usage.h" +#include "applets.h" +; + +int main(void) +{ + write(1, usage_messages, sizeof(usage_messages)); + return 0; +} diff --git a/i/pc104/initrd/conf/busybox/applets/usage_compressed b/i/pc104/initrd/conf/busybox/applets/usage_compressed new file mode 100755 index 0000000..fd581cc --- /dev/null +++ b/i/pc104/initrd/conf/busybox/applets/usage_compressed @@ -0,0 +1,19 @@ +#!/bin/sh + +target="$1" +loc="$2" + +test "$target" || exit 1 +test "$loc" || loc=. +test -x "$loc/usage" || exit 1 +test "$SED" || SED=sed + +sz=`"$loc/usage" | wc -c` || exit 1 + +exec >"$target" + +echo 'static const char packed_usage[] = ' +"$loc/usage" | bzip2 -1 | od -v -t x1 \ +| $SED -e 's/^[^ ]*//' -e 's/ *\(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/' +echo ';' +echo '#define SIZEOF_usage_messages' `expr 0 + $sz` diff --git a/i/pc104/initrd/conf/busybox/arch/i386/Makefile b/i/pc104/initrd/conf/busybox/arch/i386/Makefile new file mode 100644 index 0000000..385dd52 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/arch/i386/Makefile @@ -0,0 +1,5 @@ +# ========================================================================== +# Build system +# ========================================================================== + +CFLAGS += $(call cc-option,-march=i386 -mpreferred-stack-boundary=2,) diff --git a/i/pc104/initrd/conf/busybox/archival/Config.in b/i/pc104/initrd/conf/busybox/archival/Config.in new file mode 100644 index 0000000..2741982 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/Config.in @@ -0,0 +1,300 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/kbuild/config-language.txt. +# + +menu "Archival Utilities" + +config AR + bool "ar" + default n + help + ar is an archival utility program used to create, modify, and + extract contents from archives. An archive is a single file holding + a collection of other files in a structure that makes it possible to + retrieve the original individual files (called archive members). + The original files' contents, mode (permissions), timestamp, owner, + and group are preserved in the archive, and can be restored on + extraction. + + The stored filename is limited to 15 characters. (for more information + see long filename support). + ar has 60 bytes of overheads for every stored file. + + This implementation of ar can extract archives, it cannot create or + modify them. + On an x86 system, the ar applet adds about 1K. + + Unless you have a specific application which requires ar, you should + probably say N here. + +config FEATURE_AR_LONG_FILENAMES + bool "Enable support for long filenames (not need for debs)" + default n + depends on AR + help + By default the ar format can only store the first 15 characters of the + filename, this option removes that limitation. + It supports the GNU ar long filename method which moves multiple long + filenames into a the data section of a new ar entry. + +config BUNZIP2 + bool "bunzip2" + default n + help + bunzip2 is a compression utility using the Burrows-Wheeler block + sorting text compression algorithm, and Huffman coding. Compression + is generally considerably better than that achieved by more + conventional LZ77/LZ78-based compressors, and approaches the + performance of the PPM family of statistical compressors. + + The BusyBox bunzip2 applet is limited to de-compression only. + On an x86 system, this applet adds about 11K. + + Unless you have a specific application which requires bunzip2, you + should probably say N here. + +config CPIO + bool "cpio" + default n + help + cpio is an archival utility program used to create, modify, and extract + contents from archives. + cpio has 110 bytes of overheads for every stored file. + + This implementation of cpio can extract cpio archives created in the + "newc" or "crc" format, it cannot create or modify them. + + Unless you have a specific application which requires cpio, you should + probably say N here. + +config DPKG + bool "dpkg" + default n + help + dpkg is a medium-level tool to install, build, remove and manage Debian packages. + + This implementation of dpkg has a number of limitations, you should use the + official dpkg if possible. + +config DPKG_DEB + bool "dpkg_deb" + default n + help + dpkg-deb packs, unpacks and provides information about Debian archives. + + This implementation of dpkg-deb cannot pack archives. + + Unless you have a specific application which requires dpkg-deb, you should + probably say N here. + +config FEATURE_DPKG_DEB_EXTRACT_ONLY + bool "extract only (-x)" + default n + depends on DPKG_DEB + help + This reduces dpkg-deb to the equivalent of "ar -p data.tar.gz | tar -zx". + However it saves space as none of the extra dpkg-deb, ar or tar options are + needed, they are linked to internally. + +config GUNZIP + bool "gunzip" + default n + help + gunzip is used to decompress archives created by gzip. + You can use the `-t' option to test the integrity of + an archive, without decompressing it. + +config FEATURE_GUNZIP_UNCOMPRESS + bool "Uncompress support" + default n + depends on GUNZIP + help + Enable if you want gunzip to have the ability to decompress + archives created by the program compress (not much + used anymore). + +config GZIP + bool "gzip" + default n + help + gzip is used to compress files. + It's probably the most widely used UNIX compression program. + +config RPM2CPIO + bool "rpm2cpio" + default n + help + Converts an RPM file into a CPIO archive. + +config RPM + bool "rpm" + default n + help + Mini RPM applet - queries and extracts RPM packages. + +config TAR + bool "tar" + default n + help + tar is an archiving program. It's commonly used with gzip to + create compressed archives. It's probably the most widely used + UNIX archive program. + +config FEATURE_TAR_CREATE + bool "Enable archive creation" + default y + depends on TAR + help + If you enable this option you'll be able to create + tar archives using the `-c' option. + +config FEATURE_TAR_BZIP2 + bool "Enable -j option to handle .tar.bz2 files" + default n + depends on TAR + help + If you enable this option you'll be able to extract + archives compressed with bzip2. + +config FEATURE_TAR_LZMA + bool "Enable -a option to handle .tar.lzma files" + default n + depends on TAR + help + If you enable this option you'll be able to extract + archives compressed with lzma. + +config FEATURE_TAR_FROM + bool "Enable -X (exclude from) and -T (include from) options)" + default n + depends on TAR + help + If you enable this option you'll be able to specify + a list of files to include or exclude from an archive. + +config FEATURE_TAR_GZIP + bool "Enable -z option" + default y + depends on TAR + help + If you enable this option tar will be able to call gzip, + when creating or extracting tar gziped archives. + +config FEATURE_TAR_COMPRESS + bool "Enable -Z option" + default n + depends on TAR + help + If you enable this option tar will be able to call uncompress, + when extracting .tar.Z archives. + +config FEATURE_TAR_OLDGNU_COMPATIBILITY + bool "Enable support for old tar header format" + default N + depends on TAR + help + This option is required to unpack archives created in + the old GNU format; help to kill this old format by + repacking your ancient archives with the new format. + +config FEATURE_TAR_GNU_EXTENSIONS + bool "Enable support for some GNU tar extensions" + default y + depends on TAR + help + With this option busybox supports GNU long filenames and + linknames. + +config FEATURE_TAR_LONG_OPTIONS + bool "Enable long options" + default n + depends on TAR && GETOPT_LONG + help + Enable use of long options, increases size by about 400 Bytes + +config UNCOMPRESS + bool "uncompress" + default n + help + uncompress is used to decompress archives created by compress. + Not much used anymore, replaced by gzip/gunzip. + +config UNLZMA + bool "unlzma" + default n + help + unlzma is a compression utility using the Lempel-Ziv-Markov chain + compression algorithm, and range coding. Compression + is generally considerably better than that achieved by the bzip2 + compressors. + + The BusyBox unlzma applet is limited to de-compression only. + On an x86 system, this applet adds about 4K. + + Unless you have a specific application which requires unlzma, you + should probably say N here. + +config FEATURE_LZMA_FAST + bool "Optimze unlzma for speed" + default n + depends on UNLZMA + help + This option reduces decompression time by about 33% at the cost of + a 2K bigger binary. + +config UNZIP + bool "unzip" + default n + help + unzip will list or extract files from a ZIP archive, + commonly found on DOS/WIN systems. The default behavior + (with no options) is to extract the archive into the + current directory. Use the `-d' option to extract to a + directory of your choice. + +comment "Common options for cpio and tar" + depends on CPIO || TAR + +config FEATURE_UNARCHIVE_TAPE + bool "Enable tape drive support" + default n + depends on CPIO || TAR + help + I don't think this is needed anymore. + +comment "Common options for dpkg and dpkg_deb" + depends on DPKG || DPKG_DEB + +config FEATURE_DEB_TAR_GZ + bool "gzip debian packages (normal)" + default y if DPKG || DPKG_DEB + depends on DPKG || DPKG_DEB + help + This is the default compression method inside the debian ar file. + + If you want compatibility with standard .deb's you should say yes here. + +config FEATURE_DEB_TAR_BZ2 + bool "bzip2 debian packages" + default n + depends on DPKG || DPKG_DEB + help + This allows dpkg and dpkg-deb to extract deb's that are compressed internally + with bzip2 instead of gzip. + + You only want this if you are creating your own custom debian packages that + use an internal control.tar.bz2 or data.tar.bz2. + +config FEATURE_DEB_TAR_LZMA + bool "lzma debian packages" + default n + depends on DPKG || DPKG_DEB + help + This allows dpkg and dpkg-deb to extract deb's that are compressed + internally with lzma instead of gzip. + + You only want this if you are creating your own custom debian + packages that use an internal control.tar.lzma or data.tar.lzma. + +endmenu diff --git a/i/pc104/initrd/conf/busybox/archival/Kbuild b/i/pc104/initrd/conf/busybox/archival/Kbuild new file mode 100644 index 0000000..07b442f --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/Kbuild @@ -0,0 +1,22 @@ +# Makefile for busybox +# +# Copyright (C) 1999-2005 by Erik Andersen +# +# Licensed under the GPL v2, see the file LICENSE in this tarball. + +libs-y += libunarchive/ + +lib-y:= +lib-$(CONFIG_AR) += ar.o +lib-$(CONFIG_BUNZIP2) += bbunzip.o +lib-$(CONFIG_UNLZMA) += bbunzip.o +lib-$(CONFIG_CPIO) += cpio.o +lib-$(CONFIG_DPKG) += dpkg.o +lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o +lib-$(CONFIG_GUNZIP) += bbunzip.o +lib-$(CONFIG_GZIP) += gzip.o bbunzip.o +lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o +lib-$(CONFIG_RPM) += rpm.o +lib-$(CONFIG_TAR) += tar.o +lib-$(CONFIG_UNCOMPRESS) += bbunzip.o +lib-$(CONFIG_UNZIP) += unzip.o diff --git a/i/pc104/initrd/conf/busybox/archival/ar.c b/i/pc104/initrd/conf/busybox/archival/ar.c new file mode 100644 index 0000000..23d9b49 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/ar.c @@ -0,0 +1,94 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini ar implementation for busybox + * + * Copyright (C) 2000 by Glenn McGrath + * Written by Glenn McGrath 1 June 2000 + * + * Based in part on BusyBox tar, Debian dpkg-deb and GNU ar. + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * + * There is no single standard to adhere to so ar may not portable + * between different systems + * http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html + */ + +#include "busybox.h" +#include "unarchive.h" + +static void header_verbose_list_ar(const file_header_t *file_header) +{ + const char *mode = bb_mode_string(file_header->mode); + char *mtime; + + mtime = ctime(&file_header->mtime); + mtime[16] = ' '; + memmove(&mtime[17], &mtime[20], 4); + mtime[21] = '\0'; + printf("%s %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid, + (int) file_header->size, &mtime[4], file_header->name); +} + +#define AR_CTX_PRINT 0x01 +#define AR_CTX_LIST 0x02 +#define AR_CTX_EXTRACT 0x04 +#define AR_OPT_PRESERVE_DATE 0x08 +#define AR_OPT_VERBOSE 0x10 +#define AR_OPT_CREATE 0x20 +#define AR_OPT_INSERT 0x40 + +int ar_main(int argc, char **argv); +int ar_main(int argc, char **argv) +{ + archive_handle_t *archive_handle; + unsigned opt; + static const char msg_unsupported_err[] = + "Archive %s not supported. Install binutils 'ar'."; + char magic[8]; + + archive_handle = init_handle(); + + /* Prepend '-' to the first argument if required */ + opt_complementary = "--:p:t:x:-1:?:p--tx:t--px:x--pt"; + opt = getopt32(argc, argv, "ptxovcr"); + + if (opt & AR_CTX_PRINT) { + archive_handle->action_data = data_extract_to_stdout; + } + if (opt & AR_CTX_LIST) { + archive_handle->action_header = header_list; + } + if (opt & AR_CTX_EXTRACT) { + archive_handle->action_data = data_extract_all; + } + if (opt & AR_OPT_PRESERVE_DATE) { + archive_handle->flags |= ARCHIVE_PRESERVE_DATE; + } + if (opt & AR_OPT_VERBOSE) { + archive_handle->action_header = header_verbose_list_ar; + } + if (opt & AR_OPT_CREATE) { + bb_error_msg_and_die(msg_unsupported_err, "creation"); + } + if (opt & AR_OPT_INSERT) { + bb_error_msg_and_die(msg_unsupported_err, "insertion"); + } + + archive_handle->src_fd = xopen(argv[optind++], O_RDONLY); + + while (optind < argc) { + archive_handle->filter = filter_accept_list; + llist_add_to(&(archive_handle->accept), argv[optind++]); + } + + xread(archive_handle->src_fd, magic, 7); + if (strncmp(magic, "!", 7) != 0) { + bb_error_msg_and_die("invalid ar magic"); + } + archive_handle->offset += 7; + + while (get_header_ar(archive_handle) == EXIT_SUCCESS) /* repeat */; + + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/archival/bbunzip.c b/i/pc104/initrd/conf/busybox/archival/bbunzip.c new file mode 100644 index 0000000..e16e6b0 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/bbunzip.c @@ -0,0 +1,355 @@ +/* vi: set sw=4 ts=4: */ +/* + * Common code for gunzip-like applets + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "busybox.h" +#include "unarchive.h" + +enum { + OPT_STDOUT = 0x1, + OPT_FORCE = 0x2, +/* gunzip only: */ + OPT_VERBOSE = 0x4, + OPT_DECOMPRESS = 0x8, + OPT_TEST = 0x10, +}; + +static +int open_to_or_warn(int to_fd, const char *filename, int flags, int mode) +{ + int fd = open(filename, flags, mode); + if (fd < 0) { + bb_perror_msg("%s", filename); + return 1; + } + if (fd != to_fd) { + if (dup2(fd, to_fd) < 0) + bb_perror_msg_and_die("cannot dup"); + close(fd); + } + return 0; +} + +int bbunpack(char **argv, + char* (*make_new_name)(char *filename), + USE_DESKTOP(long long) int (*unpacker)(void) +) +{ + struct stat stat_buf; + USE_DESKTOP(long long) int status; + char *filename, *new_name; + smallint exitcode = 0; + + do { + /* NB: new_name is *maybe* malloc'ed! */ + new_name = NULL; + filename = *argv; /* can be NULL - 'streaming' bunzip2 */ + + if (filename && LONE_DASH(filename)) + filename = NULL; + + /* Open src */ + if (filename) { + if (stat(filename, &stat_buf) != 0) { + bb_perror_msg("%s", filename); + err: + exitcode = 1; + goto free_name; + } + if (open_to_or_warn(STDIN_FILENO, filename, O_RDONLY, 0)) + goto err; + } + + /* Special cases: test, stdout */ + if (option_mask32 & (OPT_STDOUT|OPT_TEST)) { + if (option_mask32 & OPT_TEST) + if (open_to_or_warn(STDOUT_FILENO, bb_dev_null, O_WRONLY, 0)) + goto err; + filename = NULL; + } + + /* Open dst if we are going to unpack to file */ + if (filename) { + new_name = make_new_name(filename); + if (!new_name) { + bb_error_msg("%s: unknown suffix - ignored", filename); + goto err; + } + /* O_EXCL: "real" bunzip2 doesn't overwrite files */ + /* GNU gunzip goes not bail out, but goes to next file */ + if (open_to_or_warn(STDOUT_FILENO, new_name, O_WRONLY | O_CREAT | O_EXCL, + stat_buf.st_mode)) + goto err; + } + + /* Check that the input is sane */ + if (isatty(STDIN_FILENO) && (option_mask32 & OPT_FORCE) == 0) { + bb_error_msg_and_die("compressed data not read from terminal, " + "use -f to force it"); + } + + status = unpacker(); + if (status < 0) + exitcode = 1; + + if (filename) { + char *del = new_name; + if (status >= 0) { + /* TODO: restore user/group/times here? */ + /* Delete _compressed_ file */ + del = filename; + /* restore extension (unless tgz -> tar case) */ + if (new_name == filename) + filename[strlen(filename)] = '.'; + } + if (unlink(del) < 0) + bb_perror_msg_and_die("cannot remove %s", del); + +#if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */ + /* Extreme bloat for gunzip compat */ + if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE) && status >= 0) { + fprintf(stderr, "%s: %u%% - replaced with %s\n", + filename, (unsigned)(stat_buf.st_size*100 / (status+1)), new_name); + } +#endif + + free_name: + if (new_name != filename) + free(new_name); + } + } while (*argv && *++argv); + + return exitcode; +} + +#if ENABLE_BUNZIP2 || ENABLE_UNLZMA || ENABLE_UNCOMPRESS + +static +char* make_new_name_generic(char *filename, const char *expected_ext) +{ + char *extension = strrchr(filename, '.'); + if (!extension || strcmp(extension + 1, expected_ext) != 0) { + /* Mimic GNU gunzip - "real" bunzip2 tries to */ + /* unpack file anyway, to file.out */ + return NULL; + } + *extension = '\0'; + return filename; +} + +#endif + + +/* + * Modified for busybox by Glenn McGrath + * Added support output to stdout by Thomas Lundquist + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#if ENABLE_BUNZIP2 + +static +char* make_new_name_bunzip2(char *filename) +{ + return make_new_name_generic(filename, "bz2"); +} + +static +USE_DESKTOP(long long) int unpack_bunzip2(void) +{ + return uncompressStream(STDIN_FILENO, STDOUT_FILENO); +} + +int bunzip2_main(int argc, char **argv); +int bunzip2_main(int argc, char **argv) +{ + getopt32(argc, argv, "cf"); + argv += optind; + if (applet_name[2] == 'c') + option_mask32 |= OPT_STDOUT; + + return bbunpack(argv, make_new_name_bunzip2, unpack_bunzip2); +} + +#endif + + +/* + * Gzip implementation for busybox + * + * Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly. + * + * Originally adjusted for busybox by Sven Rudolph + * based on gzip sources + * + * Adjusted further by Erik Andersen to support files as + * well as stdin/stdout, and to generally behave itself wrt command line + * handling. + * + * General cleanup to better adhere to the style guide and make use of standard + * busybox functions by Glenn McGrath + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * + * gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface + * Copyright (C) 1992-1993 Jean-loup Gailly + * The unzip code was written and put in the public domain by Mark Adler. + * Portions of the lzw code are derived from the public domain 'compress' + * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, + * Ken Turkowski, Dave Mack and Peter Jannesen. + * + * See the license_msg below and the file COPYING for the software license. + * See the file algorithm.doc for the compression algorithms and file formats. + */ + +#if ENABLE_GUNZIP + +static +char* make_new_name_gunzip(char *filename) +{ + char *extension = strrchr(filename, '.'); + + if (!extension) + return NULL; + + extension++; + if (strcmp(extension, "tgz" + 1) == 0 +#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS + || strcmp(extension, "Z") == 0 +#endif + ) { + extension[-1] = '\0'; + } else if(strcmp(extension, "tgz") == 0) { + filename = xstrdup(filename); + extension = strrchr(filename, '.'); + extension[2] = 'a'; + extension[3] = 'r'; + } else { + return NULL; + } + return filename; +} + +static +USE_DESKTOP(long long) int unpack_gunzip(void) +{ + USE_DESKTOP(long long) int status = -1; + + /* do the decompression, and cleanup */ + if (xread_char(STDIN_FILENO) == 0x1f) { + unsigned char magic2; + + magic2 = xread_char(STDIN_FILENO); + if (ENABLE_FEATURE_GUNZIP_UNCOMPRESS && magic2 == 0x9d) { + status = uncompress(STDIN_FILENO, STDOUT_FILENO); + } else if (magic2 == 0x8b) { + check_header_gzip_or_die(STDIN_FILENO); + status = inflate_gunzip(STDIN_FILENO, STDOUT_FILENO); + } else { + goto bad_magic; + } + if (status < 0) { + bb_error_msg("error inflating"); + } + } else { + bad_magic: + bb_error_msg("invalid magic"); + /* status is still == -1 */ + } + return status; +} + +int gunzip_main(int argc, char **argv); +int gunzip_main(int argc, char **argv) +{ + getopt32(argc, argv, "cfvdt"); + argv += optind; + /* if called as zcat */ + if (applet_name[1] == 'c') + option_mask32 |= OPT_STDOUT; + + return bbunpack(argv, make_new_name_gunzip, unpack_gunzip); +} + +#endif + + +/* + * Small lzma deflate implementation. + * Copyright (C) 2006 Aurelien Jacobs + * + * Based on bunzip.c from busybox + * + * Licensed under GPL v2, see file LICENSE in this tarball for details. + */ + +#if ENABLE_UNLZMA + +static +char* make_new_name_unlzma(char *filename) +{ + return make_new_name_generic(filename, "lzma"); +} + +static +USE_DESKTOP(long long) int unpack_unlzma(void) +{ + return unlzma(STDIN_FILENO, STDOUT_FILENO); +} + +int unlzma_main(int argc, char **argv); +int unlzma_main(int argc, char **argv) +{ + getopt32(argc, argv, "c"); + argv += optind; + /* lzmacat? */ + if (applet_name[4] == 'c') + option_mask32 |= OPT_STDOUT; + + return bbunpack(argv, make_new_name_unlzma, unpack_unlzma); +} + +#endif + + +/* + * Uncompress applet for busybox (c) 2002 Glenn McGrath + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#if ENABLE_UNCOMPRESS + +static +char* make_new_name_uncompress(char *filename) +{ + return make_new_name_generic(filename, "Z"); +} + +static +USE_DESKTOP(long long) int unpack_uncompress(void) +{ + USE_DESKTOP(long long) int status = -1; + + if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) { + bb_error_msg("invalid magic"); + } else { + status = uncompress(STDIN_FILENO, STDOUT_FILENO); + } + return status; +} + +int uncompress_main(int argc, char **argv); +int uncompress_main(int argc, char **argv) +{ + getopt32(argc, argv, "cf"); + argv += optind; + + return bbunpack(argv, make_new_name_uncompress, unpack_uncompress); +} + +#endif diff --git a/i/pc104/initrd/conf/busybox/archival/cpio.c b/i/pc104/initrd/conf/busybox/archival/cpio.c new file mode 100644 index 0000000..0113867 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/cpio.c @@ -0,0 +1,87 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini cpio implementation for busybox + * + * Copyright (C) 2001 by Glenn McGrath + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * + * Limitations: + * Doesn't check CRC's + * Only supports new ASCII and CRC formats + * + */ +#include +#include +#include +#include +#include "unarchive.h" +#include "busybox.h" + +#define CPIO_OPT_EXTRACT 0x01 +#define CPIO_OPT_TEST 0x02 +#define CPIO_OPT_UNCONDITIONAL 0x04 +#define CPIO_OPT_VERBOSE 0x08 +#define CPIO_OPT_FILE 0x10 +#define CPIO_OPT_CREATE_LEADING_DIR 0x20 +#define CPIO_OPT_PRESERVE_MTIME 0x40 + +int cpio_main(int argc, char **argv); +int cpio_main(int argc, char **argv) +{ + archive_handle_t *archive_handle; + char *cpio_filename = NULL; + unsigned opt; + + /* Initialise */ + archive_handle = init_handle(); + archive_handle->src_fd = STDIN_FILENO; + archive_handle->seek = seek_by_read; + archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE; + + opt = getopt32(argc, argv, "ituvF:dm", &cpio_filename); + + /* One of either extract or test options must be given */ + if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) { + bb_show_usage(); + } + + if (opt & CPIO_OPT_TEST) { + /* if both extract and test options are given, ignore extract option */ + if (opt & CPIO_OPT_EXTRACT) { + opt &= ~CPIO_OPT_EXTRACT; + } + archive_handle->action_header = header_list; + } + if (opt & CPIO_OPT_EXTRACT) { + archive_handle->action_data = data_extract_all; + } + if (opt & CPIO_OPT_UNCONDITIONAL) { + archive_handle->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL; + archive_handle->flags &= ~ARCHIVE_EXTRACT_NEWER; + } + if (opt & CPIO_OPT_VERBOSE) { + if (archive_handle->action_header == header_list) { + archive_handle->action_header = header_verbose_list; + } else { + archive_handle->action_header = header_list; + } + } + if (cpio_filename) { /* CPIO_OPT_FILE */ + archive_handle->src_fd = xopen(cpio_filename, O_RDONLY); + archive_handle->seek = seek_by_jump; + } + if (opt & CPIO_OPT_CREATE_LEADING_DIR) { + archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS; + } + + while (optind < argc) { + archive_handle->filter = filter_accept_list; + llist_add_to(&(archive_handle->accept), argv[optind]); + optind++; + } + + while (get_header_cpio(archive_handle) == EXIT_SUCCESS); + + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/archival/dpkg.c b/i/pc104/initrd/conf/busybox/archival/dpkg.c new file mode 100644 index 0000000..0a42deb --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/dpkg.c @@ -0,0 +1,1754 @@ +/* vi: set sw=4 ts=4: */ +/* + * mini dpkg implementation for busybox. + * this is not meant as a replacement for dpkg + * + * written by glenn mcgrath with the help of others + * copyright (c) 2001 by glenn mcgrath + * + * started life as a busybox implementation of udpkg + * + * licensed under gplv2 or later, see file license in this tarball for details. + */ + +/* + * known difference between busybox dpkg and the official dpkg that i don't + * consider important, its worth keeping a note of differences anyway, just to + * make it easier to maintain. + * - the first value for the confflile: field isnt placed on a new line. + * - when installing a package the status: field is placed at the end of the + * section, rather than just after the package: field. + * + * bugs that need to be fixed + * - (unknown, please let me know when you find any) + * + */ + +#include "busybox.h" +#include "unarchive.h" + +/* note: if you vary hash_prime sizes be aware, + * 1) tweaking these will have a big effect on how much memory this program uses. + * 2) for computational efficiency these hash tables should be at least 20% + * larger than the maximum number of elements stored in it. + * 3) all _hash_prime's must be a prime number or chaos is assured, if your looking + * for a prime, try http://www.utm.edu/research/primes/lists/small/10000.txt + * 4) if you go bigger than 15 bits you may get into trouble (untested) as its + * sometimes cast to an unsigned, if you go to 16 bit you will overlap + * int's and chaos is assured, 16381 is the max prime for 14 bit field + */ + +/* NAME_HASH_PRIME, Stores package names and versions, + * I estimate it should be at least 50% bigger than PACKAGE_HASH_PRIME, + * as there a lot of duplicate version numbers */ +#define NAME_HASH_PRIME 16381 + +/* PACKAGE_HASH_PRIME, Maximum number of unique packages, + * It must not be smaller than STATUS_HASH_PRIME, + * Currently only packages from status_hashtable are stored in here, but in + * future this may be used to store packages not only from a status file, + * but an available_hashtable, and even multiple packages files. + * Package can be stored more than once if they have different versions. + * e.g. The same package may have different versions in the status file + * and available file */ +#define PACKAGE_HASH_PRIME 10007 +typedef struct edge_s { + unsigned operator:3; + unsigned type:4; + unsigned name:14; + unsigned version:14; +} edge_t; + +typedef struct common_node_s { + unsigned name:14; + unsigned version:14; + unsigned num_of_edges:14; + edge_t **edge; +} common_node_t; + +/* Currently it doesnt store packages that have state-status of not-installed + * So it only really has to be the size of the maximum number of packages + * likely to be installed at any one time, so there is a bit of leeway here */ +#define STATUS_HASH_PRIME 8191 +typedef struct status_node_s { + unsigned package:14; /* has to fit PACKAGE_HASH_PRIME */ + unsigned status:14; /* has to fit STATUS_HASH_PRIME */ +} status_node_t; + +/* Were statically declared here, but such a big bss is nommu-unfriendly */ +static char **name_hashtable; /* [NAME_HASH_PRIME + 1] */ +static common_node_t **package_hashtable; /* [PACKAGE_HASH_PRIME + 1] */ +static status_node_t **status_hashtable; /* [STATUS_HASH_PRIME + 1] */ + +/* Even numbers are for 'extras', like ored dependencies or null */ +enum edge_type_e { + EDGE_NULL = 0, + EDGE_PRE_DEPENDS = 1, + EDGE_OR_PRE_DEPENDS = 2, + EDGE_DEPENDS = 3, + EDGE_OR_DEPENDS = 4, + EDGE_REPLACES = 5, + EDGE_PROVIDES = 7, + EDGE_CONFLICTS = 9, + EDGE_SUGGESTS = 11, + EDGE_RECOMMENDS = 13, + EDGE_ENHANCES = 15 +}; +enum operator_e { + VER_NULL = 0, + VER_EQUAL = 1, + VER_LESS = 2, + VER_LESS_EQUAL = 3, + VER_MORE = 4, + VER_MORE_EQUAL = 5, + VER_ANY = 6 +}; + +typedef struct deb_file_s { + char *control_file; + char *filename; + unsigned package:14; +} deb_file_t; + + +static void make_hash(const char *key, unsigned *start, unsigned *decrement, const int hash_prime) +{ + unsigned long int hash_num = key[0]; + int len = strlen(key); + int i; + + /* Maybe i should have uses a "proper" hashing algorithm here instead + * of making one up myself, seems to be working ok though. */ + for (i = 1; i < len; i++) { + /* shifts the ascii based value and adds it to previous value + * shift amount is mod 24 because long int is 32 bit and data + * to be shifted is 8, don't want to shift data to where it has + * no effect*/ + hash_num += ((key[i] + key[i-1]) << ((key[i] * i) % 24)); + } + *start = (unsigned) hash_num % hash_prime; + *decrement = (unsigned) 1 + (hash_num % (hash_prime - 1)); +} + +/* this adds the key to the hash table */ +static int search_name_hashtable(const char *key) +{ + unsigned probe_address = 0; + unsigned probe_decrement = 0; + + make_hash(key, &probe_address, &probe_decrement, NAME_HASH_PRIME); + while (name_hashtable[probe_address] != NULL) { + if (strcmp(name_hashtable[probe_address], key) == 0) { + return probe_address; + } + probe_address -= probe_decrement; + if ((int)probe_address < 0) { + probe_address += NAME_HASH_PRIME; + } + } + name_hashtable[probe_address] = xstrdup(key); + return probe_address; +} + +/* this DOESNT add the key to the hashtable + * TODO make it consistent with search_name_hashtable + */ +static unsigned search_status_hashtable(const char *key) +{ + unsigned probe_address = 0; + unsigned probe_decrement = 0; + + make_hash(key, &probe_address, &probe_decrement, STATUS_HASH_PRIME); + while (status_hashtable[probe_address] != NULL) { + if (strcmp(key, name_hashtable[package_hashtable[status_hashtable[probe_address]->package]->name]) == 0) { + break; + } + probe_address -= probe_decrement; + if ((int)probe_address < 0) { + probe_address += STATUS_HASH_PRIME; + } + } + return probe_address; +} + +/* Need to rethink version comparison, maybe the official dpkg has something i can use ? */ +static int version_compare_part(const char *version1, const char *version2) +{ + int upstream_len1 = 0; + int upstream_len2 = 0; + char *name1_char; + char *name2_char; + int len1 = 0; + int len2 = 0; + int tmp_int; + int ver_num1; + int ver_num2; + + if (version1 == NULL) { + version1 = xstrdup(""); + } + if (version2 == NULL) { + version2 = xstrdup(""); + } + upstream_len1 = strlen(version1); + upstream_len2 = strlen(version2); + + while ((len1 < upstream_len1) || (len2 < upstream_len2)) { + /* Compare non-digit section */ + tmp_int = strcspn(&version1[len1], "0123456789"); + name1_char = xstrndup(&version1[len1], tmp_int); + len1 += tmp_int; + tmp_int = strcspn(&version2[len2], "0123456789"); + name2_char = xstrndup(&version2[len2], tmp_int); + len2 += tmp_int; + tmp_int = strcmp(name1_char, name2_char); + free(name1_char); + free(name2_char); + if (tmp_int != 0) { + return tmp_int; + } + + /* Compare digits */ + tmp_int = strspn(&version1[len1], "0123456789"); + name1_char = xstrndup(&version1[len1], tmp_int); + len1 += tmp_int; + tmp_int = strspn(&version2[len2], "0123456789"); + name2_char = xstrndup(&version2[len2], tmp_int); + len2 += tmp_int; + ver_num1 = atoi(name1_char); + ver_num2 = atoi(name2_char); + free(name1_char); + free(name2_char); + if (ver_num1 < ver_num2) { + return -1; + } + if (ver_num1 > ver_num2) { + return 1; + } + } + return 0; +} + +/* if ver1 < ver2 return -1, + * if ver1 = ver2 return 0, + * if ver1 > ver2 return 1, + */ +static int version_compare(const unsigned ver1, const unsigned ver2) +{ + char *ch_ver1 = name_hashtable[ver1]; + char *ch_ver2 = name_hashtable[ver2]; + + char epoch1, epoch2; + char *deb_ver1, *deb_ver2; + char *ver1_ptr, *ver2_ptr; + char *upstream_ver1; + char *upstream_ver2; + int result; + + /* Compare epoch */ + if (ch_ver1[1] == ':') { + epoch1 = ch_ver1[0]; + ver1_ptr = strchr(ch_ver1, ':') + 1; + } else { + epoch1 = '0'; + ver1_ptr = ch_ver1; + } + if (ch_ver2[1] == ':') { + epoch2 = ch_ver2[0]; + ver2_ptr = strchr(ch_ver2, ':') + 1; + } else { + epoch2 = '0'; + ver2_ptr = ch_ver2; + } + if (epoch1 < epoch2) { + return -1; + } + else if (epoch1 > epoch2) { + return 1; + } + + /* Compare upstream version */ + upstream_ver1 = xstrdup(ver1_ptr); + upstream_ver2 = xstrdup(ver2_ptr); + + /* Chop off debian version, and store for later use */ + deb_ver1 = strrchr(upstream_ver1, '-'); + deb_ver2 = strrchr(upstream_ver2, '-'); + if (deb_ver1) { + deb_ver1[0] = '\0'; + deb_ver1++; + } + if (deb_ver2) { + deb_ver2[0] = '\0'; + deb_ver2++; + } + result = version_compare_part(upstream_ver1, upstream_ver2); + if (!result) + /* Compare debian versions */ + result = version_compare_part(deb_ver1, deb_ver2); + + free(upstream_ver1); + free(upstream_ver2); + return result; +} + +static int test_version(const unsigned version1, const unsigned version2, const unsigned operator) +{ + const int version_result = version_compare(version1, version2); + switch (operator) { + case VER_ANY: + return TRUE; + case VER_EQUAL: + return (version_result == 0); + case VER_LESS: + return (version_result < 0); + case VER_LESS_EQUAL: + return (version_result <= 0); + case VER_MORE: + return (version_result > 0); + case VER_MORE_EQUAL: + return (version_result >= 0); + } + return FALSE; +} + + +static int search_package_hashtable(const unsigned name, const unsigned version, const unsigned operator) +{ + unsigned probe_address = 0; + unsigned probe_decrement = 0; + + make_hash(name_hashtable[name], &probe_address, &probe_decrement, PACKAGE_HASH_PRIME); + while (package_hashtable[probe_address] != NULL) { + if (package_hashtable[probe_address]->name == name) { + if (operator == VER_ANY) { + return probe_address; + } + if (test_version(package_hashtable[probe_address]->version, version, operator)) { + return probe_address; + } + } + probe_address -= probe_decrement; + if ((int)probe_address < 0) { + probe_address += PACKAGE_HASH_PRIME; + } + } + return probe_address; +} + +/* + * This function searches through the entire package_hashtable looking + * for a package which provides "needle". It returns the index into + * the package_hashtable for the providing package. + * + * needle is the index into name_hashtable of the package we are + * looking for. + * + * start_at is the index in the package_hashtable to start looking + * at. If start_at is -1 then start at the beginning. This is to allow + * for repeated searches since more than one package might provide + * needle. + * + * FIXME: I don't think this is very efficient, but I thought I'd keep + * it simple for now until it proves to be a problem. + */ +static int search_for_provides(int needle, int start_at) { + int i, j; + common_node_t *p; + for (i = start_at + 1; i < PACKAGE_HASH_PRIME; i++) { + p = package_hashtable[i]; + if (p == NULL) + continue; + for (j = 0; j < p->num_of_edges; j++) + if (p->edge[j]->type == EDGE_PROVIDES && p->edge[j]->name == needle) + return i; + } + return -1; +} + +/* + * Add an edge to a node + */ +static void add_edge_to_node(common_node_t *node, edge_t *edge) +{ + node->num_of_edges++; + node->edge = xrealloc(node->edge, sizeof(edge_t) * (node->num_of_edges + 1)); + node->edge[node->num_of_edges - 1] = edge; +} + +/* + * Create one new node and one new edge for every dependency. + * + * Dependencies which contain multiple alternatives are represented as + * an EDGE_OR_PRE_DEPENDS or EDGE_OR_DEPENDS node, followed by a + * number of EDGE_PRE_DEPENDS or EDGE_DEPENDS nodes. The name field of + * the OR edge contains the full dependency string while the version + * field contains the number of EDGE nodes which follow as part of + * this alternative. + */ +static void add_split_dependencies(common_node_t *parent_node, const char *whole_line, unsigned edge_type) +{ + char *line = xstrdup(whole_line); + char *line2; + char *line_ptr1 = NULL; + char *line_ptr2 = NULL; + char *field; + char *field2; + char *version; + edge_t *edge; + edge_t *or_edge; + int offset_ch; + + field = strtok_r(line, ",", &line_ptr1); + do { + /* skip leading spaces */ + field += strspn(field, " "); + line2 = xstrdup(field); + field2 = strtok_r(line2, "|", &line_ptr2); + or_edge = NULL; + if ((edge_type == EDGE_DEPENDS || edge_type == EDGE_PRE_DEPENDS) + && (strcmp(field, field2) != 0) + ) { + or_edge = xmalloc(sizeof(edge_t)); + or_edge->type = edge_type + 1; + or_edge->name = search_name_hashtable(field); + or_edge->version = 0; // tracks the number of altenatives + add_edge_to_node(parent_node, or_edge); + } + + do { + edge = xmalloc(sizeof(edge_t)); + edge->type = edge_type; + + /* Skip any extra leading spaces */ + field2 += strspn(field2, " "); + + /* Get dependency version info */ + version = strchr(field2, '('); + if (version == NULL) { + edge->operator = VER_ANY; + /* Get the versions hash number, adding it if the number isnt already in there */ + edge->version = search_name_hashtable("ANY"); + } else { + /* Skip leading ' ' or '(' */ + version += strspn(field2, " ("); + /* Calculate length of any operator characters */ + offset_ch = strspn(version, "<=>"); + /* Determine operator */ + if (offset_ch > 0) { + if (strncmp(version, "=", offset_ch) == 0) { + edge->operator = VER_EQUAL; + } + else if (strncmp(version, "<<", offset_ch) == 0) { + edge->operator = VER_LESS; + } + else if (strncmp(version, "<=", offset_ch) == 0) { + edge->operator = VER_LESS_EQUAL; + } + else if (strncmp(version, ">>", offset_ch) == 0) { + edge->operator = VER_MORE; + } + else if (strncmp(version, ">=", offset_ch) == 0) { + edge->operator = VER_MORE_EQUAL; + } else { + bb_error_msg_and_die("illegal operator"); + } + } + /* skip to start of version numbers */ + version += offset_ch; + version += strspn(version, " "); + + /* Truncate version at trailing ' ' or ')' */ + version[strcspn(version, " )")] = '\0'; + /* Get the versions hash number, adding it if the number isnt already in there */ + edge->version = search_name_hashtable(version); + } + + /* Get the dependency name */ + field2[strcspn(field2, " (")] = '\0'; + edge->name = search_name_hashtable(field2); + + if (or_edge) + or_edge->version++; + + add_edge_to_node(parent_node, edge); + } while ((field2 = strtok_r(NULL, "|", &line_ptr2)) != NULL); + free(line2); + } while ((field = strtok_r(NULL, ",", &line_ptr1)) != NULL); + free(line); +} + +static void free_package(common_node_t *node) +{ + unsigned i; + if (node) { + for (i = 0; i < node->num_of_edges; i++) { + free(node->edge[i]); + } + free(node->edge); + free(node); + } +} + +/* + * Gets the next package field from package_buffer, seperated into the field name + * and field value, it returns the int offset to the first character of the next field + */ +static int read_package_field(const char *package_buffer, char **field_name, char **field_value) +{ + int offset_name_start = 0; + int offset_name_end = 0; + int offset_value_start = 0; + int offset_value_end = 0; + int offset = 0; + int next_offset; + int name_length; + int value_length; + int exit_flag = FALSE; + + if (package_buffer == NULL) { + *field_name = NULL; + *field_value = NULL; + return -1; + } + while (1) { + next_offset = offset + 1; + switch (package_buffer[offset]) { + case '\0': + exit_flag = TRUE; + break; + case ':': + if (offset_name_end == 0) { + offset_name_end = offset; + offset_value_start = next_offset; + } + /* TODO: Name might still have trailing spaces if ':' isnt + * immediately after name */ + break; + case '\n': + /* TODO: The char next_offset may be out of bounds */ + if (package_buffer[next_offset] != ' ') { + exit_flag = TRUE; + break; + } + case '\t': + case ' ': + /* increment the value start point if its a just filler */ + if (offset_name_start == offset) { + offset_name_start++; + } + if (offset_value_start == offset) { + offset_value_start++; + } + break; + } + if (exit_flag) { + /* Check that the names are valid */ + offset_value_end = offset; + name_length = offset_name_end - offset_name_start; + value_length = offset_value_end - offset_value_start; + if (name_length == 0) { + break; + } + if ((name_length > 0) && (value_length > 0)) { + break; + } + + /* If not valid, start fresh with next field */ + exit_flag = FALSE; + offset_name_start = offset + 1; + offset_name_end = 0; + offset_value_start = offset + 1; + offset_value_end = offset + 1; + offset++; + } + offset++; + } + *field_name = NULL; + if (name_length) { + *field_name = xstrndup(&package_buffer[offset_name_start], name_length); + } + *field_value = NULL; + if (value_length > 0) { + *field_value = xstrndup(&package_buffer[offset_value_start], value_length); + } + return next_offset; +} + +static unsigned fill_package_struct(char *control_buffer) +{ + static const char *const field_names[] = { "Package", "Version", + "Pre-Depends", "Depends","Replaces", "Provides", + "Conflicts", "Suggests", "Recommends", "Enhances", 0 + }; + + common_node_t *new_node = xzalloc(sizeof(common_node_t)); + char *field_name; + char *field_value; + int field_start = 0; + int num = -1; + int buffer_length = strlen(control_buffer); + + new_node->version = search_name_hashtable("unknown"); + while (field_start < buffer_length) { + unsigned field_num; + + field_start += read_package_field(&control_buffer[field_start], + &field_name, &field_value); + + if (field_name == NULL) { + goto fill_package_struct_cleanup; /* Oh no, the dreaded goto statement ! */ + } + + field_num = index_in_str_array(field_names, field_name); + switch (field_num) { + case 0: /* Package */ + new_node->name = search_name_hashtable(field_value); + break; + case 1: /* Version */ + new_node->version = search_name_hashtable(field_value); + break; + case 2: /* Pre-Depends */ + add_split_dependencies(new_node, field_value, EDGE_PRE_DEPENDS); + break; + case 3: /* Depends */ + add_split_dependencies(new_node, field_value, EDGE_DEPENDS); + break; + case 4: /* Replaces */ + add_split_dependencies(new_node, field_value, EDGE_REPLACES); + break; + case 5: /* Provides */ + add_split_dependencies(new_node, field_value, EDGE_PROVIDES); + break; + case 6: /* Conflicts */ + add_split_dependencies(new_node, field_value, EDGE_CONFLICTS); + break; + case 7: /* Suggests */ + add_split_dependencies(new_node, field_value, EDGE_SUGGESTS); + break; + case 8: /* Recommends */ + add_split_dependencies(new_node, field_value, EDGE_RECOMMENDS); + break; + case 9: /* Enhances */ + add_split_dependencies(new_node, field_value, EDGE_ENHANCES); + break; + } + fill_package_struct_cleanup: + free(field_name); + free(field_value); + } + + if (new_node->version == search_name_hashtable("unknown")) { + free_package(new_node); + return -1; + } + num = search_package_hashtable(new_node->name, new_node->version, VER_EQUAL); + free_package(package_hashtable[num]); + package_hashtable[num] = new_node; + return num; +} + +/* if num = 1, it returns the want status, 2 returns flag, 3 returns status */ +static unsigned get_status(const unsigned status_node, const int num) +{ + char *status_string = name_hashtable[status_hashtable[status_node]->status]; + char *state_sub_string; + unsigned state_sub_num; + int len; + int i; + + /* set tmp_string to point to the start of the word number */ + for (i = 1; i < num; i++) { + /* skip past a word */ + status_string += strcspn(status_string, " "); + /* skip past the separating spaces */ + status_string += strspn(status_string, " "); + } + len = strcspn(status_string, " \n"); + state_sub_string = xstrndup(status_string, len); + state_sub_num = search_name_hashtable(state_sub_string); + free(state_sub_string); + return state_sub_num; +} + +static void set_status(const unsigned status_node_num, const char *new_value, const int position) +{ + const unsigned new_value_len = strlen(new_value); + const unsigned new_value_num = search_name_hashtable(new_value); + unsigned want = get_status(status_node_num, 1); + unsigned flag = get_status(status_node_num, 2); + unsigned status = get_status(status_node_num, 3); + int want_len = strlen(name_hashtable[want]); + int flag_len = strlen(name_hashtable[flag]); + int status_len = strlen(name_hashtable[status]); + char *new_status; + + switch (position) { + case 1: + want = new_value_num; + want_len = new_value_len; + break; + case 2: + flag = new_value_num; + flag_len = new_value_len; + break; + case 3: + status = new_value_num; + status_len = new_value_len; + break; + default: + bb_error_msg_and_die("DEBUG ONLY: this shouldnt happen"); + } + + new_status = xasprintf("%s %s %s", name_hashtable[want], name_hashtable[flag], name_hashtable[status]); + status_hashtable[status_node_num]->status = search_name_hashtable(new_status); + free(new_status); +} + +static const char *describe_status(int status_num) { + int status_want, status_state ; + if (status_hashtable[status_num] == NULL || status_hashtable[status_num]->status == 0) + return "is not installed or flagged to be installed\n"; + + status_want = get_status(status_num, 1); + status_state = get_status(status_num, 3); + + if (status_state == search_name_hashtable("installed")) { + if (status_want == search_name_hashtable("install")) + return "is installed"; + if (status_want == search_name_hashtable("deinstall")) + return "is marked to be removed"; + if (status_want == search_name_hashtable("purge")) + return "is marked to be purged"; + } + if (status_want == search_name_hashtable("unknown")) + return "is in an indeterminate state"; + if (status_want == search_name_hashtable("install")) + return "is marked to be installed"; + + return "is not installed or flagged to be installed"; +} + + +static void index_status_file(const char *filename) +{ + FILE *status_file; + char *control_buffer; + char *status_line; + status_node_t *status_node = NULL; + unsigned status_num; + + status_file = xfopen(filename, "r"); + while ((control_buffer = xmalloc_fgets_str(status_file, "\n\n")) != NULL) { + const unsigned package_num = fill_package_struct(control_buffer); + if (package_num != -1) { + status_node = xmalloc(sizeof(status_node_t)); + /* fill_package_struct doesnt handle the status field */ + status_line = strstr(control_buffer, "Status:"); + if (status_line != NULL) { + status_line += 7; + status_line += strspn(status_line, " \n\t"); + status_line = xstrndup(status_line, strcspn(status_line, "\n")); + status_node->status = search_name_hashtable(status_line); + free(status_line); + } + status_node->package = package_num; + status_num = search_status_hashtable(name_hashtable[package_hashtable[status_node->package]->name]); + status_hashtable[status_num] = status_node; + } + free(control_buffer); + } + fclose(status_file); +} + +static void write_buffer_no_status(FILE *new_status_file, const char *control_buffer) +{ + char *name; + char *value; + int start = 0; + while (1) { + start += read_package_field(&control_buffer[start], &name, &value); + if (name == NULL) { + break; + } + if (strcmp(name, "Status") != 0) { + fprintf(new_status_file, "%s: %s\n", name, value); + } + } +} + +/* This could do with a cleanup */ +static void write_status_file(deb_file_t **deb_file) +{ + FILE *old_status_file = xfopen("/var/lib/dpkg/status", "r"); + FILE *new_status_file = xfopen("/var/lib/dpkg/status.udeb", "w"); + char *package_name; + char *status_from_file; + char *control_buffer = NULL; + char *tmp_string; + int status_num; + int field_start = 0; + int write_flag; + int i = 0; + + /* Update previously known packages */ + while ((control_buffer = xmalloc_fgets_str(old_status_file, "\n\n")) != NULL) { + if ((tmp_string = strstr(control_buffer, "Package:")) == NULL) { + continue; + } + + tmp_string += 8; + tmp_string += strspn(tmp_string, " \n\t"); + package_name = xstrndup(tmp_string, strcspn(tmp_string, "\n")); + write_flag = FALSE; + tmp_string = strstr(control_buffer, "Status:"); + if (tmp_string != NULL) { + /* Seperate the status value from the control buffer */ + tmp_string += 7; + tmp_string += strspn(tmp_string, " \n\t"); + status_from_file = xstrndup(tmp_string, strcspn(tmp_string, "\n")); + } else { + status_from_file = NULL; + } + + /* Find this package in the status hashtable */ + status_num = search_status_hashtable(package_name); + if (status_hashtable[status_num] != NULL) { + const char *status_from_hashtable = name_hashtable[status_hashtable[status_num]->status]; + if (strcmp(status_from_file, status_from_hashtable) != 0) { + /* New status isnt exactly the same as old status */ + const int state_status = get_status(status_num, 3); + if ((strcmp("installed", name_hashtable[state_status]) == 0) || + (strcmp("unpacked", name_hashtable[state_status]) == 0)) { + /* We need to add the control file from the package */ + i = 0; + while (deb_file[i] != NULL) { + if (strcmp(package_name, name_hashtable[package_hashtable[deb_file[i]->package]->name]) == 0) { + /* Write a status file entry with a modified status */ + /* remove trailing \n's */ + write_buffer_no_status(new_status_file, deb_file[i]->control_file); + set_status(status_num, "ok", 2); + fprintf(new_status_file, "Status: %s\n\n", + name_hashtable[status_hashtable[status_num]->status]); + write_flag = TRUE; + break; + } + i++; + } + /* This is temperary, debugging only */ + if (deb_file[i] == NULL) { + bb_error_msg_and_die("ALERT: cannot find a control file, " + "your status file may be broken, status may be " + "incorrect for %s", package_name); + } + } + else if (strcmp("not-installed", name_hashtable[state_status]) == 0) { + /* Only write the Package, Status, Priority and Section lines */ + fprintf(new_status_file, "Package: %s\n", package_name); + fprintf(new_status_file, "Status: %s\n", status_from_hashtable); + + while (1) { + char *field_name; + char *field_value; + field_start += read_package_field(&control_buffer[field_start], &field_name, &field_value); + if (field_name == NULL) { + break; + } + if ((strcmp(field_name, "Priority") == 0) || + (strcmp(field_name, "Section") == 0)) { + fprintf(new_status_file, "%s: %s\n", field_name, field_value); + } + } + write_flag = TRUE; + fputs("\n", new_status_file); + } + else if (strcmp("config-files", name_hashtable[state_status]) == 0) { + /* only change the status line */ + while (1) { + char *field_name; + char *field_value; + field_start += read_package_field(&control_buffer[field_start], &field_name, &field_value); + if (field_name == NULL) { + break; + } + /* Setup start point for next field */ + if (strcmp(field_name, "Status") == 0) { + fprintf(new_status_file, "Status: %s\n", status_from_hashtable); + } else { + fprintf(new_status_file, "%s: %s\n", field_name, field_value); + } + } + write_flag = TRUE; + fputs("\n", new_status_file); + } + } + } + /* If the package from the status file wasnt handle above, do it now*/ + if (! write_flag) { + fprintf(new_status_file, "%s\n\n", control_buffer); + } + + free(status_from_file); + free(package_name); + free(control_buffer); + } + + /* Write any new packages */ + for (i = 0; deb_file[i] != NULL; i++) { + status_num = search_status_hashtable(name_hashtable[package_hashtable[deb_file[i]->package]->name]); + if (strcmp("reinstreq", name_hashtable[get_status(status_num, 2)]) == 0) { + write_buffer_no_status(new_status_file, deb_file[i]->control_file); + set_status(status_num, "ok", 2); + fprintf(new_status_file, "Status: %s\n\n", name_hashtable[status_hashtable[status_num]->status]); + } + } + fclose(old_status_file); + fclose(new_status_file); + + + /* Create a separate backfile to dpkg */ + if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) { + struct stat stat_buf; + xstat("/var/lib/dpkg/status", &stat_buf); + /* Its ok if renaming the status file fails because status + * file doesnt exist, maybe we are starting from scratch */ + bb_error_msg("no status file found, creating new one"); + } + + if (rename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status") == -1) { + bb_error_msg_and_die("DANGER: cannot create status file, " + "you need to manually repair your status file"); + } +} + +/* This function returns TRUE if the given package can satisfy a + * dependency of type depend_type. + * + * A pre-depends is satisfied only if a package is already installed, + * which a regular depends can be satisfied by a package which we want + * to install. + */ +static int package_satisfies_dependency(int package, int depend_type) +{ + int status_num = search_status_hashtable(name_hashtable[package_hashtable[package]->name]); + + /* status could be unknown if package is a pure virtual + * provides which cannot satisfy any dependency by itself. + */ + if (status_hashtable[status_num] == NULL) + return 0; + + switch (depend_type) { + case EDGE_PRE_DEPENDS: return get_status(status_num, 3) == search_name_hashtable("installed"); + case EDGE_DEPENDS: return get_status(status_num, 1) == search_name_hashtable("install"); + } + return 0; +} + +static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count) +{ + int *conflicts = NULL; + int conflicts_num = 0; + int i = deb_start; + int j; + + /* Check for conflicts + * TODO: TEST if conflicts with other packages to be installed + * + * Add install packages and the packages they provide + * to the list of files to check conflicts for + */ + + /* Create array of package numbers to check against + * installed package for conflicts*/ + while (deb_file[i] != NULL) { + const unsigned package_num = deb_file[i]->package; + conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1)); + conflicts[conflicts_num] = package_num; + conflicts_num++; + /* add provides to conflicts list */ + for (j = 0; j < package_hashtable[package_num]->num_of_edges; j++) { + if (package_hashtable[package_num]->edge[j]->type == EDGE_PROVIDES) { + const int conflicts_package_num = search_package_hashtable( + package_hashtable[package_num]->edge[j]->name, + package_hashtable[package_num]->edge[j]->version, + package_hashtable[package_num]->edge[j]->operator); + if (package_hashtable[conflicts_package_num] == NULL) { + /* create a new package */ + common_node_t *new_node = xzalloc(sizeof(common_node_t)); + new_node->name = package_hashtable[package_num]->edge[j]->name; + new_node->version = package_hashtable[package_num]->edge[j]->version; + package_hashtable[conflicts_package_num] = new_node; + } + conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1)); + conflicts[conflicts_num] = conflicts_package_num; + conflicts_num++; + } + } + i++; + } + + /* Check conflicts */ + i = 0; + while (deb_file[i] != NULL) { + const common_node_t *package_node = package_hashtable[deb_file[i]->package]; + int status_num = 0; + status_num = search_status_hashtable(name_hashtable[package_node->name]); + + if (get_status(status_num, 3) == search_name_hashtable("installed")) { + i++; + continue; + } + + for (j = 0; j < package_node->num_of_edges; j++) { + const edge_t *package_edge = package_node->edge[j]; + + if (package_edge->type == EDGE_CONFLICTS) { + const unsigned package_num = + search_package_hashtable(package_edge->name, + package_edge->version, + package_edge->operator); + int result = 0; + if (package_hashtable[package_num] != NULL) { + status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]); + + if (get_status(status_num, 1) == search_name_hashtable("install")) { + result = test_version(package_hashtable[deb_file[i]->package]->version, + package_edge->version, package_edge->operator); + } + } + + if (result) { + bb_error_msg_and_die("package %s conflicts with %s", + name_hashtable[package_node->name], + name_hashtable[package_edge->name]); + } + } + } + i++; + } + + + /* Check dependendcies */ + for (i = 0; i < PACKAGE_HASH_PRIME; i++) { + int status_num = 0; + int number_of_alternatives = 0; + const edge_t * root_of_alternatives = NULL; + const common_node_t *package_node = package_hashtable[i]; + + /* If the package node does not exist then this + * package is a virtual one. In which case there are + * no dependencies to check. + */ + if (package_node == NULL) continue; + + status_num = search_status_hashtable(name_hashtable[package_node->name]); + + /* If there is no status then this package is a + * virtual one provided by something else. In which + * case there are no dependencies to check. + */ + if (status_hashtable[status_num] == NULL) continue; + + /* If we don't want this package installed then we may + * as well ignore it's dependencies. + */ + if (get_status(status_num, 1) != search_name_hashtable("install")) { + continue; + } + + /* This code is tested only for EDGE_DEPENDS, since I + * have no suitable pre-depends available. There is no + * reason that it shouldn't work though :-) + */ + for (j = 0; j < package_node->num_of_edges; j++) { + const edge_t *package_edge = package_node->edge[j]; + unsigned package_num; + + if (package_edge->type == EDGE_OR_PRE_DEPENDS || + package_edge->type == EDGE_OR_DEPENDS) { /* start an EDGE_OR_ list */ + number_of_alternatives = package_edge->version; + root_of_alternatives = package_edge; + continue; + } else if (number_of_alternatives == 0) { /* not in the middle of an EDGE_OR_ list */ + number_of_alternatives = 1; + root_of_alternatives = NULL; + } + + package_num = search_package_hashtable(package_edge->name, package_edge->version, package_edge->operator); + + if (package_edge->type == EDGE_PRE_DEPENDS || + package_edge->type == EDGE_DEPENDS) { + int result=1; + status_num = 0; + + /* If we are inside an alternative then check + * this edge is the right type. + * + * EDGE_DEPENDS == OR_DEPENDS -1 + * EDGE_PRE_DEPENDS == OR_PRE_DEPENDS -1 + */ + if (root_of_alternatives && package_edge->type != root_of_alternatives->type - 1) + bb_error_msg_and_die("fatal error, package dependencies corrupt: %d != %d - 1", + package_edge->type, root_of_alternatives->type); + + if (package_hashtable[package_num] != NULL) + result = !package_satisfies_dependency(package_num, package_edge->type); + + if (result) { /* check for other package which provide what we are looking for */ + int provider = -1; + + while ((provider = search_for_provides(package_edge->name, provider)) > -1) { + if (package_hashtable[provider] == NULL) { + puts("Have a provider but no package information for it"); + continue; + } + result = !package_satisfies_dependency(provider, package_edge->type); + + if (result == 0) + break; + } + } + + /* It must be already installed, or to be installed */ + number_of_alternatives--; + if (result && number_of_alternatives == 0) { + if (root_of_alternatives) + bb_error_msg_and_die( + "package %s %sdepends on %s, " + "which cannot be satisfied", + name_hashtable[package_node->name], + package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "", + name_hashtable[root_of_alternatives->name]); + else + bb_error_msg_and_die( + "package %s %sdepends on %s, which %s\n", + name_hashtable[package_node->name], + package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "", + name_hashtable[package_edge->name], + describe_status(status_num)); + } else if (result == 0 && number_of_alternatives) { + /* we've found a package which + * satisfies the dependency, + * so skip over the rest of + * the alternatives. + */ + j += number_of_alternatives; + number_of_alternatives = 0; + } + } + } + } + free(conflicts); + return TRUE; +} + +static char **create_list(const char *filename) +{ + FILE *list_stream; + char **file_list = NULL; + char *line = NULL; + int count = 0; + + /* don't use [xw]fopen here, handle error ourself */ + list_stream = fopen(filename, "r"); + if (list_stream == NULL) { + return NULL; + } + + while ((line = xmalloc_getline(list_stream)) != NULL) { + file_list = xrealloc(file_list, sizeof(char *) * (count + 2)); + file_list[count] = line; + count++; + } + fclose(list_stream); + + if (count == 0) { + return NULL; + } else { + file_list[count] = NULL; + return file_list; + } +} + +/* maybe i should try and hook this into remove_file.c somehow */ +static int remove_file_array(char **remove_names, char **exclude_names) +{ + struct stat path_stat; + int match_flag; + int remove_flag = FALSE; + int i,j; + + if (remove_names == NULL) { + return FALSE; + } + for (i = 0; remove_names[i] != NULL; i++) { + match_flag = FALSE; + if (exclude_names != NULL) { + for (j = 0; exclude_names[j] != 0; j++) { + if (strcmp(remove_names[i], exclude_names[j]) == 0) { + match_flag = TRUE; + break; + } + } + } + if (!match_flag) { + if (lstat(remove_names[i], &path_stat) < 0) { + continue; + } + if (S_ISDIR(path_stat.st_mode)) { + if (rmdir(remove_names[i]) != -1) { + remove_flag = TRUE; + } + } else { + if (unlink(remove_names[i]) != -1) { + remove_flag = TRUE; + } + } + } + } + return remove_flag; +} + +static int run_package_script(const char *package_name, const char *script_type) +{ + struct stat path_stat; + char *script_path; + int result; + + script_path = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type); + + /* If the file doesnt exist is isnt a fatal */ + result = lstat(script_path, &path_stat) < 0 ? EXIT_SUCCESS : system(script_path); + free(script_path); + return result; +} + +static const char *all_control_files[] = {"preinst", "postinst", "prerm", "postrm", + "list", "md5sums", "shlibs", "conffiles", "config", "templates", NULL }; + +static char **all_control_list(const char *package_name) +{ + unsigned i = 0; + char **remove_files; + + /* Create a list of all /var/lib/dpkg/info/ files */ + remove_files = xzalloc(sizeof(all_control_files)); + while (all_control_files[i]) { + remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, all_control_files[i]); + i++; + } + + return remove_files; +} + +static void free_array(char **array) +{ + + if (array) { + unsigned i = 0; + while (array[i]) { + free(array[i]); + i++; + } + free(array); + } +} + +/* This function lists information on the installed packages. It loops through + * the status_hashtable to retrieve the info. This results in smaller code than + * scanning the status file. The resulting list, however, is unsorted. + */ +static void list_packages(void) +{ + int i; + + puts(" Name Version"); + puts("+++-==============-=============="); + + /* go through status hash, dereference package hash and finally strings */ + for (i=0; istatus]; + name_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->name]; + vers_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->version]; + + /* get abbreviation for status field 1 */ + s1 = stat_str[0] == 'i' ? 'i' : 'r'; + + /* get abbreviation for status field 2 */ + for (j=0, spccnt=0; stat_str[j] && spccnt<2; j++) { + if (stat_str[j] == ' ') spccnt++; + } + s2 = stat_str[j]; + + /* print out the line formatted like Debian dpkg */ + printf("%c%c %-14s %s\n", s1, s2, name_str, vers_str); + } + } +} + +static void remove_package(const unsigned package_num, int noisy) +{ + const char *package_name = name_hashtable[package_hashtable[package_num]->name]; + const char *package_version = name_hashtable[package_hashtable[package_num]->version]; + const unsigned status_num = search_status_hashtable(package_name); + const int package_name_length = strlen(package_name); + char **remove_files; + char **exclude_files; + char list_name[package_name_length + 25]; + char conffile_name[package_name_length + 30]; + int return_value; + + if (noisy) + printf("Removing %s (%s)...\n", package_name, package_version); + + /* run prerm script */ + return_value = run_package_script(package_name, "prerm"); + if (return_value == -1) { + bb_error_msg_and_die("script failed, prerm failure"); + } + + /* Create a list of files to remove, and a separate list of those to keep */ + sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name); + remove_files = create_list(list_name); + + sprintf(conffile_name, "/var/lib/dpkg/info/%s.conffiles", package_name); + exclude_files = create_list(conffile_name); + + /* Some directories can't be removed straight away, so do multiple passes */ + while (remove_file_array(remove_files, exclude_files)) /*repeat */; + free_array(exclude_files); + free_array(remove_files); + + /* Create a list of files in /var/lib/dpkg/info/.* to keep */ + exclude_files = xzalloc(sizeof(char*) * 3); + exclude_files[0] = xstrdup(conffile_name); + exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.postrm", package_name); + + /* Create a list of all /var/lib/dpkg/info/ files */ + remove_files = all_control_list(package_name); + + remove_file_array(remove_files, exclude_files); + free_array(remove_files); + free_array(exclude_files); + + /* rename .conffile to .list */ + rename(conffile_name, list_name); + + /* Change package status */ + set_status(status_num, "config-files", 3); +} + +static void purge_package(const unsigned package_num) +{ + const char *package_name = name_hashtable[package_hashtable[package_num]->name]; + const char *package_version = name_hashtable[package_hashtable[package_num]->version]; + const unsigned status_num = search_status_hashtable(package_name); + char **remove_files; + char **exclude_files; + char list_name[strlen(package_name) + 25]; + + printf("Purging %s (%s)...\n", package_name, package_version); + + /* run prerm script */ + if (run_package_script(package_name, "prerm") != 0) { + bb_error_msg_and_die("script failed, prerm failure"); + } + + /* Create a list of files to remove */ + sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name); + remove_files = create_list(list_name); + + exclude_files = xzalloc(sizeof(char*)); + + /* Some directories cant be removed straight away, so do multiple passes */ + while (remove_file_array(remove_files, exclude_files)) /* repeat */; + free_array(remove_files); + + /* Create a list of all /var/lib/dpkg/info/ files */ + remove_files = all_control_list(package_name); + remove_file_array(remove_files, exclude_files); + free_array(remove_files); + free(exclude_files); + + /* run postrm script */ + if (run_package_script(package_name, "postrm") == -1) { + bb_error_msg_and_die("postrm fialure.. set status to what?"); + } + + /* Change package status */ + set_status(status_num, "not-installed", 3); +} + +static archive_handle_t *init_archive_deb_ar(const char *filename) +{ + archive_handle_t *ar_handle; + + /* Setup an ar archive handle that refers to the gzip sub archive */ + ar_handle = init_handle(); + ar_handle->filter = filter_accept_list_reassign; + ar_handle->src_fd = xopen(filename, O_RDONLY); + + return ar_handle; +} + +static void init_archive_deb_control(archive_handle_t *ar_handle) +{ + archive_handle_t *tar_handle; + + /* Setup the tar archive handle */ + tar_handle = init_handle(); + tar_handle->src_fd = ar_handle->src_fd; + + /* We don't care about data.tar.* or debian-binary, just control.tar.* */ +#ifdef CONFIG_FEATURE_DEB_TAR_GZ + llist_add_to(&(ar_handle->accept), (char*)"control.tar.gz"); +#endif +#ifdef CONFIG_FEATURE_DEB_TAR_BZ2 + llist_add_to(&(ar_handle->accept), (char*)"control.tar.bz2"); +#endif + + /* Assign the tar handle as a subarchive of the ar handle */ + ar_handle->sub_archive = tar_handle; +} + +static void init_archive_deb_data(archive_handle_t *ar_handle) +{ + archive_handle_t *tar_handle; + + /* Setup the tar archive handle */ + tar_handle = init_handle(); + tar_handle->src_fd = ar_handle->src_fd; + + /* We don't care about control.tar.* or debian-binary, just data.tar.* */ +#ifdef CONFIG_FEATURE_DEB_TAR_GZ + llist_add_to(&(ar_handle->accept), (char*)"data.tar.gz"); +#endif +#ifdef CONFIG_FEATURE_DEB_TAR_BZ2 + llist_add_to(&(ar_handle->accept), (char*)"data.tar.bz2"); +#endif + + /* Assign the tar handle as a subarchive of the ar handle */ + ar_handle->sub_archive = tar_handle; +} + +static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, llist_t *myaccept) +{ + ar_handle->sub_archive->action_data = data_extract_to_buffer; + ar_handle->sub_archive->accept = myaccept; + ar_handle->sub_archive->filter = filter_accept_list; + + unpack_ar_archive(ar_handle); + close(ar_handle->src_fd); + + return ar_handle->sub_archive->buffer; +} + +static void data_extract_all_prefix(archive_handle_t *archive_handle) +{ + char *name_ptr = archive_handle->file_header->name; + + name_ptr += strspn(name_ptr, "./"); + if (name_ptr[0] != '\0') { + archive_handle->file_header->name = xasprintf("%s%s", archive_handle->buffer, name_ptr); + data_extract_all(archive_handle); + } +} + +static void unpack_package(deb_file_t *deb_file) +{ + const char *package_name = name_hashtable[package_hashtable[deb_file->package]->name]; + const unsigned status_num = search_status_hashtable(package_name); + const unsigned status_package_num = status_hashtable[status_num]->package; + char *info_prefix; + char *list_filename; + archive_handle_t *archive_handle; + FILE *out_stream; + llist_t *accept_list = NULL; + int i = 0; + + /* If existing version, remove it first */ + if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) { + /* Package is already installed, remove old version first */ + printf("Preparing to replace %s %s (using %s)...\n", package_name, + name_hashtable[package_hashtable[status_package_num]->version], + deb_file->filename); + remove_package(status_package_num, 0); + } else { + printf("Unpacking %s (from %s)...\n", package_name, deb_file->filename); + } + + /* Extract control.tar.gz to /var/lib/dpkg/info/.filename */ + info_prefix = xasprintf("/var/lib/dpkg/info/%s.", package_name); + archive_handle = init_archive_deb_ar(deb_file->filename); + init_archive_deb_control(archive_handle); + + while (all_control_files[i]) { + char *c = xasprintf("./%s", all_control_files[i]); + llist_add_to(&accept_list, c); + i++; + } + archive_handle->sub_archive->accept = accept_list; + archive_handle->sub_archive->filter = filter_accept_list; + archive_handle->sub_archive->action_data = data_extract_all_prefix; + archive_handle->sub_archive->buffer = info_prefix; + archive_handle->sub_archive->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL; + unpack_ar_archive(archive_handle); + + /* Run the preinst prior to extracting */ + if (run_package_script(package_name, "preinst") != 0) { + /* when preinst returns exit code != 0 then quit installation process */ + bb_error_msg_and_die("subprocess pre-installation script returned error"); + } + + /* Extract data.tar.gz to the root directory */ + archive_handle = init_archive_deb_ar(deb_file->filename); + init_archive_deb_data(archive_handle); + archive_handle->sub_archive->action_data = data_extract_all_prefix; + archive_handle->sub_archive->buffer = (char*)"/"; /* huh? */ + archive_handle->sub_archive->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL; + unpack_ar_archive(archive_handle); + + /* Create the list file */ + list_filename = xasprintf("/var/lib/dpkg/info/%s.list", package_name); + out_stream = xfopen(list_filename, "w"); + while (archive_handle->sub_archive->passed) { + /* the leading . has been stripped by data_extract_all_prefix already */ + fputs(archive_handle->sub_archive->passed->data, out_stream); + fputc('\n', out_stream); + archive_handle->sub_archive->passed = archive_handle->sub_archive->passed->link; + } + fclose(out_stream); + + /* change status */ + set_status(status_num, "install", 1); + set_status(status_num, "unpacked", 3); + + free(info_prefix); + free(list_filename); +} + +static void configure_package(deb_file_t *deb_file) +{ + const char *package_name = name_hashtable[package_hashtable[deb_file->package]->name]; + const char *package_version = name_hashtable[package_hashtable[deb_file->package]->version]; + const int status_num = search_status_hashtable(package_name); + + printf("Setting up %s (%s)...\n", package_name, package_version); + + /* Run the postinst script */ + if (run_package_script(package_name, "postinst") != 0) { + /* TODO: handle failure gracefully */ + bb_error_msg_and_die("postrm failure.. set status to what?"); + } + /* Change status to reflect success */ + set_status(status_num, "install", 1); + set_status(status_num, "installed", 3); +} + +int dpkg_main(int argc, char **argv); +int dpkg_main(int argc, char **argv) +{ + deb_file_t **deb_file = NULL; + status_node_t *status_node; + char *str_f; + int opt; + int package_num; + int deb_count = 0; + int state_status; + int status_num; + int i; + enum { + OPT_configure = 0x1, + OPT_force_ignore_depends = 0x2, + OPT_install = 0x4, + OPT_list_installed = 0x8, + OPT_purge = 0x10, + OPT_remove = 0x20, + OPT_unpack = 0x40, + }; + + opt = getopt32(argc, argv, "CF:ilPru", &str_f); + //if (opt & OPT_configure) ... // -C + if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg) + if (strcmp(str_f, "depends")) + opt &= ~OPT_force_ignore_depends; + } + //if (opt & OPT_install) ... // -i + //if (opt & OPT_list_installed) ... // -l + //if (opt & OPT_purge) ... // -P + //if (opt & OPT_remove) ... // -r + //if (opt & OPT_unpack) ... // -u (--unpack in official dpkg) + argc -= optind; + argv += optind; + /* check for non-option argument if expected */ + if (!opt || (!argc && !(opt && OPT_list_installed))) + bb_show_usage(); + + name_hashtable = xzalloc(sizeof(name_hashtable[0]) * (NAME_HASH_PRIME + 1)); + package_hashtable = xzalloc(sizeof(package_hashtable[0]) * (PACKAGE_HASH_PRIME + 1)); + status_hashtable = xzalloc(sizeof(status_hashtable[0]) * (STATUS_HASH_PRIME + 1)); + +/* puts("(Reading database ... xxxxx files and directories installed.)"); */ + index_status_file("/var/lib/dpkg/status"); + + /* if the list action was given print the installed packages and exit */ + if (opt & OPT_list_installed) { + list_packages(); + return EXIT_SUCCESS; + } + + /* Read arguments and store relevant info in structs */ + while (*argv) { + /* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */ + deb_file = xrealloc(deb_file, sizeof(deb_file[0]) * (deb_count + 2)); + deb_file[deb_count] = xzalloc(sizeof(deb_file[0][0])); + if (opt & (OPT_install | OPT_unpack)) { + /* -i/-u: require filename */ + archive_handle_t *archive_handle; + llist_t *control_list = NULL; + + /* Extract the control file */ + llist_add_to(&control_list, (char*)"./control"); + archive_handle = init_archive_deb_ar(argv[0]); + init_archive_deb_control(archive_handle); + deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list); + if (deb_file[deb_count]->control_file == NULL) { + bb_error_msg_and_die("cannot extract control file"); + } + deb_file[deb_count]->filename = xstrdup(argv[0]); + package_num = fill_package_struct(deb_file[deb_count]->control_file); + + if (package_num == -1) { + bb_error_msg("invalid control file in %s", argv[0]); + argv++; + continue; + } + deb_file[deb_count]->package = (unsigned) package_num; + + /* Add the package to the status hashtable */ + if (opt & (OPT_unpack | OPT_install)) { + /* Try and find a currently installed version of this package */ + status_num = search_status_hashtable(name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]); + /* If no previous entry was found initialise a new entry */ + if (status_hashtable[status_num] == NULL + || status_hashtable[status_num]->status == 0 + ) { + status_node = xmalloc(sizeof(status_node_t)); + status_node->package = deb_file[deb_count]->package; + /* reinstreq isnt changed to "ok" until the package control info + * is written to the status file*/ + status_node->status = search_name_hashtable("install reinstreq not-installed"); + status_hashtable[status_num] = status_node; + } else { + set_status(status_num, "install", 1); + set_status(status_num, "reinstreq", 2); + } + } + } else if (opt & (OPT_configure | OPT_purge | OPT_remove)) { + /* -C/-p/-r: require package name */ + deb_file[deb_count]->package = search_package_hashtable( + search_name_hashtable(argv[0]), + search_name_hashtable("ANY"), VER_ANY); + if (package_hashtable[deb_file[deb_count]->package] == NULL) { + bb_error_msg_and_die("package %s is uninstalled or unknown", argv[0]); + } + package_num = deb_file[deb_count]->package; + status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]); + state_status = get_status(status_num, 3); + + /* check package status is "installed" */ + if (opt & OPT_remove) { + if (strcmp(name_hashtable[state_status], "not-installed") == 0 + || strcmp(name_hashtable[state_status], "config-files") == 0 + ) { + bb_error_msg_and_die("%s is already removed", name_hashtable[package_hashtable[package_num]->name]); + } + set_status(status_num, "deinstall", 1); + } else if (opt & OPT_purge) { + /* if package status is "conf-files" then its ok */ + if (strcmp(name_hashtable[state_status], "not-installed") == 0) { + bb_error_msg_and_die("%s is already purged", name_hashtable[package_hashtable[package_num]->name]); + } + set_status(status_num, "purge", 1); + } + } + deb_count++; + argv++; + } + if (!deb_count) + bb_error_msg_and_die("no package files specified"); + deb_file[deb_count] = NULL; + + /* Check that the deb file arguments are installable */ + if (!(opt & OPT_force_ignore_depends)) { + if (!check_deps(deb_file, 0, deb_count)) { + bb_error_msg_and_die("dependency check failed"); + } + } + + /* TODO: install or remove packages in the correct dependency order */ + for (i = 0; i < deb_count; i++) { + /* Remove or purge packages */ + if (opt & OPT_remove) { + remove_package(deb_file[i]->package, 1); + } + else if (opt & OPT_purge) { + purge_package(deb_file[i]->package); + } + else if (opt & OPT_unpack) { + unpack_package(deb_file[i]); + } + else if (opt & OPT_install) { + unpack_package(deb_file[i]); + /* package is configured in second pass below */ + } + else if (opt & OPT_configure) { + configure_package(deb_file[i]); + } + } + /* configure installed packages */ + if (opt & OPT_install) { + for (i = 0; i < deb_count; i++) + configure_package(deb_file[i]); + } + + write_status_file(deb_file); + + if (ENABLE_FEATURE_CLEAN_UP) { + for (i = 0; i < deb_count; i++) { + free(deb_file[i]->control_file); + free(deb_file[i]->filename); + free(deb_file[i]); + } + + free(deb_file); + + for (i = 0; i < NAME_HASH_PRIME; i++) { + free(name_hashtable[i]); + } + + for (i = 0; i < PACKAGE_HASH_PRIME; i++) { + free_package(package_hashtable[i]); + } + + for (i = 0; i < STATUS_HASH_PRIME; i++) { + free(status_hashtable[i]); + } + + free(status_hashtable); + free(package_hashtable); + free(name_hashtable); + } + + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/archival/dpkg_deb.c b/i/pc104/initrd/conf/busybox/archival/dpkg_deb.c new file mode 100644 index 0000000..fde3c33 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/dpkg_deb.c @@ -0,0 +1,97 @@ +/* vi: set sw=4 ts=4: */ +/* + * dpkg-deb packs, unpacks and provides information about Debian archives. + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ +#include "busybox.h" +#include "unarchive.h" + +#define DPKG_DEB_OPT_CONTENTS 1 +#define DPKG_DEB_OPT_CONTROL 2 +#define DPKG_DEB_OPT_FIELD 4 +#define DPKG_DEB_OPT_EXTRACT 8 +#define DPKG_DEB_OPT_EXTRACT_VERBOSE 16 + +int dpkg_deb_main(int argc, char **argv); +int dpkg_deb_main(int argc, char **argv) +{ + archive_handle_t *ar_archive; + archive_handle_t *tar_archive; + llist_t *control_tar_llist = NULL; + unsigned opt; + const char *extract_dir = NULL; + short argcount = 1; + + /* Setup the tar archive handle */ + tar_archive = init_handle(); + + /* Setup an ar archive handle that refers to the gzip sub archive */ + ar_archive = init_handle(); + ar_archive->sub_archive = tar_archive; + ar_archive->filter = filter_accept_list_reassign; + +#ifdef CONFIG_FEATURE_DEB_TAR_GZ + llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz"); + llist_add_to(&control_tar_llist, (char*)"control.tar.gz"); +#endif + +#ifdef CONFIG_FEATURE_DEB_TAR_BZ2 + llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2"); + llist_add_to(&control_tar_llist, (char*)"control.tar.bz2"); +#endif + + opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX"; + opt = getopt32(argc, argv, "cefXx"); + + if (opt & DPKG_DEB_OPT_CONTENTS) { + tar_archive->action_header = header_verbose_list; + } + if (opt & DPKG_DEB_OPT_CONTROL) { + ar_archive->accept = control_tar_llist; + tar_archive->action_data = data_extract_all; + if (optind + 1 == argc) { + extract_dir = "./DEBIAN"; + } else { + argcount++; + } + } + if (opt & DPKG_DEB_OPT_FIELD) { + /* Print the entire control file + * it should accept a second argument which specifies a + * specific field to print */ + ar_archive->accept = control_tar_llist; + llist_add_to(&(tar_archive->accept), (char*)"./control"); + tar_archive->filter = filter_accept_list; + tar_archive->action_data = data_extract_to_stdout; + } + if (opt & DPKG_DEB_OPT_EXTRACT) { + tar_archive->action_header = header_list; + } + if (opt & (DPKG_DEB_OPT_EXTRACT_VERBOSE | DPKG_DEB_OPT_EXTRACT)) { + tar_archive->action_data = data_extract_all; + argcount = 2; + } + + if ((optind + argcount) != argc) { + bb_show_usage(); + } + + tar_archive->src_fd = ar_archive->src_fd = xopen(argv[optind++], O_RDONLY); + + /* Workout where to extract the files */ + /* 2nd argument is a dir name */ + if (argv[optind]) { + extract_dir = argv[optind]; + } + if (extract_dir) { + mkdir(extract_dir, 0777); /* bb_make_directory(extract_dir, 0777, 0) */ + xchdir(extract_dir); + } + unpack_ar_archive(ar_archive); + + /* Cleanup */ + close(ar_archive->src_fd); + + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/archival/gzip.c b/i/pc104/initrd/conf/busybox/archival/gzip.c new file mode 100644 index 0000000..39391df --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/gzip.c @@ -0,0 +1,2085 @@ +/* vi: set sw=4 ts=4: */ +/* + * Gzip implementation for busybox + * + * Based on GNU gzip Copyright (C) 1992-1993 Jean-loup Gailly. + * + * Originally adjusted for busybox by Charles P. Wright + * "this is a stripped down version of gzip I put into busybox, it does + * only standard in to standard out with -9 compression. It also requires + * the zcat module for some important functions." + * + * Adjusted further by Erik Andersen to support + * files as well as stdin/stdout, and to generally behave itself wrt + * command line handling. + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* big objects in bss: + * 00000020 b bl_count + * 00000074 b base_length + * 00000078 b base_dist + * 00000078 b static_dtree + * 0000009c b bl_tree + * 000000f4 b dyn_dtree + * 00000100 b length_code + * 00000200 b dist_code + * 0000023d b depth + * 00000400 b flag_buf + * 0000047a b heap + * 00000480 b static_ltree + * 000008f4 b dyn_ltree + */ + +/* TODO: full support for -v for DESKTOP + * "/usr/bin/gzip -v a bogus aa" should say: +a: 85.1% -- replaced with a.gz +gzip: bogus: No such file or directory +aa: 85.1% -- replaced with aa.gz +*/ + +#include "busybox.h" + + +/* =========================================================================== + */ +//#define DEBUG 1 +/* Diagnostic functions */ +#ifdef DEBUG +# define Assert(cond,msg) {if(!(cond)) bb_error_msg(msg);} +# define Trace(x) fprintf x +# define Tracev(x) {if (verbose) fprintf x ;} +# define Tracevv(x) {if (verbose > 1) fprintf x ;} +# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} +# define Tracecv(c,x) {if (verbose > 1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + + +/* =========================================================================== + */ +#define SMALL_MEM + +#ifndef INBUFSIZ +# ifdef SMALL_MEM +# define INBUFSIZ 0x2000 /* input buffer size */ +# else +# define INBUFSIZ 0x8000 /* input buffer size */ +# endif +#endif + +#ifndef OUTBUFSIZ +# ifdef SMALL_MEM +# define OUTBUFSIZ 8192 /* output buffer size */ +# else +# define OUTBUFSIZ 16384 /* output buffer size */ +# endif +#endif + +#ifndef DIST_BUFSIZE +# ifdef SMALL_MEM +# define DIST_BUFSIZE 0x2000 /* buffer for distances, see trees.c */ +# else +# define DIST_BUFSIZE 0x8000 /* buffer for distances, see trees.c */ +# endif +#endif + +/* gzip flag byte */ +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define RESERVED 0xC0 /* bit 6,7: reserved */ + +/* internal file attribute */ +#define UNKNOWN 0xffff +#define BINARY 0 +#define ASCII 1 + +#ifndef WSIZE +# define WSIZE 0x8000 /* window size--must be a power of two, and */ +#endif /* at least 32K for zip's deflate method */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +#define MAX_DIST (WSIZE-MIN_LOOKAHEAD) +/* In order to simplify the code, particularly on 16 bit machines, match + * distances are limited to MAX_DIST instead of WSIZE. + */ + +#ifndef MAX_PATH_LEN +# define MAX_PATH_LEN 1024 /* max pathname length */ +#endif + +#define seekable() 0 /* force sequential output */ +#define translate_eol 0 /* no option -a yet */ + +#ifndef BITS +# define BITS 16 +#endif +#define INIT_BITS 9 /* Initial number of bits per code */ + +#define BIT_MASK 0x1f /* Mask for 'number of compression bits' */ +/* Mask 0x20 is reserved to mean a fourth header byte, and 0x40 is free. + * It's a pity that old uncompress does not check bit 0x20. That makes + * extension of the format actually undesirable because old compress + * would just crash on the new format instead of giving a meaningful + * error message. It does check the number of bits, but it's more + * helpful to say "unsupported format, get a new version" than + * "can only handle 16 bits". + */ + +#ifdef MAX_EXT_CHARS +# define MAX_SUFFIX MAX_EXT_CHARS +#else +# define MAX_SUFFIX 30 +#endif + + +/* =========================================================================== + * Compile with MEDIUM_MEM to reduce the memory requirements or + * with SMALL_MEM to use as little memory as possible. Use BIG_MEM if the + * entire input file can be held in memory (not possible on 16 bit systems). + * Warning: defining these symbols affects HASH_BITS (see below) and thus + * affects the compression ratio. The compressed output + * is still correct, and might even be smaller in some cases. + */ + +#ifdef SMALL_MEM +# define HASH_BITS 13 /* Number of bits used to hash strings */ +#endif +#ifdef MEDIUM_MEM +# define HASH_BITS 14 +#endif +#ifndef HASH_BITS +# define HASH_BITS 15 + /* For portability to 16 bit machines, do not use values above 15. */ +#endif + +#define HASH_SIZE (unsigned)(1<= 4. + */ + + max_insert_length = max_lazy_match, +/* Insert new strings in the hash table only if the match length + * is not greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + + good_match = 32, +/* Use a faster search when the previous match is longer than this */ + +/* Values for max_lazy_match, good_match and max_chain_length, depending on + * the desired pack level (0..9). The values given below have been tuned to + * exclude worst case performance for pathological files. Better values may be + * found for specific files. + */ + + nice_match = 258, /* Stop searching when current match exceeds this */ +/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 + * For deflate_fast() (levels <= 3) good is ignored and lazy has a different + * meaning. + */ +}; + + +struct globals { + + lng block_start; + +/* window position at the beginning of the current output block. Gets + * negative when the window is moved backwards. + */ + unsigned ins_h; /* hash index of string to be inserted */ + +#define H_SHIFT ((HASH_BITS+MIN_MATCH-1) / MIN_MATCH) +/* Number of bits by which ins_h and del_h must be shifted at each + * input step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * H_SHIFT * MIN_MATCH >= HASH_BITS + */ + + unsigned prev_length; + +/* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + unsigned strstart; /* start of string to insert */ + unsigned match_start; /* start of matching string */ + unsigned lookahead; /* number of valid bytes ahead in window */ + +/* =========================================================================== + */ +#define DECLARE(type, array, size) \ + type * array +#define ALLOC(type, array, size) \ + array = xzalloc((size_t)(((size)+1L)/2) * 2*sizeof(type)); +#define FREE(array) \ + do { free(array); array = NULL; } while (0) + + /* global buffers */ + + /* buffer for literals or lengths */ + /* DECLARE(uch, l_buf, LIT_BUFSIZE); */ + DECLARE(uch, l_buf, INBUFSIZ); + + DECLARE(ush, d_buf, DIST_BUFSIZE); + DECLARE(uch, outbuf, OUTBUFSIZ); + +/* Sliding window. Input bytes are read into the second half of the window, + * and move to the first half later to keep a dictionary of at least WSIZE + * bytes. With this organization, matches are limited to a distance of + * WSIZE-MAX_MATCH bytes, but this ensures that IO is always + * performed with a length multiple of the block size. Also, it limits + * the window size to 64K, which is quite useful on MSDOS. + * To do: limit the window size to WSIZE+BSZ if SMALL_MEM (the code would + * be less efficient). + */ + DECLARE(uch, window, 2L * WSIZE); + +/* Link to older string with same hash index. To limit the size of this + * array to 64K, this link is maintained only for the last 32K strings. + * An index in this array is thus a window index modulo 32K. + */ + /* DECLARE(Pos, prev, WSIZE); */ + DECLARE(ush, prev, 1L << BITS); + +/* Heads of the hash chains or 0. */ + /* DECLARE(Pos, head, 1<> 8; + } else { + put_8bit(w); + put_8bit(w >> 8); + } +} + +static void put_32bit(ulg n) +{ + put_16bit(n); + put_16bit(n >> 16); +} + +/* =========================================================================== + * Clear input and output buffers + */ +static void clear_bufs(void) +{ + G1.outcnt = 0; +#ifdef DEBUG + G1.insize = 0; +#endif + G1.isize = 0; +} + + +/* =========================================================================== + * Run a set of bytes through the crc shift register. If s is a NULL + * pointer, then initialize the crc shift register contents instead. + * Return the current crc in either case. + */ +static uint32_t updcrc(uch * s, unsigned n) +{ + uint32_t c = G1.crc; + while (n) { + c = G1.crc_32_tab[(uch)(c ^ *s++)] ^ (c >> 8); + n--; + } + G1.crc = c; + return c; +} + + +/* =========================================================================== + * Read a new buffer from the current input file, perform end-of-line + * translation, and update the crc and input file size. + * IN assertion: size >= 2 (for end-of-line translation) + */ +static unsigned file_read(void *buf, unsigned size) +{ + unsigned len; + + Assert(G1.insize == 0, "l_buf not empty"); + + len = safe_read(ifd, buf, size); + if (len == (unsigned)(-1) || len == 0) + return len; + + updcrc(buf, len); + G1.isize += len; + return len; +} + + +/* =========================================================================== + * Send a value on a given number of bits. + * IN assertion: length <= 16 and value fits in length bits. + */ +static void send_bits(int value, int length) +{ +#ifdef DEBUG + Tracev((stderr, " l %2d v %4x ", length, value)); + Assert(length > 0 && length <= 15, "invalid length"); + G1.bits_sent += length; +#endif + /* If not enough room in bi_buf, use (valid) bits from bi_buf and + * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) + * unused bits in value. + */ + if (G1.bi_valid > (int) BUF_SIZE - length) { + G1.bi_buf |= (value << G1.bi_valid); + put_16bit(G1.bi_buf); + G1.bi_buf = (ush) value >> (BUF_SIZE - G1.bi_valid); + G1.bi_valid += length - BUF_SIZE; + } else { + G1.bi_buf |= value << G1.bi_valid; + G1.bi_valid += length; + } +} + + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 + */ +static unsigned bi_reverse(unsigned code, int len) +{ + unsigned res = 0; + + while (1) { + res |= code & 1; + if (--len <= 0) return res; + code >>= 1; + res <<= 1; + } +} + + +/* =========================================================================== + * Write out any remaining bits in an incomplete byte. + */ +static void bi_windup(void) +{ + if (G1.bi_valid > 8) { + put_16bit(G1.bi_buf); + } else if (G1.bi_valid > 0) { + put_8bit(G1.bi_buf); + } + G1.bi_buf = 0; + G1.bi_valid = 0; +#ifdef DEBUG + G1.bits_sent = (G1.bits_sent + 7) & ~7; +#endif +} + + +/* =========================================================================== + * Copy a stored block to the zip file, storing first the length and its + * one's complement if requested. + */ +static void copy_block(char *buf, unsigned len, int header) +{ + bi_windup(); /* align on byte boundary */ + + if (header) { + put_16bit(len); + put_16bit(~len); +#ifdef DEBUG + G1.bits_sent += 2 * 16; +#endif + } +#ifdef DEBUG + G1.bits_sent += (ulg) len << 3; +#endif + while (len--) { + put_8bit(*buf++); + } +} + + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead, and sets eofile if end of input file. + * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0 + * OUT assertions: at least one byte has been read, or eofile is set; + * file reads are performed for at least two bytes (required for the + * translate_eol option). + */ +static void fill_window(void) +{ + unsigned n, m; + unsigned more = WINDOW_SIZE - G1.lookahead - G1.strstart; + /* Amount of free space at the end of the window. */ + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (more == (unsigned) -1) { + /* Very unlikely, but possible on 16 bit machine if strstart == 0 + * and lookahead == 1 (input done one byte at time) + */ + more--; + } else if (G1.strstart >= WSIZE + MAX_DIST) { + /* By the IN assertion, the window is not empty so we can't confuse + * more == 0 with more == 64K on a 16 bit machine. + */ + Assert(WINDOW_SIZE == 2 * WSIZE, "no sliding with BIG_MEM"); + + memcpy(G1.window, G1.window + WSIZE, WSIZE); + G1.match_start -= WSIZE; + G1.strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */ + + G1.block_start -= WSIZE; + + for (n = 0; n < HASH_SIZE; n++) { + m = head[n]; + head[n] = (Pos) (m >= WSIZE ? m - WSIZE : 0); + } + for (n = 0; n < WSIZE; n++) { + m = G1.prev[n]; + G1.prev[n] = (Pos) (m >= WSIZE ? m - WSIZE : 0); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } + more += WSIZE; + } + /* At this point, more >= 2 */ + if (!G1.eofile) { + n = file_read(G1.window + G1.strstart + G1.lookahead, more); + if (n == 0 || n == (unsigned) -1) { + G1.eofile = 1; + } else { + G1.lookahead += n; + } + } +} + + +/* =========================================================================== + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is + * garbage. + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + */ + +/* For MSDOS, OS/2 and 386 Unix, an optimized version is in match.asm or + * match.s. The code is functionally equivalent, so you can use the C version + * if desired. + */ +static int longest_match(IPos cur_match) +{ + unsigned chain_length = max_chain_length; /* max hash chain length */ + uch *scan = G1.window + G1.strstart; /* current string */ + uch *match; /* matched string */ + int len; /* length of current match */ + int best_len = G1.prev_length; /* best match length so far */ + IPos limit = G1.strstart > (IPos) MAX_DIST ? G1.strstart - (IPos) MAX_DIST : 0; + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + +/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ +#if HASH_BITS < 8 || MAX_MATCH != 258 +# error Code too clever +#endif + uch *strend = G1.window + G1.strstart + MAX_MATCH; + uch scan_end1 = scan[best_len - 1]; + uch scan_end = scan[best_len]; + + /* Do not waste too much time if we already have a good match: */ + if (G1.prev_length >= good_match) { + chain_length >>= 2; + } + Assert(G1.strstart <= WINDOW_SIZE - MIN_LOOKAHEAD, "insufficient lookahead"); + + do { + Assert(cur_match < G1.strstart, "no future"); + match = G1.window + cur_match; + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2: + */ + if (match[best_len] != scan_end || + match[best_len - 1] != scan_end1 || + *match != *scan || *++match != scan[1]) + continue; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match++; + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && scan < strend); + + len = MAX_MATCH - (int) (strend - scan); + scan = strend - MAX_MATCH; + + if (len > best_len) { + G1.match_start = cur_match; + best_len = len; + if (len >= nice_match) + break; + scan_end1 = scan[best_len - 1]; + scan_end = scan[best_len]; + } + } while ((cur_match = G1.prev[cur_match & WMASK]) > limit + && --chain_length != 0); + + return best_len; +} + + +#ifdef DEBUG +/* =========================================================================== + * Check that the match at match_start is indeed a match. + */ +static void check_match(IPos start, IPos match, int length) +{ + /* check that the match is indeed a match */ + if (memcmp(G1.window + match, G1.window + start, length) != 0) { + bb_error_msg(" start %d, match %d, length %d", start, match, length); + bb_error_msg("invalid match"); + } + if (verbose > 1) { + bb_error_msg("\\[%d,%d]", start - match, length); + do { + putc(G1.window[start++], stderr); + } while (--length != 0); + } +} +#else +# define check_match(start, match, length) ((void)0) +#endif + + +/* trees.c -- output deflated data using Huffman coding + * Copyright (C) 1992-1993 Jean-loup Gailly + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +/* PURPOSE + * Encode various sets of source values using variable-length + * binary code trees. + * + * DISCUSSION + * The PKZIP "deflation" process uses several Huffman trees. The more + * common source values are represented by shorter bit sequences. + * + * Each code tree is stored in the ZIP file in a compressed form + * which is itself a Huffman encoding of the lengths of + * all the code strings (in ascending order by source values). + * The actual code strings are reconstructed from the lengths in + * the UNZIP process, as described in the "application note" + * (APPNOTE.TXT) distributed as part of PKWARE's PKZIP program. + * + * REFERENCES + * Lynch, Thomas J. + * Data Compression: Techniques and Applications, pp. 53-55. + * Lifetime Learning Publications, 1985. ISBN 0-534-03418-7. + * + * Storer, James A. + * Data Compression: Methods and Theory, pp. 49-50. + * Computer Science Press, 1988. ISBN 0-7167-8156-5. + * + * Sedgewick, R. + * Algorithms, p290. + * Addison-Wesley, 1983. ISBN 0-201-06672-6. + * + * INTERFACE + * void ct_init() + * Allocate the match buffer, initialize the various tables [and save + * the location of the internal file attribute (ascii/binary) and + * method (DEFLATE/STORE) -- deleted in bbox] + * + * void ct_tally(int dist, int lc); + * Save the match info and tally the frequency counts. + * + * ulg flush_block(char *buf, ulg stored_len, int eof) + * Determine the best encoding for the current block: dynamic trees, + * static trees or store, and output the encoded block to the zip + * file. Returns the total compressed length for the file so far. + */ + +#define MAX_BITS 15 +/* All codes must not exceed MAX_BITS bits */ + +#define MAX_BL_BITS 7 +/* Bit length codes must not exceed MAX_BL_BITS bits */ + +#define LENGTH_CODES 29 +/* number of length codes, not counting the special END_BLOCK code */ + +#define LITERALS 256 +/* number of literal bytes 0..255 */ + +#define END_BLOCK 256 +/* end of block literal code */ + +#define L_CODES (LITERALS+1+LENGTH_CODES) +/* number of Literal or Length codes, including the END_BLOCK code */ + +#define D_CODES 30 +/* number of distance codes */ + +#define BL_CODES 19 +/* number of codes used to transfer the bit lengths */ + +typedef uch extra_bits_t; + +/* extra bits for each length code */ +static const extra_bits_t extra_lbits[LENGTH_CODES]= { + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, + 4, 4, 5, 5, 5, 5, 0 +}; + +/* extra bits for each distance code */ +static const extra_bits_t extra_dbits[D_CODES] = { + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, + 10, 10, 11, 11, 12, 12, 13, 13 +}; + +/* extra bits for each bit length code */ +static const extra_bits_t extra_blbits[BL_CODES] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7 }; + +/* number of codes at each bit length for an optimal tree */ +static const uch bl_order[BL_CODES] = { + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#ifndef LIT_BUFSIZE +# ifdef SMALL_MEM +# define LIT_BUFSIZE 0x2000 +# else +# ifdef MEDIUM_MEM +# define LIT_BUFSIZE 0x4000 +# else +# define LIT_BUFSIZE 0x8000 +# endif +# endif +#endif +#ifndef DIST_BUFSIZE +# define DIST_BUFSIZE LIT_BUFSIZE +#endif +/* Sizes of match buffers for literals/lengths and distances. There are + * 4 reasons for limiting LIT_BUFSIZE to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input data is + * still in the window so we can still emit a stored block even when input + * comes from standard input. (This can also be done for all blocks if + * LIT_BUFSIZE is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting trees + * more frequently. + * - I can't count above 4 + * The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to save + * memory at the expense of compression). Some optimizations would be possible + * if we rely on DIST_BUFSIZE == LIT_BUFSIZE. + */ +#define REP_3_6 16 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */ +#define REPZ_3_10 17 +/* repeat a zero length 3-10 times (3 bits of repeat count) */ +#define REPZ_11_138 18 +/* repeat a zero length 11-138 times (7 bits of repeat count) */ + +/* =========================================================================== +*/ +/* Data structure describing a single value and its code string. */ +typedef struct ct_data { + union { + ush freq; /* frequency count */ + ush code; /* bit string */ + } fc; + union { + ush dad; /* father node in Huffman tree */ + ush len; /* length of bit string */ + } dl; +} ct_data; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len + +#define HEAP_SIZE (2*L_CODES + 1) +/* maximum heap size */ + +typedef struct tree_desc { + ct_data *dyn_tree; /* the dynamic tree */ + ct_data *static_tree; /* corresponding static tree or NULL */ + const extra_bits_t *extra_bits; /* extra bits for each code or NULL */ + int extra_base; /* base index for extra_bits */ + int elems; /* max number of elements in the tree */ + int max_length; /* max bit length for the codes */ + int max_code; /* largest code with non zero frequency */ +} tree_desc; + +struct globals2 { + + ush heap[HEAP_SIZE]; /* heap used to build the Huffman trees */ + int heap_len; /* number of elements in the heap */ + int heap_max; /* element of largest frequency */ + +/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + + ct_data dyn_ltree[HEAP_SIZE]; /* literal and length tree */ + ct_data dyn_dtree[2 * D_CODES + 1]; /* distance tree */ + + ct_data static_ltree[L_CODES + 2]; + +/* The static literal tree. Since the bit lengths are imposed, there is no + * need for the L_CODES extra codes used during heap construction. However + * The codes 286 and 287 are needed to build a canonical tree (see ct_init + * below). + */ + + ct_data static_dtree[D_CODES]; + +/* The static distance tree. (Actually a trivial tree since all codes use + * 5 bits.) + */ + + ct_data bl_tree[2 * BL_CODES + 1]; + +/* Huffman tree for the bit lengths */ + + tree_desc l_desc; + tree_desc d_desc; + tree_desc bl_desc; + + ush bl_count[MAX_BITS + 1]; + +/* The lengths of the bit length codes are sent in order of decreasing + * probability, to avoid transmitting the lengths for unused bit length codes. + */ + + uch depth[2 * L_CODES + 1]; + +/* Depth of each subtree used as tie breaker for trees of equal frequency */ + + uch length_code[MAX_MATCH - MIN_MATCH + 1]; + +/* length code for each normalized match length (0 == MIN_MATCH) */ + + uch dist_code[512]; + +/* distance codes. The first 256 values correspond to the distances + * 3 .. 258, the last 256 values correspond to the top 8 bits of + * the 15 bit distances. + */ + + int base_length[LENGTH_CODES]; + +/* First normalized length for each code (0 = MIN_MATCH) */ + + int base_dist[D_CODES]; + +/* First normalized distance for each code (0 = distance of 1) */ + + uch flag_buf[LIT_BUFSIZE / 8]; + +/* flag_buf is a bit array distinguishing literals from lengths in + * l_buf, thus indicating the presence or absence of a distance. + */ + + unsigned last_lit; /* running index in l_buf */ + unsigned last_dist; /* running index in d_buf */ + unsigned last_flags; /* running index in flag_buf */ + uch flags; /* current flags not yet saved in flag_buf */ + uch flag_bit; /* current bit used in flags */ + +/* bits are filled in flags starting at bit 0 (least significant). + * Note: these flags are overkill in the current code since we don't + * take advantage of DIST_BUFSIZE == LIT_BUFSIZE. + */ + + ulg opt_len; /* bit length of current block with optimal trees */ + ulg static_len; /* bit length of current block with static trees */ + + ulg compressed_len; /* total bit length of compressed file */ +}; + +#define G2ptr ((struct globals2*)(ptr_to_globals)) +#define G2 (*G2ptr) + + +/* =========================================================================== + */ +static void gen_codes(ct_data * tree, int max_code); +static void build_tree(tree_desc * desc); +static void scan_tree(ct_data * tree, int max_code); +static void send_tree(ct_data * tree, int max_code); +static int build_bl_tree(void); +static void send_all_trees(int lcodes, int dcodes, int blcodes); +static void compress_block(ct_data * ltree, ct_data * dtree); + + +#ifndef DEBUG +/* Send a code of the given tree. c and tree must not have side effects */ +# define SEND_CODE(c, tree) send_bits(tree[c].Code, tree[c].Len) +#else +# define SEND_CODE(c, tree) \ +{ \ + if (verbose > 1) bb_error_msg("\ncd %3d ",(c)); \ + send_bits(tree[c].Code, tree[c].Len); \ +} +#endif + +#define D_CODE(dist) \ + ((dist) < 256 ? G2.dist_code[dist] : G2.dist_code[256 + ((dist)>>7)]) +/* Mapping from a distance to a distance code. dist is the distance - 1 and + * must not have side effects. dist_code[256] and dist_code[257] are never + * used. + * The arguments must not have side effects. + */ + + +/* =========================================================================== + * Initialize a new block. + */ +static void init_block(void) +{ + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) + G2.dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) + G2.dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) + G2.bl_tree[n].Freq = 0; + + G2.dyn_ltree[END_BLOCK].Freq = 1; + G2.opt_len = G2.static_len = 0; + G2.last_lit = G2.last_dist = G2.last_flags = 0; + G2.flags = 0; + G2.flag_bit = 1; +} + + +/* =========================================================================== + * Restore the heap property by moving down the tree starting at node k, + * exchanging a node with the smallest of its two sons if necessary, stopping + * when the heap property is re-established (each father smaller than its + * two sons). + */ + +/* Compares to subtrees, using the tree depth as tie breaker when + * the subtrees have equal frequency. This minimizes the worst case length. */ +#define SMALLER(tree, n, m) \ + (tree[n].Freq < tree[m].Freq \ + || (tree[n].Freq == tree[m].Freq && G2.depth[n] <= G2.depth[m])) + +static void pqdownheap(ct_data * tree, int k) +{ + int v = G2.heap[k]; + int j = k << 1; /* left son of k */ + + while (j <= G2.heap_len) { + /* Set j to the smallest of the two sons: */ + if (j < G2.heap_len && SMALLER(tree, G2.heap[j + 1], G2.heap[j])) + j++; + + /* Exit if v is smaller than both sons */ + if (SMALLER(tree, v, G2.heap[j])) + break; + + /* Exchange v with the smallest son */ + G2.heap[k] = G2.heap[j]; + k = j; + + /* And continue down the tree, setting j to the left son of k */ + j <<= 1; + } + G2.heap[k] = v; +} + + +/* =========================================================================== + * Compute the optimal bit lengths for a tree and update the total bit length + * for the current block. + * IN assertion: the fields freq and dad are set, heap[heap_max] and + * above are the tree nodes sorted by increasing frequency. + * OUT assertions: the field len is set to the optimal bit length, the + * array bl_count contains the frequencies for each bit length. + * The length opt_len is updated; static_len is also updated if stree is + * not null. + */ +static void gen_bitlen(tree_desc * desc) +{ + ct_data *tree = desc->dyn_tree; + const extra_bits_t *extra = desc->extra_bits; + int base = desc->extra_base; + int max_code = desc->max_code; + int max_length = desc->max_length; + ct_data *stree = desc->static_tree; + int h; /* heap index */ + int n, m; /* iterate over the tree elements */ + int bits; /* bit length */ + int xbits; /* extra bits */ + ush f; /* frequency */ + int overflow = 0; /* number of elements with bit length too large */ + + for (bits = 0; bits <= MAX_BITS; bits++) + G2.bl_count[bits] = 0; + + /* In a first pass, compute the optimal bit lengths (which may + * overflow in the case of the bit length tree). + */ + tree[G2.heap[G2.heap_max]].Len = 0; /* root of the heap */ + + for (h = G2.heap_max + 1; h < HEAP_SIZE; h++) { + n = G2.heap[h]; + bits = tree[tree[n].Dad].Len + 1; + if (bits > max_length) { + bits = max_length; + overflow++; + } + tree[n].Len = (ush) bits; + /* We overwrite tree[n].Dad which is no longer needed */ + + if (n > max_code) + continue; /* not a leaf node */ + + G2.bl_count[bits]++; + xbits = 0; + if (n >= base) + xbits = extra[n - base]; + f = tree[n].Freq; + G2.opt_len += (ulg) f *(bits + xbits); + + if (stree) + G2.static_len += (ulg) f * (stree[n].Len + xbits); + } + if (overflow == 0) + return; + + Trace((stderr, "\nbit length overflow\n")); + /* This happens for example on obj2 and pic of the Calgary corpus */ + + /* Find the first bit length which could increase: */ + do { + bits = max_length - 1; + while (G2.bl_count[bits] == 0) + bits--; + G2.bl_count[bits]--; /* move one leaf down the tree */ + G2.bl_count[bits + 1] += 2; /* move one overflow item as its brother */ + G2.bl_count[max_length]--; + /* The brother of the overflow item also moves one step up, + * but this does not affect bl_count[max_length] + */ + overflow -= 2; + } while (overflow > 0); + + /* Now recompute all bit lengths, scanning in increasing frequency. + * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all + * lengths instead of fixing only the wrong ones. This idea is taken + * from 'ar' written by Haruhiko Okumura.) + */ + for (bits = max_length; bits != 0; bits--) { + n = G2.bl_count[bits]; + while (n != 0) { + m = G2.heap[--h]; + if (m > max_code) + continue; + if (tree[m].Len != (unsigned) bits) { + Trace((stderr, "code %d bits %d->%d\n", m, tree[m].Len, bits)); + G2.opt_len += ((int32_t) bits - tree[m].Len) * tree[m].Freq; + tree[m].Len = bits; + } + n--; + } + } +} + + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +static void gen_codes(ct_data * tree, int max_code) +{ + ush next_code[MAX_BITS + 1]; /* next code value for each bit length */ + ush code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = (code + G2.bl_count[bits - 1]) << 1; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert(code + G2.bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, + "inconsistent bit counts"); + Tracev((stderr, "\ngen_codes: max_code %d ", max_code)); + + for (n = 0; n <= max_code; n++) { + int len = tree[n].Len; + + if (len == 0) + continue; + /* Now reverse the bits */ + tree[n].Code = bi_reverse(next_code[len]++, len); + + Tracec(tree != G2.static_ltree, + (stderr, "\nn %3d %c l %2d c %4x (%x) ", n, + (isgraph(n) ? n : ' '), len, tree[n].Code, + next_code[len] - 1)); + } +} + + +/* =========================================================================== + * Construct one Huffman tree and assigns the code bit strings and lengths. + * Update the total bit length for the current block. + * IN assertion: the field freq is set for all tree elements. + * OUT assertions: the fields len and code are set to the optimal bit length + * and corresponding code. The length opt_len is updated; static_len is + * also updated if stree is not null. The field max_code is set. + */ + +/* Remove the smallest element from the heap and recreate the heap with + * one less element. Updates heap and heap_len. */ + +#define SMALLEST 1 +/* Index within the heap array of least frequent node in the Huffman tree */ + +#define PQREMOVE(tree, top) \ +do { \ + top = G2.heap[SMALLEST]; \ + G2.heap[SMALLEST] = G2.heap[G2.heap_len--]; \ + pqdownheap(tree, SMALLEST); \ +} while (0) + +static void build_tree(tree_desc * desc) +{ + ct_data *tree = desc->dyn_tree; + ct_data *stree = desc->static_tree; + int elems = desc->elems; + int n, m; /* iterate over heap elements */ + int max_code = -1; /* largest code with non zero frequency */ + int node = elems; /* next internal node of the tree */ + + /* Construct the initial heap, with least frequent element in + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + * heap[0] is not used. + */ + G2.heap_len = 0; + G2.heap_max = HEAP_SIZE; + + for (n = 0; n < elems; n++) { + if (tree[n].Freq != 0) { + G2.heap[++G2.heap_len] = max_code = n; + G2.depth[n] = 0; + } else { + tree[n].Len = 0; + } + } + + /* The pkzip format requires that at least one distance code exists, + * and that at least one bit should be sent even if there is only one + * possible code. So to avoid special checks later on we force at least + * two codes of non zero frequency. + */ + while (G2.heap_len < 2) { + int new = G2.heap[++G2.heap_len] = (max_code < 2 ? ++max_code : 0); + + tree[new].Freq = 1; + G2.depth[new] = 0; + G2.opt_len--; + if (stree) + G2.static_len -= stree[new].Len; + /* new is 0 or 1 so it does not have extra bits */ + } + desc->max_code = max_code; + + /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + * establish sub-heaps of increasing lengths: + */ + for (n = G2.heap_len / 2; n >= 1; n--) + pqdownheap(tree, n); + + /* Construct the Huffman tree by repeatedly combining the least two + * frequent nodes. + */ + do { + PQREMOVE(tree, n); /* n = node of least frequency */ + m = G2.heap[SMALLEST]; /* m = node of next least frequency */ + + G2.heap[--G2.heap_max] = n; /* keep the nodes sorted by frequency */ + G2.heap[--G2.heap_max] = m; + + /* Create a new node father of n and m */ + tree[node].Freq = tree[n].Freq + tree[m].Freq; + G2.depth[node] = MAX(G2.depth[n], G2.depth[m]) + 1; + tree[n].Dad = tree[m].Dad = (ush) node; +#ifdef DUMP_BL_TREE + if (tree == G2.bl_tree) { + bb_error_msg("\nnode %d(%d), sons %d(%d) %d(%d)", + node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); + } +#endif + /* and insert the new node in the heap */ + G2.heap[SMALLEST] = node++; + pqdownheap(tree, SMALLEST); + + } while (G2.heap_len >= 2); + + G2.heap[--G2.heap_max] = G2.heap[SMALLEST]; + + /* At this point, the fields freq and dad are set. We can now + * generate the bit lengths. + */ + gen_bitlen((tree_desc *) desc); + + /* The field len is now set, we can generate the bit codes */ + gen_codes((ct_data *) tree, max_code); +} + + +/* =========================================================================== + * Scan a literal or distance tree to determine the frequencies of the codes + * in the bit length tree. Updates opt_len to take into account the repeat + * counts. (The contribution of the bit length codes will be added later + * during the construction of bl_tree.) + */ +static void scan_tree(ct_data * tree, int max_code) +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + if (nextlen == 0) { + max_count = 138; + min_count = 3; + } + tree[max_code + 1].Len = 0xffff; /* guard */ + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; + nextlen = tree[n + 1].Len; + if (++count < max_count && curlen == nextlen) + continue; + + if (count < min_count) { + G2.bl_tree[curlen].Freq += count; + } else if (curlen != 0) { + if (curlen != prevlen) + G2.bl_tree[curlen].Freq++; + G2.bl_tree[REP_3_6].Freq++; + } else if (count <= 10) { + G2.bl_tree[REPZ_3_10].Freq++; + } else { + G2.bl_tree[REPZ_11_138].Freq++; + } + count = 0; + prevlen = curlen; + + max_count = 7; + min_count = 4; + if (nextlen == 0) { + max_count = 138; + min_count = 3; + } else if (curlen == nextlen) { + max_count = 6; + min_count = 3; + } + } +} + + +/* =========================================================================== + * Send a literal or distance tree in compressed form, using the codes in + * bl_tree. + */ +static void send_tree(ct_data * tree, int max_code) +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + +/* tree[max_code+1].Len = -1; *//* guard already set */ + if (nextlen == 0) + max_count = 138, min_count = 3; + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; + nextlen = tree[n + 1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + do { + SEND_CODE(curlen, G2.bl_tree); + } while (--count); + } else if (curlen != 0) { + if (curlen != prevlen) { + SEND_CODE(curlen, G2.bl_tree); + count--; + } + Assert(count >= 3 && count <= 6, " 3_6?"); + SEND_CODE(REP_3_6, G2.bl_tree); + send_bits(count - 3, 2); + } else if (count <= 10) { + SEND_CODE(REPZ_3_10, G2.bl_tree); + send_bits(count - 3, 3); + } else { + SEND_CODE(REPZ_11_138, G2.bl_tree); + send_bits(count - 11, 7); + } + count = 0; + prevlen = curlen; + if (nextlen == 0) { + max_count = 138; + min_count = 3; + } else if (curlen == nextlen) { + max_count = 6; + min_count = 3; + } else { + max_count = 7; + min_count = 4; + } + } +} + + +/* =========================================================================== + * Construct the Huffman tree for the bit lengths and return the index in + * bl_order of the last bit length code to send. + */ +static int build_bl_tree(void) +{ + int max_blindex; /* index of last bit length code of non zero freq */ + + /* Determine the bit length frequencies for literal and distance trees */ + scan_tree(G2.dyn_ltree, G2.l_desc.max_code); + scan_tree(G2.dyn_dtree, G2.d_desc.max_code); + + /* Build the bit length tree: */ + build_tree(&G2.bl_desc); + /* opt_len now includes the length of the tree representations, except + * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. + */ + + /* Determine the number of bit length codes to send. The pkzip format + * requires that at least 4 bit length codes be sent. (appnote.txt says + * 3 but the actual value used is 4.) + */ + for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { + if (G2.bl_tree[bl_order[max_blindex]].Len != 0) + break; + } + /* Update opt_len to include the bit length tree and counts */ + G2.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; + Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", G2.opt_len, G2.static_len)); + + return max_blindex; +} + + +/* =========================================================================== + * Send the header for a block using dynamic Huffman trees: the counts, the + * lengths of the bit length codes, the literal tree and the distance tree. + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + */ +static void send_all_trees(int lcodes, int dcodes, int blcodes) +{ + int rank; /* index in bl_order */ + + Assert(lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); + Assert(lcodes <= L_CODES && dcodes <= D_CODES + && blcodes <= BL_CODES, "too many codes"); + Tracev((stderr, "\nbl counts: ")); + send_bits(lcodes - 257, 5); /* not +255 as stated in appnote.txt */ + send_bits(dcodes - 1, 5); + send_bits(blcodes - 4, 4); /* not -3 as stated in appnote.txt */ + for (rank = 0; rank < blcodes; rank++) { + Tracev((stderr, "\nbl code %2d ", bl_order[rank])); + send_bits(G2.bl_tree[bl_order[rank]].Len, 3); + } + Tracev((stderr, "\nbl tree: sent %ld", G1.bits_sent)); + + send_tree((ct_data *) G2.dyn_ltree, lcodes - 1); /* send the literal tree */ + Tracev((stderr, "\nlit tree: sent %ld", G1.bits_sent)); + + send_tree((ct_data *) G2.dyn_dtree, dcodes - 1); /* send the distance tree */ + Tracev((stderr, "\ndist tree: sent %ld", G1.bits_sent)); +} + + +/* =========================================================================== + * Save the match info and tally the frequency counts. Return true if + * the current block must be flushed. + */ +static int ct_tally(int dist, int lc) +{ + G1.l_buf[G2.last_lit++] = lc; + if (dist == 0) { + /* lc is the unmatched char */ + G2.dyn_ltree[lc].Freq++; + } else { + /* Here, lc is the match length - MIN_MATCH */ + dist--; /* dist = match distance - 1 */ + Assert((ush) dist < (ush) MAX_DIST + && (ush) lc <= (ush) (MAX_MATCH - MIN_MATCH) + && (ush) D_CODE(dist) < (ush) D_CODES, "ct_tally: bad match" + ); + + G2.dyn_ltree[G2.length_code[lc] + LITERALS + 1].Freq++; + G2.dyn_dtree[D_CODE(dist)].Freq++; + + G1.d_buf[G2.last_dist++] = dist; + G2.flags |= G2.flag_bit; + } + G2.flag_bit <<= 1; + + /* Output the flags if they fill a byte: */ + if ((G2.last_lit & 7) == 0) { + G2.flag_buf[G2.last_flags++] = G2.flags; + G2.flags = 0; + G2.flag_bit = 1; + } + /* Try to guess if it is profitable to stop the current block here */ + if ((G2.last_lit & 0xfff) == 0) { + /* Compute an upper bound for the compressed length */ + ulg out_length = G2.last_lit * 8L; + ulg in_length = (ulg) G1.strstart - G1.block_start; + int dcode; + + for (dcode = 0; dcode < D_CODES; dcode++) { + out_length += G2.dyn_dtree[dcode].Freq * (5L + extra_dbits[dcode]); + } + out_length >>= 3; + Trace((stderr, + "\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ", + G2.last_lit, G2.last_dist, in_length, out_length, + 100L - out_length * 100L / in_length)); + if (G2.last_dist < G2.last_lit / 2 && out_length < in_length / 2) + return 1; + } + return (G2.last_lit == LIT_BUFSIZE - 1 || G2.last_dist == DIST_BUFSIZE); + /* We avoid equality with LIT_BUFSIZE because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ +} + +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +static void compress_block(ct_data * ltree, ct_data * dtree) +{ + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned lx = 0; /* running index in l_buf */ + unsigned dx = 0; /* running index in d_buf */ + unsigned fx = 0; /* running index in flag_buf */ + uch flag = 0; /* current flags */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (G2.last_lit != 0) do { + if ((lx & 7) == 0) + flag = G2.flag_buf[fx++]; + lc = G1.l_buf[lx++]; + if ((flag & 1) == 0) { + SEND_CODE(lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr, " '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = G2.length_code[lc]; + SEND_CODE(code + LITERALS + 1, ltree); /* send the length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= G2.base_length[code]; + send_bits(lc, extra); /* send the extra length bits */ + } + dist = G1.d_buf[dx++]; + /* Here, dist is the match distance - 1 */ + code = D_CODE(dist); + Assert(code < D_CODES, "bad d_code"); + + SEND_CODE(code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= G2.base_dist[code]; + send_bits(dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + flag >>= 1; + } while (lx < G2.last_lit); + + SEND_CODE(END_BLOCK, ltree); +} + + +/* =========================================================================== + * Determine the best encoding for the current block: dynamic trees, static + * trees or store, and output the encoded block to the zip file. This function + * returns the total compressed length for the file so far. + */ +static ulg flush_block(char *buf, ulg stored_len, int eof) +{ + ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ + int max_blindex; /* index of last bit length code of non zero freq */ + + G2.flag_buf[G2.last_flags] = G2.flags; /* Save the flags for the last 8 items */ + + /* Construct the literal and distance trees */ + build_tree(&G2.l_desc); + Tracev((stderr, "\nlit data: dyn %ld, stat %ld", G2.opt_len, G2.static_len)); + + build_tree(&G2.d_desc); + Tracev((stderr, "\ndist data: dyn %ld, stat %ld", G2.opt_len, G2.static_len)); + /* At this point, opt_len and static_len are the total bit lengths of + * the compressed block data, excluding the tree representations. + */ + + /* Build the bit length tree for the above two trees, and get the index + * in bl_order of the last bit length code to send. + */ + max_blindex = build_bl_tree(); + + /* Determine the best encoding. Compute first the block length in bytes */ + opt_lenb = (G2.opt_len + 3 + 7) >> 3; + static_lenb = (G2.static_len + 3 + 7) >> 3; + + Trace((stderr, + "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ", + opt_lenb, G2.opt_len, static_lenb, G2.static_len, stored_len, + G2.last_lit, G2.last_dist)); + + if (static_lenb <= opt_lenb) + opt_lenb = static_lenb; + + /* If compression failed and this is the first and last block, + * and if the zip file can be seeked (to rewrite the local header), + * the whole file is transformed into a stored file: + */ + if (stored_len <= opt_lenb && eof && G2.compressed_len == 0L && seekable()) { + /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ + if (buf == NULL) + bb_error_msg("block vanished"); + + copy_block(buf, (unsigned) stored_len, 0); /* without header */ + G2.compressed_len = stored_len << 3; + + } else if (stored_len + 4 <= opt_lenb && buf != NULL) { + /* 4: two words for the lengths */ + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + * Otherwise we can't have processed more than WSIZE input bytes since + * the last block flush, because compression would have been + * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + * transform a block into a stored block. + */ + send_bits((STORED_BLOCK << 1) + eof, 3); /* send block type */ + G2.compressed_len = (G2.compressed_len + 3 + 7) & ~7L; + G2.compressed_len += (stored_len + 4) << 3; + + copy_block(buf, (unsigned) stored_len, 1); /* with header */ + + } else if (static_lenb == opt_lenb) { + send_bits((STATIC_TREES << 1) + eof, 3); + compress_block((ct_data *) G2.static_ltree, (ct_data *) G2.static_dtree); + G2.compressed_len += 3 + G2.static_len; + } else { + send_bits((DYN_TREES << 1) + eof, 3); + send_all_trees(G2.l_desc.max_code + 1, G2.d_desc.max_code + 1, + max_blindex + 1); + compress_block((ct_data *) G2.dyn_ltree, (ct_data *) G2.dyn_dtree); + G2.compressed_len += 3 + G2.opt_len; + } + Assert(G2.compressed_len == G1.bits_sent, "bad compressed size"); + init_block(); + + if (eof) { + bi_windup(); + G2.compressed_len += 7; /* align on byte boundary */ + } + Tracev((stderr, "\ncomprlen %lu(%lu) ", G2.compressed_len >> 3, + G2.compressed_len - 7 * eof)); + + return G2.compressed_len >> 3; +} + + +/* =========================================================================== + * Update a hash value with the given input byte + * IN assertion: all calls to to UPDATE_HASH are made with consecutive + * input characters, so that a running hash key can be computed from the + * previous key instead of complete recalculation each time. + */ +#define UPDATE_HASH(h, c) (h = (((h)<= 0L \ + ? (char*)&G1.window[(unsigned)G1.block_start] \ + : (char*)NULL, \ + (ulg)G1.strstart - G1.block_start, \ + (eof) \ + ) + +/* Insert string s in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * IN assertion: all calls to to INSERT_STRING are made with consecutive + * input characters and the first MIN_MATCH bytes of s are valid + * (except for the last MIN_MATCH-1 bytes of the input file). */ +#define INSERT_STRING(s, match_head) \ +do { \ + UPDATE_HASH(G1.ins_h, G1.window[(s) + MIN_MATCH-1]); \ + G1.prev[(s) & WMASK] = match_head = head[G1.ins_h]; \ + head[G1.ins_h] = (s); \ +} while (0) + +static ulg deflate(void) +{ + IPos hash_head; /* head of hash chain */ + IPos prev_match; /* previous match */ + int flush; /* set if current block must be flushed */ + int match_available = 0; /* set if previous match exists */ + unsigned match_length = MIN_MATCH - 1; /* length of best match */ + + /* Process the input block. */ + while (G1.lookahead != 0) { + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + INSERT_STRING(G1.strstart, hash_head); + + /* Find the longest match, discarding those <= prev_length. + */ + G1.prev_length = match_length; + prev_match = G1.match_start; + match_length = MIN_MATCH - 1; + + if (hash_head != 0 && G1.prev_length < max_lazy_match + && G1.strstart - hash_head <= MAX_DIST + ) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + match_length = longest_match(hash_head); + /* longest_match() sets match_start */ + if (match_length > G1.lookahead) + match_length = G1.lookahead; + + /* Ignore a length 3 match if it is too distant: */ + if (match_length == MIN_MATCH && G1.strstart - G1.match_start > TOO_FAR) { + /* If prev_match is also MIN_MATCH, G1.match_start is garbage + * but we will ignore the current match anyway. + */ + match_length--; + } + } + /* If there was a match at the previous step and the current + * match is not better, output the previous match: + */ + if (G1.prev_length >= MIN_MATCH && match_length <= G1.prev_length) { + check_match(G1.strstart - 1, prev_match, G1.prev_length); + flush = ct_tally(G1.strstart - 1 - prev_match, G1.prev_length - MIN_MATCH); + + /* Insert in hash table all strings up to the end of the match. + * strstart-1 and strstart are already inserted. + */ + G1.lookahead -= G1.prev_length - 1; + G1.prev_length -= 2; + do { + G1.strstart++; + INSERT_STRING(G1.strstart, hash_head); + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH + * these bytes are garbage, but it does not matter since the + * next lookahead bytes will always be emitted as literals. + */ + } while (--G1.prev_length != 0); + match_available = 0; + match_length = MIN_MATCH - 1; + G1.strstart++; + if (flush) { + FLUSH_BLOCK(0); + G1.block_start = G1.strstart; + } + } else if (match_available) { + /* If there was no match at the previous position, output a + * single literal. If there was a match but the current match + * is longer, truncate the previous match to a single literal. + */ + Tracevv((stderr, "%c", G1.window[G1.strstart - 1])); + if (ct_tally(0, G1.window[G1.strstart - 1])) { + FLUSH_BLOCK(0); + G1.block_start = G1.strstart; + } + G1.strstart++; + G1.lookahead--; + } else { + /* There is no previous match to compare with, wait for + * the next step to decide. + */ + match_available = 1; + G1.strstart++; + G1.lookahead--; + } + Assert(G1.strstart <= G1.isize && lookahead <= G1.isize, "a bit too far"); + + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + while (G1.lookahead < MIN_LOOKAHEAD && !G1.eofile) + fill_window(); + } + if (match_available) + ct_tally(0, G1.window[G1.strstart - 1]); + + return FLUSH_BLOCK(1); /* eof */ +} + + +/* =========================================================================== + * Initialize the bit string routines. + */ +static void bi_init(void) +{ + G1.bi_buf = 0; + G1.bi_valid = 0; +#ifdef DEBUG + G1.bits_sent = 0L; +#endif +} + + +/* =========================================================================== + * Initialize the "longest match" routines for a new file + */ +static void lm_init(ush * flagsp) +{ + unsigned j; + + /* Initialize the hash table. */ + memset(head, 0, HASH_SIZE * sizeof(*head)); + /* prev will be initialized on the fly */ + + /* speed options for the general purpose bit flag */ + *flagsp |= 2; /* FAST 4, SLOW 2 */ + /* ??? reduce max_chain_length for binary files */ + + G1.strstart = 0; + G1.block_start = 0L; + + G1.lookahead = file_read(G1.window, + sizeof(int) <= 2 ? (unsigned) WSIZE : 2 * WSIZE); + + if (G1.lookahead == 0 || G1.lookahead == (unsigned) -1) { + G1.eofile = 1; + G1.lookahead = 0; + return; + } + G1.eofile = 0; + /* Make sure that we always have enough lookahead. This is important + * if input comes from a device such as a tty. + */ + while (G1.lookahead < MIN_LOOKAHEAD && !G1.eofile) + fill_window(); + + G1.ins_h = 0; + for (j = 0; j < MIN_MATCH - 1; j++) + UPDATE_HASH(G1.ins_h, G1.window[j]); + /* If lookahead < MIN_MATCH, ins_h is garbage, but this is + * not important since only literal bytes will be emitted. + */ +} + + +/* =========================================================================== + * Allocate the match buffer, initialize the various tables and save the + * location of the internal file attribute (ascii/binary) and method + * (DEFLATE/STORE). + * One callsite in zip() + */ +static void ct_init(void) +{ + int n; /* iterates over tree elements */ + int length; /* length value */ + int code; /* code value */ + int dist; /* distance index */ + + G2.compressed_len = 0L; + +#ifdef NOT_NEEDED + if (G2.static_dtree[0].Len != 0) + return; /* ct_init already called */ +#endif + + /* Initialize the mapping length (0..255) -> length code (0..28) */ + length = 0; + for (code = 0; code < LENGTH_CODES - 1; code++) { + G2.base_length[code] = length; + for (n = 0; n < (1 << extra_lbits[code]); n++) { + G2.length_code[length++] = code; + } + } + Assert(length == 256, "ct_init: length != 256"); + /* Note that the length 255 (match length 258) can be represented + * in two different ways: code 284 + 5 bits or code 285, so we + * overwrite length_code[255] to use the best encoding: + */ + G2.length_code[length - 1] = code; + + /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ + dist = 0; + for (code = 0; code < 16; code++) { + G2.base_dist[code] = dist; + for (n = 0; n < (1 << extra_dbits[code]); n++) { + G2.dist_code[dist++] = code; + } + } + Assert(dist == 256, "ct_init: dist != 256"); + dist >>= 7; /* from now on, all distances are divided by 128 */ + for (; code < D_CODES; code++) { + G2.base_dist[code] = dist << 7; + for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { + G2.dist_code[256 + dist++] = code; + } + } + Assert(dist == 256, "ct_init: 256+dist != 512"); + + /* Construct the codes of the static literal tree */ + /* already zeroed - it's in bss + for (n = 0; n <= MAX_BITS; n++) + G2.bl_count[n] = 0; */ + + n = 0; + while (n <= 143) { + G2.static_ltree[n++].Len = 8; + G2.bl_count[8]++; + } + while (n <= 255) { + G2.static_ltree[n++].Len = 9; + G2.bl_count[9]++; + } + while (n <= 279) { + G2.static_ltree[n++].Len = 7; + G2.bl_count[7]++; + } + while (n <= 287) { + G2.static_ltree[n++].Len = 8; + G2.bl_count[8]++; + } + /* Codes 286 and 287 do not exist, but we must include them in the + * tree construction to get a canonical Huffman tree (longest code + * all ones) + */ + gen_codes((ct_data *) G2.static_ltree, L_CODES + 1); + + /* The static distance tree is trivial: */ + for (n = 0; n < D_CODES; n++) { + G2.static_dtree[n].Len = 5; + G2.static_dtree[n].Code = bi_reverse(n, 5); + } + + /* Initialize the first block of the first file: */ + init_block(); +} + + +/* =========================================================================== + * Deflate in to out. + * IN assertions: the input and output buffers are cleared. + */ + +static void zip(ulg time_stamp) +{ + ush deflate_flags = 0; /* pkzip -es, -en or -ex equivalent */ + + G1.outcnt = 0; + + /* Write the header to the gzip file. See algorithm.doc for the format */ + /* magic header for gzip files: 1F 8B */ + /* compression method: 8 (DEFLATED) */ + /* general flags: 0 */ + put_32bit(0x00088b1f); + put_32bit(time_stamp); + + /* Write deflated file to zip file */ + G1.crc = ~0; + + bi_init(); + ct_init(); + lm_init(&deflate_flags); + + put_8bit(deflate_flags); /* extra flags */ + put_8bit(3); /* OS identifier = 3 (Unix) */ + + deflate(); + + /* Write the crc and uncompressed size */ + put_32bit(~G1.crc); + put_32bit(G1.isize); + + flush_outbuf(); +} + + +/* ======================================================================== */ +static +char* make_new_name_gzip(char *filename) +{ + return xasprintf("%s.gz", filename); +} + +static +USE_DESKTOP(long long) int pack_gzip(void) +{ + struct stat s; + + clear_bufs(); + s.st_ctime = 0; + fstat(STDIN_FILENO, &s); + zip(s.st_ctime); + return 0; +} + +int gzip_main(int argc, char **argv); +int gzip_main(int argc, char **argv) +{ + unsigned opt; + + /* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */ + opt = getopt32(argc, argv, "cfv" USE_GUNZIP("d") "q123456789" ); + option_mask32 &= 0x7; /* Clear -d, ignore -q, -0..9 */ + //if (opt & 0x1) // -c + //if (opt & 0x2) // -f + //if (opt & 0x4) // -v +#if ENABLE_GUNZIP /* gunzip_main may not be visible... */ + if (opt & 0x8) { // -d + return gunzip_main(argc, argv); + } +#endif + argv += optind; + + PTR_TO_GLOBALS = xzalloc(sizeof(struct globals) + sizeof(struct globals2)) + + sizeof(struct globals); + G2.l_desc.dyn_tree = G2.dyn_ltree; + G2.l_desc.static_tree = G2.static_ltree; + G2.l_desc.extra_bits = extra_lbits; + G2.l_desc.extra_base = LITERALS + 1; + G2.l_desc.elems = L_CODES; + G2.l_desc.max_length = MAX_BITS; + //G2.l_desc.max_code = 0; + + G2.d_desc.dyn_tree = G2.dyn_dtree; + G2.d_desc.static_tree = G2.static_dtree; + G2.d_desc.extra_bits = extra_dbits; + //G2.d_desc.extra_base = 0; + G2.d_desc.elems = D_CODES; + G2.d_desc.max_length = MAX_BITS; + //G2.d_desc.max_code = 0; + + G2.bl_desc.dyn_tree = G2.bl_tree; + //G2.bl_desc.static_tree = NULL; + G2.bl_desc.extra_bits = extra_blbits, + //G2.bl_desc.extra_base = 0; + G2.bl_desc.elems = BL_CODES; + G2.bl_desc.max_length = MAX_BL_BITS; + //G2.bl_desc.max_code = 0; + + /* Allocate all global buffers (for DYN_ALLOC option) */ + ALLOC(uch, G1.l_buf, INBUFSIZ); + ALLOC(uch, G1.outbuf, OUTBUFSIZ); + ALLOC(ush, G1.d_buf, DIST_BUFSIZE); + ALLOC(uch, G1.window, 2L * WSIZE); + ALLOC(ush, G1.prev, 1L << BITS); + + /* Initialise the CRC32 table */ + G1.crc_32_tab = crc32_filltable(0); + + return bbunpack(argv, make_new_name_gzip, pack_gzip); +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/Kbuild b/i/pc104/initrd/conf/busybox/archival/libunarchive/Kbuild new file mode 100644 index 0000000..4e14541 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/Kbuild @@ -0,0 +1,59 @@ +# Makefile for busybox +# +# Copyright (C) 1999-2004 by Erik Andersen +# +# Licensed under the GPL v2 or later, see the file LICENSE in this tarball. + +lib-y:= \ +\ + data_skip.o \ + data_extract_all.o \ + data_extract_to_stdout.o \ + data_extract_to_buffer.o \ +\ + filter_accept_all.o \ + filter_accept_list.o \ + filter_accept_reject_list.o \ +\ + header_skip.o \ + header_list.o \ + header_verbose_list.o \ +\ + archive_xread_all_eof.o \ +\ + seek_by_read.o \ + seek_by_jump.o \ +\ + data_align.o \ + find_list_entry.o \ + open_transformer.o \ + init_handle.o + +GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o +DPKG_FILES:= \ + get_header_ar.o \ + unpack_ar_archive.o \ + get_header_tar.o \ + filter_accept_list_reassign.o + +lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o +lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o +lib-$(CONFIG_UNLZMA) += decompress_unlzma.o +lib-$(CONFIG_CPIO) += get_header_cpio.o +lib-$(CONFIG_DPKG) += $(DPKG_FILES) +lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES) +lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o +lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o +lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o +lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES) +lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o +lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o +lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o +lib-$(CONFIG_TAR) += get_header_tar.o +lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o +lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o +lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o +lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o +lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o +lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES) +lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/archive_xread_all_eof.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/archive_xread_all_eof.c new file mode 100644 index 0000000..007f68c --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/archive_xread_all_eof.c @@ -0,0 +1,20 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "unarchive.h" +#include "libbb.h" + +ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, + unsigned char *buf, size_t count) +{ + ssize_t size; + + size = full_read(archive_handle->src_fd, buf, count); + if (size != 0 && size != count) { + bb_error_msg_and_die("short read: %u of %u", + (unsigned)size, (unsigned)count); + } + return size; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/check_header_gzip.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/check_header_gzip.c new file mode 100644 index 0000000..66aa574 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/check_header_gzip.c @@ -0,0 +1,59 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "libbb.h" +#include "unarchive.h" /* for external decl of check_header_gzip_or_die */ + +void check_header_gzip_or_die(int src_fd) +{ + union { + unsigned char raw[8]; + struct { + unsigned char method; + unsigned char flags; + unsigned int mtime; + unsigned char xtra_flags; + unsigned char os_flags; + } formatted; + } header; + + xread(src_fd, header.raw, 8); + + /* Check the compression method */ + if (header.formatted.method != 8) { + bb_error_msg_and_die("unknown compression method %d", + header.formatted.method); + } + + if (header.formatted.flags & 0x04) { + /* bit 2 set: extra field present */ + unsigned extra_short; + + extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8); + while (extra_short > 0) { + /* Ignore extra field */ + xread_char(src_fd); + extra_short--; + } + } + + /* Discard original name if any */ + if (header.formatted.flags & 0x08) { + /* bit 3 set: original file name present */ + while (xread_char(src_fd) != 0); + } + + /* Discard file comment if any */ + if (header.formatted.flags & 0x10) { + /* bit 4 set: file comment present */ + while (xread_char(src_fd) != 0); + } + + /* Read the header checksum */ + if (header.formatted.flags & 0x02) { + xread_char(src_fd); + xread_char(src_fd); + } +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/data_align.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/data_align.c new file mode 100644 index 0000000..946c94d --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/data_align.c @@ -0,0 +1,17 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include + +#include "libbb.h" +#include "unarchive.h" + +void data_align(archive_handle_t *archive_handle, const unsigned short boundary) +{ + const unsigned short skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary; + + archive_handle->seek(archive_handle, skip_amount); + archive_handle->offset += skip_amount; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_all.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_all.c new file mode 100644 index 0000000..0bb5bfe --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_all.c @@ -0,0 +1,127 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "libbb.h" +#include "unarchive.h" + +void data_extract_all(archive_handle_t *archive_handle) +{ + file_header_t *file_header = archive_handle->file_header; + int dst_fd; + int res; + + if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) { + char *name = xstrdup(file_header->name); + bb_make_directory(dirname(name), -1, FILEUTILS_RECUR); + free(name); + } + + /* Check if the file already exists */ + if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) { + /* Remove the existing entry if it exists */ + if (((file_header->mode & S_IFMT) != S_IFDIR) + && (unlink(file_header->name) == -1) + && (errno != ENOENT) + ) { + bb_perror_msg_and_die("cannot remove old file"); + } + } + else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) { + /* Remove the existing entry if its older than the extracted entry */ + struct stat statbuf; + if (lstat(file_header->name, &statbuf) == -1) { + if (errno != ENOENT) { + bb_perror_msg_and_die("cannot stat old file"); + } + } + else if (statbuf.st_mtime <= file_header->mtime) { + if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { + bb_error_msg("%s not created: newer or " + "same age file exists", file_header->name); + } + data_skip(archive_handle); + return; + } + else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) { + bb_perror_msg_and_die("cannot remove old file %s", + file_header->name); + } + } + + /* Handle hard links separately + * We identified hard links as regular files of size 0 with a symlink */ + if (S_ISREG(file_header->mode) && (file_header->link_name) + && (file_header->size == 0) + ) { + /* hard link */ + res = link(file_header->link_name, file_header->name); + if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { + bb_perror_msg("cannot create hard link"); + } + } else { + /* Create the filesystem entry */ + switch (file_header->mode & S_IFMT) { + case S_IFREG: { + /* Regular file */ + dst_fd = xopen3(file_header->name, O_WRONLY | O_CREAT | O_EXCL, + file_header->mode); + bb_copyfd_exact_size(archive_handle->src_fd, dst_fd, file_header->size); + close(dst_fd); + break; + } + case S_IFDIR: + res = mkdir(file_header->name, file_header->mode); + if ((errno != EISDIR) && (res == -1) + && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET) + ) { + bb_perror_msg("extract_archive: %s", file_header->name); + } + break; + case S_IFLNK: + /* Symlink */ + res = symlink(file_header->link_name, file_header->name); + if ((res == -1) + && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET) + ) { + bb_perror_msg("cannot create symlink " + "from %s to '%s'", + file_header->name, + file_header->link_name); + } + break; + case S_IFSOCK: + case S_IFBLK: + case S_IFCHR: + case S_IFIFO: + res = mknod(file_header->name, file_header->mode, file_header->device); + if ((res == -1) + && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET) + ) { + bb_perror_msg("cannot create node %s", file_header->name); + } + break; + default: + bb_error_msg_and_die("unrecognized file type"); + } + } + + if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) { + lchown(file_header->name, file_header->uid, file_header->gid); + } + /* uclibc has no lchmod, glibc is even stranger - + * it has lchmod which seems to do nothing! + * so we use chmod... */ + if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_PERM) + && (file_header->mode & S_IFMT) != S_IFLNK + ) { + chmod(file_header->name, file_header->mode); + } + + if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) { + struct utimbuf t; + t.actime = t.modtime = file_header->mtime; + utime(file_header->name, &t); + } +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_to_buffer.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_to_buffer.c new file mode 100644 index 0000000..d8fcdf3 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_to_buffer.c @@ -0,0 +1,17 @@ +/* vi: set sw=4 ts=4: */ +/* + * Copyright 2002 Glenn McGrath + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "libbb.h" +#include "unarchive.h" + +void data_extract_to_buffer(archive_handle_t *archive_handle) +{ + unsigned int size = archive_handle->file_header->size; + + archive_handle->buffer = xzalloc(size + 1); + xread(archive_handle->src_fd, archive_handle->buffer, size); +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_to_stdout.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_to_stdout.c new file mode 100644 index 0000000..d87a4a5 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/data_extract_to_stdout.c @@ -0,0 +1,13 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "unarchive.h" + +void data_extract_to_stdout(archive_handle_t *archive_handle) +{ + bb_copyfd_exact_size(archive_handle->src_fd, + STDOUT_FILENO, + archive_handle->file_header->size); +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/data_skip.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/data_skip.c new file mode 100644 index 0000000..dc3505a --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/data_skip.c @@ -0,0 +1,16 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include +#include +#include +#include +#include "unarchive.h" +#include "libbb.h" + +void data_skip(archive_handle_t *archive_handle) +{ + archive_handle->seek(archive_handle, archive_handle->file_header->size); +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_bunzip2.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_bunzip2.c new file mode 100644 index 0000000..ff7d64d --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_bunzip2.c @@ -0,0 +1,731 @@ +/* vi: set sw=4 ts=4: */ +/* Small bzip2 deflate implementation, by Rob Landley (rob@landley.net). + + Based on bzip2 decompression code by Julian R Seward (jseward@acm.org), + which also acknowledges contributions by Mike Burrows, David Wheeler, + Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten, + Robert Sedgewick, and Jon L. Bentley. + + Licensed under GPLv2 or later, see file LICENSE in this tarball for details. +*/ + +/* + Size and speed optimizations by Manuel Novoa III (mjn3@codepoet.org). + + More efficient reading of Huffman codes, a streamlined read_bunzip() + function, and various other tweaks. In (limited) tests, approximately + 20% faster than bzcat on x86 and about 10% faster on arm. + + Note that about 2/3 of the time is spent in read_unzip() reversing + the Burrows-Wheeler transformation. Much of that time is delay + resulting from cache misses. + + I would ask that anyone benefiting from this work, especially those + using it in commercial products, consider making a donation to my local + non-profit hospice organization (www.hospiceacadiana.com) in the name of + the woman I loved, Toni W. Hagan, who passed away Feb. 12, 2003. + + Manuel + */ + +#include "libbb.h" +#include "unarchive.h" + +/* Constants for Huffman coding */ +#define MAX_GROUPS 6 +#define GROUP_SIZE 50 /* 64 would have been more efficient */ +#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */ +#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */ +#define SYMBOL_RUNA 0 +#define SYMBOL_RUNB 1 + +/* Status return values */ +#define RETVAL_OK 0 +#define RETVAL_LAST_BLOCK (-1) +#define RETVAL_NOT_BZIP_DATA (-2) +#define RETVAL_UNEXPECTED_INPUT_EOF (-3) +#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4) +#define RETVAL_DATA_ERROR (-5) +#define RETVAL_OUT_OF_MEMORY (-6) +#define RETVAL_OBSOLETE_INPUT (-7) + +/* Other housekeeping constants */ +#define IOBUF_SIZE 4096 + +/* This is what we know about each Huffman coding group */ +struct group_data { + /* We have an extra slot at the end of limit[] for a sentinal value. */ + int limit[MAX_HUFCODE_BITS+1],base[MAX_HUFCODE_BITS],permute[MAX_SYMBOLS]; + int minLen, maxLen; +}; + +/* Structure holding all the housekeeping data, including IO buffers and + memory that persists between calls to bunzip */ + +typedef struct { + /* State for interrupting output loop */ + + int writeCopies,writePos,writeRunCountdown,writeCount,writeCurrent; + + /* I/O tracking data (file handles, buffers, positions, etc.) */ + + int in_fd,out_fd,inbufCount,inbufPos /*,outbufPos*/; + unsigned char *inbuf /*,*outbuf*/; + unsigned int inbufBitCount, inbufBits; + + /* The CRC values stored in the block header and calculated from the data */ + + uint32_t headerCRC, totalCRC, writeCRC; + uint32_t *crc32Table; + /* Intermediate buffer and its size (in bytes) */ + + unsigned int *dbuf, dbufSize; + + /* These things are a bit too big to go on the stack */ + + unsigned char selectors[32768]; /* nSelectors=15 bits */ + struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */ + + /* For I/O error handling */ + + jmp_buf jmpbuf; +} bunzip_data; + +/* Return the next nnn bits of input. All reads from the compressed input + are done through this function. All reads are big endian */ + +static unsigned int get_bits(bunzip_data *bd, char bits_wanted) +{ + unsigned int bits=0; + + /* If we need to get more data from the byte buffer, do so. (Loop getting + one byte at a time to enforce endianness and avoid unaligned access.) */ + + while (bd->inbufBitCountinbufPos==bd->inbufCount) { + if((bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE)) <= 0) + longjmp(bd->jmpbuf,RETVAL_UNEXPECTED_INPUT_EOF); + bd->inbufPos=0; + } + + /* Avoid 32-bit overflow (dump bit buffer to top of output) */ + + if(bd->inbufBitCount>=24) { + bits=bd->inbufBits&((1<inbufBitCount)-1); + bits_wanted-=bd->inbufBitCount; + bits<<=bits_wanted; + bd->inbufBitCount=0; + } + + /* Grab next 8 bits of input from buffer. */ + + bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++]; + bd->inbufBitCount+=8; + } + + /* Calculate result */ + + bd->inbufBitCount-=bits_wanted; + bits|=(bd->inbufBits>>bd->inbufBitCount)&((1<dbuf; + dbufSize=bd->dbufSize; + selectors=bd->selectors; + + /* Reset longjmp I/O error handling */ + + i=setjmp(bd->jmpbuf); + if (i) return i; + + /* Read in header signature and CRC, then validate signature. + (last block signature means CRC is for whole file, return now) */ + + i = get_bits(bd,24); + j = get_bits(bd,24); + bd->headerCRC=get_bits(bd,32); + if ((i == 0x177245) && (j == 0x385090)) return RETVAL_LAST_BLOCK; + if ((i != 0x314159) || (j != 0x265359)) return RETVAL_NOT_BZIP_DATA; + + /* We can add support for blockRandomised if anybody complains. There was + some code for this in busybox 1.0.0-pre3, but nobody ever noticed that + it didn't actually work. */ + + if (get_bits(bd,1)) return RETVAL_OBSOLETE_INPUT; + if ((origPtr=get_bits(bd,24)) > dbufSize) return RETVAL_DATA_ERROR; + + /* mapping table: if some byte values are never used (encoding things + like ascii text), the compression code removes the gaps to have fewer + symbols to deal with, and writes a sparse bitfield indicating which + values were present. We make a translation table to convert the symbols + back to the corresponding bytes. */ + + t=get_bits(bd, 16); + symTotal=0; + for (i=0;i<16;i++) { + if(t&(1<<(15-i))) { + k=get_bits(bd,16); + for (j=0;j<16;j++) + if(k&(1<<(15-j))) symToByte[symTotal++]=(16*i)+j; + } + } + + /* How many different Huffman coding groups does this block use? */ + + groupCount=get_bits(bd,3); + if (groupCount<2 || groupCount>MAX_GROUPS) return RETVAL_DATA_ERROR; + + /* nSelectors: Every GROUP_SIZE many symbols we select a new Huffman coding + group. Read in the group selector list, which is stored as MTF encoded + bit runs. (MTF=Move To Front, as each value is used it's moved to the + start of the list.) */ + + if(!(nSelectors=get_bits(bd, 15))) return RETVAL_DATA_ERROR; + for (i=0; i=groupCount) return RETVAL_DATA_ERROR; + + /* Decode MTF to get the next selector */ + + uc = mtfSymbol[j]; + for (;j;j--) mtfSymbol[j] = mtfSymbol[j-1]; + mtfSymbol[0]=selectors[i]=uc; + } + + /* Read the Huffman coding tables for each group, which code for symTotal + literal symbols, plus two run symbols (RUNA, RUNB) */ + + symCount=symTotal+2; + for (j=0; j (MAX_HUFCODE_BITS-1)) + return RETVAL_DATA_ERROR; + + /* If first bit is 0, stop. Else second bit indicates whether + to increment or decrement the value. Optimization: grab 2 + bits and unget the second if the first was 0. */ + + k = get_bits(bd,2); + if (k < 2) { + bd->inbufBitCount++; + break; + } + + /* Add one if second bit 1, else subtract 1. Avoids if/else */ + + t+=(((k+1)&2)-1); + } + + /* Correct for the initial -1, to get the final symbol length */ + + length[i]=t+1; + } + + /* Find largest and smallest lengths in this group */ + + minLen=maxLen=length[0]; + for (i = 1; i < symCount; i++) { + if(length[i] > maxLen) maxLen = length[i]; + else if(length[i] < minLen) minLen = length[i]; + } + + /* Calculate permute[], base[], and limit[] tables from length[]. + * + * permute[] is the lookup table for converting Huffman coded symbols + * into decoded symbols. base[] is the amount to subtract from the + * value of a Huffman symbol of a given length when using permute[]. + * + * limit[] indicates the largest numerical value a symbol with a given + * number of bits can have. This is how the Huffman codes can vary in + * length: each code with a value>limit[length] needs another bit. + */ + + hufGroup=bd->groups+j; + hufGroup->minLen = minLen; + hufGroup->maxLen = maxLen; + + /* Note that minLen can't be smaller than 1, so we adjust the base + and limit array pointers so we're not always wasting the first + entry. We do this again when using them (during symbol decoding).*/ + + base=hufGroup->base-1; + limit=hufGroup->limit-1; + + /* Calculate permute[]. Concurently, initialize temp[] and limit[]. */ + + pp=0; + for (i=minLen;i<=maxLen;i++) { + temp[i]=limit[i]=0; + for (t=0;tpermute[pp++] = t; + } + + /* Count symbols coded for at each bit length */ + + for (i=0;ilimit[length] comparison. */ + + limit[i]= (pp << (maxLen - i)) - 1; + pp<<=1; + base[i+1]=pp-(t+=temp[i]); + } + limit[maxLen+1] = INT_MAX; /* Sentinal value for reading next sym. */ + limit[maxLen]=pp+temp[maxLen]-1; + base[minLen]=0; + } + + /* We've finished reading and digesting the block header. Now read this + block's Huffman coded symbols from the file and undo the Huffman coding + and run length encoding, saving the result into dbuf[dbufCount++]=uc */ + + /* Initialize symbol occurrence counters and symbol Move To Front table */ + + for (i=0;i<256;i++) { + byteCount[i] = 0; + mtfSymbol[i]=(unsigned char)i; + } + + /* Loop through compressed symbols. */ + + runPos=dbufCount=selector=0; + for (;;) { + + /* fetch next Huffman coding group from list. */ + + symCount=GROUP_SIZE-1; + if(selector>=nSelectors) return RETVAL_DATA_ERROR; + hufGroup=bd->groups+selectors[selector++]; + base=hufGroup->base-1; + limit=hufGroup->limit-1; +continue_this_group: + + /* Read next Huffman-coded symbol. */ + + /* Note: It is far cheaper to read maxLen bits and back up than it is + to read minLen bits and then an additional bit at a time, testing + as we go. Because there is a trailing last block (with file CRC), + there is no danger of the overread causing an unexpected EOF for a + valid compressed file. As a further optimization, we do the read + inline (falling back to a call to get_bits if the buffer runs + dry). The following (up to got_huff_bits:) is equivalent to + j=get_bits(bd,hufGroup->maxLen); + */ + + while (bd->inbufBitCountmaxLen) { + if(bd->inbufPos==bd->inbufCount) { + j = get_bits(bd,hufGroup->maxLen); + goto got_huff_bits; + } + bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++]; + bd->inbufBitCount+=8; + }; + bd->inbufBitCount-=hufGroup->maxLen; + j = (bd->inbufBits>>bd->inbufBitCount)&((1<maxLen)-1); + +got_huff_bits: + + /* Figure how how many bits are in next symbol and unget extras */ + + i=hufGroup->minLen; + while (j>limit[i]) ++i; + bd->inbufBitCount += (hufGroup->maxLen - i); + + /* Huffman decode value to get nextSym (with bounds checking) */ + + if ((i > hufGroup->maxLen) + || (((unsigned)(j=(j>>(hufGroup->maxLen-i))-base[i])) + >= MAX_SYMBOLS)) + return RETVAL_DATA_ERROR; + nextSym = hufGroup->permute[j]; + + /* We have now decoded the symbol, which indicates either a new literal + byte, or a repeated run of the most recent literal byte. First, + check if nextSym indicates a repeated run, and if so loop collecting + how many times to repeat the last literal. */ + + if (((unsigned)nextSym) <= SYMBOL_RUNB) { /* RUNA or RUNB */ + + /* If this is the start of a new run, zero out counter */ + + if(!runPos) { + runPos = 1; + t = 0; + } + + /* Neat trick that saves 1 symbol: instead of or-ing 0 or 1 at + each bit position, add 1 or 2 instead. For example, + 1011 is 1<<0 + 1<<1 + 2<<2. 1010 is 2<<0 + 2<<1 + 1<<2. + You can make any bit pattern that way using 1 less symbol than + the basic or 0/1 method (except all bits 0, which would use no + symbols, but a run of length 0 doesn't mean anything in this + context). Thus space is saved. */ + + t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */ + if(runPos < dbufSize) runPos <<= 1; + goto end_of_huffman_loop; + } + + /* When we hit the first non-run symbol after a run, we now know + how many times to repeat the last literal, so append that many + copies to our buffer of decoded symbols (dbuf) now. (The last + literal used is the one at the head of the mtfSymbol array.) */ + + if(runPos) { + runPos=0; + if(dbufCount+t>=dbufSize) return RETVAL_DATA_ERROR; + + uc = symToByte[mtfSymbol[0]]; + byteCount[uc] += t; + while (t--) dbuf[dbufCount++]=uc; + } + + /* Is this the terminating symbol? */ + + if(nextSym>symTotal) break; + + /* At this point, nextSym indicates a new literal character. Subtract + one to get the position in the MTF array at which this literal is + currently to be found. (Note that the result can't be -1 or 0, + because 0 and 1 are RUNA and RUNB. But another instance of the + first symbol in the mtf array, position 0, would have been handled + as part of a run above. Therefore 1 unused mtf position minus + 2 non-literal nextSym values equals -1.) */ + + if(dbufCount>=dbufSize) return RETVAL_DATA_ERROR; + i = nextSym - 1; + uc = mtfSymbol[i]; + + /* Adjust the MTF array. Since we typically expect to move only a + * small number of symbols, and are bound by 256 in any case, using + * memmove here would typically be bigger and slower due to function + * call overhead and other assorted setup costs. */ + + do { + mtfSymbol[i] = mtfSymbol[i-1]; + } while (--i); + mtfSymbol[0] = uc; + uc=symToByte[uc]; + + /* We have our literal byte. Save it into dbuf. */ + + byteCount[uc]++; + dbuf[dbufCount++] = (unsigned int)uc; + + /* Skip group initialization if we're not done with this group. Done + * this way to avoid compiler warning. */ + +end_of_huffman_loop: + if(symCount--) goto continue_this_group; + } + + /* At this point, we've read all the Huffman-coded symbols (and repeated + runs) for this block from the input stream, and decoded them into the + intermediate buffer. There are dbufCount many decoded bytes in dbuf[]. + Now undo the Burrows-Wheeler transform on dbuf. + See http://dogma.net/markn/articles/bwt/bwt.htm + */ + + /* Turn byteCount into cumulative occurrence counts of 0 to n-1. */ + + j=0; + for (i=0;i<256;i++) { + k=j+byteCount[i]; + byteCount[i] = j; + j=k; + } + + /* Figure out what order dbuf would be in if we sorted it. */ + + for (i=0;i=dbufCount) return RETVAL_DATA_ERROR; + bd->writePos=dbuf[origPtr]; + bd->writeCurrent=(unsigned char)(bd->writePos&0xff); + bd->writePos>>=8; + bd->writeRunCountdown=5; + } + bd->writeCount=dbufCount; + + return RETVAL_OK; +} + +/* Undo burrows-wheeler transform on intermediate buffer to produce output. + If start_bunzip was initialized with out_fd=-1, then up to len bytes of + data are written to outbuf. Return value is number of bytes written or + error (all errors are negative numbers). If out_fd!=-1, outbuf and len + are ignored, data is written to out_fd and return is RETVAL_OK or error. +*/ + +static int read_bunzip(bunzip_data *bd, char *outbuf, int len) +{ + const unsigned int *dbuf; + int pos,current,previous,gotcount; + + /* If last read was short due to end of file, return last block now */ + if(bd->writeCount<0) return bd->writeCount; + + gotcount = 0; + dbuf=bd->dbuf; + pos=bd->writePos; + current=bd->writeCurrent; + + /* We will always have pending decoded data to write into the output + buffer unless this is the very first call (in which case we haven't + Huffman-decoded a block into the intermediate buffer yet). */ + + if (bd->writeCopies) { + + /* Inside the loop, writeCopies means extra copies (beyond 1) */ + + --bd->writeCopies; + + /* Loop outputting bytes */ + + for (;;) { + + /* If the output buffer is full, snapshot state and return */ + + if(gotcount >= len) { + bd->writePos=pos; + bd->writeCurrent=current; + bd->writeCopies++; + return len; + } + + /* Write next byte into output buffer, updating CRC */ + + outbuf[gotcount++] = current; + bd->writeCRC=(((bd->writeCRC)<<8) + ^bd->crc32Table[((bd->writeCRC)>>24)^current]); + + /* Loop now if we're outputting multiple copies of this byte */ + + if (bd->writeCopies) { + --bd->writeCopies; + continue; + } +decode_next_byte: + if (!bd->writeCount--) break; + /* Follow sequence vector to undo Burrows-Wheeler transform */ + previous=current; + pos=dbuf[pos]; + current=pos&0xff; + pos>>=8; + + /* After 3 consecutive copies of the same byte, the 4th is a repeat + count. We count down from 4 instead + * of counting up because testing for non-zero is faster */ + + if(--bd->writeRunCountdown) { + if(current!=previous) bd->writeRunCountdown=4; + } else { + + /* We have a repeated run, this byte indicates the count */ + + bd->writeCopies=current; + current=previous; + bd->writeRunCountdown=5; + + /* Sometimes there are just 3 bytes (run length 0) */ + + if(!bd->writeCopies) goto decode_next_byte; + + /* Subtract the 1 copy we'd output anyway to get extras */ + + --bd->writeCopies; + } + } + + /* Decompression of this block completed successfully */ + + bd->writeCRC=~bd->writeCRC; + bd->totalCRC=((bd->totalCRC<<1) | (bd->totalCRC>>31)) ^ bd->writeCRC; + + /* If this block had a CRC error, force file level CRC error. */ + + if(bd->writeCRC!=bd->headerCRC) { + bd->totalCRC=bd->headerCRC+1; + return RETVAL_LAST_BLOCK; + } + } + + /* Refill the intermediate buffer by Huffman-decoding next block of input */ + /* (previous is just a convenient unused temp variable here) */ + + previous=get_next_block(bd); + if(previous) { + bd->writeCount=previous; + return (previous!=RETVAL_LAST_BLOCK) ? previous : gotcount; + } + bd->writeCRC=~0; + pos=bd->writePos; + current=bd->writeCurrent; + goto decode_next_byte; +} + +/* Allocate the structure, read file header. If in_fd==-1, inbuf must contain + a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are + ignored, and data is read from file handle into temporary buffer. */ + +static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf, + int len) +{ + bunzip_data *bd; + unsigned int i; + const unsigned int BZh0=(((unsigned int)'B')<<24)+(((unsigned int)'Z')<<16) + +(((unsigned int)'h')<<8)+(unsigned int)'0'; + + /* Figure out how much data to allocate */ + + i=sizeof(bunzip_data); + if(in_fd!=-1) i+=IOBUF_SIZE; + + /* Allocate bunzip_data. Most fields initialize to zero. */ + + bd=*bdp=xzalloc(i); + + /* Setup input buffer */ + + if(-1==(bd->in_fd=in_fd)) { + bd->inbuf=inbuf; + bd->inbufCount=len; + } else bd->inbuf=(unsigned char *)(bd+1); + + /* Init the CRC32 table (big endian) */ + + bd->crc32Table = crc32_filltable(1); + + /* Setup for I/O error handling via longjmp */ + + i=setjmp(bd->jmpbuf); + if(i) return i; + + /* Ensure that file starts with "BZh['1'-'9']." */ + + i = get_bits(bd,32); + if (((unsigned int)(i-BZh0-1)) >= 9) return RETVAL_NOT_BZIP_DATA; + + /* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of + uncompressed data. Allocate intermediate buffer for block. */ + + bd->dbufSize=100000*(i-BZh0); + + bd->dbuf=xmalloc(bd->dbufSize * sizeof(int)); + return RETVAL_OK; +} + +/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data, + not end of file.) */ + +USE_DESKTOP(long long) int +uncompressStream(int src_fd, int dst_fd) +{ + USE_DESKTOP(long long total_written = 0;) + char *outbuf; + bunzip_data *bd; + int i; + + outbuf=xmalloc(IOBUF_SIZE); + i=start_bunzip(&bd,src_fd,0,0); + if(!i) { + for (;;) { + if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break; + if(i!=write(dst_fd,outbuf,i)) { + i=RETVAL_UNEXPECTED_OUTPUT_EOF; + break; + } + USE_DESKTOP(total_written += i;) + } + } + + /* Check CRC and release memory */ + + if(i==RETVAL_LAST_BLOCK) { + if (bd->headerCRC!=bd->totalCRC) { + bb_error_msg("data integrity error when decompressing"); + } else { + i=RETVAL_OK; + } + } else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) { + bb_error_msg("compressed file ends unexpectedly"); + } else { + bb_error_msg("decompression failed"); + } + free(bd->dbuf); + free(bd); + free(outbuf); + + return i ? i : USE_DESKTOP(total_written) + 0; +} + +#ifdef TESTING + +static char * const bunzip_errors[]={NULL,"Bad file checksum","Not bzip data", + "Unexpected input EOF","Unexpected output EOF","Data error", + "Out of memory","Obsolete (pre 0.9.5) bzip format not supported."}; + +/* Dumb little test thing, decompress stdin to stdout */ +int main(int argc, char *argv[]) +{ + int i=uncompressStream(0,1); + char c; + + if(i<0) fprintf(stderr,"%s\n", bunzip_errors[-i]); + else if(read(0,&c,1)) fprintf(stderr,"Trailing garbage ignored\n"); + return -i; +} +#endif diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_uncompress.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_uncompress.c new file mode 100644 index 0000000..8ce3cba --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_uncompress.c @@ -0,0 +1,308 @@ +/* vi: set sw=4 ts=4: */ +#include "libbb.h" + +/* uncompress for busybox -- (c) 2002 Robert Griebl + * + * based on the original compress42.c source + * (see disclaimer below) + */ + + +/* (N)compress42.c - File compression ala IEEE Computer, Mar 1992. + * + * Authors: + * Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas) + * Jim McKie (decvax!mcvax!jim) + * Steve Davies (decvax!vax135!petsd!peora!srd) + * Ken Turkowski (decvax!decwrl!turtlevax!ken) + * James A. Woods (decvax!ihnp4!ames!jaw) + * Joe Orost (decvax!vax135!petsd!joe) + * Dave Mack (csu@alembic.acs.com) + * Peter Jannesen, Network Communication Systems + * (peter@ncs.nl) + * + * marc@suse.de : a small security fix for a buffer overflow + * + * [... History snipped ...] + * + */ +#include +#include +#include + +/* Default input buffer size */ +#define IBUFSIZ 2048 + +/* Default output buffer size */ +#define OBUFSIZ 2048 + +/* Defines for third byte of header */ +#define MAGIC_1 (char_type)'\037' /* First byte of compressed file */ +#define MAGIC_2 (char_type)'\235' /* Second byte of compressed file */ +#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */ + /* Masks 0x20 and 0x40 are free. */ + /* I think 0x20 should mean that there is */ + /* a fourth header byte (for expansion). */ +#define BLOCK_MODE 0x80 /* Block compresssion if table is full and */ + /* compression rate is dropping flush tables */ + /* the next two codes should not be changed lightly, as they must not */ + /* lie within the contiguous general code space. */ +#define FIRST 257 /* first free entry */ +#define CLEAR 256 /* table clear output code */ + +#define INIT_BITS 9 /* initial number of bits/code */ + + +/* machine variants which require cc -Dmachine: pdp11, z8000, DOS */ +#define FAST + +#define HBITS 17 /* 50% occupancy */ +#define HSIZE (1< BITS) { + bb_error_msg("compressed with %d bits, can only handle " + "%d bits", maxbits, BITS); + return -1; + } + + n_bits = INIT_BITS; + maxcode = MAXCODE(INIT_BITS) - 1; + bitmask = (1 << INIT_BITS) - 1; + oldcode = -1; + finchar = 0; + outpos = 0; + posbits = 0 << 3; + + free_ent = ((block_mode) ? FIRST : 256); + + /* As above, initialize the first 256 entries in the table. */ + clear_tab_prefixof(); + + for (code = 255; code >= 0; --code) { + tab_suffixof(code) = (unsigned char) code; + } + + do { + resetbuf: + { + int i; + int e; + int o; + + o = posbits >> 3; + e = insize - o; + + for (i = 0; i < e; ++i) + inbuf[i] = inbuf[i + o]; + + insize = e; + posbits = 0; + } + + if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) { + rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ); +//error check?? + insize += rsize; + } + + inbits = ((rsize > 0) ? (insize - insize % n_bits) << 3 : + (insize << 3) - (n_bits - 1)); + + while (inbits > posbits) { + if (free_ent > maxcode) { + posbits = + ((posbits - 1) + + ((n_bits << 3) - + (posbits - 1 + (n_bits << 3)) % (n_bits << 3))); + ++n_bits; + if (n_bits == maxbits) { + maxcode = maxmaxcode; + } else { + maxcode = MAXCODE(n_bits) - 1; + } + bitmask = (1 << n_bits) - 1; + goto resetbuf; + } + { + unsigned char *p = &inbuf[posbits >> 3]; + + code = ((((long) (p[0])) | ((long) (p[1]) << 8) | + ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask; + } + posbits += n_bits; + + + if (oldcode == -1) { + oldcode = code; + finchar = (int) oldcode; + outbuf[outpos++] = (unsigned char) finchar; + continue; + } + + if (code == CLEAR && block_mode) { + clear_tab_prefixof(); + free_ent = FIRST - 1; + posbits = + ((posbits - 1) + + ((n_bits << 3) - + (posbits - 1 + (n_bits << 3)) % (n_bits << 3))); + n_bits = INIT_BITS; + maxcode = MAXCODE(INIT_BITS) - 1; + bitmask = (1 << INIT_BITS) - 1; + goto resetbuf; + } + + incode = code; + stackp = de_stack; + + /* Special case for KwKwK string. */ + if (code >= free_ent) { + if (code > free_ent) { + unsigned char *p; + + posbits -= n_bits; + p = &inbuf[posbits >> 3]; + + bb_error_msg + ("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)", + insize, posbits, p[-1], p[0], p[1], p[2], p[3], + (posbits & 07)); + bb_error_msg("uncompress: corrupt input"); + return -1; + } + + *--stackp = (unsigned char) finchar; + code = oldcode; + } + + /* Generate output characters in reverse order */ + while ((long int) code >= (long int) 256) { + *--stackp = tab_suffixof(code); + code = tab_prefixof(code); + } + + finchar = tab_suffixof(code); + *--stackp = (unsigned char) finchar; + + /* And put them out in forward order */ + { + int i; + + i = de_stack - stackp; + if (outpos + i >= OBUFSIZ) { + do { + if (i > OBUFSIZ - outpos) { + i = OBUFSIZ - outpos; + } + + if (i > 0) { + memcpy(outbuf + outpos, stackp, i); + outpos += i; + } + + if (outpos >= OBUFSIZ) { + full_write(fd_out, outbuf, outpos); +//error check?? + USE_DESKTOP(total_written += outpos;) + outpos = 0; + } + stackp += i; + i = de_stack - stackp; + } while (i > 0); + } else { + memcpy(outbuf + outpos, stackp, i); + outpos += i; + } + } + + /* Generate the new entry. */ + code = free_ent; + if (code < maxmaxcode) { + tab_prefixof(code) = (unsigned short) oldcode; + tab_suffixof(code) = (unsigned char) finchar; + free_ent = code + 1; + } + + /* Remember previous code. */ + oldcode = incode; + } + + } while (rsize > 0); + + if (outpos > 0) { + full_write(fd_out, outbuf, outpos); +//error check?? + USE_DESKTOP(total_written += outpos;) + } + + RELEASE_CONFIG_BUFFER(inbuf); + RELEASE_CONFIG_BUFFER(outbuf); + return USE_DESKTOP(total_written) + 0; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_unlzma.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_unlzma.c new file mode 100644 index 0000000..15a0275 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_unlzma.c @@ -0,0 +1,497 @@ +/* vi: set sw=4 ts=4: */ +/* + * Small lzma deflate implementation. + * Copyright (C) 2006 Aurelien Jacobs + * + * Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/) + * Copyright (C) 1999-2005 Igor Pavlov + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "libbb.h" +#include "unarchive.h" + +#ifdef CONFIG_FEATURE_LZMA_FAST +# define speed_inline ATTRIBUTE_ALWAYS_INLINE +#else +# define speed_inline +#endif + + +typedef struct { + int fd; + uint8_t *ptr; + +/* Was keeping rc on stack in unlzma and separately allocating buffer, + * but with "buffer 'attached to' allocated rc" code is smaller: */ + /* uint8_t *buffer; */ +#define RC_BUFFER ((uint8_t*)(rc+1)) + + uint8_t *buffer_end; + +/* Had provisions for variable buffer, but we don't need it here */ + /* int buffer_size; */ +#define RC_BUFFER_SIZE 0x10000 + + uint32_t code; + uint32_t range; + uint32_t bound; +} rc_t; + +#define RC_TOP_BITS 24 +#define RC_MOVE_BITS 5 +#define RC_MODEL_TOTAL_BITS 11 + + +/* Called twice: once at startup and once in rc_normalize() */ +static void rc_read(rc_t * rc) +{ + int buffer_size = safe_read(rc->fd, RC_BUFFER, RC_BUFFER_SIZE); + if (buffer_size <= 0) + bb_error_msg_and_die("unexpected EOF"); + rc->ptr = RC_BUFFER; + rc->buffer_end = RC_BUFFER + buffer_size; +} + +/* Called once */ +static rc_t* rc_init(int fd) /*, int buffer_size) */ +{ + int i; + rc_t* rc; + + rc = xmalloc(sizeof(rc_t) + RC_BUFFER_SIZE); + + rc->fd = fd; + /* rc->buffer_size = buffer_size; */ + rc->buffer_end = RC_BUFFER + RC_BUFFER_SIZE; + rc->ptr = rc->buffer_end; + + rc->code = 0; + rc->range = 0xFFFFFFFF; + for (i = 0; i < 5; i++) { + if (rc->ptr >= rc->buffer_end) + rc_read(rc); + rc->code = (rc->code << 8) | *rc->ptr++; + } + return rc; +} + +/* Called once */ +static ATTRIBUTE_ALWAYS_INLINE void rc_free(rc_t * rc) +{ + if (ENABLE_FEATURE_CLEAN_UP) + free(rc); +} + +/* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */ +static void rc_do_normalize(rc_t * rc) +{ + if (rc->ptr >= rc->buffer_end) + rc_read(rc); + rc->range <<= 8; + rc->code = (rc->code << 8) | *rc->ptr++; +} +static ATTRIBUTE_ALWAYS_INLINE void rc_normalize(rc_t * rc) +{ + if (rc->range < (1 << RC_TOP_BITS)) { + rc_do_normalize(rc); + } +} + +/* Called 9 times */ +/* Why rc_is_bit_0_helper exists? + * Because we want to always expose (rc->code < rc->bound) to optimizer + */ +static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p) +{ + rc_normalize(rc); + rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS); + return rc->bound; +} +static ATTRIBUTE_ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p) +{ + uint32_t t = rc_is_bit_0_helper(rc, p); + return rc->code < t; +} + +/* Called ~10 times, but very small, thus inlined */ +static speed_inline void rc_update_bit_0(rc_t * rc, uint16_t * p) +{ + rc->range = rc->bound; + *p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS; +} +static speed_inline void rc_update_bit_1(rc_t * rc, uint16_t * p) +{ + rc->range -= rc->bound; + rc->code -= rc->bound; + *p -= *p >> RC_MOVE_BITS; +} + +/* Called 4 times in unlzma loop */ +static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol) +{ + if (rc_is_bit_0(rc, p)) { + rc_update_bit_0(rc, p); + *symbol *= 2; + return 0; + } else { + rc_update_bit_1(rc, p); + *symbol = *symbol * 2 + 1; + return 1; + } +} + +/* Called once */ +static ATTRIBUTE_ALWAYS_INLINE int rc_direct_bit(rc_t * rc) +{ + rc_normalize(rc); + rc->range >>= 1; + if (rc->code >= rc->range) { + rc->code -= rc->range; + return 1; + } + return 0; +} + +/* Called twice */ +static speed_inline void +rc_bit_tree_decode(rc_t * rc, uint16_t * p, int num_levels, int *symbol) +{ + int i = num_levels; + + *symbol = 1; + while (i--) + rc_get_bit(rc, p + *symbol, symbol); + *symbol -= 1 << num_levels; +} + + +typedef struct { + uint8_t pos; + uint32_t dict_size; + uint64_t dst_size; +} __attribute__ ((packed)) lzma_header_t; + + +/* #defines will force compiler to compute/optimize each one with each usage. + * Have heart and use enum instead. */ +enum { + LZMA_BASE_SIZE = 1846, + LZMA_LIT_SIZE = 768, + + LZMA_NUM_POS_BITS_MAX = 4, + + LZMA_LEN_NUM_LOW_BITS = 3, + LZMA_LEN_NUM_MID_BITS = 3, + LZMA_LEN_NUM_HIGH_BITS = 8, + + LZMA_LEN_CHOICE = 0, + LZMA_LEN_CHOICE_2 = (LZMA_LEN_CHOICE + 1), + LZMA_LEN_LOW = (LZMA_LEN_CHOICE_2 + 1), + LZMA_LEN_MID = (LZMA_LEN_LOW \ + + (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_LOW_BITS))), + LZMA_LEN_HIGH = (LZMA_LEN_MID \ + + (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_MID_BITS))), + LZMA_NUM_LEN_PROBS = (LZMA_LEN_HIGH + (1 << LZMA_LEN_NUM_HIGH_BITS)), + + LZMA_NUM_STATES = 12, + LZMA_NUM_LIT_STATES = 7, + + LZMA_START_POS_MODEL_INDEX = 4, + LZMA_END_POS_MODEL_INDEX = 14, + LZMA_NUM_FULL_DISTANCES = (1 << (LZMA_END_POS_MODEL_INDEX >> 1)), + + LZMA_NUM_POS_SLOT_BITS = 6, + LZMA_NUM_LEN_TO_POS_STATES = 4, + + LZMA_NUM_ALIGN_BITS = 4, + + LZMA_MATCH_MIN_LEN = 2, + + LZMA_IS_MATCH = 0, + LZMA_IS_REP = (LZMA_IS_MATCH + (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX)), + LZMA_IS_REP_G0 = (LZMA_IS_REP + LZMA_NUM_STATES), + LZMA_IS_REP_G1 = (LZMA_IS_REP_G0 + LZMA_NUM_STATES), + LZMA_IS_REP_G2 = (LZMA_IS_REP_G1 + LZMA_NUM_STATES), + LZMA_IS_REP_0_LONG = (LZMA_IS_REP_G2 + LZMA_NUM_STATES), + LZMA_POS_SLOT = (LZMA_IS_REP_0_LONG \ + + (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX)), + LZMA_SPEC_POS = (LZMA_POS_SLOT \ + + (LZMA_NUM_LEN_TO_POS_STATES << LZMA_NUM_POS_SLOT_BITS)), + LZMA_ALIGN = (LZMA_SPEC_POS \ + + LZMA_NUM_FULL_DISTANCES - LZMA_END_POS_MODEL_INDEX), + LZMA_LEN_CODER = (LZMA_ALIGN + (1 << LZMA_NUM_ALIGN_BITS)), + LZMA_REP_LEN_CODER = (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS), + LZMA_LITERAL = (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS), +}; + + +USE_DESKTOP(long long) int +unlzma(int src_fd, int dst_fd) +{ + USE_DESKTOP(long long total_written = 0;) + lzma_header_t header; + int lc, pb, lp; + uint32_t pos_state_mask; + uint32_t literal_pos_mask; + uint32_t pos; + uint16_t *p; + uint16_t *prob; + uint16_t *prob_lit; + int num_bits; + int num_probs; + rc_t *rc; + int i, mi; + uint8_t *buffer; + uint8_t previous_byte = 0; + size_t buffer_pos = 0, global_pos = 0; + int len = 0; + int state = 0; + uint32_t rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1; + + xread(src_fd, &header, sizeof(header)); + + if (header.pos >= (9 * 5 * 5)) + bb_error_msg_and_die("bad header"); + mi = header.pos / 9; + lc = header.pos % 9; + pb = mi / 5; + lp = mi % 5; + pos_state_mask = (1 << pb) - 1; + literal_pos_mask = (1 << lp) - 1; + + header.dict_size = SWAP_LE32(header.dict_size); + header.dst_size = SWAP_LE64(header.dst_size); + + if (header.dict_size == 0) + header.dict_size = 1; + + buffer = xmalloc(MIN(header.dst_size, header.dict_size)); + + num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)); + p = xmalloc(num_probs * sizeof(*p)); + num_probs = LZMA_LITERAL + (LZMA_LIT_SIZE << (lc + lp)); + for (i = 0; i < num_probs; i++) + p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1; + + rc = rc_init(src_fd); /*, RC_BUFFER_SIZE); */ + + while (global_pos + buffer_pos < header.dst_size) { + int pos_state = (buffer_pos + global_pos) & pos_state_mask; + + prob = + p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state; + if (rc_is_bit_0(rc, prob)) { + mi = 1; + rc_update_bit_0(rc, prob); + prob = (p + LZMA_LITERAL + (LZMA_LIT_SIZE + * ((((buffer_pos + global_pos) & literal_pos_mask) << lc) + + (previous_byte >> (8 - lc))))); + + if (state >= LZMA_NUM_LIT_STATES) { + int match_byte; + + pos = buffer_pos - rep0; + while (pos >= header.dict_size) + pos += header.dict_size; + match_byte = buffer[pos]; + do { + int bit; + + match_byte <<= 1; + bit = match_byte & 0x100; + prob_lit = prob + 0x100 + bit + mi; + if (rc_get_bit(rc, prob_lit, &mi)) { + if (!bit) + break; + } else { + if (bit) + break; + } + } while (mi < 0x100); + } + while (mi < 0x100) { + prob_lit = prob + mi; + rc_get_bit(rc, prob_lit, &mi); + } + previous_byte = (uint8_t) mi; + + buffer[buffer_pos++] = previous_byte; + if (buffer_pos == header.dict_size) { + buffer_pos = 0; + global_pos += header.dict_size; + if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size) + goto bad; + USE_DESKTOP(total_written += header.dict_size;) + } + if (state < 4) + state = 0; + else if (state < 10) + state -= 3; + else + state -= 6; + } else { + int offset; + uint16_t *prob_len; + + rc_update_bit_1(rc, prob); + prob = p + LZMA_IS_REP + state; + if (rc_is_bit_0(rc, prob)) { + rc_update_bit_0(rc, prob); + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + state = state < LZMA_NUM_LIT_STATES ? 0 : 3; + prob = p + LZMA_LEN_CODER; + } else { + rc_update_bit_1(rc, prob); + prob = p + LZMA_IS_REP_G0 + state; + if (rc_is_bit_0(rc, prob)) { + rc_update_bit_0(rc, prob); + prob = (p + LZMA_IS_REP_0_LONG + + (state << LZMA_NUM_POS_BITS_MAX) + pos_state); + if (rc_is_bit_0(rc, prob)) { + rc_update_bit_0(rc, prob); + + state = state < LZMA_NUM_LIT_STATES ? 9 : 11; + pos = buffer_pos - rep0; + while (pos >= header.dict_size) + pos += header.dict_size; + previous_byte = buffer[pos]; + buffer[buffer_pos++] = previous_byte; + if (buffer_pos == header.dict_size) { + buffer_pos = 0; + global_pos += header.dict_size; + if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size) + goto bad; + USE_DESKTOP(total_written += header.dict_size;) + } + continue; + } else { + rc_update_bit_1(rc, prob); + } + } else { + uint32_t distance; + + rc_update_bit_1(rc, prob); + prob = p + LZMA_IS_REP_G1 + state; + if (rc_is_bit_0(rc, prob)) { + rc_update_bit_0(rc, prob); + distance = rep1; + } else { + rc_update_bit_1(rc, prob); + prob = p + LZMA_IS_REP_G2 + state; + if (rc_is_bit_0(rc, prob)) { + rc_update_bit_0(rc, prob); + distance = rep2; + } else { + rc_update_bit_1(rc, prob); + distance = rep3; + rep3 = rep2; + } + rep2 = rep1; + } + rep1 = rep0; + rep0 = distance; + } + state = state < LZMA_NUM_LIT_STATES ? 8 : 11; + prob = p + LZMA_REP_LEN_CODER; + } + + prob_len = prob + LZMA_LEN_CHOICE; + if (rc_is_bit_0(rc, prob_len)) { + rc_update_bit_0(rc, prob_len); + prob_len = (prob + LZMA_LEN_LOW + + (pos_state << LZMA_LEN_NUM_LOW_BITS)); + offset = 0; + num_bits = LZMA_LEN_NUM_LOW_BITS; + } else { + rc_update_bit_1(rc, prob_len); + prob_len = prob + LZMA_LEN_CHOICE_2; + if (rc_is_bit_0(rc, prob_len)) { + rc_update_bit_0(rc, prob_len); + prob_len = (prob + LZMA_LEN_MID + + (pos_state << LZMA_LEN_NUM_MID_BITS)); + offset = 1 << LZMA_LEN_NUM_LOW_BITS; + num_bits = LZMA_LEN_NUM_MID_BITS; + } else { + rc_update_bit_1(rc, prob_len); + prob_len = prob + LZMA_LEN_HIGH; + offset = ((1 << LZMA_LEN_NUM_LOW_BITS) + + (1 << LZMA_LEN_NUM_MID_BITS)); + num_bits = LZMA_LEN_NUM_HIGH_BITS; + } + } + rc_bit_tree_decode(rc, prob_len, num_bits, &len); + len += offset; + + if (state < 4) { + int pos_slot; + + state += LZMA_NUM_LIT_STATES; + prob = + p + LZMA_POS_SLOT + + ((len < + LZMA_NUM_LEN_TO_POS_STATES ? len : + LZMA_NUM_LEN_TO_POS_STATES - 1) + << LZMA_NUM_POS_SLOT_BITS); + rc_bit_tree_decode(rc, prob, LZMA_NUM_POS_SLOT_BITS, + &pos_slot); + if (pos_slot >= LZMA_START_POS_MODEL_INDEX) { + num_bits = (pos_slot >> 1) - 1; + rep0 = 2 | (pos_slot & 1); + if (pos_slot < LZMA_END_POS_MODEL_INDEX) { + rep0 <<= num_bits; + prob = p + LZMA_SPEC_POS + rep0 - pos_slot - 1; + } else { + num_bits -= LZMA_NUM_ALIGN_BITS; + while (num_bits--) + rep0 = (rep0 << 1) | rc_direct_bit(rc); + prob = p + LZMA_ALIGN; + rep0 <<= LZMA_NUM_ALIGN_BITS; + num_bits = LZMA_NUM_ALIGN_BITS; + } + i = 1; + mi = 1; + while (num_bits--) { + if (rc_get_bit(rc, prob + mi, &mi)) + rep0 |= i; + i <<= 1; + } + } else + rep0 = pos_slot; + if (++rep0 == 0) + break; + } + + len += LZMA_MATCH_MIN_LEN; + + do { + pos = buffer_pos - rep0; + while (pos >= header.dict_size) + pos += header.dict_size; + previous_byte = buffer[pos]; + buffer[buffer_pos++] = previous_byte; + if (buffer_pos == header.dict_size) { + buffer_pos = 0; + global_pos += header.dict_size; + if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size) + goto bad; + USE_DESKTOP(total_written += header.dict_size;) + } + len--; + } while (len != 0 && buffer_pos < header.dst_size); + } + } + + + if (full_write(dst_fd, buffer, buffer_pos) != buffer_pos) { + bad: + rc_free(rc); + return -1; + } + rc_free(rc); + USE_DESKTOP(total_written += buffer_pos;) + return USE_DESKTOP(total_written) + 0; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_unzip.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_unzip.c new file mode 100644 index 0000000..331fe34 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/decompress_unzip.c @@ -0,0 +1,1104 @@ +/* vi: set sw=4 ts=4: */ +/* + * gunzip implementation for busybox + * + * Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly. + * + * Originally adjusted for busybox by Sven Rudolph + * based on gzip sources + * + * Adjusted further by Erik Andersen to support + * files as well as stdin/stdout, and to generally behave itself wrt + * command line handling. + * + * General cleanup to better adhere to the style guide and make use of standard + * busybox functions by Glenn McGrath + * + * read_gz interface + associated hacking by Laurence Anderson + * + * Fixed huft_build() so decoding end-of-block code does not grab more bits + * than necessary (this is required by unzip applet), added inflate_cleanup() + * to free leaked bytebuffer memory (used in unzip.c), and some minor style + * guide cleanups by Ed Clark + * + * gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface + * Copyright (C) 1992-1993 Jean-loup Gailly + * The unzip code was written and put in the public domain by Mark Adler. + * Portions of the lzw code are derived from the public domain 'compress' + * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, + * Ken Turkowski, Dave Mack and Peter Jannesen. + * + * See the file algorithm.doc for the compression algorithms and file formats. + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "libbb.h" +#include "unarchive.h" + +typedef struct huft_s { + unsigned char e; /* number of extra bits or operation */ + unsigned char b; /* number of bits in this code or subcode */ + union { + unsigned short n; /* literal, length base, or distance base */ + struct huft_s *t; /* pointer to next level of table */ + } v; +} huft_t; + +enum { + /* gunzip_window size--must be a power of two, and + * at least 32K for zip's deflate method */ + GUNZIP_WSIZE = 0x8000, + /* If BMAX needs to be larger than 16, then h and x[] should be ulg. */ + BMAX = 16, /* maximum bit length of any code (16 for explode) */ + N_MAX = 288, /* maximum number of codes in any set */ +}; + + +/* This is somewhat complex-looking arrangement, but it allows + * to place decompressor state either in bss or in + * malloc'ed space simply by changing #defines below. + * Sizes on i386: + * text data bss dec hex + * 5256 0 108 5364 14f4 - bss + * 4915 0 0 4915 1333 - malloc + */ +#define STATE_IN_BSS 0 +#define STATE_IN_MALLOC 1 + + +typedef struct state_t { + off_t gunzip_bytes_out; /* number of output bytes */ + uint32_t gunzip_crc; + + int gunzip_src_fd; + unsigned gunzip_outbuf_count; /* bytes in output buffer */ + + unsigned char *gunzip_window; + + uint32_t *gunzip_crc_table; + + /* bitbuffer */ + unsigned gunzip_bb; /* bit buffer */ + unsigned char gunzip_bk; /* bits in bit buffer */ + + /* These control the size of the STATE()bytebuffer */ + unsigned bytebuffer_max; + unsigned char *bytebuffer; + unsigned bytebuffer_offset; + unsigned bytebuffer_size; + + /* private data of inflate_codes() */ + unsigned inflate_codes_ml; /* masks for bl and bd bits */ + unsigned inflate_codes_md; /* masks for bl and bd bits */ + unsigned inflate_codes_bb; /* bit buffer */ + unsigned inflate_codes_k; /* number of bits in bit buffer */ + unsigned inflate_codes_w; /* current gunzip_window position */ + huft_t *inflate_codes_tl; + huft_t *inflate_codes_td; + unsigned inflate_codes_bl; + unsigned inflate_codes_bd; + unsigned inflate_codes_nn; /* length and index for copy */ + unsigned inflate_codes_dd; + smallint resume_copy; + + /* private data of inflate_get_next_window() */ + smallint method; /* Method == -1 for stored, -2 for codes */ + smallint need_another_block; + smallint end_reached; + + /* private data of inflate_stored() */ + unsigned inflate_stored_n; + unsigned inflate_stored_b; + unsigned inflate_stored_k; + unsigned inflate_stored_w; +} state_t; +#define gunzip_bytes_out (S()gunzip_bytes_out ) +#define gunzip_crc (S()gunzip_crc ) +#define gunzip_src_fd (S()gunzip_src_fd ) +#define gunzip_outbuf_count (S()gunzip_outbuf_count) +#define gunzip_window (S()gunzip_window ) +#define gunzip_crc_table (S()gunzip_crc_table ) +#define gunzip_bb (S()gunzip_bb ) +#define gunzip_bk (S()gunzip_bk ) +#define bytebuffer_max (S()bytebuffer_max ) +#define bytebuffer (S()bytebuffer ) +#define bytebuffer_offset (S()bytebuffer_offset ) +#define bytebuffer_size (S()bytebuffer_size ) +#define inflate_codes_ml (S()inflate_codes_ml ) +#define inflate_codes_md (S()inflate_codes_md ) +#define inflate_codes_bb (S()inflate_codes_bb ) +#define inflate_codes_k (S()inflate_codes_k ) +#define inflate_codes_w (S()inflate_codes_w ) +#define inflate_codes_tl (S()inflate_codes_tl ) +#define inflate_codes_td (S()inflate_codes_td ) +#define inflate_codes_bl (S()inflate_codes_bl ) +#define inflate_codes_bd (S()inflate_codes_bd ) +#define inflate_codes_nn (S()inflate_codes_nn ) +#define inflate_codes_dd (S()inflate_codes_dd ) +#define resume_copy (S()resume_copy ) +#define method (S()method ) +#define need_another_block (S()need_another_block ) +#define end_reached (S()end_reached ) +#define inflate_stored_n (S()inflate_stored_n ) +#define inflate_stored_b (S()inflate_stored_b ) +#define inflate_stored_k (S()inflate_stored_k ) +#define inflate_stored_w (S()inflate_stored_w ) +#define INIT_STATE ({ bytebuffer_size = 0; method = -1; need_another_block = 1; }) + + +/* This is generic part */ +#if STATE_IN_BSS /* Use global data segment */ +#define DECLARE_STATE /*nothing*/ +#define ALLOC_STATE (init_state()) +#define DEALLOC_STATE ((void)0) +#define S() state. +#define PASS_STATE /*nothing*/ +#define PASS_STATE_ONLY /*nothing*/ +#define STATE_PARAM /*nothing*/ +#define STATE_PARAM_ONLY void +static state_t state; +static void init_state(void) +{ + INIT_STATE; +} +#endif + +#if STATE_IN_MALLOC /* Use malloc space */ +#define DECLARE_STATE state_t *state +#define ALLOC_STATE (state = alloc_state()) +#define DEALLOC_STATE free(state) +#define S() state-> +#define PASS_STATE state, +#define PASS_STATE_ONLY state +#define STATE_PARAM state_t *state, +#define STATE_PARAM_ONLY state_t *state +static state_t* alloc_state(void) +{ + state_t* state = xzalloc(sizeof(*state)); + INIT_STATE; + return state; +} +#endif + + +static const unsigned short mask_bits[] = { + 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, + 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff +}; + +/* Copy lengths for literal codes 257..285 */ +static const unsigned short cplens[] = { + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, + 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 +}; + +/* note: see note #13 above about the 258 in this list. */ +/* Extra bits for literal codes 257..285 */ +static const unsigned char cplext[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, + 5, 5, 5, 0, 99, 99 +}; /* 99 == invalid */ + +/* Copy offsets for distance codes 0..29 */ +static const unsigned short cpdist[] = { + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, + 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 +}; + +/* Extra bits for distance codes */ +static const unsigned char cpdext[] = { + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, + 11, 11, 12, 12, 13, 13 +}; + +/* Tables for deflate from PKZIP's appnote.txt. */ +/* Order of the bit length code lengths */ +static const unsigned char border[] = { + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 +}; + +static unsigned fill_bitbuffer(STATE_PARAM unsigned bitbuffer, unsigned *current, const unsigned required) +{ + while (*current < required) { + if (bytebuffer_offset >= bytebuffer_size) { + /* Leave the first 4 bytes empty so we can always unwind the bitbuffer + * to the front of the bytebuffer, leave 4 bytes free at end of tail + * so we can easily top up buffer in check_trailer_gzip() */ + bytebuffer_size = safe_read(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8); + if (1 > bytebuffer_size) +//shouldn't we propagate error? + bb_error_msg_and_die("unexpected end of file"); + bytebuffer_size += 4; + bytebuffer_offset = 4; + } + bitbuffer |= ((unsigned) bytebuffer[bytebuffer_offset]) << *current; + bytebuffer_offset++; + *current += 8; + } + return bitbuffer; +} + +/* + * Free the malloc'ed tables built by huft_build(), which makes a linked + * list of the tables it made, with the links in a dummy first entry of + * each table. + * t: table to free + */ +static void huft_free(huft_t * p) +{ + huft_t *q; + + /* Go through linked list, freeing from the malloced (t[-1]) address. */ + while (p) { + q = (--p)->v.t; + free(p); + p = q; + } +} + +/* Given a list of code lengths and a maximum table size, make a set of + * tables to decode that set of codes. Return zero on success, one if + * the given code set is incomplete (the tables are still built in this + * case), two if the input is invalid (all zero length codes or an + * oversubscribed set of lengths), and three if not enough memory. + * + * b: code lengths in bits (all assumed <= BMAX) + * n: number of codes (assumed <= N_MAX) + * s: number of simple-valued codes (0..s-1) + * d: list of base values for non-simple codes + * e: list of extra bits for non-simple codes + * t: result: starting table + * m: maximum lookup bits, returns actual + */ +static int huft_build(unsigned *b, const unsigned n, + const unsigned s, const unsigned short *d, + const unsigned char *e, huft_t ** t, unsigned *m) +{ + unsigned a; /* counter for codes of length k */ + unsigned c[BMAX + 1]; /* bit length count table */ + unsigned eob_len; /* length of end-of-block code (value 256) */ + unsigned f; /* i repeats in table every f entries */ + int g; /* maximum code length */ + int htl; /* table level */ + unsigned i; /* counter, current code */ + unsigned j; /* counter */ + int k; /* number of bits in current code */ + unsigned *p; /* pointer into c[], b[], or v[] */ + huft_t *q; /* points to current table */ + huft_t r; /* table entry for structure assignment */ + huft_t *u[BMAX]; /* table stack */ + unsigned v[N_MAX]; /* values in order of bit length */ + int ws[BMAX+1]; /* bits decoded stack */ + int w; /* bits decoded */ + unsigned x[BMAX + 1]; /* bit offsets, then code stack */ + unsigned *xp; /* pointer into x */ + int y; /* number of dummy codes added */ + unsigned z; /* number of entries in current table */ + + /* Length of EOB code, if any */ + eob_len = n > 256 ? b[256] : BMAX; + + /* Generate counts for each bit length */ + memset(c, 0, sizeof(c)); + p = b; + i = n; + do { + c[*p]++; /* assume all entries <= BMAX */ + p++; /* Can't combine with above line (Solaris bug) */ + } while (--i); + if (c[0] == n) { /* null input--all zero length codes */ + *t = NULL; + *m = 0; + return 2; + } + + /* Find minimum and maximum length, bound *m by those */ + for (j = 1; (c[j] == 0) && (j <= BMAX); j++); + k = j; /* minimum code length */ + for (i = BMAX; (c[i] == 0) && i; i--); + g = i; /* maximum code length */ + *m = (*m < j) ? j : ((*m > i) ? i : *m); + + /* Adjust last length count to fill out codes, if needed */ + for (y = 1 << j; j < i; j++, y <<= 1) { + y -= c[j]; + if (y < 0) { + return 2; /* bad input: more codes than bits */ + } + } + y -= c[i]; + if (y < 0) { + return 2; + } + c[i] += y; + + /* Generate starting offsets into the value table for each length */ + x[1] = j = 0; + p = c + 1; + xp = x + 2; + while (--i) { /* note that i == g from above */ + j += *p++; + *xp++ = j; + } + + /* Make a table of values in order of bit lengths */ + p = b; + i = 0; + do { + j = *p++; + if (j != 0) { + v[x[j]++] = i; + } + } while (++i < n); + + /* Generate the Huffman codes and for each, make the table entries */ + x[0] = i = 0; /* first Huffman code is zero */ + p = v; /* grab values in bit order */ + htl = -1; /* no tables yet--level -1 */ + w = ws[0] = 0; /* bits decoded */ + u[0] = NULL; /* just to keep compilers happy */ + q = NULL; /* ditto */ + z = 0; /* ditto */ + + /* go through the bit lengths (k already is bits in shortest code) */ + for (; k <= g; k++) { + a = c[k]; + while (a--) { + /* here i is the Huffman code of length k bits for value *p */ + /* make tables up to required level */ + while (k > ws[htl + 1]) { + w = ws[++htl]; + + /* compute minimum size table less than or equal to *m bits */ + z = g - w; + z = z > *m ? *m : z; /* upper limit on table size */ + j = k - w; + f = 1 << j; + if (f > a + 1) { /* try a k-w bit table */ + /* too few codes for k-w bit table */ + f -= a + 1; /* deduct codes from patterns left */ + xp = c + k; + while (++j < z) { /* try smaller tables up to z bits */ + f <<= 1; + if (f <= *++xp) { + break; /* enough codes to use up j bits */ + } + f -= *xp; /* else deduct codes from patterns */ + } + } + j = (w + j > eob_len && w < eob_len) ? eob_len - w : j; /* make EOB code end at table */ + z = 1 << j; /* table entries for j-bit table */ + ws[htl+1] = w + j; /* set bits decoded in stack */ + + /* allocate and link in new table */ + q = xzalloc((z + 1) * sizeof(huft_t)); + *t = q + 1; /* link to list for huft_free() */ + t = &(q->v.t); + u[htl] = ++q; /* table starts after link */ + + /* connect to last table, if there is one */ + if (htl) { + x[htl] = i; /* save pattern for backing up */ + r.b = (unsigned char) (w - ws[htl - 1]); /* bits to dump before this table */ + r.e = (unsigned char) (16 + j); /* bits in this table */ + r.v.t = q; /* pointer to this table */ + j = (i & ((1 << w) - 1)) >> ws[htl - 1]; + u[htl - 1][j] = r; /* connect to last table */ + } + } + + /* set up table entry in r */ + r.b = (unsigned char) (k - w); + if (p >= v + n) { + r.e = 99; /* out of values--invalid code */ + } else if (*p < s) { + r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is EOB code */ + r.v.n = (unsigned short) (*p++); /* simple code is just the value */ + } else { + r.e = (unsigned char) e[*p - s]; /* non-simple--look up in lists */ + r.v.n = d[*p++ - s]; + } + + /* fill code-like entries with r */ + f = 1 << (k - w); + for (j = i >> w; j < z; j += f) { + q[j] = r; + } + + /* backwards increment the k-bit code i */ + for (j = 1 << (k - 1); i & j; j >>= 1) { + i ^= j; + } + i ^= j; + + /* backup over finished tables */ + while ((i & ((1 << w) - 1)) != x[htl]) { + w = ws[--htl]; + } + } + } + + /* return actual size of base table */ + *m = ws[1]; + + /* Return true (1) if we were given an incomplete table */ + return y != 0 && g != 1; +} + + +/* + * inflate (decompress) the codes in a deflated (compressed) block. + * Return an error code or zero if it all goes ok. + * + * tl, td: literal/length and distance decoder tables + * bl, bd: number of bits decoded by tl[] and td[] + */ +/* called once from inflate_block */ + +/* map formerly local static variables to globals */ +#define ml inflate_codes_ml +#define md inflate_codes_md +#define bb inflate_codes_bb +#define k inflate_codes_k +#define w inflate_codes_w +#define tl inflate_codes_tl +#define td inflate_codes_td +#define bl inflate_codes_bl +#define bd inflate_codes_bd +#define nn inflate_codes_nn +#define dd inflate_codes_dd +static void inflate_codes_setup(STATE_PARAM huft_t * my_tl, huft_t * my_td, const unsigned my_bl, const unsigned my_bd) +{ + tl = my_tl; + td = my_td; + bl = my_bl; + bd = my_bd; + /* make local copies of globals */ + bb = gunzip_bb; /* initialize bit buffer */ + k = gunzip_bk; + w = gunzip_outbuf_count; /* initialize gunzip_window position */ + /* inflate the coded data */ + ml = mask_bits[bl]; /* precompute masks for speed */ + md = mask_bits[bd]; +} +/* called once from inflate_get_next_window */ +static int inflate_codes(STATE_PARAM_ONLY) +{ + unsigned e; /* table entry flag/number of extra bits */ + huft_t *t; /* pointer to table entry */ + + if (resume_copy) goto do_copy; + + while (1) { /* do until end of block */ + bb = fill_bitbuffer(PASS_STATE bb, &k, bl); + t = tl + ((unsigned) bb & ml); + e = t->e; + if (e > 16) + do { + if (e == 99) { +//shouldn't we propagate error? + bb_error_msg_and_die("inflate_codes error 1"); + } + bb >>= t->b; + k -= t->b; + e -= 16; + bb = fill_bitbuffer(PASS_STATE bb, &k, e); + t = t->v.t + ((unsigned) bb & mask_bits[e]); + e = t->e; + } while (e > 16); + bb >>= t->b; + k -= t->b; + if (e == 16) { /* then it's a literal */ + gunzip_window[w++] = (unsigned char) t->v.n; + if (w == GUNZIP_WSIZE) { + gunzip_outbuf_count = w; + //flush_gunzip_window(); + w = 0; + return 1; // We have a block to read + } + } else { /* it's an EOB or a length */ + /* exit if end of block */ + if (e == 15) { + break; + } + + /* get length of block to copy */ + bb = fill_bitbuffer(PASS_STATE bb, &k, e); + nn = t->v.n + ((unsigned) bb & mask_bits[e]); + bb >>= e; + k -= e; + + /* decode distance of block to copy */ + bb = fill_bitbuffer(PASS_STATE bb, &k, bd); + t = td + ((unsigned) bb & md); + e = t->e; + if (e > 16) + do { + if (e == 99) +//shouldn't we propagate error? + bb_error_msg_and_die("inflate_codes error 2"); + bb >>= t->b; + k -= t->b; + e -= 16; + bb = fill_bitbuffer(PASS_STATE bb, &k, e); + t = t->v.t + ((unsigned) bb & mask_bits[e]); + e = t->e; + } while (e > 16); + bb >>= t->b; + k -= t->b; + bb = fill_bitbuffer(PASS_STATE bb, &k, e); + dd = w - t->v.n - ((unsigned) bb & mask_bits[e]); + bb >>= e; + k -= e; + + /* do the copy */ + do_copy: + do { + /* Was: nn -= (e = (e = GUNZIP_WSIZE - ((dd &= GUNZIP_WSIZE - 1) > w ? dd : w)) > nn ? nn : e); */ + /* Who wrote THAT?? rewritten as: */ + dd &= GUNZIP_WSIZE - 1; + e = GUNZIP_WSIZE - (dd > w ? dd : w); + if (e > nn) e = nn; + nn -= e; + + /* copy to new buffer to prevent possible overwrite */ + if (w - dd >= e) { /* (this test assumes unsigned comparison) */ + memcpy(gunzip_window + w, gunzip_window + dd, e); + w += e; + dd += e; + } else { + /* do it slow to avoid memcpy() overlap */ + /* !NOMEMCPY */ + do { + gunzip_window[w++] = gunzip_window[dd++]; + } while (--e); + } + if (w == GUNZIP_WSIZE) { + gunzip_outbuf_count = w; + resume_copy = (nn != 0); + //flush_gunzip_window(); + w = 0; + return 1; + } + } while (nn); + resume_copy = 0; + } + } + + /* restore the globals from the locals */ + gunzip_outbuf_count = w; /* restore global gunzip_window pointer */ + gunzip_bb = bb; /* restore global bit buffer */ + gunzip_bk = k; + + /* normally just after call to inflate_codes, but save code by putting it here */ + /* free the decoding tables, return */ + huft_free(tl); + huft_free(td); + + /* done */ + return 0; +} +#undef ml +#undef md +#undef bb +#undef k +#undef w +#undef tl +#undef td +#undef bl +#undef bd +#undef nn +#undef dd + + +/* called once from inflate_block */ +static void inflate_stored_setup(STATE_PARAM int my_n, int my_b, int my_k) +{ + inflate_stored_n = my_n; + inflate_stored_b = my_b; + inflate_stored_k = my_k; + /* initialize gunzip_window position */ + inflate_stored_w = gunzip_outbuf_count; +} +/* called once from inflate_get_next_window */ +static int inflate_stored(STATE_PARAM_ONLY) +{ + /* read and output the compressed data */ + while (inflate_stored_n--) { + inflate_stored_b = fill_bitbuffer(PASS_STATE inflate_stored_b, &inflate_stored_k, 8); + gunzip_window[inflate_stored_w++] = (unsigned char) inflate_stored_b; + if (inflate_stored_w == GUNZIP_WSIZE) { + gunzip_outbuf_count = inflate_stored_w; + //flush_gunzip_window(); + inflate_stored_w = 0; + inflate_stored_b >>= 8; + inflate_stored_k -= 8; + return 1; // We have a block + } + inflate_stored_b >>= 8; + inflate_stored_k -= 8; + } + + /* restore the globals from the locals */ + gunzip_outbuf_count = inflate_stored_w; /* restore global gunzip_window pointer */ + gunzip_bb = inflate_stored_b; /* restore global bit buffer */ + gunzip_bk = inflate_stored_k; + return 0; // Finished +} + + +/* + * decompress an inflated block + * e: last block flag + * + * GLOBAL VARIABLES: bb, kk, + */ +/* Return values: -1 = inflate_stored, -2 = inflate_codes */ +/* One callsite in inflate_get_next_window */ +static int inflate_block(STATE_PARAM smallint *e) +{ + unsigned t; /* block type */ + unsigned b; /* bit buffer */ + unsigned k; /* number of bits in bit buffer */ + + /* make local bit buffer */ + + b = gunzip_bb; + k = gunzip_bk; + + /* read in last block bit */ + b = fill_bitbuffer(PASS_STATE b, &k, 1); + *e = b & 1; + b >>= 1; + k -= 1; + + /* read in block type */ + b = fill_bitbuffer(PASS_STATE b, &k, 2); + t = (unsigned) b & 3; + b >>= 2; + k -= 2; + + /* restore the global bit buffer */ + gunzip_bb = b; + gunzip_bk = k; + + /* inflate that block type */ + switch (t) { + case 0: /* Inflate stored */ + { + unsigned n; /* number of bytes in block */ + unsigned b_stored; /* bit buffer */ + unsigned k_stored; /* number of bits in bit buffer */ + + /* make local copies of globals */ + b_stored = gunzip_bb; /* initialize bit buffer */ + k_stored = gunzip_bk; + + /* go to byte boundary */ + n = k_stored & 7; + b_stored >>= n; + k_stored -= n; + + /* get the length and its complement */ + b_stored = fill_bitbuffer(PASS_STATE b_stored, &k_stored, 16); + n = ((unsigned) b_stored & 0xffff); + b_stored >>= 16; + k_stored -= 16; + + b_stored = fill_bitbuffer(PASS_STATE b_stored, &k_stored, 16); + if (n != (unsigned) ((~b_stored) & 0xffff)) { + return 1; /* error in compressed data */ + } + b_stored >>= 16; + k_stored -= 16; + + inflate_stored_setup(PASS_STATE n, b_stored, k_stored); // Setup inflate_stored + + return -1; + } + case 1: + /* Inflate fixed + * decompress an inflated type 1 (fixed Huffman codes) block. We should + * either replace this with a custom decoder, or at least precompute the + * Huffman tables. */ + { + int i; /* temporary variable */ + huft_t *tl; /* literal/length code table */ + huft_t *td; /* distance code table */ + unsigned bl; /* lookup bits for tl */ + unsigned bd; /* lookup bits for td */ + unsigned l[288]; /* length list for huft_build */ + + /* set up literal table */ + for (i = 0; i < 144; i++) { + l[i] = 8; + } + for (; i < 256; i++) { + l[i] = 9; + } + for (; i < 280; i++) { + l[i] = 7; + } + for (; i < 288; i++) { /* make a complete, but wrong code set */ + l[i] = 8; + } + bl = 7; + i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl); + if (i != 0) { + return i; + } + + /* set up distance table */ + for (i = 0; i < 30; i++) { /* make an incomplete code set */ + l[i] = 5; + } + bd = 5; + i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd); + if (i > 1) { + huft_free(tl); + return i; + } + + /* decompress until an end-of-block code */ + inflate_codes_setup(PASS_STATE tl, td, bl, bd); // Setup inflate_codes + + /* huft_free code moved into inflate_codes */ + + return -2; + } + case 2: /* Inflate dynamic */ + { + const int dbits = 6; /* bits in base distance lookup table */ + const int lbits = 9; /* bits in base literal/length lookup table */ + + huft_t *tl; /* literal/length code table */ + huft_t *td; /* distance code table */ + unsigned i; /* temporary variables */ + unsigned j; + unsigned l; /* last length */ + unsigned m; /* mask for bit lengths table */ + unsigned n; /* number of lengths to get */ + unsigned bl; /* lookup bits for tl */ + unsigned bd; /* lookup bits for td */ + unsigned nb; /* number of bit length codes */ + unsigned nl; /* number of literal/length codes */ + unsigned nd; /* number of distance codes */ + + unsigned ll[286 + 30]; /* literal/length and distance code lengths */ + unsigned b_dynamic; /* bit buffer */ + unsigned k_dynamic; /* number of bits in bit buffer */ + + /* make local bit buffer */ + b_dynamic = gunzip_bb; + k_dynamic = gunzip_bk; + + /* read in table lengths */ + b_dynamic = fill_bitbuffer(PASS_STATE b_dynamic, &k_dynamic, 5); + nl = 257 + ((unsigned) b_dynamic & 0x1f); /* number of literal/length codes */ + + b_dynamic >>= 5; + k_dynamic -= 5; + b_dynamic = fill_bitbuffer(PASS_STATE b_dynamic, &k_dynamic, 5); + nd = 1 + ((unsigned) b_dynamic & 0x1f); /* number of distance codes */ + + b_dynamic >>= 5; + k_dynamic -= 5; + b_dynamic = fill_bitbuffer(PASS_STATE b_dynamic, &k_dynamic, 4); + nb = 4 + ((unsigned) b_dynamic & 0xf); /* number of bit length codes */ + + b_dynamic >>= 4; + k_dynamic -= 4; + if (nl > 286 || nd > 30) { + return 1; /* bad lengths */ + } + + /* read in bit-length-code lengths */ + for (j = 0; j < nb; j++) { + b_dynamic = fill_bitbuffer(PASS_STATE b_dynamic, &k_dynamic, 3); + ll[border[j]] = (unsigned) b_dynamic & 7; + b_dynamic >>= 3; + k_dynamic -= 3; + } + for (; j < 19; j++) { + ll[border[j]] = 0; + } + + /* build decoding table for trees--single level, 7 bit lookup */ + bl = 7; + i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl); + if (i != 0) { + if (i == 1) { + huft_free(tl); + } + return i; /* incomplete code set */ + } + + /* read in literal and distance code lengths */ + n = nl + nd; + m = mask_bits[bl]; + i = l = 0; + while ((unsigned) i < n) { + b_dynamic = fill_bitbuffer(PASS_STATE b_dynamic, &k_dynamic, (unsigned)bl); + j = (td = tl + ((unsigned) b_dynamic & m))->b; + b_dynamic >>= j; + k_dynamic -= j; + j = td->v.n; + if (j < 16) { /* length of code in bits (0..15) */ + ll[i++] = l = j; /* save last length in l */ + } else if (j == 16) { /* repeat last length 3 to 6 times */ + b_dynamic = fill_bitbuffer(PASS_STATE b_dynamic, &k_dynamic, 2); + j = 3 + ((unsigned) b_dynamic & 3); + b_dynamic >>= 2; + k_dynamic -= 2; + if ((unsigned) i + j > n) { + return 1; + } + while (j--) { + ll[i++] = l; + } + } else if (j == 17) { /* 3 to 10 zero length codes */ + b_dynamic = fill_bitbuffer(PASS_STATE b_dynamic, &k_dynamic, 3); + j = 3 + ((unsigned) b_dynamic & 7); + b_dynamic >>= 3; + k_dynamic -= 3; + if ((unsigned) i + j > n) { + return 1; + } + while (j--) { + ll[i++] = 0; + } + l = 0; + } else { /* j == 18: 11 to 138 zero length codes */ + b_dynamic = fill_bitbuffer(PASS_STATE b_dynamic, &k_dynamic, 7); + j = 11 + ((unsigned) b_dynamic & 0x7f); + b_dynamic >>= 7; + k_dynamic -= 7; + if ((unsigned) i + j > n) { + return 1; + } + while (j--) { + ll[i++] = 0; + } + l = 0; + } + } + + /* free decoding table for trees */ + huft_free(tl); + + /* restore the global bit buffer */ + gunzip_bb = b_dynamic; + gunzip_bk = k_dynamic; + + /* build the decoding tables for literal/length and distance codes */ + bl = lbits; + + i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl); + if (i != 0) { + if (i == 1) { +//shouldn't we propagate error? + bb_error_msg_and_die("incomplete literal tree"); + /* huft_free(tl); */ + } + return i; /* incomplete code set */ + } + + bd = dbits; + i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd); + if (i != 0) { + if (i == 1) { +//shouldn't we propagate error? + bb_error_msg_and_die("incomplete distance tree"); + /* huft_free(td); */ + } + huft_free(tl); + return i; /* incomplete code set */ + } + + /* decompress until an end-of-block code */ + inflate_codes_setup(PASS_STATE tl, td, bl, bd); // Setup inflate_codes + + /* huft_free code moved into inflate_codes */ + + return -2; + } + default: + /* bad block type */ +//shouldn't we propagate error? + bb_error_msg_and_die("bad block type %d", t); + } +} + +/* Two callsites, both in inflate_get_next_window */ +static void calculate_gunzip_crc(STATE_PARAM_ONLY) +{ + int n; + for (n = 0; n < gunzip_outbuf_count; n++) { + gunzip_crc = gunzip_crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] ^ (gunzip_crc >> 8); + } + gunzip_bytes_out += gunzip_outbuf_count; +} + +/* One callsite in inflate_unzip_internal */ +static int inflate_get_next_window(STATE_PARAM_ONLY) +{ + gunzip_outbuf_count = 0; + + while (1) { + int ret; + + if (need_another_block) { + if (end_reached) { + calculate_gunzip_crc(PASS_STATE_ONLY); + end_reached = 0; + need_another_block = 1; + return 0; /* Last block */ + } + method = inflate_block(PASS_STATE &end_reached); + need_another_block = 0; + } + + switch (method) { + case -1: + ret = inflate_stored(PASS_STATE_ONLY); + break; + case -2: + ret = inflate_codes(PASS_STATE_ONLY); + break; + default: +//shouldn't we propagate error? + bb_error_msg_and_die("inflate error %d", method); + } + + if (ret == 1) { + calculate_gunzip_crc(PASS_STATE_ONLY); + return 1; // More data left + } + need_another_block = 1; // End of that block + } + /* Doesnt get here */ +} + + +/* Called from inflate_gunzip() and inflate_unzip() */ +/* NB: bytebuffer is allocated here but freeing it is left to the caller! */ +static USE_DESKTOP(long long) int +inflate_unzip_internal(STATE_PARAM int in, int out) +{ + USE_DESKTOP(long long) int n = 0; + ssize_t nwrote; + + /* Allocate all global buffers (for DYN_ALLOC option) */ + gunzip_window = xmalloc(GUNZIP_WSIZE); + gunzip_outbuf_count = 0; + gunzip_bytes_out = 0; + gunzip_src_fd = in; + + /* initialize gunzip_window, bit buffer */ + gunzip_bk = 0; + gunzip_bb = 0; + + /* Create the crc table */ + gunzip_crc_table = crc32_filltable(0); + gunzip_crc = ~0; + + /* Allocate space for buffer */ + bytebuffer = xmalloc(bytebuffer_max); + + while (1) { + int r = inflate_get_next_window(PASS_STATE_ONLY); + nwrote = full_write(out, gunzip_window, gunzip_outbuf_count); + if (nwrote != gunzip_outbuf_count) { + bb_perror_msg("write"); + n = -1; + goto ret; + } + USE_DESKTOP(n += nwrote;) + if (r == 0) break; + } + + /* Store unused bytes in a global buffer so calling applets can access it */ + if (gunzip_bk >= 8) { + /* Undo too much lookahead. The next read will be byte aligned + * so we can discard unused bits in the last meaningful byte. */ + bytebuffer_offset--; + bytebuffer[bytebuffer_offset] = gunzip_bb & 0xff; + gunzip_bb >>= 8; + gunzip_bk -= 8; + } + ret: + /* Cleanup */ + free(gunzip_window); + free(gunzip_crc_table); + return n; +} + + +USE_DESKTOP(long long) int +inflate_unzip(inflate_unzip_result *res, unsigned bufsize, int in, int out) +{ + USE_DESKTOP(long long) int n; + DECLARE_STATE; + + ALLOC_STATE; + + bytebuffer_max = bufsize + 8; + bytebuffer_offset = 4; + n = inflate_unzip_internal(PASS_STATE in, out); + + res->crc = gunzip_crc; + res->bytes_out = gunzip_bytes_out; + free(bytebuffer); + DEALLOC_STATE; + return n; +} + + +USE_DESKTOP(long long) int +inflate_gunzip(int in, int out) +{ + uint32_t stored_crc = 0; + unsigned count; + USE_DESKTOP(long long) int n; + DECLARE_STATE; + + ALLOC_STATE; + + bytebuffer_max = 0x8000; + n = inflate_unzip_internal(PASS_STATE in, out); + + if (n < 0) goto ret; + + /* top up the input buffer with the rest of the trailer */ + count = bytebuffer_size - bytebuffer_offset; + if (count < 8) { + xread(in, &bytebuffer[bytebuffer_size], 8 - count); +//shouldn't we propagate error? + bytebuffer_size += 8 - count; + } + for (count = 0; count != 4; count++) { + stored_crc |= (bytebuffer[bytebuffer_offset] << (count * 8)); + bytebuffer_offset++; + } + + /* Validate decompression - crc */ + if (stored_crc != (~gunzip_crc)) { + bb_error_msg("crc error"); + n = -1; + goto ret; + } + + /* Validate decompression - size */ + if (gunzip_bytes_out != + (bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) | + (bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24)) + ) { + bb_error_msg("incorrect length"); + n = -1; + } + ret: + free(bytebuffer); + DEALLOC_STATE; + return n; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_all.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_all.c new file mode 100644 index 0000000..5c991ca --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_all.c @@ -0,0 +1,17 @@ +/* vi: set sw=4 ts=4: */ +/* + * Copyright (C) 2002 by Glenn McGrath + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include +#include "unarchive.h" + +/* Accept any non-null name, its not really a filter at all */ +char filter_accept_all(archive_handle_t *archive_handle) +{ + if (archive_handle->file_header->name) + return EXIT_SUCCESS; + return EXIT_FAILURE; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_list.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_list.c new file mode 100644 index 0000000..cfc1b0c --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_list.c @@ -0,0 +1,19 @@ +/* vi: set sw=4 ts=4: */ +/* + * Copyright (C) 2002 by Glenn McGrath + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include +#include "unarchive.h" + +/* + * Accept names that are in the accept list, ignoring reject list. + */ +char filter_accept_list(archive_handle_t *archive_handle) +{ + if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) + return EXIT_SUCCESS; + return EXIT_FAILURE; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_list_reassign.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_list_reassign.c new file mode 100644 index 0000000..0fb536f --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_list_reassign.c @@ -0,0 +1,44 @@ +/* vi: set sw=4 ts=4: */ +/* + * Copyright (C) 2002 by Glenn McGrath + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "libbb.h" +#include "unarchive.h" + +/* + * Reassign the subarchive metadata parser based on the filename extension + * e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz + * or if its a .tar.bz2 make archive_handle->sub_archive handle that + */ +char filter_accept_list_reassign(archive_handle_t *archive_handle) +{ + /* Check the file entry is in the accept list */ + if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) { + const char *name_ptr; + + /* Extract the last 2 extensions */ + name_ptr = strrchr(archive_handle->file_header->name, '.'); + + /* Modify the subarchive handler based on the extension */ +#ifdef CONFIG_FEATURE_DEB_TAR_GZ + if (strcmp(name_ptr, ".gz") == 0) { + archive_handle->action_data_subarchive = get_header_tar_gz; + return EXIT_SUCCESS; + } +#endif +#ifdef CONFIG_FEATURE_DEB_TAR_BZ2 + if (strcmp(name_ptr, ".bz2") == 0) { + archive_handle->action_data_subarchive = get_header_tar_bz2; + return EXIT_SUCCESS; + } +#endif + if (ENABLE_FEATURE_DEB_TAR_LZMA && !strcmp(name_ptr, ".lzma")) { + archive_handle->action_data_subarchive = get_header_tar_lzma; + return EXIT_SUCCESS; + } + } + return EXIT_FAILURE; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_reject_list.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_reject_list.c new file mode 100644 index 0000000..79da350 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/filter_accept_reject_list.c @@ -0,0 +1,33 @@ +/* vi: set sw=4 ts=4: */ +/* + * Copyright (C) 2002 by Glenn McGrath + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include +#include "unarchive.h" + +/* + * Accept names that are in the accept list and not in the reject list + */ +char filter_accept_reject_list(archive_handle_t *archive_handle) +{ + const char *key = archive_handle->file_header->name; + const llist_t *reject_entry = find_list_entry2(archive_handle->reject, key); + const llist_t *accept_entry; + + /* If the key is in a reject list fail */ + if (reject_entry) { + return EXIT_FAILURE; + } + accept_entry = find_list_entry2(archive_handle->accept, key); + + /* Fail if an accept list was specified and the key wasnt in there */ + if ((accept_entry == NULL) && archive_handle->accept) { + return EXIT_FAILURE; + } + + /* Accepted */ + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/find_list_entry.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/find_list_entry.c new file mode 100644 index 0000000..d1afc72 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/find_list_entry.c @@ -0,0 +1,54 @@ +/* vi: set sw=4 ts=4: */ +/* + * Copyright (C) 2002 by Glenn McGrath + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include +#include +#include "unarchive.h" + +/* Find a string in a shell pattern list */ +const llist_t *find_list_entry(const llist_t *list, const char *filename) +{ + while (list) { + if (fnmatch(list->data, filename, 0) == 0) { + return list; + } + list = list->link; + } + return NULL; +} + +/* Same, but compares only path components present in pattern + * (extra trailing path components in filename are assumed to match) + */ +const llist_t *find_list_entry2(const llist_t *list, const char *filename) +{ + char buf[PATH_MAX]; + int pattern_slash_cnt; + const char *c; + char *d; + + while (list) { + c = list->data; + pattern_slash_cnt = 0; + while (*c) + if (*c++ == '/') pattern_slash_cnt++; + c = filename; + d = buf; + /* paranoia is better that buffer overflows */ + while (*c && d != buf + sizeof(buf)-1) { + if (*c == '/' && --pattern_slash_cnt < 0) + break; + *d++ = *c++; + } + *d = '\0'; + if (fnmatch(list->data, buf, 0) == 0) { + return list; + } + list = list->link; + } + return NULL; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_ar.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_ar.c new file mode 100644 index 0000000..c691f1b --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_ar.c @@ -0,0 +1,126 @@ +/* vi: set sw=4 ts=4: */ +/* Copyright 2001 Glenn McGrath. + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "libbb.h" +#include "unarchive.h" + +char get_header_ar(archive_handle_t *archive_handle) +{ + int err; + file_header_t *typed = archive_handle->file_header; + union { + char raw[60]; + struct { + char name[16]; + char date[12]; + char uid[6]; + char gid[6]; + char mode[8]; + char size[10]; + char magic[2]; + } formatted; + } ar; +#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES + static char *ar_long_names; + static unsigned int ar_long_name_size; +#endif + + /* dont use xread as we want to handle the error ourself */ + if (read(archive_handle->src_fd, ar.raw, 60) != 60) { + /* End Of File */ + return EXIT_FAILURE; + } + + /* ar header starts on an even byte (2 byte aligned) + * '\n' is used for padding + */ + if (ar.raw[0] == '\n') { + /* fix up the header, we started reading 1 byte too early */ + memmove(ar.raw, &ar.raw[1], 59); + ar.raw[59] = xread_char(archive_handle->src_fd); + archive_handle->offset++; + } + archive_handle->offset += 60; + + /* align the headers based on the header magic */ + if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n') + bb_error_msg_and_die("invalid ar header"); + + /* FIXME: more thorough routine would be in order here */ + /* (we have something like that in tar) */ + /* but for now we are lax. This code works because */ + /* on misformatted numbers bb_strtou returns all-ones */ + typed->mode = err = bb_strtou(ar.formatted.mode, NULL, 8); + if (err == -1) bb_error_msg_and_die("invalid ar header"); + typed->mtime = err = bb_strtou(ar.formatted.date, NULL, 10); + if (err == -1) bb_error_msg_and_die("invalid ar header"); + typed->uid = err = bb_strtou(ar.formatted.uid, NULL, 10); + if (err == -1) bb_error_msg_and_die("invalid ar header"); + typed->gid = err = bb_strtou(ar.formatted.gid, NULL, 10); + if (err == -1) bb_error_msg_and_die("invalid ar header"); + typed->size = err = bb_strtou(ar.formatted.size, NULL, 10); + if (err == -1) bb_error_msg_and_die("invalid ar header"); + + /* long filenames have '/' as the first character */ + if (ar.formatted.name[0] == '/') { +#if ENABLE_FEATURE_AR_LONG_FILENAMES + unsigned long_offset; + + if (ar.formatted.name[1] == '/') { + /* If the second char is a '/' then this entries data section + * stores long filename for multiple entries, they are stored + * in static variable long_names for use in future entries */ + ar_long_name_size = typed->size; + ar_long_names = xmalloc(ar_long_name_size); + xread(archive_handle->src_fd, ar_long_names, ar_long_name_size); + archive_handle->offset += ar_long_name_size; + /* This ar entries data section only contained filenames for other records + * they are stored in the static ar_long_names for future reference */ + return get_header_ar(archive_handle); /* Return next header */ + } + + if (ar.formatted.name[1] == ' ') { + /* This is the index of symbols in the file for compilers */ + data_skip(archive_handle); + archive_handle->offset += typed->size; + return get_header_ar(archive_handle); /* Return next header */ + } + + /* The number after the '/' indicates the offset in the ar data section + * (saved in variable long_name) that conatains the real filename */ + long_offset = atoi(&ar.formatted.name[1]); + if (long_offset >= ar_long_name_size) { + bb_error_msg_and_die("can't resolve long filename"); + } + typed->name = xstrdup(ar_long_names + long_offset); +#else + bb_error_msg_and_die("long filenames not supported"); +#endif + } else { + /* short filenames */ + typed->name = xstrndup(ar.formatted.name, 16); + } + + typed->name[strcspn(typed->name, " /")] = '\0'; + + if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) { + archive_handle->action_header(typed); + if (archive_handle->sub_archive) { + while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS) + /* repeat */; + } else { + archive_handle->action_data(archive_handle); + } + } else { + data_skip(archive_handle); + } + + archive_handle->offset += typed->size; + /* Set the file pointer to the correct spot, we may have been reading a compressed file */ + lseek(archive_handle->src_fd, archive_handle->offset, SEEK_SET); + + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_cpio.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_cpio.c new file mode 100644 index 0000000..6fd1340 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_cpio.c @@ -0,0 +1,160 @@ +/* vi: set sw=4 ts=4: */ +/* Copyright 2002 Laurence Anderson + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "libbb.h" +#include "unarchive.h" + +typedef struct hardlinks_s { + char *name; + int inode; + struct hardlinks_s *next; +} hardlinks_t; + +char get_header_cpio(archive_handle_t *archive_handle) +{ + static hardlinks_t *saved_hardlinks = NULL; + static unsigned short pending_hardlinks = 0; + static int inode; + file_header_t *file_header = archive_handle->file_header; + char cpio_header[110]; + int namesize; + char dummy[16]; + int major, minor, nlink; + + if (pending_hardlinks) { /* Deal with any pending hardlinks */ + hardlinks_t *tmp, *oldtmp; + + tmp = saved_hardlinks; + oldtmp = NULL; + + file_header->link_name = file_header->name; + file_header->size = 0; + + while (tmp) { + if (tmp->inode != inode) { + tmp = tmp->next; + continue; + } + + file_header->name = tmp->name; + + if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) { + archive_handle->action_data(archive_handle); + archive_handle->action_header(archive_handle->file_header); + } + + pending_hardlinks--; + + oldtmp = tmp; + tmp = tmp->next; + free(oldtmp->name); + free(oldtmp); + if (oldtmp == saved_hardlinks) + saved_hardlinks = tmp; + } + + file_header->name = file_header->link_name; + + if (pending_hardlinks > 1) { + bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?"); + } + + /* No more pending hardlinks, read next file entry */ + pending_hardlinks = 0; + } + + /* There can be padding before archive header */ + data_align(archive_handle, 4); + + if (archive_xread_all_eof(archive_handle, (unsigned char*)cpio_header, 110) == 0) { + return EXIT_FAILURE; + } + archive_handle->offset += 110; + + if (strncmp(&cpio_header[0], "07070", 5) != 0 + || (cpio_header[5] != '1' && cpio_header[5] != '2') + ) { + bb_error_msg_and_die("unsupported cpio format, use newc or crc"); + } + + { + unsigned long tmpsize; + sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c", + dummy, &inode, (unsigned int*)&file_header->mode, + (unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid, + &nlink, &file_header->mtime, &tmpsize, + dummy, &major, &minor, &namesize, dummy); + file_header->size = tmpsize; + } + + free(file_header->name); + file_header->name = xzalloc(namesize + 1); + /* Read in filename */ + xread(archive_handle->src_fd, file_header->name, namesize); + archive_handle->offset += namesize; + + /* Update offset amount and skip padding before file contents */ + data_align(archive_handle, 4); + + if (strcmp(file_header->name, "TRAILER!!!") == 0) { + /* Always round up */ + printf("%d blocks\n", (int) (archive_handle->offset % 512 ? + archive_handle->offset / 512 + 1 : + archive_handle->offset / 512 + )); + if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */ + hardlinks_t *tmp = saved_hardlinks; + hardlinks_t *oldtmp = NULL; + while (tmp) { + bb_error_msg("%s not created: cannot resolve hardlink", tmp->name); + oldtmp = tmp; + tmp = tmp->next; + free(oldtmp->name); + free(oldtmp); + } + saved_hardlinks = NULL; + pending_hardlinks = 0; + } + return EXIT_FAILURE; + } + + if (S_ISLNK(file_header->mode)) { + file_header->link_name = xzalloc(file_header->size + 1); + xread(archive_handle->src_fd, file_header->link_name, file_header->size); + archive_handle->offset += file_header->size; + file_header->size = 0; /* Stop possible seeks in future */ + } else { + file_header->link_name = NULL; + } + if (nlink > 1 && !S_ISDIR(file_header->mode)) { + if (file_header->size == 0) { /* Put file on a linked list for later */ + hardlinks_t *new = xmalloc(sizeof(hardlinks_t)); + new->next = saved_hardlinks; + new->inode = inode; + /* name current allocated, freed later */ + new->name = file_header->name; + file_header->name = NULL; + saved_hardlinks = new; + return EXIT_SUCCESS; /* Skip this one */ + } + /* Found the file with data in */ + pending_hardlinks = nlink; + } + file_header->device = makedev(major, minor); + + if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) { + archive_handle->action_data(archive_handle); + archive_handle->action_header(archive_handle->file_header); + } else { + data_skip(archive_handle); + } + + archive_handle->offset += file_header->size; + + free(file_header->link_name); + + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar.c new file mode 100644 index 0000000..b3efdec --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar.c @@ -0,0 +1,284 @@ +/* vi: set sw=4 ts=4: */ +/* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * + * FIXME: + * In privileged mode if uname and gname map to a uid and gid then use the + * mapped value instead of the uid/gid values in tar header + * + * References: + * GNU tar and star man pages, + * Opengroup's ustar interchange format, + * http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html + */ + +#include "libbb.h" +#include "unarchive.h" + +#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS +static char *longname; +static char *linkname; +#else +enum { + longname = 0, + linkname = 0, +}; +#endif + +/* NB: _DESTROYS_ str[len] character! */ +static unsigned long long getOctal(char *str, int len) +{ + unsigned long long v; + /* Actually, tar header allows leading spaces also. + * Oh well, we will be liberal and skip this... + * The only downside probably is that we allow "-123" too :) + if (*str < '0' || *str > '7') + bb_error_msg_and_die("corrupted octal value in tar header"); + */ + str[len] = '\0'; + v = strtoull(str, &str, 8); + if (*str) + bb_error_msg_and_die("corrupted octal value in tar header"); + return v; +} +#define GET_OCTAL(a) getOctal((a), sizeof(a)) + +void BUG_tar_header_size(void); +char get_header_tar(archive_handle_t *archive_handle) +{ + static int end; + + file_header_t *file_header = archive_handle->file_header; + struct { + /* ustar header, Posix 1003.1 */ + char name[100]; /* 0-99 */ + char mode[8]; /* 100-107 */ + char uid[8]; /* 108-115 */ + char gid[8]; /* 116-123 */ + char size[12]; /* 124-135 */ + char mtime[12]; /* 136-147 */ + char chksum[8]; /* 148-155 */ + char typeflag; /* 156-156 */ + char linkname[100]; /* 157-256 */ + char magic[6]; /* 257-262 */ + char version[2]; /* 263-264 */ + char uname[32]; /* 265-296 */ + char gname[32]; /* 297-328 */ + char devmajor[8]; /* 329-336 */ + char devminor[8]; /* 337-344 */ + char prefix[155]; /* 345-499 */ + char padding[12]; /* 500-512 */ + } tar; + char *cp; + int i, sum_u, sum_s, sum; + int parse_names; + + if (sizeof(tar) != 512) + BUG_tar_header_size(); + +#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS + again: +#endif + /* Align header */ + data_align(archive_handle, 512); + + again_after_align: + + xread(archive_handle->src_fd, &tar, 512); + archive_handle->offset += 512; + + /* If there is no filename its an empty header */ + if (tar.name[0] == 0) { + if (end) { + /* This is the second consecutive empty header! End of archive! + * Read until the end to empty the pipe from gz or bz2 + */ + while (full_read(archive_handle->src_fd, &tar, 512) == 512) + /* repeat */; + return EXIT_FAILURE; + } + end = 1; + return EXIT_SUCCESS; + } + end = 0; + + /* Check header has valid magic, "ustar" is for the proper tar + * 0's are for the old tar format + */ + if (strncmp(tar.magic, "ustar", 5) != 0) { +#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY + if (memcmp(tar.magic, "\0\0\0\0", 5) != 0) +#endif + bb_error_msg_and_die("invalid tar magic"); + } + + /* Do checksum on headers. + * POSIX says that checksum is done on unsigned bytes, but + * Sun and HP-UX gets it wrong... more details in + * GNU tar source. */ + sum_s = sum_u = ' ' * sizeof(tar.chksum); + for (i = 0; i < 148 ; i++) { + sum_u += ((unsigned char*)&tar)[i]; + sum_s += ((signed char*)&tar)[i]; + } + for (i = 156; i < 512 ; i++) { + sum_u += ((unsigned char*)&tar)[i]; + sum_s += ((signed char*)&tar)[i]; + } + /* This field does not need special treatment (getOctal) */ + sum = xstrtoul(tar.chksum, 8); + if (sum_u != sum && sum_s != sum) { + bb_error_msg_and_die("invalid tar header checksum"); + } + + /* 0 is reserved for high perf file, treat as normal file */ + if (!tar.typeflag) tar.typeflag = '0'; + parse_names = (tar.typeflag >= '0' && tar.typeflag <= '7'); + + /* getOctal trashes subsequent field, therefore we call it + * on fields in reverse order */ + if (tar.devmajor[0]) { + unsigned minor = GET_OCTAL(tar.devminor); + unsigned major = GET_OCTAL(tar.devmajor); + file_header->device = makedev(major, minor); + } + file_header->link_name = NULL; + if (!linkname && parse_names && tar.linkname[0]) { + /* we trash magic[0] here, it's ok */ + tar.linkname[sizeof(tar.linkname)] = '\0'; + file_header->link_name = xstrdup(tar.linkname); + /* FIXME: what if we have non-link object with link_name? */ + /* Will link_name be free()ed? */ + } + file_header->mtime = GET_OCTAL(tar.mtime); + file_header->size = GET_OCTAL(tar.size); + file_header->gid = GET_OCTAL(tar.gid); + file_header->uid = GET_OCTAL(tar.uid); + /* Set bits 0-11 of the files mode */ + file_header->mode = 07777 & GET_OCTAL(tar.mode); + + file_header->name = NULL; + if (!longname && parse_names) { + /* we trash mode[0] here, it's ok */ + tar.name[sizeof(tar.name)] = '\0'; + if (tar.prefix[0]) { + /* and padding[0] */ + tar.prefix[sizeof(tar.prefix)] = '\0'; + file_header->name = concat_path_file(tar.prefix, tar.name); + } else + file_header->name = xstrdup(tar.name); + } + + /* Set bits 12-15 of the files mode */ + /* (typeflag was not trashed because chksum does not use getOctal) */ + switch (tar.typeflag) { + /* busybox identifies hard links as being regular files with 0 size and a link name */ + case '1': + file_header->mode |= S_IFREG; + break; + case '7': + /* case 0: */ + case '0': +#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY + if (last_char_is(file_header->name, '/')) { + file_header->mode |= S_IFDIR; + } else +#endif + file_header->mode |= S_IFREG; + break; + case '2': + file_header->mode |= S_IFLNK; + break; + case '3': + file_header->mode |= S_IFCHR; + break; + case '4': + file_header->mode |= S_IFBLK; + break; + case '5': + file_header->mode |= S_IFDIR; + break; + case '6': + file_header->mode |= S_IFIFO; + break; +#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS + case 'L': + /* free: paranoia: tar with several consecutive longnames */ + free(longname); + /* For paranoia reasons we allocate extra NUL char */ + longname = xzalloc(file_header->size + 1); + /* We read ASCIZ string, including NUL */ + xread(archive_handle->src_fd, longname, file_header->size); + archive_handle->offset += file_header->size; + /* return get_header_tar(archive_handle); */ + /* gcc 4.1.1 didn't optimize it into jump */ + /* so we will do it ourself, this also saves stack */ + goto again; + case 'K': + free(linkname); + linkname = xzalloc(file_header->size + 1); + xread(archive_handle->src_fd, linkname, file_header->size); + archive_handle->offset += file_header->size; + /* return get_header_tar(archive_handle); */ + goto again; + case 'D': /* GNU dump dir */ + case 'M': /* Continuation of multi volume archive */ + case 'N': /* Old GNU for names > 100 characters */ + case 'S': /* Sparse file */ + case 'V': /* Volume header */ +#endif + case 'g': /* pax global header */ + case 'x': { /* pax extended header */ + off_t sz; + bb_error_msg("warning: skipping header '%c'", tar.typeflag); + sz = (file_header->size + 511) & ~(off_t)511; + archive_handle->offset += sz; + sz >>= 9; /* sz /= 512 but w/o contortions for signed div */ + while (sz--) + xread(archive_handle->src_fd, &tar, 512); + /* return get_header_tar(archive_handle); */ + goto again_after_align; + } + default: + bb_error_msg_and_die("unknown typeflag: 0x%x", tar.typeflag); + } + +#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS + if (longname) { + file_header->name = longname; + longname = NULL; + } + if (linkname) { + file_header->link_name = linkname; + linkname = NULL; + } +#endif + if (!strncmp(file_header->name, "/../"+1, 3) + || strstr(file_header->name, "/../") + ) { + bb_error_msg_and_die("name with '..' encountered: '%s'", + file_header->name); + } + + /* Strip trailing '/' in directories */ + /* Must be done after mode is set as '/' is used to check if it's a directory */ + cp = last_char_is(file_header->name, '/'); + + if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) { + archive_handle->action_header(archive_handle->file_header); + /* Note that we kill the '/' only after action_header() */ + /* (like GNU tar 1.15.1: verbose mode outputs "dir/dir/") */ + if (cp) *cp = '\0'; + archive_handle->flags |= ARCHIVE_EXTRACT_QUIET; + archive_handle->action_data(archive_handle); + llist_add_to(&(archive_handle->passed), file_header->name); + } else { + data_skip(archive_handle); + free(file_header->name); + } + archive_handle->offset += file_header->size; + + free(file_header->link_name); + /* Do not free(file_header->name)! */ + + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_bz2.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_bz2.c new file mode 100644 index 0000000..d8715c0 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_bz2.c @@ -0,0 +1,20 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "libbb.h" +#include "unarchive.h" + +char get_header_tar_bz2(archive_handle_t *archive_handle) +{ + /* Can't lseek over pipes */ + archive_handle->seek = seek_by_read; + + archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompressStream); + archive_handle->offset = 0; + while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/; + + /* Can only do one file at a time */ + return EXIT_FAILURE; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_gz.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_gz.c new file mode 100644 index 0000000..1f07e4e --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_gz.c @@ -0,0 +1,31 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include + +#include "libbb.h" +#include "unarchive.h" + +char get_header_tar_gz(archive_handle_t *archive_handle) +{ + unsigned char magic[2]; + + /* Can't lseek over pipes */ + archive_handle->seek = seek_by_read; + + xread(archive_handle->src_fd, &magic, 2); + if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { + bb_error_msg_and_die("invalid gzip magic"); + } + + check_header_gzip_or_die(archive_handle->src_fd); + + archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip); + archive_handle->offset = 0; + while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/; + + /* Can only do one file at a time */ + return EXIT_FAILURE; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_lzma.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_lzma.c new file mode 100644 index 0000000..06b8daa --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/get_header_tar_lzma.c @@ -0,0 +1,22 @@ +/* vi: set sw=4 ts=4: */ +/* + * Small lzma deflate implementation. + * Copyright (C) 2006 Aurelien Jacobs + * + * Licensed under GPL v2, see file LICENSE in this tarball for details. + */ + +#include "unarchive.h" + +char get_header_tar_lzma(archive_handle_t * archive_handle) +{ + /* Can't lseek over pipes */ + archive_handle->seek = seek_by_read; + + archive_handle->src_fd = open_transformer(archive_handle->src_fd, unlzma); + archive_handle->offset = 0; + while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/; + + /* Can only do one file at a time */ + return EXIT_FAILURE; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/header_list.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/header_list.c new file mode 100644 index 0000000..fb461a6 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/header_list.c @@ -0,0 +1,11 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ +#include +#include "unarchive.h" + +void header_list(const file_header_t *file_header) +{ + puts(file_header->name); +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/header_skip.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/header_skip.c new file mode 100644 index 0000000..53242e0 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/header_skip.c @@ -0,0 +1,10 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ +#include +#include "unarchive.h" + +void header_skip(const file_header_t *file_header ATTRIBUTE_UNUSED) +{ +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/header_verbose_list.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/header_verbose_list.c new file mode 100644 index 0000000..7b97e52 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/header_verbose_list.c @@ -0,0 +1,31 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "libbb.h" +#include "unarchive.h" + +void header_verbose_list(const file_header_t *file_header) +{ + struct tm *mtime = localtime(&(file_header->mtime)); + + printf("%s %d/%d %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s", + bb_mode_string(file_header->mode), + file_header->uid, + file_header->gid, + file_header->size, + 1900 + mtime->tm_year, + 1 + mtime->tm_mon, + mtime->tm_mday, + mtime->tm_hour, + mtime->tm_min, + mtime->tm_sec, + file_header->name); + + if (file_header->link_name) { + printf(" -> %s", file_header->link_name); + } + /* putchar isnt used anywhere else i dont think */ + puts(""); +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/init_handle.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/init_handle.c new file mode 100644 index 0000000..309d329 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/init_handle.c @@ -0,0 +1,22 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "libbb.h" +#include "unarchive.h" + +archive_handle_t *init_handle(void) +{ + archive_handle_t *archive_handle; + + /* Initialize default values */ + archive_handle = xzalloc(sizeof(archive_handle_t)); + archive_handle->file_header = xzalloc(sizeof(file_header_t)); + archive_handle->action_header = header_skip; + archive_handle->action_data = data_skip; + archive_handle->filter = filter_accept_all; + archive_handle->seek = seek_by_jump; + + return archive_handle; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/open_transformer.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/open_transformer.c new file mode 100644 index 0000000..456d3e9 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/open_transformer.c @@ -0,0 +1,44 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include +#include + +#include "libbb.h" + +#include "unarchive.h" + +/* transformer(), more than meets the eye */ +int open_transformer(int src_fd, + USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd)) +{ + int fd_pipe[2]; + int pid; + + if (pipe(fd_pipe) != 0) { + bb_perror_msg_and_die("can't create pipe"); + } + + pid = fork(); + if (pid == -1) { + bb_perror_msg_and_die("fork failed"); + } + + if (pid == 0) { + /* child process */ + close(fd_pipe[0]); /* We don't wan't to read from the parent */ + // FIXME: error check? + transformer(src_fd, fd_pipe[1]); + close(fd_pipe[1]); /* Send EOF */ + close(src_fd); + exit(0); + /* notreached */ + } + + /* parent process */ + close(fd_pipe[1]); /* Don't want to write to the child */ + + return fd_pipe[0]; +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/seek_by_jump.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/seek_by_jump.c new file mode 100644 index 0000000..d605f61 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/seek_by_jump.c @@ -0,0 +1,24 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include +#include +#include +#include + +#include "libbb.h" +#include "unarchive.h" + +void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount) +{ + if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) { +#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE + if (errno == ESPIPE) { + seek_by_read(archive_handle, amount); + } else +#endif + bb_perror_msg_and_die("seek failure"); + } +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/seek_by_read.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/seek_by_read.c new file mode 100644 index 0000000..e46af48 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/seek_by_read.c @@ -0,0 +1,18 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include + +#include "unarchive.h" +#include "libbb.h" + +/* If we are reading through a pipe(), or from stdin then we can't lseek, + * we must read and discard the data to skip over it. + */ +void seek_by_read(const archive_handle_t *archive_handle, const unsigned int jump_size) +{ + if (jump_size) + bb_copyfd_exact_size(archive_handle->src_fd, -1, jump_size); +} diff --git a/i/pc104/initrd/conf/busybox/archival/libunarchive/unpack_ar_archive.c b/i/pc104/initrd/conf/busybox/archival/libunarchive/unpack_ar_archive.c new file mode 100644 index 0000000..6a84ae8 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/libunarchive/unpack_ar_archive.c @@ -0,0 +1,22 @@ +/* vi: set sw=4 ts=4: */ +/* + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ +#include +#include +#include +#include "unarchive.h" +#include "libbb.h" + +void unpack_ar_archive(archive_handle_t *ar_archive) +{ + char magic[7]; + + xread(ar_archive->src_fd, magic, 7); + if (strncmp(magic, "!", 7) != 0) { + bb_error_msg_and_die("invalid ar magic"); + } + ar_archive->offset += 7; + + while (get_header_ar(ar_archive) == EXIT_SUCCESS); +} diff --git a/i/pc104/initrd/conf/busybox/archival/rpm.c b/i/pc104/initrd/conf/busybox/archival/rpm.c new file mode 100644 index 0000000..a48dda3 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/rpm.c @@ -0,0 +1,367 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini rpm applet for busybox + * + * Copyright (C) 2001,2002 by Laurence Anderson + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "busybox.h" +#include "unarchive.h" + +#define RPM_HEADER_MAGIC "\216\255\350" +#define RPM_CHAR_TYPE 1 +#define RPM_INT8_TYPE 2 +#define RPM_INT16_TYPE 3 +#define RPM_INT32_TYPE 4 +/* #define RPM_INT64_TYPE 5 ---- These aren't supported (yet) */ +#define RPM_STRING_TYPE 6 +#define RPM_BIN_TYPE 7 +#define RPM_STRING_ARRAY_TYPE 8 +#define RPM_I18NSTRING_TYPE 9 + +#define TAG_NAME 1000 +#define TAG_VERSION 1001 +#define TAG_RELEASE 1002 +#define TAG_SUMMARY 1004 +#define TAG_DESCRIPTION 1005 +#define TAG_BUILDTIME 1006 +#define TAG_BUILDHOST 1007 +#define TAG_SIZE 1009 +#define TAG_VENDOR 1011 +#define TAG_LICENSE 1014 +#define TAG_PACKAGER 1015 +#define TAG_GROUP 1016 +#define TAG_URL 1020 +#define TAG_PREIN 1023 +#define TAG_POSTIN 1024 +#define TAG_FILEFLAGS 1037 +#define TAG_FILEUSERNAME 1039 +#define TAG_FILEGROUPNAME 1040 +#define TAG_SOURCERPM 1044 +#define TAG_PREINPROG 1085 +#define TAG_POSTINPROG 1086 +#define TAG_PREFIXS 1098 +#define TAG_DIRINDEXES 1116 +#define TAG_BASENAMES 1117 +#define TAG_DIRNAMES 1118 +#define RPMFILE_CONFIG (1 << 0) +#define RPMFILE_DOC (1 << 1) + +enum rpm_functions_e { + rpm_query = 1, + rpm_install = 2, + rpm_query_info = 4, + rpm_query_package = 8, + rpm_query_list = 16, + rpm_query_list_doc = 32, + rpm_query_list_config = 64 +}; + +typedef struct { + uint32_t tag; /* 4 byte tag */ + uint32_t type; /* 4 byte type */ + uint32_t offset; /* 4 byte offset */ + uint32_t count; /* 4 byte count */ +} rpm_index; + +static void *map; +static rpm_index **mytags; +static int tagcount; + +static void extract_cpio_gz(int fd); +static rpm_index **rpm_gettags(int fd, int *num_tags); +static int bsearch_rpmtag(const void *key, const void *item); +static char *rpm_getstr(int tag, int itemindex); +static int rpm_getint(int tag, int itemindex); +static int rpm_getcount(int tag); +static void fileaction_dobackup(char *filename, int fileref); +static void fileaction_setowngrp(char *filename, int fileref); +static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref)); + +int rpm_main(int argc, char **argv); +int rpm_main(int argc, char **argv) +{ + int opt = 0, func = 0, rpm_fd, offset; + const int pagesize = getpagesize(); + + while ((opt = getopt(argc, argv, "iqpldc")) != -1) { + switch (opt) { + case 'i': /* First arg: Install mode, with q: Information */ + if (!func) func = rpm_install; + else func |= rpm_query_info; + break; + case 'q': /* First arg: Query mode */ + if (func) bb_show_usage(); + func = rpm_query; + break; + case 'p': /* Query a package */ + func |= rpm_query_package; + break; + case 'l': /* List files in a package */ + func |= rpm_query_list; + break; + case 'd': /* List doc files in a package (implies list) */ + func |= rpm_query_list; + func |= rpm_query_list_doc; + break; + case 'c': /* List config files in a package (implies list) */ + func |= rpm_query_list; + func |= rpm_query_list_config; + break; + default: + bb_show_usage(); + } + } + argv += optind; + argc -= optind; + if (!argc) bb_show_usage(); + + while (*argv) { + rpm_fd = xopen(*argv++, O_RDONLY); + mytags = rpm_gettags(rpm_fd, &tagcount); + if (!mytags) + bb_error_msg_and_die("error reading rpm header"); + offset = xlseek(rpm_fd, 0, SEEK_CUR); + /* Mimimum is one page */ + map = mmap(0, offset > pagesize ? (offset + offset % pagesize) : pagesize, PROT_READ, MAP_PRIVATE, rpm_fd, 0); + + if (func & rpm_install) { + /* Backup any config files */ + loop_through_files(TAG_BASENAMES, fileaction_dobackup); + /* Extact the archive */ + extract_cpio_gz(rpm_fd); + /* Set the correct file uid/gid's */ + loop_through_files(TAG_BASENAMES, fileaction_setowngrp); + } + else if ((func & (rpm_query|rpm_query_package)) == (rpm_query|rpm_query_package)) { + if (!(func & (rpm_query_info|rpm_query_list))) { + /* If just a straight query, just give package name */ + printf("%s-%s-%s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_RELEASE, 0)); + } + if (func & rpm_query_info) { + /* Do the nice printout */ + time_t bdate_time; + struct tm *bdate; + char bdatestring[50]; + printf("Name : %-29sRelocations: %s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_PREFIXS, 0) ? rpm_getstr(TAG_PREFIXS, 0) : "(not relocateable)"); + printf("Version : %-34sVendor: %s\n", rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_VENDOR, 0) ? rpm_getstr(TAG_VENDOR, 0) : "(none)"); + bdate_time = rpm_getint(TAG_BUILDTIME, 0); + bdate = localtime((time_t *) &bdate_time); + strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate); + printf("Release : %-30sBuild Date: %s\n", rpm_getstr(TAG_RELEASE, 0), bdatestring); + printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstr(TAG_BUILDHOST, 0)); + printf("Group : %-30sSource RPM: %s\n", rpm_getstr(TAG_GROUP, 0), rpm_getstr(TAG_SOURCERPM, 0)); + printf("Size : %-33dLicense: %s\n", rpm_getint(TAG_SIZE, 0), rpm_getstr(TAG_LICENSE, 0)); + printf("URL : %s\n", rpm_getstr(TAG_URL, 0)); + printf("Summary : %s\n", rpm_getstr(TAG_SUMMARY, 0)); + printf("Description :\n%s\n", rpm_getstr(TAG_DESCRIPTION, 0)); + } + if (func & rpm_query_list) { + int count, it, flags; + count = rpm_getcount(TAG_BASENAMES); + for (it = 0; it < count; it++) { + flags = rpm_getint(TAG_FILEFLAGS, it); + switch (func & (rpm_query_list_doc|rpm_query_list_config)) { + case rpm_query_list_doc: + if (!(flags & RPMFILE_DOC)) continue; + break; + case rpm_query_list_config: + if (!(flags & RPMFILE_CONFIG)) continue; + break; + case rpm_query_list_doc|rpm_query_list_config: + if (!(flags & (RPMFILE_CONFIG|RPMFILE_DOC))) continue; + break; + } + printf("%s%s\n", + rpm_getstr(TAG_DIRNAMES, rpm_getint(TAG_DIRINDEXES, it)), + rpm_getstr(TAG_BASENAMES, it)); + } + } + } + free(mytags); + } + return 0; +} + +static void extract_cpio_gz(int fd) { + archive_handle_t *archive_handle; + unsigned char magic[2]; + + /* Initialise */ + archive_handle = init_handle(); + archive_handle->seek = seek_by_read; + //archive_handle->action_header = header_list; + archive_handle->action_data = data_extract_all; + archive_handle->flags |= ARCHIVE_PRESERVE_DATE; + archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS; + archive_handle->src_fd = fd; + archive_handle->offset = 0; + + xread(archive_handle->src_fd, &magic, 2); + if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { + bb_error_msg_and_die("invalid gzip magic"); + } + check_header_gzip_or_die(archive_handle->src_fd); + xchdir("/"); /* Install RPM's to root */ + + archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip); + archive_handle->offset = 0; + while (get_header_cpio(archive_handle) == EXIT_SUCCESS) + /* loop */; +} + + +static rpm_index **rpm_gettags(int fd, int *num_tags) +{ + /* We should never need mode than 200, and realloc later */ + rpm_index **tags = xzalloc(200 * sizeof(struct rpmtag *)); + int pass, tagindex = 0; + + xlseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */ + + /* 1st pass is the signature headers, 2nd is the main stuff */ + for (pass = 0; pass < 2; pass++) { + struct { + char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */ + uint8_t version; /* 1 byte version number */ + uint32_t reserved; /* 4 bytes reserved */ + uint32_t entries; /* Number of entries in header (4 bytes) */ + uint32_t size; /* Size of store (4 bytes) */ + } header; + rpm_index *tmpindex; + int storepos; + + xread(fd, &header, sizeof(header)); + if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) + return NULL; /* Invalid magic */ + if (header.version != 1) + return NULL; /* This program only supports v1 headers */ + header.size = ntohl(header.size); + header.entries = ntohl(header.entries); + storepos = xlseek(fd,0,SEEK_CUR) + header.entries * 16; + + while (header.entries--) { + tmpindex = tags[tagindex++] = xmalloc(sizeof(rpm_index)); + xread(fd, tmpindex, sizeof(rpm_index)); + tmpindex->tag = ntohl(tmpindex->tag); + tmpindex->type = ntohl(tmpindex->type); + tmpindex->count = ntohl(tmpindex->count); + tmpindex->offset = storepos + ntohl(tmpindex->offset); + if (pass==0) + tmpindex->tag -= 743; + } + xlseek(fd, header.size, SEEK_CUR); /* Seek past store */ + /* Skip padding to 8 byte boundary after reading signature headers */ + if (pass==0) + xlseek(fd, (8 - (xlseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR); + } + tags = xrealloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */ + *num_tags = tagindex; + return tags; /* All done, leave the file at the start of the gzipped cpio archive */ +} + +static int bsearch_rpmtag(const void *key, const void *item) +{ + int *tag = (int *)key; + rpm_index **tmp = (rpm_index **) item; + return (*tag - tmp[0]->tag); +} + +static int rpm_getcount(int tag) +{ + rpm_index **found; + found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag); + if (!found) + return 0; + return found[0]->count; +} + +static char *rpm_getstr(int tag, int itemindex) +{ + rpm_index **found; + found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag); + if (!found || itemindex >= found[0]->count) + return NULL; + if (found[0]->type == RPM_STRING_TYPE || found[0]->type == RPM_I18NSTRING_TYPE || found[0]->type == RPM_STRING_ARRAY_TYPE) { + int n; + char *tmpstr = (char *) (map + found[0]->offset); + for (n=0; n < itemindex; n++) + tmpstr = tmpstr + strlen(tmpstr) + 1; + return tmpstr; + } + return NULL; +} + +static int rpm_getint(int tag, int itemindex) +{ + rpm_index **found; + int *tmpint; /* NB: using int8_t* would be easier to code */ + + /* gcc throws warnings here when sizeof(void*)!=sizeof(int) ... + * it's ok to ignore it because tag won't be used as a pointer */ + found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag); + if (!found || itemindex >= found[0]->count) + return -1; + + tmpint = (int *) (map + found[0]->offset); + + if (found[0]->type == RPM_INT32_TYPE) { + tmpint = (int *) ((char *) tmpint + itemindex*4); + /*return ntohl(*tmpint);*/ + /* int can be != int32_t */ + return ntohl(*(int32_t*)tmpint); + } + if (found[0]->type == RPM_INT16_TYPE) { + tmpint = (int *) ((char *) tmpint + itemindex*2); + /* ??? read int, and THEN ntohs() it?? */ + /*return ntohs(*tmpint);*/ + return ntohs(*(int16_t*)tmpint); + } + if (found[0]->type == RPM_INT8_TYPE) { + tmpint = (int *) ((char *) tmpint + itemindex); + /* ??? why we don't read byte here??? */ + /*return ntohs(*tmpint);*/ + return *(int8_t*)tmpint; + } + return -1; +} + +static void fileaction_dobackup(char *filename, int fileref) +{ + struct stat oldfile; + int stat_res; + char *newname; + if (rpm_getint(TAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { + /* Only need to backup config files */ + stat_res = lstat(filename, &oldfile); + if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { + /* File already exists - really should check MD5's etc to see if different */ + newname = xasprintf("%s.rpmorig", filename); + copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS); + remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE); + free(newname); + } + } +} + +static void fileaction_setowngrp(char *filename, int fileref) +{ + int uid, gid; + uid = xuname2uid(rpm_getstr(TAG_FILEUSERNAME, fileref)); + gid = xgroup2gid(rpm_getstr(TAG_FILEGROUPNAME, fileref)); + chown(filename, uid, gid); +} + +static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref)) +{ + int count = 0; + while (rpm_getstr(filetag, count)) { + char* filename = xasprintf("%s%s", + rpm_getstr(TAG_DIRNAMES, rpm_getint(TAG_DIRINDEXES, count)), + rpm_getstr(TAG_BASENAMES, count)); + fileaction(filename, count++); + free(filename); + } +} diff --git a/i/pc104/initrd/conf/busybox/archival/rpm2cpio.c b/i/pc104/initrd/conf/busybox/archival/rpm2cpio.c new file mode 100644 index 0000000..307d1a0 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/rpm2cpio.c @@ -0,0 +1,90 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini rpm2cpio implementation for busybox + * + * Copyright (C) 2001 by Laurence Anderson + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ +#include "busybox.h" +#include "unarchive.h" + +#define RPM_MAGIC "\355\253\356\333" +#define RPM_HEADER_MAGIC "\216\255\350" + +struct rpm_lead { + unsigned char magic[4]; + uint8_t major, minor; + uint16_t type; + uint16_t archnum; + char name[66]; + uint16_t osnum; + uint16_t signature_type; + char reserved[16]; +}; + +struct rpm_header { + char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */ + uint8_t version; /* 1 byte version number */ + uint32_t reserved; /* 4 bytes reserved */ + uint32_t entries; /* Number of entries in header (4 bytes) */ + uint32_t size; /* Size of store (4 bytes) */ +}; + +static void skip_header(int rpm_fd) +{ + struct rpm_header header; + + xread(rpm_fd, &header, sizeof(struct rpm_header)); + if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) { + bb_error_msg_and_die("invalid RPM header magic"); /* Invalid magic */ + } + if (header.version != 1) { + bb_error_msg_and_die("unsupported RPM header version"); /* This program only supports v1 headers */ + } + header.entries = ntohl(header.entries); + header.size = ntohl(header.size); + lseek (rpm_fd, 16 * header.entries, SEEK_CUR); /* Seek past index entries */ + lseek (rpm_fd, header.size, SEEK_CUR); /* Seek past store */ +} + +/* No getopt required */ +int rpm2cpio_main(int argc, char **argv); +int rpm2cpio_main(int argc, char **argv) +{ + struct rpm_lead lead; + int rpm_fd; + unsigned char magic[2]; + + if (argc == 1) { + rpm_fd = STDIN_FILENO; + } else { + rpm_fd = xopen(argv[1], O_RDONLY); + } + + xread(rpm_fd, &lead, sizeof(struct rpm_lead)); + if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) { + bb_error_msg_and_die("invalid RPM magic"); /* Just check the magic, the rest is irrelevant */ + } + + /* Skip the signature header */ + skip_header(rpm_fd); + lseek(rpm_fd, (8 - (lseek(rpm_fd, 0, SEEK_CUR) % 8)) % 8, SEEK_CUR); + + /* Skip the main header */ + skip_header(rpm_fd); + + xread(rpm_fd, &magic, 2); + if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { + bb_error_msg_and_die("invalid gzip magic"); + } + + check_header_gzip_or_die(rpm_fd); + if (inflate_gunzip(rpm_fd, STDOUT_FILENO) < 0) { + bb_error_msg("error inflating"); + } + + close(rpm_fd); + + return 0; +} diff --git a/i/pc104/initrd/conf/busybox/archival/tar.c b/i/pc104/initrd/conf/busybox/archival/tar.c new file mode 100644 index 0000000..176a7e2 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/tar.c @@ -0,0 +1,939 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini tar implementation for busybox + * + * Modified to use common extraction code used by ar, cpio, dpkg-deb, dpkg + * Glenn McGrath + * + * Note, that as of BusyBox-0.43, tar has been completely rewritten from the + * ground up. It still has remnants of the old code lying about, but it is + * very different now (i.e., cleaner, less global variables, etc.) + * + * Copyright (C) 1999-2004 by Erik Andersen + * + * Based in part in the tar implementation in sash + * Copyright (c) 1999 by David I. Bell + * Permission is granted to use, distribute, or modify this source, + * provided that this copyright notice remains intact. + * Permission to distribute sash derived code under the GPL has been granted. + * + * Based in part on the tar implementation from busybox-0.28 + * Copyright (C) 1995 Bruce Perens + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include +#include +#include "busybox.h" +#include "unarchive.h" + +#if ENABLE_FEATURE_TAR_CREATE + +/* Tar file constants */ + +#define TAR_BLOCK_SIZE 512 + +/* POSIX tar Header Block, from POSIX 1003.1-1990 */ +#define NAME_SIZE 100 +#define NAME_SIZE_STR "100" +typedef struct TarHeader TarHeader; +struct TarHeader { /* byte offset */ + char name[NAME_SIZE]; /* 0-99 */ + char mode[8]; /* 100-107 */ + char uid[8]; /* 108-115 */ + char gid[8]; /* 116-123 */ + char size[12]; /* 124-135 */ + char mtime[12]; /* 136-147 */ + char chksum[8]; /* 148-155 */ + char typeflag; /* 156-156 */ + char linkname[NAME_SIZE]; /* 157-256 */ + char magic[6]; /* 257-262 */ + char version[2]; /* 263-264 */ + char uname[32]; /* 265-296 */ + char gname[32]; /* 297-328 */ + char devmajor[8]; /* 329-336 */ + char devminor[8]; /* 337-344 */ + char prefix[155]; /* 345-499 */ + char padding[12]; /* 500-512 (pad to exactly the TAR_BLOCK_SIZE) */ +}; + +/* +** writeTarFile(), writeFileToTarball(), and writeTarHeader() are +** the only functions that deal with the HardLinkInfo structure. +** Even these functions use the xxxHardLinkInfo() functions. +*/ +typedef struct HardLinkInfo HardLinkInfo; +struct HardLinkInfo { + HardLinkInfo *next; /* Next entry in list */ + dev_t dev; /* Device number */ + ino_t ino; /* Inode number */ + short linkCount; /* (Hard) Link Count */ + char name[1]; /* Start of filename (must be last) */ +}; + +/* Some info to be carried along when creating a new tarball */ +typedef struct TarBallInfo TarBallInfo; +struct TarBallInfo { + int tarFd; /* Open-for-write file descriptor + for the tarball */ + struct stat statBuf; /* Stat info for the tarball, letting + us know the inode and device that the + tarball lives, so we can avoid trying + to include the tarball into itself */ + int verboseFlag; /* Whether to print extra stuff or not */ + const llist_t *excludeList; /* List of files to not include */ + HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */ + HardLinkInfo *hlInfo; /* Hard Link Info for the current file */ +}; + +/* A nice enum with all the possible tar file content types */ +enum TarFileType { + REGTYPE = '0', /* regular file */ + REGTYPE0 = '\0', /* regular file (ancient bug compat) */ + LNKTYPE = '1', /* hard link */ + SYMTYPE = '2', /* symbolic link */ + CHRTYPE = '3', /* character special */ + BLKTYPE = '4', /* block special */ + DIRTYPE = '5', /* directory */ + FIFOTYPE = '6', /* FIFO special */ + CONTTYPE = '7', /* reserved */ + GNULONGLINK = 'K', /* GNU long (>100 chars) link name */ + GNULONGNAME = 'L', /* GNU long (>100 chars) file name */ +}; +typedef enum TarFileType TarFileType; + +/* Might be faster (and bigger) if the dev/ino were stored in numeric order;) */ +static void addHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr, + struct stat *statbuf, + const char *fileName) +{ + /* Note: hlInfoHeadPtr can never be NULL! */ + HardLinkInfo *hlInfo; + + hlInfo = xmalloc(sizeof(HardLinkInfo) + strlen(fileName)); + hlInfo->next = *hlInfoHeadPtr; + *hlInfoHeadPtr = hlInfo; + hlInfo->dev = statbuf->st_dev; + hlInfo->ino = statbuf->st_ino; + hlInfo->linkCount = statbuf->st_nlink; + strcpy(hlInfo->name, fileName); +} + +static void freeHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr) +{ + HardLinkInfo *hlInfo; + HardLinkInfo *hlInfoNext; + + if (hlInfoHeadPtr) { + hlInfo = *hlInfoHeadPtr; + while (hlInfo) { + hlInfoNext = hlInfo->next; + free(hlInfo); + hlInfo = hlInfoNext; + } + *hlInfoHeadPtr = NULL; + } +} + +/* Might be faster (and bigger) if the dev/ino were stored in numeric order;) */ +static HardLinkInfo *findHardLinkInfo(HardLinkInfo * hlInfo, struct stat *statbuf) +{ + while (hlInfo) { + if ((statbuf->st_ino == hlInfo->ino) && (statbuf->st_dev == hlInfo->dev)) + break; + hlInfo = hlInfo->next; + } + return hlInfo; +} + +/* Put an octal string into the specified buffer. + * The number is zero padded and possibly null terminated. + * Stores low-order bits only if whole value does not fit. */ +static void putOctal(char *cp, int len, off_t value) +{ + char tempBuffer[sizeof(off_t)*3+1]; + char *tempString = tempBuffer; + int width; + + width = sprintf(tempBuffer, "%0*"OFF_FMT"o", len, value); + tempString += (width - len); + + /* If string has leading zeroes, we can drop one */ + /* and field will have trailing '\0' */ + /* (increases chances of compat with other tars) */ + if (tempString[0] == '0') + tempString++; + + /* Copy the string to the field */ + memcpy(cp, tempString, len); +} +#define PUT_OCTAL(a, b) putOctal((a), sizeof(a), (b)) + +static void chksum_and_xwrite(int fd, struct TarHeader* hp) +{ + /* POSIX says that checksum is done on unsigned bytes + * (Sun and HP-UX gets it wrong... more details in + * GNU tar source) */ + const unsigned char *cp; + int chksum, size; + + strcpy(hp->magic, "ustar "); + + /* Calculate and store the checksum (i.e., the sum of all of the bytes of + * the header). The checksum field must be filled with blanks for the + * calculation. The checksum field is formatted differently from the + * other fields: it has 6 digits, a null, then a space -- rather than + * digits, followed by a null like the other fields... */ + memset(hp->chksum, ' ', sizeof(hp->chksum)); + cp = (const unsigned char *) hp; + chksum = 0; + size = sizeof(*hp); + do { chksum += *cp++; } while (--size); + putOctal(hp->chksum, sizeof(hp->chksum)-1, chksum); + + /* Now write the header out to disk */ + xwrite(fd, hp, sizeof(*hp)); +} + +#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS +static void writeLongname(int fd, int type, const char *name, int dir) +{ + static const struct { + char mode[8]; /* 100-107 */ + char uid[8]; /* 108-115 */ + char gid[8]; /* 116-123 */ + char size[12]; /* 124-135 */ + char mtime[12]; /* 136-147 */ + } prefilled = { + "0000000", + "0000000", + "0000000", + "00000000000", + "00000000000", + }; + struct TarHeader header; + int size; + + dir = !!dir; /* normalize: 0/1 */ + size = strlen(name) + 1 + dir; /* GNU tar uses strlen+1 */ + /* + dir: account for possible '/' */ + + memset(&header, 0, sizeof(header)); + strcpy(header.name, "././@LongLink"); + memcpy(header.mode, prefilled.mode, sizeof(prefilled)); + PUT_OCTAL(header.size, size); + header.typeflag = type; + chksum_and_xwrite(fd, &header); + + /* Write filename[/] and pad the block. */ + /* dir=0: writes 'name', pads */ + /* dir=1: writes 'name', writes '/', pads */ + dir *= 2; + xwrite(fd, name, size - dir); + xwrite(fd, "/", dir); + size = (-size) & (TAR_BLOCK_SIZE-1); + memset(&header, 0, size); + xwrite(fd, &header, size); +} +#endif + +/* Write out a tar header for the specified file/directory/whatever */ +void BUG_tar_header_size(void); +static int writeTarHeader(struct TarBallInfo *tbInfo, + const char *header_name, const char *fileName, struct stat *statbuf) +{ + struct TarHeader header; + + if (sizeof(header) != 512) + BUG_tar_header_size(); + + memset(&header, 0, sizeof(struct TarHeader)); + + strncpy(header.name, header_name, sizeof(header.name)); + + /* POSIX says to mask mode with 07777. */ + PUT_OCTAL(header.mode, statbuf->st_mode & 07777); + PUT_OCTAL(header.uid, statbuf->st_uid); + PUT_OCTAL(header.gid, statbuf->st_gid); + memset(header.size, '0', sizeof(header.size)-1); /* Regular file size is handled later */ + PUT_OCTAL(header.mtime, statbuf->st_mtime); + + /* Enter the user and group names */ + safe_strncpy(header.uname, get_cached_username(statbuf->st_uid), sizeof(header.uname)); + safe_strncpy(header.gname, get_cached_groupname(statbuf->st_gid), sizeof(header.gname)); + + if (tbInfo->hlInfo) { + /* This is a hard link */ + header.typeflag = LNKTYPE; + strncpy(header.linkname, tbInfo->hlInfo->name, + sizeof(header.linkname)); +#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS + /* Write out long linkname if needed */ + if (header.linkname[sizeof(header.linkname)-1]) + writeLongname(tbInfo->tarFd, GNULONGLINK, + tbInfo->hlInfo->name, 0); +#endif + } else if (S_ISLNK(statbuf->st_mode)) { + char *lpath = xmalloc_readlink_or_warn(fileName); + if (!lpath) + return FALSE; + header.typeflag = SYMTYPE; + strncpy(header.linkname, lpath, sizeof(header.linkname)); +#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS + /* Write out long linkname if needed */ + if (header.linkname[sizeof(header.linkname)-1]) + writeLongname(tbInfo->tarFd, GNULONGLINK, lpath, 0); +#else + /* If it is larger than 100 bytes, bail out */ + if (header.linkname[sizeof(header.linkname)-1]) { + free(lpath); + bb_error_msg("names longer than "NAME_SIZE_STR" chars not supported"); + return FALSE; + } +#endif + free(lpath); + } else if (S_ISDIR(statbuf->st_mode)) { + header.typeflag = DIRTYPE; + /* Append '/' only if there is a space for it */ + if (!header.name[sizeof(header.name)-1]) + header.name[strlen(header.name)] = '/'; + } else if (S_ISCHR(statbuf->st_mode)) { + header.typeflag = CHRTYPE; + PUT_OCTAL(header.devmajor, major(statbuf->st_rdev)); + PUT_OCTAL(header.devminor, minor(statbuf->st_rdev)); + } else if (S_ISBLK(statbuf->st_mode)) { + header.typeflag = BLKTYPE; + PUT_OCTAL(header.devmajor, major(statbuf->st_rdev)); + PUT_OCTAL(header.devminor, minor(statbuf->st_rdev)); + } else if (S_ISFIFO(statbuf->st_mode)) { + header.typeflag = FIFOTYPE; + } else if (S_ISREG(statbuf->st_mode)) { + if (sizeof(statbuf->st_size) > 4 + && statbuf->st_size > (off_t)0777777777777LL + ) { + bb_error_msg_and_die("cannot store file '%s' " + "of size %"OFF_FMT"d, aborting", + fileName, statbuf->st_size); + } + header.typeflag = REGTYPE; + PUT_OCTAL(header.size, statbuf->st_size); + } else { + bb_error_msg("%s: unknown file type", fileName); + return FALSE; + } + +#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS + /* Write out long name if needed */ + /* (we, like GNU tar, output long linkname *before* long name) */ + if (header.name[sizeof(header.name)-1]) + writeLongname(tbInfo->tarFd, GNULONGNAME, + header_name, S_ISDIR(statbuf->st_mode)); +#endif + + /* Now write the header out to disk */ + chksum_and_xwrite(tbInfo->tarFd, &header); + + /* Now do the verbose thing (or not) */ + if (tbInfo->verboseFlag) { + FILE *vbFd = stdout; + + if (tbInfo->tarFd == STDOUT_FILENO) /* If the archive goes to stdout, verbose to stderr */ + vbFd = stderr; + /* GNU "tar cvvf" prints "extended" listing a-la "ls -l" */ + /* We don't have such excesses here: for us "v" == "vv" */ + /* '/' is probably a GNUism */ + fprintf(vbFd, "%s%s\n", header_name, + S_ISDIR(statbuf->st_mode) ? "/" : ""); + } + + return TRUE; +} + +#if ENABLE_FEATURE_TAR_FROM +static int exclude_file(const llist_t *excluded_files, const char *file) +{ + while (excluded_files) { + if (excluded_files->data[0] == '/') { + if (fnmatch(excluded_files->data, file, + FNM_PATHNAME | FNM_LEADING_DIR) == 0) + return 1; + } else { + const char *p; + + for (p = file; p[0] != '\0'; p++) { + if ((p == file || p[-1] == '/') && p[0] != '/' && + fnmatch(excluded_files->data, p, + FNM_PATHNAME | FNM_LEADING_DIR) == 0) + return 1; + } + } + excluded_files = excluded_files->link; + } + + return 0; +} +#else +#define exclude_file(excluded_files, file) 0 +#endif + +static int writeFileToTarball(const char *fileName, struct stat *statbuf, + void *userData, int depth ATTRIBUTE_UNUSED) +{ + struct TarBallInfo *tbInfo = (struct TarBallInfo *) userData; + const char *header_name; + int inputFileFd = -1; + + /* + * Check to see if we are dealing with a hard link. + * If so - + * Treat the first occurance of a given dev/inode as a file while + * treating any additional occurances as hard links. This is done + * by adding the file information to the HardLinkInfo linked list. + */ + tbInfo->hlInfo = NULL; + if (statbuf->st_nlink > 1) { + tbInfo->hlInfo = findHardLinkInfo(tbInfo->hlInfoHead, statbuf); + if (tbInfo->hlInfo == NULL) + addHardLinkInfo(&tbInfo->hlInfoHead, statbuf, fileName); + } + + /* It is against the rules to archive a socket */ + if (S_ISSOCK(statbuf->st_mode)) { + bb_error_msg("%s: socket ignored", fileName); + return TRUE; + } + + /* It is a bad idea to store the archive we are in the process of creating, + * so check the device and inode to be sure that this particular file isn't + * the new tarball */ + if (tbInfo->statBuf.st_dev == statbuf->st_dev && + tbInfo->statBuf.st_ino == statbuf->st_ino) { + bb_error_msg("%s: file is the archive; skipping", fileName); + return TRUE; + } + + header_name = fileName; + while (header_name[0] == '/') { + static int alreadyWarned = FALSE; + + if (alreadyWarned == FALSE) { + bb_error_msg("removing leading '/' from member names"); + alreadyWarned = TRUE; + } + header_name++; + } + +#if !ENABLE_FEATURE_TAR_GNU_EXTENSIONS + if (strlen(fileName) >= NAME_SIZE) { + bb_error_msg("names longer than "NAME_SIZE_STR" chars not supported"); + return TRUE; + } +#endif + + if (header_name[0] == '\0') + return TRUE; + + if (exclude_file(tbInfo->excludeList, header_name)) + return SKIP; + + /* Is this a regular file? */ + if (tbInfo->hlInfo == NULL && S_ISREG(statbuf->st_mode)) { + /* open the file we want to archive, and make sure all is well */ + inputFileFd = open(fileName, O_RDONLY); + if (inputFileFd < 0) { + bb_perror_msg("%s: cannot open", fileName); + return FALSE; + } + } + + /* Add an entry to the tarball */ + if (writeTarHeader(tbInfo, header_name, fileName, statbuf) == FALSE) { + return FALSE; + } + + /* If it was a regular file, write out the body */ + if (inputFileFd >= 0) { + size_t readSize; + /* Wwrite the file to the archive. */ + /* We record size into header first, */ + /* and then write out file. If file shrinks in between, */ + /* tar will be corrupted. So we don't allow for that. */ + /* NB: GNU tar 1.16 warns and pads with zeroes */ + /* or even seeks back and updates header */ + bb_copyfd_exact_size(inputFileFd, tbInfo->tarFd, statbuf->st_size); + ////off_t readSize; + ////readSize = bb_copyfd_size(inputFileFd, tbInfo->tarFd, statbuf->st_size); + ////if (readSize != statbuf->st_size && readSize >= 0) { + //// bb_error_msg_and_die("short read from %s, aborting", fileName); + ////} + + /* Check that file did not grow in between? */ + /* if (safe_read(inputFileFd, 1) == 1) warn but continue? */ + + close(inputFileFd); + + /* Pad the file up to the tar block size */ + /* (a few tricks here in the name of code size) */ + readSize = (-(int)statbuf->st_size) & (TAR_BLOCK_SIZE-1); + memset(bb_common_bufsiz1, 0, readSize); + xwrite(tbInfo->tarFd, bb_common_bufsiz1, readSize); + } + + return TRUE; +} + +static int writeTarFile(const int tar_fd, const int verboseFlag, + const unsigned long dereferenceFlag, const llist_t *include, + const llist_t *exclude, const int gzip) +{ + pid_t gzipPid = 0; + int errorFlag = FALSE; + struct TarBallInfo tbInfo; + + tbInfo.hlInfoHead = NULL; + + fchmod(tar_fd, 0644); + tbInfo.tarFd = tar_fd; + tbInfo.verboseFlag = verboseFlag; + + /* Store the stat info for the tarball's file, so + * can avoid including the tarball into itself.... */ + if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0) + bb_perror_msg_and_die("cannot stat tar file"); + + if ((ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2) && gzip) { + int gzipDataPipe[2] = { -1, -1 }; + int gzipStatusPipe[2] = { -1, -1 }; + volatile int vfork_exec_errno = 0; + const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2"; + + if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0) + bb_perror_msg_and_die("pipe"); + + signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */ + +#if defined(__GNUC__) && __GNUC__ + /* Avoid vfork clobbering */ + (void) &include; + (void) &errorFlag; + (void) &zip_exec; +#endif + + gzipPid = vfork(); + + if (gzipPid == 0) { + dup2(gzipDataPipe[0], 0); + close(gzipDataPipe[1]); + + dup2(tbInfo.tarFd, 1); + + close(gzipStatusPipe[0]); + fcntl(gzipStatusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows success */ + + BB_EXECLP(zip_exec, zip_exec, "-f", NULL); + vfork_exec_errno = errno; + + close(gzipStatusPipe[1]); + exit(-1); + } else if (gzipPid > 0) { + close(gzipDataPipe[0]); + close(gzipStatusPipe[1]); + + while (1) { + char buf; + + int n = full_read(gzipStatusPipe[0], &buf, 1); + + if (n == 0 && vfork_exec_errno != 0) { + errno = vfork_exec_errno; + bb_perror_msg_and_die("cannot exec %s", zip_exec); + } else if ((n < 0) && (errno == EAGAIN || errno == EINTR)) + continue; /* try it again */ + break; + } + close(gzipStatusPipe[0]); + + tbInfo.tarFd = gzipDataPipe[1]; + } else bb_perror_msg_and_die("vfork gzip"); + } + + tbInfo.excludeList = exclude; + + /* Read the directory/files and iterate over them one at a time */ + while (include) { + if (!recursive_action(include->data, TRUE, dereferenceFlag, + FALSE, writeFileToTarball, writeFileToTarball, &tbInfo, 0)) + { + errorFlag = TRUE; + } + include = include->link; + } + /* Write two empty blocks to the end of the archive */ + memset(bb_common_bufsiz1, 0, 2*TAR_BLOCK_SIZE); + xwrite(tbInfo.tarFd, bb_common_bufsiz1, 2*TAR_BLOCK_SIZE); + + /* To be pedantically correct, we would check if the tarball + * is smaller than 20 tar blocks, and pad it if it was smaller, + * but that isn't necessary for GNU tar interoperability, and + * so is considered a waste of space */ + + /* Close so the child process (if any) will exit */ + close(tbInfo.tarFd); + + /* Hang up the tools, close up shop, head home */ + if (ENABLE_FEATURE_CLEAN_UP) + freeHardLinkInfo(&tbInfo.hlInfoHead); + + if (errorFlag) + bb_error_msg("error exit delayed from previous errors"); + + if (gzipPid) { + int status; + if (waitpid(gzipPid, &status, 0) == -1) + bb_perror_msg("waitpid"); + else if (!WIFEXITED(status) || WEXITSTATUS(status)) + /* gzip was killed or has exited with nonzero! */ + errorFlag = TRUE; + } + return errorFlag; +} +#else +int writeTarFile(const int tar_fd, const int verboseFlag, + const unsigned long dereferenceFlag, const llist_t *include, + const llist_t *exclude, const int gzip); +#endif /* FEATURE_TAR_CREATE */ + +#if ENABLE_FEATURE_TAR_FROM +static llist_t *append_file_list_to_list(llist_t *list) +{ + FILE *src_stream; + llist_t *cur = list; + llist_t *tmp; + char *line; + llist_t *newlist = NULL; + + while (cur) { + src_stream = xfopen(cur->data, "r"); + tmp = cur; + cur = cur->link; + free(tmp); + while ((line = xmalloc_getline(src_stream)) != NULL) { + /* kill trailing '/' unless the string is just "/" */ + char *cp = last_char_is(line, '/'); + if (cp > line) + *cp = '\0'; + llist_add_to(&newlist, line); + } + fclose(src_stream); + } + return newlist; +} +#else +#define append_file_list_to_list(x) 0 +#endif + +#if ENABLE_FEATURE_TAR_COMPRESS +static char get_header_tar_Z(archive_handle_t *archive_handle) +{ + /* Can't lseek over pipes */ + archive_handle->seek = seek_by_read; + + /* do the decompression, and cleanup */ + if (xread_char(archive_handle->src_fd) != 0x1f + || xread_char(archive_handle->src_fd) != 0x9d + ) { + bb_error_msg_and_die("invalid magic"); + } + + archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress); + archive_handle->offset = 0; + while (get_header_tar(archive_handle) == EXIT_SUCCESS) + /* nothing */; + + /* Can only do one file at a time */ + return EXIT_FAILURE; +} +#else +#define get_header_tar_Z NULL +#endif + +#ifdef CHECK_FOR_CHILD_EXITCODE +/* Looks like it isn't needed - tar detects malformed (truncated) + * archive if e.g. bunzip2 fails */ +static int child_error; + +static void handle_SIGCHLD(int status) +{ + /* Actually, 'status' is a signo. We reuse it for other needs */ + + /* Wait for any child without blocking */ + if (waitpid(-1, &status, WNOHANG) < 0) + /* wait failed?! I'm confused... */ + return; + + if (WIFEXITED(status) && WEXITSTATUS(status)==0) + /* child exited with 0 */ + return; + /* Cannot happen? + if(!WIFSIGNALED(status) && !WIFEXITED(status)) return; */ + child_error = 1; +} +#endif + +enum { + OPTBIT_KEEP_OLD = 7, + USE_FEATURE_TAR_CREATE( OPTBIT_CREATE ,) + USE_FEATURE_TAR_CREATE( OPTBIT_DEREFERENCE ,) + USE_FEATURE_TAR_BZIP2( OPTBIT_BZIP2 ,) + USE_FEATURE_TAR_LZMA( OPTBIT_LZMA ,) + USE_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,) + USE_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,) + USE_FEATURE_TAR_GZIP( OPTBIT_GZIP ,) + USE_FEATURE_TAR_COMPRESS(OPTBIT_COMPRESS ,) + OPTBIT_NOPRESERVE_OWN, + OPTBIT_NOPRESERVE_PERM, + OPT_TEST = 1 << 0, // t + OPT_EXTRACT = 1 << 1, // x + OPT_BASEDIR = 1 << 2, // C + OPT_TARNAME = 1 << 3, // f + OPT_2STDOUT = 1 << 4, // O + OPT_P = 1 << 5, // p + OPT_VERBOSE = 1 << 6, // v + OPT_KEEP_OLD = 1 << 7, // k + OPT_CREATE = USE_FEATURE_TAR_CREATE( (1<flags = ARCHIVE_CREATE_LEADING_DIRS + | ARCHIVE_PRESERVE_DATE + | ARCHIVE_EXTRACT_UNCONDITIONAL; + + /* Prepend '-' to the first argument if required */ + opt_complementary = "--:" // first arg is options + "tt:vv:" // count -t,-v + "?:" // bail out with usage instead of error return + "X::T::" // cumulative lists +#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM + "\xff::" // cumulative lists for --exclude +#endif + USE_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd + USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive + SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive +#if ENABLE_FEATURE_TAR_LONG_OPTIONS + applet_long_options = tar_long_options; +#endif + opt = getopt32(argc, argv, + "txC:f:Opvk" + USE_FEATURE_TAR_CREATE( "ch" ) + USE_FEATURE_TAR_BZIP2( "j" ) + USE_FEATURE_TAR_LZMA( "a" ) + USE_FEATURE_TAR_FROM( "T:X:") + USE_FEATURE_TAR_GZIP( "z" ) + USE_FEATURE_TAR_COMPRESS("Z" ) + , &base_dir // -C dir + , &tar_filename // -f filename + USE_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T + USE_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X +#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM + , &excludes // --exclude +#endif + , &verboseFlag // combined count for -t and -v + , &verboseFlag // combined count for -t and -v + ); + + if (verboseFlag) tar_handle->action_header = header_verbose_list; + if (verboseFlag == 1) tar_handle->action_header = header_list; + + if (opt & OPT_EXTRACT) + tar_handle->action_data = data_extract_all; + + if (opt & OPT_2STDOUT) + tar_handle->action_data = data_extract_to_stdout; + + if (opt & OPT_KEEP_OLD) + tar_handle->flags &= ~ARCHIVE_EXTRACT_UNCONDITIONAL; + + if (opt & OPT_NOPRESERVE_OWN) + tar_handle->flags |= ARCHIVE_NOPRESERVE_OWN; + + if (opt & OPT_NOPRESERVE_PERM) + tar_handle->flags |= ARCHIVE_NOPRESERVE_PERM; + + if (opt & OPT_GZIP) + get_header_ptr = get_header_tar_gz; + + if (opt & OPT_BZIP2) + get_header_ptr = get_header_tar_bz2; + + if (opt & OPT_LZMA) + get_header_ptr = get_header_tar_lzma; + + if (opt & OPT_COMPRESS) + get_header_ptr = get_header_tar_Z; + +#if ENABLE_FEATURE_TAR_FROM + tar_handle->reject = append_file_list_to_list(tar_handle->reject); +#if ENABLE_FEATURE_TAR_LONG_OPTIONS + /* Append excludes to reject */ + while (excludes) { + llist_t *next = excludes->link; + excludes->link = tar_handle->reject; + tar_handle->reject = excludes; + excludes = next; + } +#endif + tar_handle->accept = append_file_list_to_list(tar_handle->accept); +#endif + + /* Check if we are reading from stdin */ + if (argv[optind] && *argv[optind] == '-') { + /* Default is to read from stdin, so just skip to next arg */ + optind++; + } + + /* Setup an array of filenames to work with */ + /* TODO: This is the same as in ar, separate function ? */ + while (optind < argc) { + /* kill trailing '/' unless the string is just "/" */ + char *cp = last_char_is(argv[optind], '/'); + if (cp > argv[optind]) + *cp = '\0'; + llist_add_to(&tar_handle->accept, argv[optind]); + optind++; + } + tar_handle->accept = llist_rev(tar_handle->accept); + + if (tar_handle->accept || tar_handle->reject) + tar_handle->filter = filter_accept_reject_list; + + /* Open the tar file */ + { + FILE *tar_stream; + int flags; + + if (opt & OPT_CREATE) { + /* Make sure there is at least one file to tar up. */ + if (tar_handle->accept == NULL) + bb_error_msg_and_die("empty archive"); + + tar_stream = stdout; + /* Mimicking GNU tar 1.15.1: */ + flags = O_WRONLY|O_CREAT|O_TRUNC; + /* was doing unlink; open(O_WRONLY|O_CREAT|O_EXCL); why? */ + } else { + tar_stream = stdin; + flags = O_RDONLY; + } + + if (LONE_DASH(tar_filename)) { + tar_handle->src_fd = fileno(tar_stream); + tar_handle->seek = seek_by_read; + } else { + tar_handle->src_fd = xopen(tar_filename, flags); + } + } + + if (base_dir) + xchdir(base_dir); + +#ifdef CHECK_FOR_CHILD_EXITCODE + /* We need to know whether child (gzip/bzip/etc) exits abnormally */ + signal(SIGCHLD, handle_SIGCHLD); +#endif + + /* create an archive */ + if (opt & OPT_CREATE) { + int zipMode = 0; + if (ENABLE_FEATURE_TAR_GZIP && get_header_ptr == get_header_tar_gz) + zipMode = 1; + if (ENABLE_FEATURE_TAR_BZIP2 && get_header_ptr == get_header_tar_bz2) + zipMode = 2; + /* NB: writeTarFile() closes tar_handle->src_fd */ + return writeTarFile(tar_handle->src_fd, verboseFlag, opt & OPT_DEREFERENCE, + tar_handle->accept, + tar_handle->reject, zipMode); + } + + while (get_header_ptr(tar_handle) == EXIT_SUCCESS) + /* nothing */; + + /* Check that every file that should have been extracted was */ + while (tar_handle->accept) { + if (!find_list_entry(tar_handle->reject, tar_handle->accept->data) + && !find_list_entry(tar_handle->passed, tar_handle->accept->data) + ) { + bb_error_msg_and_die("%s: not found in archive", + tar_handle->accept->data); + } + tar_handle->accept = tar_handle->accept->link; + } + if (ENABLE_FEATURE_CLEAN_UP /* && tar_handle->src_fd != STDIN_FILENO */) + close(tar_handle->src_fd); + + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/archival/unzip.c b/i/pc104/initrd/conf/busybox/archival/unzip.c new file mode 100644 index 0000000..5e63170 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/archival/unzip.c @@ -0,0 +1,376 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini unzip implementation for busybox + * + * Copyright (C) 2004 by Ed Clark + * + * Loosely based on original busybox unzip applet by Laurence Anderson. + * All options and features should work in this version. + * + * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. + */ + +/* For reference see + * http://www.pkware.com/company/standards/appnote/ + * http://www.info-zip.org/pub/infozip/doc/appnote-iz-latest.zip + */ + +/* TODO + * Endian issues + * Zip64 + other methods + * Improve handling of zip format, ie. + * - deferred CRC, comp. & uncomp. lengths (zip header flags bit 3) + * - unix file permissions, etc. + * - central directory + */ + +#include "busybox.h" +#include "unarchive.h" + +#define ZIP_FILEHEADER_MAGIC SWAP_LE32(0x04034b50) +#define ZIP_CDS_MAGIC SWAP_LE32(0x02014b50) +#define ZIP_CDS_END_MAGIC SWAP_LE32(0x06054b50) +#define ZIP_DD_MAGIC SWAP_LE32(0x08074b50) + +typedef union { + unsigned char raw[26]; + struct { + unsigned short version; /* 0-1 */ + unsigned short flags; /* 2-3 */ + unsigned short method; /* 4-5 */ + unsigned short modtime; /* 6-7 */ + unsigned short moddate; /* 8-9 */ + unsigned int crc32 ATTRIBUTE_PACKED; /* 10-13 */ + unsigned int cmpsize ATTRIBUTE_PACKED; /* 14-17 */ + unsigned int ucmpsize ATTRIBUTE_PACKED; /* 18-21 */ + unsigned short filename_len; /* 22-23 */ + unsigned short extra_len; /* 24-25 */ + } formatted ATTRIBUTE_PACKED; +} zip_header_t; + +static void unzip_skip(int fd, off_t skip) +{ + if (lseek(fd, skip, SEEK_CUR) == (off_t)-1) { + if (errno != ESPIPE) + bb_error_msg_and_die("seek failure"); + bb_copyfd_exact_size(fd, -1, skip); + } +} + +static void unzip_create_leading_dirs(char *fn) +{ + /* Create all leading directories */ + char *name = xstrdup(fn); + if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) { + bb_error_msg_and_die("exiting"); /* bb_make_directory is noisy */ + } + free(name); +} + +static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd) +{ + if (zip_header->formatted.method == 0) { + /* Method 0 - stored (not compressed) */ + off_t size = zip_header->formatted.ucmpsize; + if (size) + bb_copyfd_exact_size(src_fd, dst_fd, size); + } else { + /* Method 8 - inflate */ + inflate_unzip_result res; + /* err = */ inflate_unzip(&res, zip_header->formatted.cmpsize, src_fd, dst_fd); +// we should check for -1 error return + /* Validate decompression - crc */ + if (zip_header->formatted.crc32 != (res.crc ^ 0xffffffffL)) { + bb_error_msg("invalid compressed data--%s error", "crc"); + return 1; + } + /* Validate decompression - size */ + if (zip_header->formatted.ucmpsize != res.bytes_out) { + bb_error_msg("invalid compressed data--%s error", "length"); + return 1; + } + } + return 0; +} + +int unzip_main(int argc, char **argv); +int unzip_main(int argc, char **argv) +{ + zip_header_t zip_header; + enum {v_silent, v_normal, v_list} verbosity = v_normal; + enum {o_prompt, o_never, o_always} overwrite = o_prompt; + unsigned int total_size = 0; + unsigned int total_entries = 0; + int src_fd = -1, dst_fd = -1; + char *src_fn = NULL, *dst_fn = NULL; + llist_t *zaccept = NULL; + llist_t *zreject = NULL; + char *base_dir = NULL; + int failed, i, opt, opt_range = 0, list_header_done = 0; + char key_buf[512]; + struct stat stat_buf; + + while ((opt = getopt(argc, argv, "-d:lnopqx")) != -1) { + switch (opt_range) { + case 0: /* Options */ + switch (opt) { + case 'l': /* List */ + verbosity = v_list; + break; + + case 'n': /* Never overwrite existing files */ + overwrite = o_never; + break; + + case 'o': /* Always overwrite existing files */ + overwrite = o_always; + break; + + case 'p': /* Extract files to stdout and fall through to set verbosity */ + dst_fd = STDOUT_FILENO; + + case 'q': /* Be quiet */ + verbosity = (verbosity == v_normal) ? v_silent : verbosity; + break; + + case 1 : /* The zip file */ + src_fn = xstrndup(optarg, strlen(optarg)+4); + opt_range++; + break; + + default: + bb_show_usage(); + + } + break; + + case 1: /* Include files */ + if (opt == 1) { + llist_add_to(&zaccept, optarg); + + } else if (opt == 'd') { + base_dir = optarg; + opt_range += 2; + + } else if (opt == 'x') { + opt_range++; + + } else { + bb_show_usage(); + } + break; + + case 2 : /* Exclude files */ + if (opt == 1) { + llist_add_to(&zreject, optarg); + + } else if (opt == 'd') { /* Extract to base directory */ + base_dir = optarg; + opt_range++; + + } else { + bb_show_usage(); + } + break; + + default: + bb_show_usage(); + } + } + + if (src_fn == NULL) { + bb_show_usage(); + } + + /* Open input file */ + if (LONE_DASH(src_fn)) { + src_fd = STDIN_FILENO; + /* Cannot use prompt mode since zip data is arriving on STDIN */ + overwrite = (overwrite == o_prompt) ? o_never : overwrite; + } else { + static const char *const extn[] = {"", ".zip", ".ZIP"}; + int orig_src_fn_len = strlen(src_fn); + for (i = 0; (i < 3) && (src_fd == -1); i++) { + strcpy(src_fn + orig_src_fn_len, extn[i]); + src_fd = open(src_fn, O_RDONLY); + } + if (src_fd == -1) { + src_fn[orig_src_fn_len] = 0; + bb_error_msg_and_die("cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn); + } + } + + /* Change dir if necessary */ + if (base_dir) + xchdir(base_dir); + + if (verbosity != v_silent) + printf("Archive: %s\n", src_fn); + + failed = 0; + + while (1) { + unsigned int magic; + + /* Check magic number */ + xread(src_fd, &magic, 4); + if (magic == ZIP_CDS_MAGIC) { + break; + } else if (magic != ZIP_FILEHEADER_MAGIC) { + bb_error_msg_and_die("invalid zip magic %08X", magic); + } + + /* Read the file header */ + xread(src_fd, zip_header.raw, 26); + zip_header.formatted.version = SWAP_LE32(zip_header.formatted.version); + zip_header.formatted.flags = SWAP_LE32(zip_header.formatted.flags); + zip_header.formatted.method = SWAP_LE32(zip_header.formatted.method); + zip_header.formatted.modtime = SWAP_LE32(zip_header.formatted.modtime); + zip_header.formatted.moddate = SWAP_LE32(zip_header.formatted.moddate); + zip_header.formatted.crc32 = SWAP_LE32(zip_header.formatted.crc32); + zip_header.formatted.cmpsize = SWAP_LE32(zip_header.formatted.cmpsize); + zip_header.formatted.ucmpsize = SWAP_LE32(zip_header.formatted.ucmpsize); + zip_header.formatted.filename_len = SWAP_LE32(zip_header.formatted.filename_len); + zip_header.formatted.extra_len = SWAP_LE32(zip_header.formatted.extra_len); + if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) { + bb_error_msg_and_die("unsupported compression method %d", zip_header.formatted.method); + } + + /* Read filename */ + free(dst_fn); + dst_fn = xzalloc(zip_header.formatted.filename_len + 1); + xread(src_fd, dst_fn, zip_header.formatted.filename_len); + + /* Skip extra header bytes */ + unzip_skip(src_fd, zip_header.formatted.extra_len); + + if ((verbosity == v_list) && !list_header_done){ + puts(" Length Date Time Name\n" + " -------- ---- ---- ----"); + list_header_done = 1; + } + + /* Filter zip entries */ + if (find_list_entry(zreject, dst_fn) || + (zaccept && !find_list_entry(zaccept, dst_fn))) { /* Skip entry */ + i = 'n'; + + } else { /* Extract entry */ + total_size += zip_header.formatted.ucmpsize; + + if (verbosity == v_list) { /* List entry */ + unsigned int dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16); + printf("%9u %02u-%02u-%02u %02u:%02u %s\n", + zip_header.formatted.ucmpsize, + (dostime & 0x01e00000) >> 21, + (dostime & 0x001f0000) >> 16, + (((dostime & 0xfe000000) >> 25) + 1980) % 100, + (dostime & 0x0000f800) >> 11, + (dostime & 0x000007e0) >> 5, + dst_fn); + total_entries++; + i = 'n'; + } else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */ + i = -1; + } else if (last_char_is(dst_fn, '/')) { /* Extract directory */ + if (stat(dst_fn, &stat_buf) == -1) { + if (errno != ENOENT) { + bb_perror_msg_and_die("cannot stat '%s'",dst_fn); + } + if (verbosity == v_normal) { + printf(" creating: %s\n", dst_fn); + } + unzip_create_leading_dirs(dst_fn); + if (bb_make_directory(dst_fn, 0777, 0)) { + bb_error_msg_and_die("exiting"); + } + } else { + if (!S_ISDIR(stat_buf.st_mode)) { + bb_error_msg_and_die("'%s' exists but is not directory", dst_fn); + } + } + i = 'n'; + + } else { /* Extract file */ + _check_file: + if (stat(dst_fn, &stat_buf) == -1) { /* File does not exist */ + if (errno != ENOENT) { + bb_perror_msg_and_die("cannot stat '%s'",dst_fn); + } + i = 'y'; + } else { /* File already exists */ + if (overwrite == o_never) { + i = 'n'; + } else if (S_ISREG(stat_buf.st_mode)) { /* File is regular file */ + if (overwrite == o_always) { + i = 'y'; + } else { + printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn); + if (!fgets(key_buf, 512, stdin)) { + bb_perror_msg_and_die("cannot read input"); + } + i = key_buf[0]; + } + } else { /* File is not regular file */ + bb_error_msg_and_die("'%s' exists but is not regular file",dst_fn); + } + } + } + } + + switch (i) { + case 'A': + overwrite = o_always; + case 'y': /* Open file and fall into unzip */ + unzip_create_leading_dirs(dst_fn); + dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC); + case -1: /* Unzip */ + if (verbosity == v_normal) { + printf(" inflating: %s\n", dst_fn); + } + if (unzip_extract(&zip_header, src_fd, dst_fd)) { + failed = 1; + } + if (dst_fd != STDOUT_FILENO) { + /* closing STDOUT is potentially bad for future business */ + close(dst_fd); + } + break; + + case 'N': + overwrite = o_never; + case 'n': + /* Skip entry data */ + unzip_skip(src_fd, zip_header.formatted.cmpsize); + break; + + case 'r': + /* Prompt for new name */ + printf("new name: "); + if (!fgets(key_buf, 512, stdin)) { + bb_perror_msg_and_die("cannot read input"); + } + free(dst_fn); + dst_fn = xstrdup(key_buf); + chomp(dst_fn); + goto _check_file; + + default: + printf("error: invalid response [%c]\n",(char)i); + goto _check_file; + } + + /* Data descriptor section */ + if (zip_header.formatted.flags & 4) { + /* skip over duplicate crc, compressed size and uncompressed size */ + unzip_skip(src_fd, 12); + } + } + + if (verbosity == v_list) { + printf(" -------- -------\n" + "%9d %d files\n", total_size, total_entries); + } + + return failed; +} diff --git a/i/pc104/initrd/conf/busybox/busybox b/i/pc104/initrd/conf/busybox/busybox new file mode 100755 index 0000000..942a5b9 Binary files /dev/null and b/i/pc104/initrd/conf/busybox/busybox differ diff --git a/i/pc104/initrd/conf/busybox/busybox.links b/i/pc104/initrd/conf/busybox/busybox.links new file mode 100644 index 0000000..de85a50 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/busybox.links @@ -0,0 +1,18 @@ +/usr/bin/[ +/usr/bin/[[ +/bin/ash +/usr/sbin/chroot +/bin/echo +/sbin/halt +/bin/hostname +/sbin/insmod +/bin/mount +/usr/bin/nc +/sbin/pivot_root +/sbin/reboot +/bin/sh +/bin/sleep +/bin/sync +/usr/bin/test +/sbin/udhcpc +/bin/umount diff --git a/i/pc104/initrd/conf/busybox/console-tools/Config.in b/i/pc104/initrd/conf/busybox/console-tools/Config.in new file mode 100644 index 0000000..4a5710d --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/Config.in @@ -0,0 +1,105 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/kbuild/config-language.txt. +# + +menu "Console Utilities" + +config CHVT + bool "chvt" + default n + help + This program is used to change to another terminal. + Example: chvt 4 (change to terminal /dev/tty4) + +config CLEAR + bool "clear" + default n + help + This program clears the terminal screen. + +config DEALLOCVT + bool "deallocvt" + default n + help + This program deallocates unused virtual consoles. + +config DUMPKMAP + bool "dumpkmap" + default n + help + This program dumps the kernel's keyboard translation table to + stdout, in binary format. You can then use loadkmap to load it. + +config LOADFONT + bool "loadfont" + default n + help + This program loads a console font from standard input. + +config LOADKMAP + bool "loadkmap" + default n + help + This program loads a keyboard translation table from + standard input. + +config OPENVT + bool "openvt" + default n + help + This program is used to start a command on an unused + virtual terminal. + +config RESET + bool "reset" + default n + help + This program is used to reset the terminal screen, if it + gets messed up. + +config RESIZE + bool "resize" + default n + help + This program is used to (re)set the width and height of your current + terminal. + +config FEATURE_RESIZE_PRINT + bool "print environment variables" + default n + depends on RESIZE + help + Prints the newly set size (number of columns and rows) of + the terminal. + E.g.: + COLUMNS=80;LINES=44;export COLUMNS LINES; + +config SETCONSOLE + bool "setconsole" + default n + help + This program redirects the system console to another device, + like the current tty while logged in via telnet. + +config FEATURE_SETCONSOLE_LONG_OPTIONS + bool "Enable long options" + default n + depends on SET_CONSOLE && GETOPT_LONG + help + Support long options for the setconsole applet. + +config SETKEYCODES + bool "setkeycodes" + default n + help + This program loads entries into the kernel's scancode-to-keycode + map, allowing unusual keyboards to generate usable keycodes. + +config SETLOGCONS + bool "setlogcons" + default n + help + This program redirects the output console of kernel messages. + +endmenu diff --git a/i/pc104/initrd/conf/busybox/console-tools/Kbuild b/i/pc104/initrd/conf/busybox/console-tools/Kbuild new file mode 100644 index 0000000..a55bc08 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/Kbuild @@ -0,0 +1,19 @@ +# Makefile for busybox +# +# Copyright (C) 1999-2005 by Erik Andersen +# +# Licensed under the GPL v2, see the file LICENSE in this tarball. + +lib-y:= +lib-$(CONFIG_CHVT) += chvt.o +lib-$(CONFIG_CLEAR) += clear.o +lib-$(CONFIG_DEALLOCVT) += deallocvt.o +lib-$(CONFIG_DUMPKMAP) += dumpkmap.o +lib-$(CONFIG_SETCONSOLE) += setconsole.o +lib-$(CONFIG_LOADFONT) += loadfont.o +lib-$(CONFIG_LOADKMAP) += loadkmap.o +lib-$(CONFIG_OPENVT) += openvt.o +lib-$(CONFIG_RESET) += reset.o +lib-$(CONFIG_RESIZE) += resize.o +lib-$(CONFIG_SETKEYCODES) += setkeycodes.o +lib-$(CONFIG_SETLOGCONS) += setlogcons.o diff --git a/i/pc104/initrd/conf/busybox/console-tools/chvt.c b/i/pc104/initrd/conf/busybox/console-tools/chvt.c new file mode 100644 index 0000000..5090811 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/chvt.c @@ -0,0 +1,34 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini chvt implementation for busybox + * + * Copyright (C) 1999-2004 by Erik Andersen + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "busybox.h" + +/* From */ +enum { + VT_ACTIVATE = 0x5606, /* make vt active */ + VT_WAITACTIVE = 0x5607 /* wait for vt active */ +}; + +int chvt_main(int argc, char **argv); +int chvt_main(int argc, char **argv) +{ + int fd, num; + + if (argc != 2) { + bb_show_usage(); + } + + fd = get_console_fd(); + num = xatoul_range(argv[1], 1, 63); + if ((-1 == ioctl(fd, VT_ACTIVATE, num)) + || (-1 == ioctl(fd, VT_WAITACTIVE, num))) { + bb_perror_msg_and_die("ioctl"); + } + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/console-tools/clear.c b/i/pc104/initrd/conf/busybox/console-tools/clear.c new file mode 100644 index 0000000..8e34d6d --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/clear.c @@ -0,0 +1,22 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini clear implementation for busybox + * + * Copyright (C) 1999-2004 by Erik Andersen + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * + */ + +/* no options, no getopt */ + +#include +#include +#include "busybox.h" + + +int clear_main(int argc, char **argv); +int clear_main(int argc, char **argv) +{ + return printf("\033[H\033[J") != 6; +} diff --git a/i/pc104/initrd/conf/busybox/console-tools/deallocvt.c b/i/pc104/initrd/conf/busybox/console-tools/deallocvt.c new file mode 100644 index 0000000..81ea68e --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/deallocvt.c @@ -0,0 +1,38 @@ +/* vi: set sw=4 ts=4: */ +/* + * Disallocate virtual terminal(s) + * + * Copyright (C) 2003 by Tito Ragusa + * Copyright (C) 1999-2004 by Erik Andersen + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* no options, no getopt */ + +#include "busybox.h" + +/* From */ +enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */ + +int deallocvt_main(int argc, char *argv[]); +int deallocvt_main(int argc, char *argv[]) +{ + /* num = 0 deallocate all unused consoles */ + int num = 0; + + switch (argc) { + case 2: + num = xatoul_range(argv[1], 1, 63); + /* Fallthrough */ + case 1: + break; + default: + bb_show_usage(); + } + + if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) { + bb_perror_msg_and_die("VT_DISALLOCATE"); + } + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/console-tools/dumpkmap.c b/i/pc104/initrd/conf/busybox/console-tools/dumpkmap.c new file mode 100644 index 0000000..0c19148 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/dumpkmap.c @@ -0,0 +1,66 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini dumpkmap implementation for busybox + * + * Copyright (C) Arne Bernin + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * + */ + +#include "busybox.h" + +/* From */ +struct kbentry { + unsigned char kb_table; + unsigned char kb_index; + unsigned short kb_value; +}; +#define KDGKBENT 0x4B46 /* gets one entry in translation table */ + +/* From */ +#define NR_KEYS 128 +#define MAX_NR_KEYMAPS 256 + +int dumpkmap_main(int argc, char **argv); +int dumpkmap_main(int argc, char **argv) +{ + struct kbentry ke; + int i, j, fd; + char flags[MAX_NR_KEYMAPS]; + + if (argc >= 2 && argv[1][0] == '-') + bb_show_usage(); + + fd = xopen(CURRENT_VC, O_RDWR); + + write(1, "bkeymap", 7); + + /* Here we want to set everything to 0 except for indexes: + * [0-2] [4-6] [8-10] [12] */ + memset(flags, 0x00, MAX_NR_KEYMAPS); + memset(flags, 0x01, 13); + flags[3] = flags[7] = flags[11] = 0; + + /* dump flags */ + write(1, flags, MAX_NR_KEYMAPS); + + for (i = 0; i < MAX_NR_KEYMAPS; i++) { + if (flags[i] == 1) { + for (j = 0; j < NR_KEYS; j++) { + ke.kb_index = j; + ke.kb_table = i; + if (ioctl(fd, KDGKBENT, &ke) < 0) { + bb_perror_msg("ioctl failed with %s, %s, %p", + (char *)&ke.kb_index, + (char *)&ke.kb_table, + &ke.kb_value); + } else { + write(1, (void*)&ke.kb_value, 2); + } + } + } + } + close(fd); + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/console-tools/loadfont.c b/i/pc104/initrd/conf/busybox/console-tools/loadfont.c new file mode 100644 index 0000000..f691b11 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/loadfont.c @@ -0,0 +1,194 @@ +/* vi: set sw=4 ts=4: */ +/* + * loadfont.c - Eugene Crosser & Andries Brouwer + * + * Version 0.96bb + * + * Loads the console font, and possibly the corresponding screen map(s). + * (Adapted for busybox by Matej Vela.) + */ +#include "busybox.h" +#include + +enum { + PSF_MAGIC1 = 0x36, + PSF_MAGIC2 = 0x04, + + PSF_MODE512 = 0x01, + PSF_MODEHASTAB = 0x02, + PSF_MAXMODE = 0x03, + PSF_SEPARATOR = 0xFFFF +}; + +struct psf_header { + unsigned char magic1, magic2; /* Magic number */ + unsigned char mode; /* PSF font mode */ + unsigned char charsize; /* Character size */ +}; + +#define PSF_MAGIC_OK(x) ((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2) + +static void loadnewfont(int fd); + +int loadfont_main(int argc, char **argv); +int loadfont_main(int argc, char **argv) +{ + int fd; + + if (argc != 1) + bb_show_usage(); + + fd = xopen(CURRENT_VC, O_RDWR); + loadnewfont(fd); + + return EXIT_SUCCESS; +} + +static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize) +{ + char buf[16384]; + int i; + + memset(buf, 0, sizeof(buf)); + + if (unit < 1 || unit > 32) + bb_error_msg_and_die("bad character size %d", unit); + + for (i = 0; i < fontsize; i++) + memcpy(buf + (32 * i), inbuf + (unit * i), unit); + +#if defined( PIO_FONTX ) && !defined( __sparc__ ) + { + struct consolefontdesc cfd; + + cfd.charcount = fontsize; + cfd.charheight = unit; + cfd.chardata = buf; + + if (ioctl(fd, PIO_FONTX, &cfd) == 0) + return; /* success */ + bb_perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)"); + } +#endif + if (ioctl(fd, PIO_FONT, buf)) + bb_perror_msg_and_die("PIO_FONT ioctl error"); +} + +static void +do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) +{ + struct unimapinit advice; + struct unimapdesc ud; + struct unipair *up; + int ct = 0, maxct; + int glyph; + uint16_t unicode; + + maxct = tailsz; /* more than enough */ + up = xmalloc(maxct * sizeof(struct unipair)); + + for (glyph = 0; glyph < fontsize; glyph++) { + while (tailsz >= 2) { + unicode = (((uint16_t) inbuf[1]) << 8) + inbuf[0]; + tailsz -= 2; + inbuf += 2; + if (unicode == PSF_SEPARATOR) + break; + up[ct].unicode = unicode; + up[ct].fontpos = glyph; + ct++; + } + } + + /* Note: after PIO_UNIMAPCLR and before PIO_UNIMAP + this printf did not work on many kernels */ + + advice.advised_hashsize = 0; + advice.advised_hashstep = 0; + advice.advised_hashlevel = 0; + if (ioctl(fd, PIO_UNIMAPCLR, &advice)) { +#ifdef ENOIOCTLCMD + if (errno == ENOIOCTLCMD) { + bb_error_msg("it seems this kernel is older than 1.1.92"); + bb_error_msg_and_die("no Unicode mapping table loaded"); + } else +#endif + bb_perror_msg_and_die("PIO_UNIMAPCLR"); + } + ud.entry_ct = ct; + ud.entries = up; + if (ioctl(fd, PIO_UNIMAP, &ud)) { + bb_perror_msg_and_die("PIO_UNIMAP"); + } +} + +static void loadnewfont(int fd) +{ + int unit; + unsigned char inbuf[32768]; /* primitive */ + unsigned int inputlth, offset; + + /* + * We used to look at the length of the input file + * with stat(); now that we accept compressed files, + * just read the entire file. + */ + inputlth = fread(inbuf, 1, sizeof(inbuf), stdin); + if (ferror(stdin)) + bb_perror_msg_and_die("error reading input font"); + /* use malloc/realloc in case of giant files; + maybe these do not occur: 16kB for the font, + and 16kB for the map leaves 32 unicode values + for each font position */ + if (!feof(stdin)) + bb_perror_msg_and_die("font too large"); + + /* test for psf first */ + { + struct psf_header psfhdr; + int fontsize; + int hastable; + unsigned int head0, head; + + if (inputlth < sizeof(struct psf_header)) + goto no_psf; + + psfhdr = *(struct psf_header *) &inbuf[0]; + + if (!PSF_MAGIC_OK(psfhdr)) + goto no_psf; + + if (psfhdr.mode > PSF_MAXMODE) + bb_error_msg_and_die("unsupported psf file mode"); + fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256); +#if !defined( PIO_FONTX ) || defined( __sparc__ ) + if (fontsize != 256) + bb_error_msg_and_die("only fontsize 256 supported"); +#endif + hastable = (psfhdr.mode & PSF_MODEHASTAB); + unit = psfhdr.charsize; + head0 = sizeof(struct psf_header); + + head = head0 + fontsize * unit; + if (head > inputlth || (!hastable && head != inputlth)) + bb_error_msg_and_die("input file: bad length"); + do_loadfont(fd, inbuf + head0, unit, fontsize); + if (hastable) + do_loadtable(fd, inbuf + head, inputlth - head, fontsize); + return; + } + no_psf: + + /* file with three code pages? */ + if (inputlth == 9780) { + offset = 40; + unit = 16; + } else { + /* bare font */ + if (inputlth & 0377) + bb_error_msg_and_die("bad input file size"); + offset = 0; + unit = inputlth / 256; + } + do_loadfont(fd, inbuf + offset, unit, 256); +} diff --git a/i/pc104/initrd/conf/busybox/console-tools/loadkmap.c b/i/pc104/initrd/conf/busybox/console-tools/loadkmap.c new file mode 100644 index 0000000..a141435 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/loadkmap.c @@ -0,0 +1,62 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini loadkmap implementation for busybox + * + * Copyright (C) 1998 Enrique Zanardi + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * + */ + +#include "busybox.h" + +#define BINARY_KEYMAP_MAGIC "bkeymap" + +/* From */ +struct kbentry { + unsigned char kb_table; + unsigned char kb_index; + unsigned short kb_value; +}; +/* sets one entry in translation table */ +#define KDSKBENT 0x4B47 + +/* From */ +#define NR_KEYS 128 +#define MAX_NR_KEYMAPS 256 + +int loadkmap_main(int argc, char **argv); +int loadkmap_main(int argc, char **argv) +{ + struct kbentry ke; + int i, j, fd; + uint16_t ibuff[NR_KEYS]; + char flags[MAX_NR_KEYMAPS]; + char buff[7]; + + if (argc != 1) + bb_show_usage(); + + fd = xopen(CURRENT_VC, O_RDWR); + + xread(0, buff, 7); + if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7)) + bb_error_msg_and_die("this is not a valid binary keymap"); + + xread(0, flags, MAX_NR_KEYMAPS); + + for (i = 0; i < MAX_NR_KEYMAPS; i++) { + if (flags[i] == 1) { + xread(0, ibuff, NR_KEYS * sizeof(uint16_t)); + for (j = 0; j < NR_KEYS; j++) { + ke.kb_index = j; + ke.kb_table = i; + ke.kb_value = ibuff[j]; + ioctl(fd, KDSKBENT, &ke); + } + } + } + + if (ENABLE_FEATURE_CLEAN_UP) close(fd); + return 0; +} diff --git a/i/pc104/initrd/conf/busybox/console-tools/openvt.c b/i/pc104/initrd/conf/busybox/console-tools/openvt.c new file mode 100644 index 0000000..eb9f49f --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/openvt.c @@ -0,0 +1,43 @@ +/* vi: set sw=4 ts=4: */ +/* + * openvt.c - open a vt to run a command. + * + * busyboxed by Quy Tonthat + * hacked by Tito + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* getopt not needed */ + +#include "busybox.h" + +int openvt_main(int argc, char **argv); +int openvt_main(int argc, char **argv) +{ + int fd; + char vtname[sizeof(VC_FORMAT) + 2]; + + if (argc < 3) { + bb_show_usage(); + } + /* check for illegal vt number: < 1 or > 63 */ + sprintf(vtname, VC_FORMAT, (int)xatoul_range(argv[1], 1, 63)); + + if (fork() == 0) { + /* child */ + /* leave current vt (controlling tty) */ + setsid(); + /* and grab new one */ + fd = xopen(vtname, O_RDWR); + /* Reassign stdin, stdout and sterr */ + dup2(fd, STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDERR_FILENO); + while (fd > 2) close(fd--); + + BB_EXECVP(argv[2], &argv[2]); + _exit(1); + } + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/console-tools/reset.c b/i/pc104/initrd/conf/busybox/console-tools/reset.c new file mode 100644 index 0000000..03b078c --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/reset.c @@ -0,0 +1,33 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini reset implementation for busybox + * + * Copyright (C) 1999-2004 by Erik Andersen + * Written by Erik Andersen and Kent Robotti + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* no options, no getopt */ + +#include +#include +#include +#include "busybox.h" + +int reset_main(int argc, char **argv); +int reset_main(int argc, char **argv) +{ + if (isatty(1)) { + /* See 'man 4 console_codes' for details: + * "ESC c" -- Reset + * "ESC ( K" -- Select user mapping + * "ESC [ J" -- Erase display + * "ESC [ 0 m" -- Reset all display attributes + * "ESC [ ? 25 h" -- Make cursor visible. + */ + printf("\033c\033(K\033[J\033[0m\033[?25h"); + } + return EXIT_SUCCESS; +} + diff --git a/i/pc104/initrd/conf/busybox/console-tools/resize.c b/i/pc104/initrd/conf/busybox/console-tools/resize.c new file mode 100644 index 0000000..64f318c --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/resize.c @@ -0,0 +1,70 @@ +/* vi: set sw=4 ts=4: */ +/* + * resize - set terminal width and height. + * + * Copyright 2006 Bernhard Fischer + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ +/* no options, no getopt */ +#include "busybox.h" + +#define ESC "\033" + +struct termios old; + +static void +onintr(int sig ATTRIBUTE_UNUSED) +{ + tcsetattr(STDERR_FILENO, TCSANOW, &old); + exit(1); +} + + +int resize_main(int argc, char **argv); +int resize_main(int argc, char **argv) +{ + struct termios new; + struct winsize w = { 0,0,0,0 }; + int ret; + + /* We use _stderr_ in order to make resize usable + * in shell backticks (those redirect stdout away from tty). + * NB: other versions of resize open "/dev/tty" + * and operate on it - should we do the same? + */ + + tcgetattr(STDERR_FILENO, &old); /* fiddle echo */ + new = old; + new.c_cflag |= (CLOCAL | CREAD); + new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); + signal(SIGINT, onintr); + signal(SIGQUIT, onintr); + signal(SIGTERM, onintr); + signal(SIGALRM, onintr); + tcsetattr(STDERR_FILENO, TCSANOW, &new); + + /* save_cursor_pos 7 + * scroll_whole_screen [r + * put_cursor_waaaay_off [$x;$yH + * get_cursor_pos [6n + * restore_cursor_pos 8 + */ + fprintf(stderr, ESC"7" ESC"[r" ESC"[999;999H" ESC"[6n"); + alarm(3); /* Just in case terminal won't answer */ + scanf(ESC"[%hu;%huR", &w.ws_row, &w.ws_col); + fprintf(stderr, ESC"8"); + + /* BTW, other versions of resize recalculate w.ws_xpixel, ws.ws_ypixel + * by calculating character cell HxW from old values + * (gotten via TIOCGWINSZ) and recomputing *pixel values */ + ret = ioctl(STDERR_FILENO, TIOCSWINSZ, &w); + + tcsetattr(STDERR_FILENO, TCSANOW, &old); + + if (ENABLE_FEATURE_RESIZE_PRINT) + printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n", + w.ws_col, w.ws_row); + + return ret; +} diff --git a/i/pc104/initrd/conf/busybox/console-tools/setconsole.c b/i/pc104/initrd/conf/busybox/console-tools/setconsole.c new file mode 100644 index 0000000..7ddef69 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/setconsole.c @@ -0,0 +1,48 @@ +/* vi: set sw=4 ts=4: */ +/* + * setconsole.c - redirect system console output + * + * Copyright (C) 2004,2005 Enrik Berkhan + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "busybox.h" + +#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS +static const struct option setconsole_long_options[] = { + { "reset", 0, NULL, 'r' }, + { 0, 0, 0, 0 } +}; +#endif + +#define OPT_SETCONS_RESET 1 + +int setconsole_main(int argc, char **argv); +int setconsole_main(int argc, char **argv) +{ + unsigned long flags; + const char *device = CURRENT_TTY; + +#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS + applet_long_options = setconsole_long_options; +#endif + flags = getopt32(argc, argv, "r"); + + if (argc - optind > 1) + bb_show_usage(); + + if (argc - optind == 1) { + if (flags & OPT_SETCONS_RESET) + bb_show_usage(); + device = argv[optind]; + } else { + if (flags & OPT_SETCONS_RESET) + device = DEV_CONSOLE; + } + + if (-1 == ioctl(xopen(device, O_RDONLY), TIOCCONS)) { + bb_perror_msg_and_die("TIOCCONS"); + } + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/console-tools/setkeycodes.c b/i/pc104/initrd/conf/busybox/console-tools/setkeycodes.c new file mode 100644 index 0000000..ff137d5 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/setkeycodes.c @@ -0,0 +1,50 @@ +/* vi: set sw=4 ts=4: */ +/* + * setkeycodes + * + * Copyright (C) 1994-1998 Andries E. Brouwer + * + * Adjusted for BusyBox by Erik Andersen + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include +#include "busybox.h" + + +/* From */ +struct kbkeycode { + unsigned int scancode, keycode; +}; +enum { + KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */ +}; + +int setkeycodes_main(int argc, char** argv); +int setkeycodes_main(int argc, char** argv) +{ + int fd, sc; + struct kbkeycode a; + + if (argc % 2 != 1 || argc < 2) { + bb_show_usage(); + } + + fd = get_console_fd(); + + while (argc > 2) { + a.keycode = xatoul_range(argv[2], 0, 127); + a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255); + if (a.scancode > 127) { + a.scancode -= 0xe000; + a.scancode += 128; + } + if (ioctl(fd, KDSETKEYCODE, &a)) { + bb_perror_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode); + } + argc -= 2; + argv += 2; + } + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/console-tools/setlogcons.c b/i/pc104/initrd/conf/busybox/console-tools/setlogcons.c new file mode 100644 index 0000000..7b5addc --- /dev/null +++ b/i/pc104/initrd/conf/busybox/console-tools/setlogcons.c @@ -0,0 +1,32 @@ +/* vi: set sw=4 ts=4: */ +/* + * setlogcons: Send kernel messages to the current console or to console N + * + * Copyright (C) 2006 by Jan Kiszka + * + * Based on setlogcons (kbd-1.12) by Andries E. Brouwer + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "busybox.h" + +int setlogcons_main(int argc, char **argv); +int setlogcons_main(int argc, char **argv) +{ + struct { + char fn; + char subarg; + } arg; + + arg.fn = 11; /* redirect kernel messages */ + arg.subarg = 0; /* to specified console (current as default) */ + + if (argc == 2) + arg.subarg = xatoul_range(argv[1], 0, 63); + + if (ioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg)) + bb_perror_msg_and_die("TIOCLINUX"); + + return 0; +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/Config.in b/i/pc104/initrd/conf/busybox/coreutils/Config.in new file mode 100644 index 0000000..000f3a8 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/Config.in @@ -0,0 +1,782 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/kbuild/config-language.txt. +# + +menu "Coreutils" + +config BASENAME + bool "basename" + default n + help + basename is used to strip the directory and suffix from filenames, + leaving just the filename itself. Enable this option if you wish + to enable the 'basename' utility. + +config CAL + bool "cal" + default n + help + cal is used to display a monthly calender. + +config CAT + bool "cat" + default n + help + cat is used to concatenate files and print them to the standard + output. Enable this option if you wish to enable the 'cat' utility. + +config CATV + bool "catv" + default n + help + Display nonprinting characters as escape sequences (like some + implementations' cat -v option). + +config CHGRP + bool "chgrp" + default n + help + chgrp is used to change the group ownership of files. + +config CHMOD + bool "chmod" + default n + help + chmod is used to change the access permission of files. + +config CHOWN + bool "chown" + default n + help + chown is used to change the user and/or group ownership + of files. + +config CHROOT + bool "chroot" + default n + help + chroot is used to change the root directory and run a command. + The default command is `/bin/sh'. + +config CKSUM + bool "cksum" + default n + help + cksum is used to calculate the CRC32 checksum of a file. + +config CMP + bool "cmp" + default n + help + cmp is used to compare two files and returns the result + to standard output. + +config COMM + bool "comm" + default n + help + comm is used to compare two files line by line and return + a three-column output. + +config CP + bool "cp" + default n + help + cp is used to copy files and directories. + +config CUT + bool "cut" + default n + help + cut is used to print selected parts of lines from + each file to stdout. + +config DATE + bool "date" + default n + help + date is used to set the system date or display the + current time in the given format. + +config FEATURE_DATE_ISOFMT + bool "Enable ISO date format output (-I)" + default y + depends on DATE + help + Enable option (-I) to output an ISO-8601 compliant + date/time string. + +config DD + bool "dd" + default n + help + dd copies a file (from standard input to standard output, + by default) using specific input and output blocksizes, + while optionally performing conversions on it. + +config FEATURE_DD_SIGNAL_HANDLING + bool "Enable DD signal handling for status reporting" + default y + depends on DD + help + sending a SIGUSR1 signal to a running `dd' process makes it + print to standard error the number of records read and written + so far, then to resume copying. + + $ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid + 10899206+0 records in 10899206+0 records out + +config FEATURE_DD_IBS_OBS + bool "Enable ibs, obs and conv options" + default n + depends on DD + help + Enables support for writing a certain number of bytes in and out, + at a time, and performing conversions on the data stream. + +config DF + bool "df" + default n + help + df reports the amount of disk space used and available + on filesystems. + +config DIFF + bool "diff" + default n + help + diff compares two files or directories and outputs the + differences between them in a form that can be given to + the patch command. + +config FEATURE_DIFF_BINARY + bool "Enable checks for binary files" + default y + depends on DIFF + help + This option enables support for checking for binary files + before a comparison is carried out. + +config FEATURE_DIFF_DIR + bool "Enable directory support" + default y + depends on DIFF + help + This option enables support for directory and subdirectory + comparison. + +config FEATURE_DIFF_MINIMAL + bool "Enable -d option to find smaller sets of changes" + default n + depends on DIFF + help + Enabling this option allows the use of -d to make diff + try hard to find the smallest possible set of changes. + +config DIRNAME + bool "dirname" + default n + help + dirname is used to strip a non-directory suffix from + a file name. + +config DOS2UNIX + bool "dos2unix/unix2dos" + default n + help + dos2unix is used to convert a text file from DOS format to + UNIX format, and vice versa. + +config UNIX2DOS + bool + default y + depends on DOS2UNIX + help + unix2dos is used to convert a text file from UNIX format to + DOS format, and vice versa. + +config DU + bool "du (default blocksize of 512 bytes)" + default n + help + du is used to report the amount of disk space used + for specified files. + +config FEATURE_DU_DEFAULT_BLOCKSIZE_1K + bool "Use a default blocksize of 1024 bytes (1K)" + default y + depends on DU + help + Use a blocksize of (1K) instead of the default 512b. + +config ECHO + bool "echo (basic SuSv3 version taking no options)" + default n + help + echo is used to print a specified string to stdout. + +# this entry also appears in shell/Config.in, next to the echo builtin +config FEATURE_FANCY_ECHO + bool "Enable echo options (-n and -e)" + default y + depends on ECHO + help + This adds options (-n and -e) to echo. + +config ENV + bool "env" + default n + help + env is used to set an environment variable and run + a command; without options it displays the current + environment. + +config FEATURE_ENV_LONG_OPTIONS + bool "Enable long options" + default n + depends on ENV && GETOPT_LONG + help + Support long options for the env applet. + +config EXPR + bool "expr" + default n + help + expr is used to calculate numbers and print the result + to standard output. + +config EXPR_MATH_SUPPORT_64 + bool "Extend Posix numbers support to 64 bit" + default n + depends on EXPR + help + Enable 64-bit math support in the expr applet. This will make + the applet slightly larger, but will allow computation with very + large numbers. + +config FALSE + bool "false" + default n + help + false returns an exit code of FALSE (1). + +config FOLD + bool "fold" + default n + help + Wrap text to fit a specific width. + +config HEAD + bool "head" + default n + help + head is used to print the first specified number of lines + from files. + +config FEATURE_FANCY_HEAD + bool "Enable head options (-c, -q, and -v)" + default n + depends on HEAD + help + This enables the head options (-c, -q, and -v). + +config HOSTID + bool "hostid" + default n + help + hostid prints the numeric identifier (in hexadecimal) for + the current host. + +config ID + bool "id" + default n + help + id displays the current user and group ID names. + +config INSTALL + bool "install" + default n + help + Copy files and set attributes. + +config FEATURE_INSTALL_LONG_OPTIONS + bool "Enable long options" + default n + depends on INSTALL && GETOPT_LONG + help + Support long options for the install applet. + +config LENGTH + bool "length" + default n + help + length is used to print out the length of a specified string. + +config LN + bool "ln" + default n + help + ln is used to create hard or soft links between files. + +config LOGNAME + bool "logname" + default n + help + logname is used to print the current user's login name. + +config LS + bool "ls" + default n + help + ls is used to list the contents of directories. + +config FEATURE_LS_FILETYPES + bool "Enable filetyping options (-p and -F)" + default y + depends on LS + help + Enable the ls options (-p and -F). + +config FEATURE_LS_FOLLOWLINKS + bool "Enable symlinks dereferencing (-L)" + default y + depends on LS + help + Enable the ls option (-L). + +config FEATURE_LS_RECURSIVE + bool "Enable recursion (-R)" + default y + depends on LS + help + Enable the ls option (-R). + +config FEATURE_LS_SORTFILES + bool "Sort the file names" + default y + depends on LS + help + Allow ls to sort file names alphabetically. + +config FEATURE_LS_TIMESTAMPS + bool "Show file timestamps" + default y + depends on LS + help + Allow ls to display timestamps for files. + +config FEATURE_LS_USERNAME + bool "Show username/groupnames" + default y + depends on LS + help + Allow ls to display username/groupname for files. + +config FEATURE_LS_COLOR + bool "Allow use of color to identify file types" + default y + depends on LS && GETOPT_LONG + help + This enables the --color option to ls. + +config FEATURE_LS_COLOR_IS_DEFAULT + bool "Produce colored ls output by default" + default n + depends on FEATURE_LS_COLOR + help + Saying yes here will turn coloring on by default, + even if no "--color" option is given to the ls command. + This is not recommended, since the colors are not + configurable, and the output may not be legible on + many output screens. + +config MD5SUM + bool "md5sum" + default n + help + md5sum is used to print or check MD5 checksums. + +config MKDIR + bool "mkdir" + default n + help + mkdir is used to create directories with the specified names. + +config FEATURE_MKDIR_LONG_OPTIONS + bool "Enable long options" + default n + depends on MKDIR && GETOPT_LONG + help + Support long options for the mkdir applet. + +config MKFIFO + bool "mkfifo" + default n + help + mkfifo is used to create FIFOs (named pipes). + The `mknod' program can also create FIFOs. + +config MKNOD + bool "mknod" + default n + help + mknod is used to create FIFOs or block/character special + files with the specified names. + +config MV + bool "mv" + default n + help + mv is used to move or rename files or directories. + +config FEATURE_MV_LONG_OPTIONS + bool "Enable long options" + default n + depends on MV && GETOPT_LONG + help + Support long options for the mv applet. + +config NICE + bool "nice" + default n + help + nice runs a program with modified scheduling priority. + +config NOHUP + bool "nohup" + default n + help + run a command immune to hangups, with output to a non-tty. + +config OD + bool "od" + default n + help + od is used to dump binary files in octal and other formats. + +config PRINTENV + bool "printenv" + default n + help + printenv is used to print all or part of environment. + +config PRINTF + bool "printf" + default n + help + printf is used to format and print specified strings. + It's similar to `echo' except it has more options. + +config PWD + bool "pwd" + default n + help + pwd is used to print the current directory. + +config REALPATH + bool "realpath" + default n + help + Return the canonicalized absolute pathname. + This isn't provided by GNU shellutils, but where else does it belong. + +config RM + bool "rm" + default n + help + rm is used to remove files or directories. + +config RMDIR + bool "rmdir" + default n + help + rmdir is used to remove empty directories. + +config SEQ + bool "seq" + default n + help + print a sequence of numbers + +config SHA1SUM + bool "sha1sum" + default n + help + Compute and check SHA1 message digest + +config SLEEP + bool "sleep (single integer arg with no suffix)" + default n + help + sleep is used to pause for a specified number of seconds, + +config FEATURE_FANCY_SLEEP + bool "Enable multiple integer args and optional time suffixes" + default n + depends on SLEEP + help + Allow sleep to pause for specified minutes, hours, and days. + +config SORT + bool "sort" + default n + help + sort is used to sort lines of text in specified files. + +config FEATURE_SORT_BIG + bool "full SuSv3 compliant sort (Support -ktcsbdfiozgM)" + default y + depends on SORT + help + Without this, sort only supports -r, -u, and an integer version + of -n. Selecting this adds sort keys, floating point support, and + more. This adds a little over 3k to a nonstatic build on x86. + + The SuSv3 sort standard is available at: + http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html + +config STAT + bool "stat" + default n + help + display file or filesystem status. + +config FEATURE_STAT_FORMAT + bool "Enable custom formats (-c)" + default n + depends on STAT + help + Without this, stat will not support the '-c format' option where + users can pass a custom format string for output. This adds about + 7k to a nonstatic build on amd64. + +config STTY + bool "stty" + default n + help + stty is used to change and print terminal line settings. + +config SUM + bool "sum" + default n + help + checksum and count the blocks in a file + +config SYNC + bool "sync" + default n + help + sync is used to flush filesystem buffers. + +config TAIL + bool "tail" + default n + help + tail is used to print the last specified number of lines + from files. + +config FEATURE_FANCY_TAIL + bool "Enable extra tail options (-q, -s, and -v)" + default y + depends on TAIL + help + The options (-q, -s, and -v) are provided by GNU tail, but + are not specific in the SUSv3 standard. + +config TEE + bool "tee" + default n + help + tee is used to read from standard input and write + to standard output and files. + +config FEATURE_TEE_USE_BLOCK_IO + bool "Enable block i/o (larger/faster) instead of byte i/o." + default n + depends on TEE + help + Enable this option for a faster tee, at expense of size. + +config TEST + bool "test" + default n + help + test is used to check file types and compare values, + returning an appropriate exit code. The bash shell + has test built in, ash can build it in optionally. + +config FEATURE_TEST_64 + bool "Extend test to 64 bit" + default n + depends on TEST + help + Enable 64-bit support in test. + +config TOUCH + bool "touch" + default n + help + touch is used to create or change the access and/or + modification timestamp of specified files. + +config TR + bool "tr" + default n + help + tr is used to squeeze, and/or delete characters from standard + input, writing to standard output. + +config FEATURE_TR_CLASSES + bool "Enable character classes (such as [:upper:])" + default n + depends on TR + help + Enable character classes, enabling commands such as: + tr [:upper:] [:lower:] to convert input into lowercase. + +config FEATURE_TR_EQUIV + bool "Enable equivalence classes" + default n + depends on TR + help + Enable equivalence classes, which essentially add the enclosed + character to the current set. For instance, tr [=a=] xyz would + replace all instances of 'a' with 'xyz'. This option is mainly + useful for cases when no other way of expressing a character + is possible. + +config TRUE + bool "true" + default n + help + true returns an exit code of TRUE (0). + +config TTY + bool "tty" + default n + help + tty is used to print the name of the current terminal to + standard output. + +config UNAME + bool "uname" + default n + help + uname is used to print system information. + +config UNIQ + bool "uniq" + default n + help + uniq is used to remove duplicate lines from a sorted file. + +config USLEEP + bool "usleep" + default n + help + usleep is used to pause for a specified number of microseconds. + +config UUDECODE + bool "uudecode" + default n + help + uudecode is used to decode a uuencoded file. + +config UUENCODE + bool "uuencode" + default n + help + uuencode is used to uuencode a file. + +config WATCH + bool "watch" + default n + select DATE + help + watch is used to execute a program periodically, showing + output to the screen. + +config WC + bool "wc" + default n + help + wc is used to print the number of bytes, words, and lines, + in specified files. + +config FEATURE_WC_LARGE + bool "Support very large files in wc" + default n + depends on WC + help + Use "unsigned long long" in wc for count variables + +config WHO + bool "who" + default n + select FEATURE_UTMP + help + who is used to show who is logged on. + +config WHOAMI + bool "whoami" + default n + help + whoami is used to print the username of the current + user id (same as id -un). + +config YES + bool "yes" + default n + help + yes is used to repeatedly output a specific string, or + the default string `y'. + +comment "Common options for cp and mv" + depends on CP || MV + +config FEATURE_PRESERVE_HARDLINKS + bool "Preserve hard links" + default n + depends on CP || MV + help + Allow cp and mv to preserve hard links. + +comment "Common options for ls, more and telnet" + depends on LS || MORE || TELNET + +config FEATURE_AUTOWIDTH + bool "Calculate terminal & column widths" + default y + depends on LS || MORE || TELNET + help + This option allows utilities such as 'ls', 'more' and 'telnet' + to determine the width of the screen, which can allow them to + display additional text or avoid wrapping text onto the next line. + If you leave this disabled, your utilities will be especially + primitive and will be unable to determine the current screen width. + +comment "Common options for df, du, ls" + depends on DF || DU || LS + +config FEATURE_HUMAN_READABLE + bool "Support for human readable output (example 13k, 23M, 235G)" + default n + depends on DF || DU || LS + help + Allow df, du, and ls to have human readable output. + +comment "Common options for md5sum, sha1sum" + depends on MD5SUM || SHA1SUM + +config FEATURE_MD5_SHA1_SUM_CHECK + bool "Enable -c, -s and -w options" + default n + depends on MD5SUM || SHA1SUM + help + Enabling the -c options allows files to be checked + against pre-calculated hash values. + + -s and -w are useful options when verifying checksums. + +endmenu diff --git a/i/pc104/initrd/conf/busybox/coreutils/Kbuild b/i/pc104/initrd/conf/busybox/coreutils/Kbuild new file mode 100644 index 0000000..dfdcbd4 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/Kbuild @@ -0,0 +1,85 @@ +# Makefile for busybox +# +# Copyright (C) 1999-2005 by Erik Andersen +# +# Licensed under the GPL v2, see the file LICENSE in this tarball. + +libs-y += libcoreutils/ + +lib-y:= +lib-$(CONFIG_BASENAME) += basename.o +lib-$(CONFIG_CAL) += cal.o +lib-$(CONFIG_CAT) += cat.o +lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty +lib-$(CONFIG_LESS) += cat.o # less too +lib-$(CONFIG_CATV) += catv.o +lib-$(CONFIG_CHGRP) += chgrp.o chown.o +lib-$(CONFIG_CHMOD) += chmod.o +lib-$(CONFIG_CHOWN) += chown.o +lib-$(CONFIG_CHROOT) += chroot.o +lib-$(CONFIG_CKSUM) += cksum.o +lib-$(CONFIG_CMP) += cmp.o +lib-$(CONFIG_COMM) += comm.o +lib-$(CONFIG_CP) += cp.o +lib-$(CONFIG_CUT) += cut.o +lib-$(CONFIG_DATE) += date.o +lib-$(CONFIG_DD) += dd.o +lib-$(CONFIG_DF) += df.o +lib-$(CONFIG_DIFF) += diff.o +lib-$(CONFIG_DIRNAME) += dirname.o +lib-$(CONFIG_DOS2UNIX) += dos2unix.o +lib-$(CONFIG_DU) += du.o +lib-$(CONFIG_ECHO) += echo.o +lib-$(CONFIG_ASH) += echo.o # used by ash +lib-$(CONFIG_ENV) += env.o +lib-$(CONFIG_EXPR) += expr.o +lib-$(CONFIG_FALSE) += false.o +lib-$(CONFIG_FOLD) += fold.o +lib-$(CONFIG_HEAD) += head.o +lib-$(CONFIG_HOSTID) += hostid.o +lib-$(CONFIG_ID) += id.o +lib-$(CONFIG_INSTALL) += install.o +lib-$(CONFIG_LENGTH) += length.o +lib-$(CONFIG_LN) += ln.o +lib-$(CONFIG_LOGNAME) += logname.o +lib-$(CONFIG_LS) += ls.o +lib-$(CONFIG_MD5SUM) += md5_sha1_sum.o +lib-$(CONFIG_MKDIR) += mkdir.o +lib-$(CONFIG_MKFIFO) += mkfifo.o +lib-$(CONFIG_MKNOD) += mknod.o +lib-$(CONFIG_MV) += mv.o +lib-$(CONFIG_NICE) += nice.o +lib-$(CONFIG_NOHUP) += nohup.o +lib-$(CONFIG_OD) += od.o +lib-$(CONFIG_PRINTENV) += printenv.o +lib-$(CONFIG_PRINTF) += printf.o +lib-$(CONFIG_PWD) += pwd.o +lib-$(CONFIG_REALPATH) += realpath.o +lib-$(CONFIG_RM) += rm.o +lib-$(CONFIG_RMDIR) += rmdir.o +lib-$(CONFIG_SEQ) += seq.o +lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o +lib-$(CONFIG_SLEEP) += sleep.o +lib-$(CONFIG_SORT) += sort.o +lib-$(CONFIG_STAT) += stat.o +lib-$(CONFIG_STTY) += stty.o +lib-$(CONFIG_SUM) += sum.o +lib-$(CONFIG_SYNC) += sync.o +lib-$(CONFIG_TAIL) += tail.o +lib-$(CONFIG_TEE) += tee.o +lib-$(CONFIG_TEST) += test.o +lib-$(CONFIG_ASH) += test.o # used by ash +lib-$(CONFIG_TOUCH) += touch.o +lib-$(CONFIG_TR) += tr.o +lib-$(CONFIG_TRUE) += true.o +lib-$(CONFIG_TTY) += tty.o +lib-$(CONFIG_UNAME) += uname.o +lib-$(CONFIG_UNIQ) += uniq.o +lib-$(CONFIG_USLEEP) += usleep.o +lib-$(CONFIG_UUDECODE) += uudecode.o +lib-$(CONFIG_UUENCODE) += uuencode.o +lib-$(CONFIG_WATCH) += watch.o +lib-$(CONFIG_WC) += wc.o +lib-$(CONFIG_WHO) += who.o +lib-$(CONFIG_WHOAMI) += whoami.o +lib-$(CONFIG_YES) += yes.o diff --git a/i/pc104/initrd/conf/busybox/coreutils/basename.c b/i/pc104/initrd/conf/busybox/coreutils/basename.c new file mode 100644 index 0000000..46f7122 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/basename.c @@ -0,0 +1,51 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini basename implementation for busybox + * + * Copyright (C) 1999-2004 by Erik Andersen + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * + */ + +/* BB_AUDIT SUSv3 compliant */ +/* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */ + + +/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) + * + * Changes: + * 1) Now checks for too many args. Need at least one and at most two. + * 2) Don't check for options, as per SUSv3. + * 3) Save some space by using strcmp(). Calling strncmp() here was silly. + */ + +#include +#include +#include +#include "busybox.h" + +int basename_main(int argc, char **argv); +int basename_main(int argc, char **argv) +{ + size_t m, n; + char *s; + + if (((unsigned int)(argc-2)) >= 2) { + bb_show_usage(); + } + + s = bb_get_last_path_component(*++argv); + + if (*++argv) { + n = strlen(*argv); + m = strlen(s); + if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) { + s[m-n] = '\0'; + } + } + + puts(s); + + fflush_stdout_and_exit(EXIT_SUCCESS); +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/cal.c b/i/pc104/initrd/conf/busybox/coreutils/cal.c new file mode 100644 index 0000000..3d61791 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/cal.c @@ -0,0 +1,352 @@ +/* vi: set sw=4 ts=4: */ +/* + * Calendar implementation for busybox + * + * See original copyright at the end of this file + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* BB_AUDIT SUSv3 compliant with -j and -y extensions (from util-linux). */ +/* BB_AUDIT BUG: The output of 'cal -j 1752' is incorrect. The upstream + * BB_AUDIT BUG: version in util-linux seems to be broken as well. */ +/* http://www.opengroup.org/onlinepubs/007904975/utilities/cal.html */ + +/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) + * + * Major size reduction... over 50% (>1.5k) on i386. + */ + +#include "busybox.h" + +#define THURSDAY 4 /* for reformation */ +#define SATURDAY 6 /* 1 Jan 1 was a Saturday */ + +#define FIRST_MISSING_DAY 639787 /* 3 Sep 1752 */ +#define NUMBER_MISSING_DAYS 11 /* 11 day correction */ + +#define MAXDAYS 42 /* max slots in a month array */ +#define SPACE -1 /* used in day array */ + +static const char days_in_month[] = { + 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 +}; + +static const char sep1752[] = { + 1, 2, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30 +}; + +static int julian; + +/* leap year -- account for Gregorian reformation in 1752 */ +#define leap_year(yr) \ + ((yr) <= 1752 ? !((yr) % 4) : \ + (!((yr) % 4) && ((yr) % 100)) || !((yr) % 400)) + +static int is_leap_year(int year) +{ + return leap_year(year); +} +#undef leap_year +#define leap_year(yr) is_leap_year(yr) + +/* number of centuries since 1700, not inclusive */ +#define centuries_since_1700(yr) \ + ((yr) > 1700 ? (yr) / 100 - 17 : 0) + +/* number of centuries since 1700 whose modulo of 400 is 0 */ +#define quad_centuries_since_1700(yr) \ + ((yr) > 1600 ? ((yr) - 1600) / 400 : 0) + +/* number of leap years between year 1 and this year, not inclusive */ +#define leap_years_since_year_1(yr) \ + ((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr)) + +static void center (char *, int, int); +static void day_array (int, int, int *); +static void trim_trailing_spaces_and_print (char *); + +static void blank_string(char *buf, size_t buflen); +static char *build_row(char *p, int *dp); + +#define DAY_LEN 3 /* 3 spaces per day */ +#define J_DAY_LEN (DAY_LEN + 1) +#define WEEK_LEN 20 /* 7 * 3 - one space at the end */ +#define J_WEEK_LEN (WEEK_LEN + 7) +#define HEAD_SEP 2 /* spaces between day headings */ + +int cal_main(int argc, char **argv); +int cal_main(int argc, char **argv) +{ + struct tm *local_time; + struct tm zero_tm; + time_t now; + int month, year, flags, i; + char *month_names[12]; + char day_headings[28]; /* 28 for julian, 21 for nonjulian */ + char buf[40]; + + flags = getopt32(argc, argv, "jy"); + + julian = flags & 1; + + argv += optind; + + month = 0; + + if ((argc -= optind) > 2) { + bb_show_usage(); + } + + if (!argc) { + time(&now); + local_time = localtime(&now); + year = local_time->tm_year + 1900; + if (!(flags & 2)) { + month = local_time->tm_mon + 1; + } + } else { + if (argc == 2) { + month = xatoul_range(*argv++, 1, 12); + } + year = xatoul_range(*argv, 1, 9999); + } + + blank_string(day_headings, sizeof(day_headings) - 7 + 7*julian); + + i = 0; + do { + zero_tm.tm_mon = i; + strftime(buf, sizeof(buf), "%B", &zero_tm); + month_names[i] = xstrdup(buf); + + if (i < 7) { + zero_tm.tm_wday = i; + strftime(buf, sizeof(buf), "%a", &zero_tm); + strncpy(day_headings + i * (3+julian) + julian, buf, 2); + } + } while (++i < 12); + + if (month) { + int row, len, days[MAXDAYS]; + int *dp = days; + char lineout[30]; + + day_array(month, year, dp); + len = sprintf(lineout, "%s %d", month_names[month - 1], year); + printf("%*s%s\n%s\n", + ((7*julian + WEEK_LEN) - len) / 2, "", + lineout, day_headings); + for (row = 0; row < 6; row++) { + build_row(lineout, dp)[0] = '\0'; + dp += 7; + trim_trailing_spaces_and_print(lineout); + } + } else { + int row, which_cal, week_len, days[12][MAXDAYS]; + int *dp; + char lineout[80]; + + sprintf(lineout, "%d", year); + center(lineout, + (WEEK_LEN * 3 + HEAD_SEP * 2) + + julian * (J_WEEK_LEN * 2 + HEAD_SEP + - (WEEK_LEN * 3 + HEAD_SEP * 2)), + 0); + puts("\n"); /* two \n's */ + for (i = 0; i < 12; i++) { + day_array(i + 1, year, days[i]); + } + blank_string(lineout, sizeof(lineout)); + week_len = WEEK_LEN + julian * (J_WEEK_LEN - WEEK_LEN); + for (month = 0; month < 12; month += 3-julian) { + center(month_names[month], week_len, HEAD_SEP); + if (!julian) { + center(month_names[month + 1], week_len, HEAD_SEP); + } + center(month_names[month + 2 - julian], week_len, 0); + printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings); + if (!julian) { + printf("%*s%s", HEAD_SEP, "", day_headings); + } + putchar('\n'); + for (row = 0; row < (6*7); row += 7) { + for (which_cal = 0; which_cal < 3-julian; which_cal++) { + dp = days[month + which_cal] + row; + build_row(lineout + which_cal * (week_len + 2), dp); + } + /* blank_string took care of nul termination. */ + trim_trailing_spaces_and_print(lineout); + } + } + } + + fflush_stdout_and_exit(0); +} + +/* + * day_array -- + * Fill in an array of 42 integers with a calendar. Assume for a moment + * that you took the (maximum) 6 rows in a calendar and stretched them + * out end to end. You would have 42 numbers or spaces. This routine + * builds that array for any month from Jan. 1 through Dec. 9999. + */ +static void day_array(int month, int year, int *days) +{ + long temp; + int i; + int j_offset; + int day, dw, dm; + + memset(days, SPACE, MAXDAYS * sizeof(int)); + + if ((month == 9) && (year == 1752)) { + size_t oday = 0; + + j_offset = julian * 244; + do { + days[oday+2] = sep1752[oday] + j_offset; + } while (++oday < sizeof(sep1752)); + + return; + } + + /* day_in_year + * return the 1 based day number within the year + */ + day = 1; + if ((month > 2) && leap_year(year)) { + ++day; + } + + i = month; + while (i) { + day += days_in_month[--i]; + } + + /* day_in_week + * return the 0 based day number for any date from 1 Jan. 1 to + * 31 Dec. 9999. Assumes the Gregorian reformation eliminates + * 3 Sep. 1752 through 13 Sep. 1752. Returns Thursday for all + * missing days. + */ + dw = THURSDAY; + temp = (long)(year - 1) * 365 + leap_years_since_year_1(year - 1) + + day; + if (temp < FIRST_MISSING_DAY) { + dw = ((temp - 1 + SATURDAY) % 7); + } else if (temp >= (FIRST_MISSING_DAY + NUMBER_MISSING_DAYS)) { + dw = (((temp - 1 + SATURDAY) - NUMBER_MISSING_DAYS) % 7); + } + + if (!julian) { + day = 1; + } + + dm = days_in_month[month]; + if ((month == 2) && leap_year(year)) { + ++dm; + } + + while (dm) { + days[dw++] = day++; + --dm; + } +} + +static void trim_trailing_spaces_and_print(char *s) +{ + char *p = s; + + while (*p) { + ++p; + } + while (p > s) { + --p; + if (!(isspace)(*p)) { /* We want the function... not the inline. */ + p[1] = '\0'; + break; + } + } + + puts(s); +} + +static void center(char *str, int len, int separate) +{ + int n = strlen(str); + len -= n; + printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, ""); +} + +static void blank_string(char *buf, size_t buflen) +{ + memset(buf, ' ', buflen); + buf[buflen-1] = '\0'; +} + +static char *build_row(char *p, int *dp) +{ + int col, val, day; + + memset(p, ' ', (julian + DAY_LEN) * 7); + + col = 0; + do { + if ((day = *dp++) != SPACE) { + if (julian) { + ++p; + if (day >= 100) { + *p = '0'; + p[-1] = (day / 100) + '0'; + day %= 100; + } + } + if ((val = day / 10) > 0) { + *p = val + '0'; + } + *++p = day % 10 + '0'; + p += 2; + } else { + p += DAY_LEN + julian; + } + } while (++col < 7); + + return p; +} + +/* + * Copyright (c) 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Kim Letkeman. + * + * 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 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. + */ + + diff --git a/i/pc104/initrd/conf/busybox/coreutils/cat.c b/i/pc104/initrd/conf/busybox/coreutils/cat.c new file mode 100644 index 0000000..7bab325 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/cat.c @@ -0,0 +1,43 @@ +/* vi: set sw=4 ts=4: */ +/* + * cat implementation for busybox + * + * Copyright (C) 2003 Manuel Novoa III + * + * Licensed under GPLv2, see file License in this tarball for details. + */ + +/* BB_AUDIT SUSv3 compliant */ +/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */ + +#include "busybox.h" + +int bb_cat(char **argv) +{ + static const char *const argv_dash[] = { "-", NULL }; + FILE *f; + int retval = EXIT_SUCCESS; + + if (!*argv) argv = (char**) &argv_dash; + + do { + f = fopen_or_warn_stdin(*argv); + if (f) { + off_t r = bb_copyfd_eof(fileno(f), STDOUT_FILENO); + fclose_if_not_stdin(f); + if (r >= 0) + continue; + } + retval = EXIT_FAILURE; + } while (*++argv); + + return retval; +} + +int cat_main(int argc, char **argv); +int cat_main(int argc, char **argv) +{ + getopt32(argc, argv, "u"); + argv += optind; + return bb_cat(argv); +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/catv.c b/i/pc104/initrd/conf/busybox/coreutils/catv.c new file mode 100644 index 0000000..826e0e9 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/catv.c @@ -0,0 +1,70 @@ +/* vi: set sw=4 ts=4: */ +/* + * cat -v implementation for busybox + * + * Copyright (C) 2006 Rob Landley + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* See "Cat -v considered harmful" at + * http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz */ + +#include "busybox.h" + +int catv_main(int argc, char **argv); +int catv_main(int argc, char **argv) +{ + int retval = EXIT_SUCCESS, fd; + unsigned flags; + + flags = getopt32(argc, argv, "etv"); +#define CATV_OPT_e (1<<0) +#define CATV_OPT_t (1<<1) +#define CATV_OPT_v (1<<2) + flags ^= CATV_OPT_v; + + argv += optind; + do { + /* Read from stdin if there's nothing else to do. */ + fd = 0; + if (*argv && 0 > (fd = xopen(*argv, O_RDONLY))) + retval = EXIT_FAILURE; + else for (;;) { + int i, res; + + res = read(fd, bb_common_bufsiz1, sizeof(bb_common_bufsiz1)); + if (res < 0) + retval = EXIT_FAILURE; + if (res < 1) + break; + for (i = 0; i < res; i++) { + char c = bb_common_bufsiz1[i]; + + if (c > 126 && (flags & CATV_OPT_v)) { + if (c == 127) { + printf("^?"); + continue; + } else { + printf("M-"); + c -= 128; + } + } + if (c < 32) { + if (c == 10) { + if (flags & CATV_OPT_e) + putchar('$'); + } else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) { + printf("^%c", c+'@'); + continue; + } + } + putchar(c); + } + } + if (ENABLE_FEATURE_CLEAN_UP && fd) + close(fd); + } while (*++argv); + + fflush_stdout_and_exit(retval); +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/chgrp.c b/i/pc104/initrd/conf/busybox/coreutils/chgrp.c new file mode 100644 index 0000000..cfb8c15 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/chgrp.c @@ -0,0 +1,28 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini chgrp implementation for busybox + * + * Copyright (C) 1999-2004 by Erik Andersen + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* BB_AUDIT SUSv3 defects - none? */ +/* BB_AUDIT GNU defects - unsupported long options. */ +/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */ + +#include "busybox.h" + +int chgrp_main(int argc, char **argv); +int chgrp_main(int argc, char **argv) +{ + /* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */ + char **p = argv; + while (*++p) { + if (p[0][0] != '-') { + p[0] = xasprintf(":%s", p[0]); + break; + } + } + return chown_main(argc, argv); +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/chmod.c b/i/pc104/initrd/conf/busybox/coreutils/chmod.c new file mode 100644 index 0000000..11c6731 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/chmod.c @@ -0,0 +1,159 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini chmod implementation for busybox + * + * Copyright (C) 1999-2004 by Erik Andersen + * + * Reworked by (C) 2002 Vladimir Oleynik + * to correctly parse '-rwxgoa' + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* BB_AUDIT SUSv3 compliant */ +/* BB_AUDIT GNU defects - unsupported long options. */ +/* http://www.opengroup.org/onlinepubs/007904975/utilities/chmod.html */ + +#include "busybox.h" + +#define OPT_RECURSE (option_mask32 & 1) +#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 2) SKIP_DESKTOP(0)) +#define OPT_CHANGED (USE_DESKTOP(option_mask32 & 4) SKIP_DESKTOP(0)) +#define OPT_QUIET (USE_DESKTOP(option_mask32 & 8) SKIP_DESKTOP(0)) +#define OPT_STR "R" USE_DESKTOP("vcf") + +/* coreutils: + * chmod never changes the permissions of symbolic links; the chmod + * system call cannot change their permissions. This is not a problem + * since the permissions of symbolic links are never used. + * However, for each symbolic link listed on the command line, chmod changes + * the permissions of the pointed-to file. In contrast, chmod ignores + * symbolic links encountered during recursive directory traversals. + */ + +static int fileAction(const char *fileName, struct stat *statbuf, void* param, int depth) +{ + mode_t newmode; + + /* match coreutils behavior */ + if (depth == 0) { + /* statbuf holds lstat result, but we need stat (follow link) */ + if (stat(fileName, statbuf)) + goto err; + } else { /* depth > 0: skip links */ + if (S_ISLNK(statbuf->st_mode)) + return TRUE; + } + newmode = statbuf->st_mode; + + if (!bb_parse_mode((char *)param, &newmode)) + bb_error_msg_and_die("invalid mode: %s", (char *)param); + + if (chmod(fileName, newmode) == 0) { + if (OPT_VERBOSE + || (OPT_CHANGED && statbuf->st_mode != newmode) + ) { + printf("mode of '%s' changed to %04o (%s)\n", fileName, + newmode & 07777, bb_mode_string(newmode)+1); + } + return TRUE; + } + err: + if (!OPT_QUIET) + bb_perror_msg("%s", fileName); + return FALSE; +} + +int chmod_main(int argc, char **argv); +int chmod_main(int argc, char **argv) +{ + int retval = EXIT_SUCCESS; + char *arg, **argp; + char *smode; + + /* Convert first encountered -r into ar, -w into aw etc + * so that getopt would not eat it */ + argp = argv; + while ((arg = *++argp)) { + /* Mode spec must be the first arg (sans -R etc) */ + /* (protect against mishandling e.g. "chmod 644 -r") */ + if (arg[0] != '-') { + arg = NULL; + break; + } + /* An option. Not a -- or valid option? */ + if (arg[1] && !strchr("-"OPT_STR, arg[1])) { + arg[0] = 'a'; + break; + } + } + + /* Parse options */ + opt_complementary = "-2"; + getopt32(argc, argv, ("-"OPT_STR) + 1); /* Reuse string */ + argv += optind; + + /* Restore option-like mode if needed */ + if (arg) arg[0] = '-'; + + /* Ok, ready to do the deed now */ + smode = *argv++; + do { + if (!recursive_action(*argv, + OPT_RECURSE, // recurse + FALSE, // follow links: coreutils doesn't + FALSE, // depth first + fileAction, // file action + fileAction, // dir action + smode, // user data + 0) // depth + ) { + retval = EXIT_FAILURE; + } + } while (*++argv); + + return retval; +} + +/* +Security: chmod is too important and too subtle. +This is a test script (busybox chmod versus coreutils). +Run it in empty directory. + +#!/bin/sh +t1="/tmp/busybox chmod" +t2="/usr/bin/chmod" +create() { + rm -rf $1; mkdir $1 + ( + cd $1 || exit 1 + mkdir dir + >up + >file + >dir/file + ln -s dir linkdir + ln -s file linkfile + ln -s ../up dir/up + ) +} +tst() { + (cd test1; $t1 $1) + (cd test2; $t2 $1) + (cd test1; ls -lR) >out1 + (cd test2; ls -lR) >out2 + echo "chmod $1" >out.diff + if ! diff -u out1 out2 >>out.diff; then exit 1; fi + rm out.diff +} +echo "If script produced 'out.diff' file, then at least one testcase failed" +create test1; create test2 +tst "a+w file" +tst "a-w dir" +tst "a+w linkfile" +tst "a-w linkdir" +tst "-R a+w file" +tst "-R a-w dir" +tst "-R a+w linkfile" +tst "-R a-w linkdir" +tst "a-r,a+x linkfile" +*/ diff --git a/i/pc104/initrd/conf/busybox/coreutils/chown.c b/i/pc104/initrd/conf/busybox/coreutils/chown.c new file mode 100644 index 0000000..f92299e --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/chown.c @@ -0,0 +1,167 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini chown implementation for busybox + * + * Copyright (C) 1999-2004 by Erik Andersen + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* BB_AUDIT SUSv3 defects - none? */ +/* BB_AUDIT GNU defects - unsupported long options. */ +/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */ + +#include "busybox.h" + +#define OPT_STR ("Rh" USE_DESKTOP("vcfLHP")) +#define BIT_RECURSE 1 +#define OPT_RECURSE (option_mask32 & 1) +#define OPT_NODEREF (option_mask32 & 2) +#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 0x04) SKIP_DESKTOP(0)) +#define OPT_CHANGED (USE_DESKTOP(option_mask32 & 0x08) SKIP_DESKTOP(0)) +#define OPT_QUIET (USE_DESKTOP(option_mask32 & 0x10) SKIP_DESKTOP(0)) +/* POSIX options + * -L traverse every symbolic link to a directory encountered + * -H if a command line argument is a symbolic link to a directory, traverse it + * -P do not traverse any symbolic links (default) + * We do not conform to the following: + * "Specifying more than one of -H, -L, and -P is not an error. + * The last option specified shall determine the behavior of the utility." */ +/* -L */ +#define BIT_TRAVERSE 0x20 +#define OPT_TRAVERSE (USE_DESKTOP(option_mask32 & BIT_TRAVERSE) SKIP_DESKTOP(0)) +/* -H or -L */ +#define BIT_TRAVERSE_TOP (0x20|0x40) +#define OPT_TRAVERSE_TOP (USE_DESKTOP(option_mask32 & BIT_TRAVERSE_TOP) SKIP_DESKTOP(0)) + +typedef int (*chown_fptr)(const char *, uid_t, gid_t); + +static struct bb_uidgid_t ugid = { -1, -1 }; + +static int fileAction(const char *fileName, struct stat *statbuf, + void *cf, int depth) +{ + uid_t u = (ugid.uid == (uid_t)-1) ? statbuf->st_uid : ugid.uid; + gid_t g = (ugid.gid == (gid_t)-1) ? statbuf->st_gid : ugid.gid; + + if (!((chown_fptr)cf)(fileName, u, g)) { + if (OPT_VERBOSE + || (OPT_CHANGED && (statbuf->st_uid != u || statbuf->st_gid != g)) + ) { + printf("changed ownership of '%s' to %u:%u\n", + fileName, (unsigned)u, (unsigned)g); + } + return TRUE; + } + if (!OPT_QUIET) + bb_perror_msg("%s", fileName); /* A filename can have % in it... */ + return FALSE; +} + +int chown_main(int argc, char **argv); +int chown_main(int argc, char **argv) +{ + int retval = EXIT_SUCCESS; + chown_fptr chown_func; + + opt_complementary = "-2"; + getopt32(argc, argv, OPT_STR); + argv += optind; + + /* This matches coreutils behavior (almost - see below) */ + chown_func = chown; + if (OPT_NODEREF + /* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */ + USE_DESKTOP( || (option_mask32 & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE) + ) { + chown_func = lchown; + } + + parse_chown_usergroup_or_die(&ugid, argv[0]); + + /* Ok, ready to do the deed now */ + argv++; + do { + char *arg = *argv; + + if (OPT_TRAVERSE_TOP) { + /* resolves symlink (even recursive) */ + arg = xmalloc_realpath(arg); + if (!arg) + continue; + } + + if (!recursive_action(arg, + OPT_RECURSE, // recurse + OPT_TRAVERSE, // follow links if -L + FALSE, // depth first + fileAction, // file action + fileAction, // dir action + chown_func, // user data + 0) // depth + ) { + retval = EXIT_FAILURE; + } + + if (OPT_TRAVERSE_TOP) + free(arg); + } while (*++argv); + + return retval; +} + +/* +Testcase. Run in empty directory. + +#!/bin/sh +t1="/tmp/busybox chown" +t2="/usr/bin/chown" +create() { + rm -rf $1; mkdir $1 + ( + cd $1 || exit 1 + mkdir dir dir2 + >up + >file + >dir/file + >dir2/file + ln -s dir linkdir + ln -s file linkfile + ln -s ../up dir/linkup + ln -s ../dir2 dir/linkupdir2 + ) + chown -R 0:0 $1 +} +tst() { + create test1 + create test2 + (cd test1; $t1 $1) + (cd test2; $t2 $1) + (cd test1; ls -lnR) >out1 + (cd test2; ls -lnR) >out2 + echo "chown $1" >out.diff + if ! diff -u out1 out2 >>out.diff; then exit 1; fi + rm out.diff +} +tst_for_each() { + tst "$1 1:1 file" + tst "$1 1:1 dir" + tst "$1 1:1 linkdir" + tst "$1 1:1 linkfile" +} +echo "If script produced 'out.diff' file, then at least one testcase failed" +# These match coreutils 6.8: +tst_for_each "" +tst_for_each "-R" +tst_for_each "-RP" +tst_for_each "-RL" +tst_for_each "-RH" +tst_for_each "-h" +tst_for_each "-hR" +tst_for_each "-hRP" +# Below: with "chown linkdir" coreutils 6.8 will chown linkdir _target_, +# we lchown _the link_. I believe we are "more correct". +#tst_for_each "-hRL" +#tst_for_each "-hRH" + +*/ diff --git a/i/pc104/initrd/conf/busybox/coreutils/chroot.c b/i/pc104/initrd/conf/busybox/coreutils/chroot.c new file mode 100644 index 0000000..fcd70f2 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/chroot.c @@ -0,0 +1,38 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini chroot implementation for busybox + * + * Copyright (C) 1999-2004 by Erik Andersen + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ + +#include "busybox.h" + +int chroot_main(int argc, char **argv); +int chroot_main(int argc, char **argv) +{ + if (argc < 2) { + bb_show_usage(); + } + + ++argv; + if (chroot(*argv)) { + bb_perror_msg_and_die("cannot change root directory to %s", *argv); + } + xchdir("/"); + + ++argv; + if (argc == 2) { + argv -= 2; + if (!(*argv = getenv("SHELL"))) { + *argv = (char *) DEFAULT_SHELL; + } + argv[1] = (char *) "-i"; + } + + BB_EXECVP(*argv, argv); + bb_perror_msg_and_die("cannot execute %s", *argv); +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/cksum.c b/i/pc104/initrd/conf/busybox/coreutils/cksum.c new file mode 100644 index 0000000..66a255c --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/cksum.c @@ -0,0 +1,54 @@ +/* vi: set sw=4 ts=4: */ +/* + * cksum - calculate the CRC32 checksum of a file + * + * Copyright (C) 2006 by Rob Sullivan, with ideas from code by Walter Harms + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ + +#include "busybox.h" + +int cksum_main(int argc, char **argv); +int cksum_main(int argc, char **argv) +{ + + uint32_t *crc32_table = crc32_filltable(1); + + FILE *fp; + uint32_t crc; + long length, filesize; + int bytes_read; + char *cp; + + int inp_stdin = (argc == optind) ? 1 : 0; + + do { + fp = fopen_or_warn_stdin((inp_stdin) ? bb_msg_standard_input : *++argv); + + crc = 0; + length = 0; + + while ((bytes_read = fread(bb_common_bufsiz1, 1, BUFSIZ, fp)) > 0) { + cp = bb_common_bufsiz1; + length += bytes_read; + while (bytes_read--) + crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ (*cp++)) & 0xffL]; + } + + filesize = length; + + for (; length; length >>= 8) + crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xffL]; + crc ^= 0xffffffffL; + + if (inp_stdin) { + printf("%" PRIu32 " %li\n", crc, filesize); + break; + } + + printf("%" PRIu32 " %li %s\n", crc, filesize, *argv); + fclose(fp); + } while (*(argv + 1)); + + fflush_stdout_and_exit(EXIT_SUCCESS); +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/cmp.c b/i/pc104/initrd/conf/busybox/coreutils/cmp.c new file mode 100644 index 0000000..cff1182 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/cmp.c @@ -0,0 +1,145 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini cmp implementation for busybox + * + * Copyright (C) 2000,2001 by Matt Kraai + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */ +/* http://www.opengroup.org/onlinepubs/007904975/utilities/cmp.html */ + +/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) + * + * Original version majorly reworked for SUSv3 compliance, bug fixes, and + * size optimizations. Changes include: + * 1) Now correctly distinguishes between errors and actual file differences. + * 2) Proper handling of '-' args. + * 3) Actual error checking of i/o. + * 4) Accept SUSv3 -l option. Note that we use the slightly nicer gnu format + * in the '-l' case. + */ + +#include "busybox.h" + +static FILE *cmp_xfopen_input(const char * const filename) +{ + FILE *fp; + + fp = fopen_or_warn_stdin(filename); + if (fp) + return fp; + exit(xfunc_error_retval); /* We already output an error message. */ +} + +static const char fmt_eof[] = "cmp: EOF on %s\n"; +static const char fmt_differ[] = "%s %s differ: char %"OFF_FMT"d, line %d\n"; +// This fmt_l_opt uses gnu-isms. SUSv3 would be "%.0s%.0s%"OFF_FMT"d %o %o\n" +static const char fmt_l_opt[] = "%.0s%.0s%"OFF_FMT"d %3o %3o\n"; + +static const char opt_chars[] = "sl"; +#define CMP_OPT_s (1<<0) +#define CMP_OPT_l (1<<1) + +int cmp_main(int argc, char **argv); +int cmp_main(int argc, char **argv) +{ + FILE *fp1, *fp2, *outfile = stdout; + const char *filename1, *filename2 = "-"; + USE_DESKTOP(off_t skip1 = 0, skip2 = 0;) + off_t char_pos = 0; + int line_pos = 1; /* Hopefully won't overflow... */ + const char *fmt; + int c1, c2; + unsigned opt; + int retval = 0; + + xfunc_error_retval = 2; /* 1 is returned if files are different. */ + + opt_complementary = "?:-1" + USE_DESKTOP(":?4") + SKIP_DESKTOP(":?2") + ":l--s:s--l"; + opt = getopt32(argc, argv, opt_chars); + argv += optind; + + filename1 = *argv; + fp1 = cmp_xfopen_input(filename1); + + if (*++argv) { + filename2 = *argv; +#if ENABLE_DESKTOP + if (*++argv) { + skip1 = XATOOFF(*argv); + if (*++argv) { + skip2 = XATOOFF(*argv); + } + } +#endif + } + + fp2 = cmp_xfopen_input(filename2); + if (fp1 == fp2) { /* Paranoia check... stdin == stdin? */ + /* Note that we don't bother reading stdin. Neither does gnu wc. + * But perhaps we should, so that other apps down the chain don't + * get the input. Consider 'echo hello | (cmp - - && cat -)'. + */ + return 0; + } + + if (opt & CMP_OPT_l) + fmt = fmt_l_opt; + else + fmt = fmt_differ; + +#if ENABLE_DESKTOP + while (skip1) { getc(fp1); skip1--; } + while (skip2) { getc(fp2); skip2--; } +#endif + do { + c1 = getc(fp1); + c2 = getc(fp2); + ++char_pos; + if (c1 != c2) { /* Remember: a read error may have occurred. */ + retval = 1; /* But assume the files are different for now. */ + if (c2 == EOF) { + /* We know that fp1 isn't at EOF or in an error state. But to + * save space below, things are setup to expect an EOF in fp1 + * if an EOF occurred. So, swap things around. + */ + fp1 = fp2; + filename1 = filename2; + c1 = c2; + } + if (c1 == EOF) { + die_if_ferror(fp1, filename1); + fmt = fmt_eof; /* Well, no error, so it must really be EOF. */ + outfile = stderr; + /* There may have been output to stdout (option -l), so + * make sure we fflush before writing to stderr. */ + xfflush_stdout(); + } + if (!(opt & CMP_OPT_s)) { + if (opt & CMP_OPT_l) { + line_pos = c1; /* line_pos is unused in the -l case. */ + } + fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2); + if (opt) { /* This must be -l since not -s. */ + /* If we encountered an EOF, + * the while check will catch it. */ + continue; + } + } + break; + } + if (c1 == '\n') { + ++line_pos; + } + } while (c1 != EOF); + + die_if_ferror(fp1, filename1); + die_if_ferror(fp2, filename2); + + fflush_stdout_and_exit(retval); +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/comm.c b/i/pc104/initrd/conf/busybox/coreutils/comm.c new file mode 100644 index 0000000..b641296 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/comm.c @@ -0,0 +1,127 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini comm implementation for busybox + * + * Copyright (C) 2005 by Robert Sullivan + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "busybox.h" + +#define COMM_OPT_1 0x01 +#define COMM_OPT_2 0x02 +#define COMM_OPT_3 0x04 + +/* These three variables control behaviour if non-zero */ + +static int only_file_1; +static int only_file_2; +static int both; + +/* writeline outputs the input given, appropriately aligned according to class */ +static void writeline(char *line, int class) +{ + if (class == 0) { + if (!only_file_1) + return; + } else if (class == 1) { + if (!only_file_2) + return; + if (only_file_1) + putchar('\t'); + } + else /*if (class == 2)*/ { + if (!both) + return; + if (only_file_1) + putchar('\t'); + if (only_file_2) + putchar('\t'); + } + fputs(line, stdout); +} + +/* This is the real core of the program - lines are compared here */ +static void cmp_files(char **infiles) +{ +#define LINE_LEN 100 +#define BB_EOF_0 0x1 +#define BB_EOF_1 0x2 + char thisline[2][LINE_LEN]; + FILE *streams[2]; + int i; + + for (i = 0; i < 2; ++i) { + streams[i] = ((infiles[i][0] == '=' && infiles[i][1]) ? stdin : xfopen(infiles[i], "r")); + fgets(thisline[i], LINE_LEN, streams[i]); + } + + while (*thisline[0] || *thisline[1]) { + int order = 0; + + i = 0; + if (feof(streams[0])) i |= BB_EOF_0; + if (feof(streams[1])) i |= BB_EOF_1; + + if (!*thisline[0]) + order = 1; + else if (!*thisline[1]) + order = -1; + else { + int tl0_len, tl1_len; + tl0_len = strlen(thisline[0]); + tl1_len = strlen(thisline[1]); + order = memcmp(thisline[0], thisline[1], tl0_len < tl1_len ? tl0_len : tl1_len); + if (!order) + order = tl0_len < tl1_len ? -1 : tl0_len != tl1_len; + } + + if (order == 0 && !i) + writeline(thisline[1], 2); + else if (order > 0 && !(i & BB_EOF_1)) + writeline(thisline[1], 1); + else if (order < 0 && !(i & BB_EOF_0)) + writeline(thisline[0], 0); + + if (i & BB_EOF_0 & BB_EOF_1) { + break; + + } else if (i) { + i = (i & BB_EOF_0 ? 1 : 0); + while (!feof(streams[i])) { + if ((order < 0 && i) || (order > 0 && !i)) + writeline(thisline[i], i); + fgets(thisline[i], LINE_LEN, streams[i]); + } + break; + + } else { + if (order >= 0) + fgets(thisline[1], LINE_LEN, streams[1]); + if (order <= 0) + fgets(thisline[0], LINE_LEN, streams[0]); + } + } + + fclose(streams[0]); + fclose(streams[1]); +} + +int comm_main(int argc, char **argv); +int comm_main(int argc, char **argv) +{ + unsigned long flags; + + flags = getopt32(argc, argv, "123"); + + if (optind + 2 != argc) + bb_show_usage(); + + only_file_1 = !(flags & COMM_OPT_1); + only_file_2 = !(flags & COMM_OPT_2); + both = !(flags & COMM_OPT_3); + + cmp_files(argv + optind); + exit(EXIT_SUCCESS); +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/cp.c b/i/pc104/initrd/conf/busybox/coreutils/cp.c new file mode 100644 index 0000000..a80e0d2 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/cp.c @@ -0,0 +1,100 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini cp implementation for busybox + * + * Copyright (C) 2000 by Matt Kraai + * SELinux support by Yuichi Nakamura + * + * Licensed under GPL v2 or later, see file LICENSE in this tarball for details. + */ + +/* http://www.opengroup.org/onlinepubs/007904975/utilities/cp.html */ + +/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) + * + * Size reduction. + */ + +#include "busybox.h" +#include "libcoreutils/coreutils.h" + +int cp_main(int argc, char **argv); +int cp_main(int argc, char **argv) +{ + struct stat source_stat; + struct stat dest_stat; + const char *last; + const char *dest; + int s_flags; + int d_flags; + int flags; + int status = 0; + enum { + OPT_a = 1 << (sizeof(FILEUTILS_CP_OPTSTR)-1), + OPT_r = 1 << (sizeof(FILEUTILS_CP_OPTSTR)), + OPT_P = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+1), + OPT_H = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+2), + OPT_L = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+3), + }; + + // Soft- and hardlinking don't mix + // -P and -d are the same (-P is POSIX, -d is GNU) + // -r and -R are the same + // -a = -pdR + opt_complementary = "?:l--s:s--l:Pd:rR:apdR"; + flags = getopt32(argc, argv, FILEUTILS_CP_OPTSTR "arPHL"); + /* Default behavior of cp is to dereference, so we don't have to do + * anything special when we are given -L. + * The behavior of -H is *almost* like -L, but not quite, so let's + * just ignore it too for fun. + if (flags & OPT_L) ... + if (flags & OPT_H) ... // deref command-line params only + */ + +#if ENABLE_SELINUX + if (flags & FILEUTILS_PRESERVE_SECURITY_CONTEXT) { + selinux_or_die(); + } +#endif + + flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */ + + if (optind + 2 > argc) { + bb_show_usage(); + } + + last = argv[argc - 1]; + argv += optind; + + /* If there are only two arguments and... */ + if (optind + 2 == argc) { + s_flags = cp_mv_stat2(*argv, &source_stat, + (flags & FILEUTILS_DEREFERENCE) ? stat : lstat); + if (s_flags < 0) + return EXIT_FAILURE; + d_flags = cp_mv_stat(last, &dest_stat); + if (d_flags < 0) + return EXIT_FAILURE; + + /* ...if neither is a directory or... */ + if ( !((s_flags | d_flags) & 2) || + /* ...recursing, the 1st is a directory, and the 2nd doesn't exist... */ + ((flags & FILEUTILS_RECUR) && (s_flags & 2) && !d_flags) + ) { + /* ...do a simple copy. */ + dest = xstrdup(last); + goto DO_COPY; /* Note: optind+2==argc implies argv[1]==last below. */ + } + } + + do { + dest = concat_path_file(last, bb_get_last_path_component(*argv)); + DO_COPY: + if (copy_file(*argv, dest, flags) < 0) { + status = 1; + } + free((void*)dest); + } while (*++argv != last); + + return status; +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/cut.c b/i/pc104/initrd/conf/busybox/coreutils/cut.c new file mode 100644 index 0000000..22014fc --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/cut.c @@ -0,0 +1,287 @@ +/* vi: set sw=4 ts=4: */ +/* + * cut.c - minimalist version of cut + * + * Copyright (C) 1999,2000,2001 by Lineo, inc. + * Written by Mark Whitley + * debloated by Bernhard Fischer + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "busybox.h" + +/* option vars */ +static const char optstring[] = "b:c:f:d:sn"; +#define CUT_OPT_BYTE_FLGS (1<<0) +#define CUT_OPT_CHAR_FLGS (1<<1) +#define CUT_OPT_FIELDS_FLGS (1<<2) +#define CUT_OPT_DELIM_FLGS (1<<3) +#define CUT_OPT_SUPPRESS_FLGS (1<<4) + +static char delim = '\t'; /* delimiter, default is tab */ + +struct cut_list { + int startpos; + int endpos; +}; + +enum { + BOL = 0, + EOL = INT_MAX, + NON_RANGE = -1 +}; + +/* growable array holding a series of lists */ +static struct cut_list *cut_lists; +static unsigned int nlists; /* number of elements in above list */ + + +static int cmpfunc(const void *a, const void *b) +{ + return (((struct cut_list *) a)->startpos - + ((struct cut_list *) b)->startpos); + +} + +static void cut_file(FILE * file) +{ + char *line = NULL; + unsigned int linenum = 0; /* keep these zero-based to be consistent */ + + /* go through every line in the file */ + while ((line = xmalloc_getline(file)) != NULL) { + + /* set up a list so we can keep track of what's been printed */ + char * printed = xzalloc(strlen(line) * sizeof(char)); + char * orig_line = line; + unsigned int cl_pos = 0; + int spos; + + /* cut based on chars/bytes XXX: only works when sizeof(char) == byte */ + if (option_mask32 & (CUT_OPT_CHAR_FLGS | CUT_OPT_BYTE_FLGS)) { + /* print the chars specified in each cut list */ + for (; cl_pos < nlists; cl_pos++) { + spos = cut_lists[cl_pos].startpos; + while (spos < strlen(line)) { + if (!printed[spos]) { + printed[spos] = 'X'; + putchar(line[spos]); + } + spos++; + if (spos > cut_lists[cl_pos].endpos + || cut_lists[cl_pos].endpos == NON_RANGE) + break; + } + } + } else if (delim == '\n') { /* cut by lines */ + spos = cut_lists[cl_pos].startpos; + + /* get out if we have no more lists to process or if the lines + * are lower than what we're interested in */ + if (linenum < spos || cl_pos >= nlists) + goto next_line; + + /* if the line we're looking for is lower than the one we were + * passed, it means we displayed it already, so move on */ + while (spos < linenum) { + spos++; + /* go to the next list if we're at the end of this one */ + if (spos > cut_lists[cl_pos].endpos + || cut_lists[cl_pos].endpos == NON_RANGE) { + cl_pos++; + /* get out if there's no more lists to process */ + if (cl_pos >= nlists) + goto next_line; + spos = cut_lists[cl_pos].startpos; + /* get out if the current line is lower than the one + * we just became interested in */ + if (linenum < spos) + goto next_line; + } + } + + /* If we made it here, it means we've found the line we're + * looking for, so print it */ + puts(line); + goto next_line; + } else { /* cut by fields */ + int ndelim = -1; /* zero-based / one-based problem */ + int nfields_printed = 0; + char *field = NULL; + const char delimiter[2] = { delim, 0 }; + + /* does this line contain any delimiters? */ + if (strchr(line, delim) == NULL) { + if (!(option_mask32 & CUT_OPT_SUPPRESS_FLGS)) + puts(line); + goto next_line; + } + + /* process each list on this line, for as long as we've got + * a line to process */ + for (; cl_pos < nlists && line; cl_pos++) { + spos = cut_lists[cl_pos].startpos; + do { + /* find the field we're looking for */ + while (line && ndelim < spos) { + field = strsep(&line, delimiter); + ndelim++; + } + + /* we found it, and it hasn't been printed yet */ + if (field && ndelim == spos && !printed[ndelim]) { + /* if this isn't our first time through, we need to + * print the delimiter after the last field that was + * printed */ + if (nfields_printed > 0) + putchar(delim); + fputs(field, stdout); + printed[ndelim] = 'X'; + nfields_printed++; /* shouldn't overflow.. */ + } + + spos++; + + /* keep going as long as we have a line to work with, + * this is a list, and we're not at the end of that + * list */ + } while (spos <= cut_lists[cl_pos].endpos && line + && cut_lists[cl_pos].endpos != NON_RANGE); + } + } + /* if we printed anything at all, we need to finish it with a + * newline cuz we were handed a chomped line */ + putchar('\n'); + next_line: + linenum++; + free(printed); + free(orig_line); + } +} + +static const char _op_on_field[] = " only when operating on fields"; + +int cut_main(int argc, char **argv); +int cut_main(int argc, char **argv) +{ + char *sopt, *ltok; + + opt_complementary = "b--bcf:c--bcf:f--bcf"; + getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, <ok); +// argc -= optind; + argv += optind; + if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS))) + bb_error_msg_and_die("expected a list of bytes, characters, or fields"); + if (option_mask32 & BB_GETOPT_ERROR) + bb_error_msg_and_die("only one type of list may be specified"); + + if (option_mask32 & CUT_OPT_DELIM_FLGS) { + if (strlen(ltok) > 1) { + bb_error_msg_and_die("the delimiter must be a single character"); + } + delim = ltok[0]; + } + + /* non-field (char or byte) cutting has some special handling */ + if (!(option_mask32 & CUT_OPT_FIELDS_FLGS)) { + if (option_mask32 & CUT_OPT_SUPPRESS_FLGS) { + bb_error_msg_and_die + ("suppressing non-delimited lines makes sense%s", + _op_on_field); + } + if (delim != '\t') { + bb_error_msg_and_die + ("a delimiter may be specified%s", _op_on_field); + } + } + + /* + * parse list and put values into startpos and endpos. + * valid list formats: N, N-, N-M, -M + * more than one list can be separated by commas + */ + { + char *ntok; + int s = 0, e = 0; + + /* take apart the lists, one by one (they are separated with commas */ + while ((ltok = strsep(&sopt, ",")) != NULL) { + + /* it's actually legal to pass an empty list */ + if (strlen(ltok) == 0) + continue; + + /* get the start pos */ + ntok = strsep(<ok, "-"); + if (ntok == NULL) { + bb_error_msg + ("internal error: ntok is null for start pos!?\n"); + } else if (strlen(ntok) == 0) { + s = BOL; + } else { + s = xatoi_u(ntok); + /* account for the fact that arrays are zero based, while + * the user expects the first char on the line to be char #1 */ + if (s != 0) + s--; + } + + /* get the end pos */ + ntok = strsep(<ok, "-"); + if (ntok == NULL) { + e = NON_RANGE; + } else if (strlen(ntok) == 0) { + e = EOL; + } else { + e = xatoi_u(ntok); + /* if the user specified and end position of 0, that means "til the + * end of the line */ + if (e == 0) + e = EOL; + e--; /* again, arrays are zero based, lines are 1 based */ + if (e == s) + e = NON_RANGE; + } + + /* if there's something left to tokenize, the user passed + * an invalid list */ + if (ltok) + bb_error_msg_and_die("invalid byte or field list"); + + /* add the new list */ + cut_lists = xrealloc(cut_lists, sizeof(struct cut_list) * (++nlists)); + cut_lists[nlists-1].startpos = s; + cut_lists[nlists-1].endpos = e; + } + + /* make sure we got some cut positions out of all that */ + if (nlists == 0) + bb_error_msg_and_die("missing list of positions"); + + /* now that the lists are parsed, we need to sort them to make life + * easier on us when it comes time to print the chars / fields / lines + */ + qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc); + } + + /* argv[0..argc-1] should be names of file to process. If no + * files were specified or '-' was specified, take input from stdin. + * Otherwise, we process all the files specified. */ + if (argv[0] == NULL || LONE_DASH(argv[0])) { + cut_file(stdin); + } else { + FILE *file; + + do { + file = fopen_or_warn(argv[0], "r"); + if (file) { + cut_file(file); + fclose(file); + } + } while (*++argv); + } + if (ENABLE_FEATURE_CLEAN_UP) + free(cut_lists); + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/date.c b/i/pc104/initrd/conf/busybox/coreutils/date.c new file mode 100644 index 0000000..dfc8b2f --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/date.c @@ -0,0 +1,241 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini date implementation for busybox + * + * by Matthew Grant + * + * iso-format handling added by Robert Griebl + * bugfixes and cleanup by Bernhard Fischer + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. +*/ + +#include "busybox.h" + +/* This 'date' command supports only 2 time setting formats, + all the GNU strftime stuff (its in libc, lets use it), + setting time using UTC and displaying it, as well as + an RFC 2822 compliant date output for shell scripting + mail commands */ + +/* Input parsing code is always bulky - used heavy duty libc stuff as + much as possible, missed out a lot of bounds checking */ + +/* Default input handling to save surprising some people */ + + +#define DATE_OPT_RFC2822 0x01 +#define DATE_OPT_SET 0x02 +#define DATE_OPT_UTC 0x04 +#define DATE_OPT_DATE 0x08 +#define DATE_OPT_REFERENCE 0x10 +#define DATE_OPT_TIMESPEC 0x20 +#define DATE_OPT_HINT 0x40 + +static void xputenv(char *s) +{ + if (putenv(s) != 0) + bb_error_msg_and_die(bb_msg_memory_exhausted); +} + +static void maybe_set_utc(int opt) +{ + if (opt & DATE_OPT_UTC) + xputenv((char*)"TZ=UTC0"); +} + +int date_main(int argc, char **argv); +int date_main(int argc, char **argv) +{ + time_t tm; + struct tm tm_time; + unsigned opt; + int ifmt = -1; + char *date_str = NULL; + char *date_fmt = NULL; + char *filename = NULL; + char *isofmt_arg; + char *hintfmt_arg; + + opt_complementary = "?:d--s:s--d" + USE_FEATURE_DATE_ISOFMT(":R--I:I--R"); + opt = getopt32(argc, argv, "Rs:ud:r:" + USE_FEATURE_DATE_ISOFMT("I::D:"), + &date_str, &date_str, &filename + USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg)); + maybe_set_utc(opt); + + if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_TIMESPEC)) { + if (!isofmt_arg) { + ifmt = 0; /* default is date */ + } else { + const char * const isoformats[] = + {"date", "hours", "minutes", "seconds"}; + + for (ifmt = 0; ifmt < 4; ifmt++) + if (!strcmp(isofmt_arg, isoformats[ifmt])) { + break; + } + if (ifmt == 4) /* parse error */ + bb_show_usage(); + } + } + + /* XXX, date_fmt == NULL from this always */ + if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+')) { + date_fmt = &argv[optind][1]; /* Skip over the '+' */ + } else if (date_str == NULL) { + opt |= DATE_OPT_SET; + date_str = argv[optind]; + } + + /* Now we have parsed all the information except the date format + which depends on whether the clock is being set or read */ + + if (filename) { + struct stat statbuf; + xstat(filename, &statbuf); + tm = statbuf.st_mtime; + } else + time(&tm); + memcpy(&tm_time, localtime(&tm), sizeof(tm_time)); + /* Zero out fields - take her back to midnight! */ + if (date_str != NULL) { + tm_time.tm_sec = 0; + tm_time.tm_min = 0; + tm_time.tm_hour = 0; + + /* Process any date input to UNIX time since 1 Jan 1970 */ + if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_HINT)) { + strptime(date_str, hintfmt_arg, &tm_time); + } else if (strchr(date_str, ':') != NULL) { + /* Parse input and assign appropriately to tm_time */ + + if (sscanf(date_str, "%d:%d:%d", &tm_time.tm_hour, &tm_time.tm_min, + &tm_time.tm_sec) == 3) { + /* no adjustments needed */ + } else if (sscanf(date_str, "%d:%d", &tm_time.tm_hour, + &tm_time.tm_min) == 2) { + /* no adjustments needed */ + } else if (sscanf(date_str, "%d.%d-%d:%d:%d", &tm_time.tm_mon, + &tm_time.tm_mday, &tm_time.tm_hour, + &tm_time.tm_min, &tm_time.tm_sec) == 5) { + /* Adjust dates from 1-12 to 0-11 */ + tm_time.tm_mon -= 1; + } else if (sscanf(date_str, "%d.%d-%d:%d", &tm_time.tm_mon, + &tm_time.tm_mday, + &tm_time.tm_hour, &tm_time.tm_min) == 4) { + /* Adjust dates from 1-12 to 0-11 */ + tm_time.tm_mon -= 1; + } else if (sscanf(date_str, "%d.%d.%d-%d:%d:%d", &tm_time.tm_year, + &tm_time.tm_mon, &tm_time.tm_mday, + &tm_time.tm_hour, &tm_time.tm_min, + &tm_time.tm_sec) == 6) { + tm_time.tm_year -= 1900; /* Adjust years */ + tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */ + } else if (sscanf(date_str, "%d.%d.%d-%d:%d", &tm_time.tm_year, + &tm_time.tm_mon, &tm_time.tm_mday, + &tm_time.tm_hour, &tm_time.tm_min) == 5) { + tm_time.tm_year -= 1900; /* Adjust years */ + tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */ + } else { + bb_error_msg_and_die(bb_msg_invalid_date, date_str); + } + } else { + int nr; + char *cp; + + nr = sscanf(date_str, "%2d%2d%2d%2d%d", &tm_time.tm_mon, + &tm_time.tm_mday, &tm_time.tm_hour, &tm_time.tm_min, + &tm_time.tm_year); + + if (nr < 4 || nr > 5) { + bb_error_msg_and_die(bb_msg_invalid_date, date_str); + } + + cp = strchr(date_str, '.'); + if (cp) { + nr = sscanf(cp + 1, "%2d", &tm_time.tm_sec); + if (nr != 1) { + bb_error_msg_and_die(bb_msg_invalid_date, date_str); + } + } + + /* correct for century - minor Y2K problem here? */ + if (tm_time.tm_year >= 1900) { + tm_time.tm_year -= 1900; + } + /* adjust date */ + tm_time.tm_mon -= 1; + } + + /* Correct any day of week and day of year etc. fields */ + tm_time.tm_isdst = -1; /* Be sure to recheck dst. */ + tm = mktime(&tm_time); + if (tm < 0) { + bb_error_msg_and_die(bb_msg_invalid_date, date_str); + } + maybe_set_utc(opt); + + /* if setting time, set it */ + if ((opt & DATE_OPT_SET) && stime(&tm) < 0) { + bb_perror_msg("cannot set date"); + } + } + + /* Display output */ + + /* Deal with format string */ + + if (date_fmt == NULL) { + int i; + date_fmt = xzalloc(32); + if (ENABLE_FEATURE_DATE_ISOFMT && ifmt >= 0) { + strcpy(date_fmt, "%Y-%m-%d"); + if (ifmt > 0) { + i = 8; + date_fmt[i++] = 'T'; + date_fmt[i++] = '%'; + date_fmt[i++] = 'H'; + if (ifmt > 1) { + date_fmt[i++] = ':'; + date_fmt[i++] = '%'; + date_fmt[i++] = 'M'; + } + if (ifmt > 2) { + date_fmt[i++] = ':'; + date_fmt[i++] = '%'; + date_fmt[i++] = 'S'; + } +format_utc: + date_fmt[i++] = '%'; + date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z'; + } + } else if (opt & DATE_OPT_RFC2822) { + /* Undo busybox.c for date -R */ + if (ENABLE_LOCALE_SUPPORT) + setlocale(LC_TIME, "C"); + strcpy(date_fmt, "%a, %d %b %Y %H:%M:%S "); + i = 22; + goto format_utc; + } else /* default case */ + date_fmt = (char*)"%a %b %e %H:%M:%S %Z %Y"; + } + + if (*date_fmt == '\0') { + /* With no format string, just print a blank line */ + *bb_common_bufsiz1 = 0; + } else { + /* Handle special conversions */ + + if (strncmp(date_fmt, "%f", 2) == 0) { + date_fmt = (char*)"%Y.%m.%d-%H:%M:%S"; + } + + /* Generate output string */ + strftime(bb_common_bufsiz1, 200, date_fmt, &tm_time); + } + puts(bb_common_bufsiz1); + + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/dd.c b/i/pc104/initrd/conf/busybox/coreutils/dd.c new file mode 100644 index 0000000..4a094e8 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/dd.c @@ -0,0 +1,249 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini dd implementation for busybox + * + * + * Copyright (C) 2000,2001 Matt Kraai + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "busybox.h" +#include /* For FEATURE_DD_SIGNAL_HANDLING */ + +static const struct suffix_mult dd_suffixes[] = { + { "c", 1 }, + { "w", 2 }, + { "b", 512 }, + { "kD", 1000 }, + { "k", 1024 }, + { "K", 1024 }, // compat with coreutils dd + { "MD", 1000000 }, + { "M", 1048576 }, + { "GD", 1000000000 }, + { "G", 1073741824 }, + { NULL, 0 } +}; + +static off_t out_full, out_part, in_full, in_part; + +static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal) +{ + fprintf(stderr, "%"OFF_FMT"d+%"OFF_FMT"d records in\n" + "%"OFF_FMT"d+%"OFF_FMT"d records out\n", + in_full, in_part, + out_full, out_part); +} + +static ssize_t full_write_or_warn(int fd, const void *buf, size_t len, + const char* filename) +{ + ssize_t n = full_write(fd, buf, len); + if (n < 0) + bb_perror_msg("writing '%s'", filename); + return n; +} + +#if ENABLE_LFS +#define XATOU_SFX xatoull_sfx +#else +#define XATOU_SFX xatoul_sfx +#endif + +int dd_main(int argc, char **argv); +int dd_main(int argc, char **argv) +{ + enum { + sync_flag = 1 << 0, + noerror = 1 << 1, + trunc_flag = 1 << 2, + twobufs_flag = 1 << 3, + }; + int flags = trunc_flag; + size_t oc = 0, ibs = 512, obs = 512; + ssize_t n, w; + off_t seek = 0, skip = 0, count = OFF_T_MAX; + int oflag, ifd, ofd; + const char *infile = NULL, *outfile = NULL; + char *ibuf, *obuf; + + if (ENABLE_FEATURE_DD_SIGNAL_HANDLING) { + struct sigaction sa; + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = dd_output_status; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGUSR1, &sa, 0); + } + + for (n = 1; n < argc; n++) { + char *arg = argv[n]; + /* Must fit into positive ssize_t */ + if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("ibs=", arg, 4)) + ibs = xatoul_range_sfx(arg+4, 0, ((size_t)-1L)/2, dd_suffixes); + else if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("obs=", arg, 4)) + obs = xatoul_range_sfx(arg+4, 0, ((size_t)-1L)/2, dd_suffixes); + else if (!strncmp("bs=", arg, 3)) + ibs = obs = xatoul_range_sfx(arg+3, 0, ((size_t)-1L)/2, dd_suffixes); + /* These can be large: */ + else if (!strncmp("count=", arg, 6)) + count = XATOU_SFX(arg+6, dd_suffixes); + else if (!strncmp("seek=", arg, 5)) + seek = XATOU_SFX(arg+5, dd_suffixes); + else if (!strncmp("skip=", arg, 5)) + skip = XATOU_SFX(arg+5, dd_suffixes); + + else if (!strncmp("if=", arg, 3)) + infile = arg+3; + else if (!strncmp("of=", arg, 3)) + outfile = arg+3; + else if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("conv=", arg, 5)) { + arg += 5; + while (1) { + if (!strncmp("notrunc", arg, 7)) { + flags &= ~trunc_flag; + arg += 7; + } else if (!strncmp("sync", arg, 4)) { + flags |= sync_flag; + arg += 4; + } else if (!strncmp("noerror", arg, 7)) { + flags |= noerror; + arg += 7; + } else { + bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv"); + } + if (arg[0] == '\0') break; + if (*arg++ != ',') bb_show_usage(); + } + } else + bb_show_usage(); + } + + ibuf = obuf = xmalloc(ibs); + if (ibs != obs) { + flags |= twobufs_flag; + obuf = xmalloc(obs); + } + + if (infile != NULL) + ifd = xopen(infile, O_RDONLY); + else { + ifd = STDIN_FILENO; + infile = bb_msg_standard_input; + } + + if (outfile != NULL) { + oflag = O_WRONLY | O_CREAT; + + if (!seek && (flags & trunc_flag)) + oflag |= O_TRUNC; + + ofd = xopen(outfile, oflag); + + if (seek && (flags & trunc_flag)) { + if (ftruncate(ofd, seek * obs) < 0) { + struct stat st; + + if (fstat(ofd, &st) < 0 || S_ISREG(st.st_mode) || + S_ISDIR(st.st_mode)) + goto die_outfile; + } + } + } else { + ofd = STDOUT_FILENO; + outfile = bb_msg_standard_output; + } + + if (skip) { + if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { + while (skip-- > 0) { + n = safe_read(ifd, ibuf, ibs); + if (n < 0) + bb_perror_msg_and_die("%s", infile); + if (n == 0) + break; + } + } + } + + if (seek) { + if (lseek(ofd, seek * obs, SEEK_CUR) < 0) + goto die_outfile; + } + + while (in_full + in_part != count) { + if (flags & noerror) { + /* Pre-zero the buffer when doing the noerror thing */ + memset(ibuf, '\0', ibs); + } + + n = safe_read(ifd, ibuf, ibs); + if (n == 0) + break; + if (n < 0) { + if (flags & noerror) { + n = ibs; + bb_perror_msg("%s", infile); + } else + bb_perror_msg_and_die("%s", infile); + } + if ((size_t)n == ibs) + in_full++; + else { + in_part++; + if (flags & sync_flag) { + memset(ibuf + n, '\0', ibs - n); + n = ibs; + } + } + if (flags & twobufs_flag) { + char *tmp = ibuf; + while (n) { + size_t d = obs - oc; + + if (d > n) + d = n; + memcpy(obuf + oc, tmp, d); + n -= d; + tmp += d; + oc += d; + if (oc == obs) { + w = full_write_or_warn(ofd, obuf, obs, outfile); + if (w < 0) goto out_status; + if (w == obs) + out_full++; + else if (w > 0) + out_part++; + oc = 0; + } + } + } else { + w = full_write_or_warn(ofd, ibuf, n, outfile); + if (w < 0) goto out_status; + if (w == obs) + out_full++; + else if (w > 0) + out_part++; + } + } + + if (ENABLE_FEATURE_DD_IBS_OBS && oc) { + w = full_write_or_warn(ofd, obuf, oc, outfile); + if (w < 0) goto out_status; + if (w > 0) + out_part++; + } + if (close(ifd) < 0) { + bb_perror_msg_and_die("%s", infile); + } + + if (close(ofd) < 0) { + die_outfile: + bb_perror_msg_and_die("%s", outfile); + } + out_status: + dd_output_status(0); + + return EXIT_SUCCESS; +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/df.c b/i/pc104/initrd/conf/busybox/coreutils/df.c new file mode 100644 index 0000000..484cabb --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/df.c @@ -0,0 +1,155 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini df implementation for busybox + * + * Copyright (C) 1999-2004 by Erik Andersen + * based on original code by (I think) Bruce Perens . + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +/* BB_AUDIT SUSv3 _NOT_ compliant -- options -P and -t missing. Also blocksize. */ +/* http://www.opengroup.org/onlinepubs/007904975/utilities/df.html */ + +/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) + * + * Size reduction. Removed floating point dependency. Added error checking + * on output. Output stats on 0-sized filesystems if specifically listed on + * the command line. Properly round *-blocks, Used, and Available quantities. + */ + +#include +#include +#include +#include +#include +#include +#include "busybox.h" + +#ifndef CONFIG_FEATURE_HUMAN_READABLE +static long kscale(long b, long bs) +{ + return ( b * (long long) bs + 1024/2 ) / 1024; +} +#endif + +int df_main(int argc, char **argv); +int df_main(int argc, char **argv) +{ + long blocks_used; + long blocks_percent_used; +#ifdef CONFIG_FEATURE_HUMAN_READABLE + unsigned long df_disp_hr = 1024; +#endif + int status = EXIT_SUCCESS; + unsigned opt; + FILE *mount_table; + struct mntent *mount_entry; + struct statfs s; + static const char hdr_1k[] = "1k-blocks"; /* default display is kilobytes */ + const char *disp_units_hdr = hdr_1k; + +#ifdef CONFIG_FEATURE_HUMAN_READABLE + opt_complementary = "h-km:k-hm:m-hk"; + opt = getopt32(argc, argv, "hmk"); + if (opt & 1) { + df_disp_hr = 0; + disp_units_hdr = " Size"; + } + if (opt & 2) { + df_disp_hr = 1024*1024; + disp_units_hdr = "1M-blocks"; + } +#else + opt = getopt32(argc, argv, "k"); +#endif + + printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n", + "", disp_units_hdr); + + mount_table = NULL; + argv += optind; + if (optind >= argc) { + mount_table = setmntent(bb_path_mtab_file, "r"); + if (!mount_table) { + bb_perror_msg_and_die(bb_path_mtab_file); + } + } + + do { + const char *device; + const char *mount_point; + + if (mount_table) { + mount_entry = getmntent(mount_table); + if (!mount_entry) { + endmntent(mount_table); + break; + } + } else { + mount_point = *argv++; + if (!mount_point) { + break; + } + mount_entry = find_mount_point(mount_point, bb_path_mtab_file); + if (!mount_entry) { + bb_error_msg("%s: can't find mount point", mount_point); + SET_ERROR: + status = EXIT_FAILURE; + continue; + } + } + + device = mount_entry->mnt_fsname; + mount_point = mount_entry->mnt_dir; + + if (statfs(mount_point, &s) != 0) { + bb_perror_msg("%s", mount_point); + goto SET_ERROR; + } + + if ((s.f_blocks > 0) || !mount_table){ + blocks_used = s.f_blocks - s.f_bfree; + blocks_percent_used = 0; + if (blocks_used + s.f_bavail) { + blocks_percent_used = (((long long) blocks_used) * 100 + + (blocks_used + s.f_bavail)/2 + ) / (blocks_used + s.f_bavail); + } + + if (strcmp(device, "rootfs") == 0) { + continue; + } else if (strcmp(device, "/dev/root") == 0) { + /* Adjusts device to be the real root device, + * or leaves device alone if it can't find it */ + device = find_block_device("/"); + if (!device) { + goto SET_ERROR; + } + } + +#ifdef CONFIG_FEATURE_HUMAN_READABLE + printf("%-20s %9s ", device, + make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr)); + + printf("%9s ", + make_human_readable_str( (s.f_blocks - s.f_bfree), + s.f_bsize, df_disp_hr)); + + printf("%9s %3ld%% %s\n", + make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr), + blocks_percent_used, mount_point); +#else + printf("%-20s %9ld %9ld %9ld %3ld%% %s\n", + device, + kscale(s.f_blocks, s.f_bsize), + kscale(s.f_blocks-s.f_bfree, s.f_bsize), + kscale(s.f_bavail, s.f_bsize), + blocks_percent_used, mount_point); +#endif + } + + } while (1); + + fflush_stdout_and_exit(status); +} diff --git a/i/pc104/initrd/conf/busybox/coreutils/diff.c b/i/pc104/initrd/conf/busybox/coreutils/diff.c new file mode 100644 index 0000000..fa6ef10 --- /dev/null +++ b/i/pc104/initrd/conf/busybox/coreutils/diff.c @@ -0,0 +1,1227 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini diff implementation for busybox, adapted from OpenBSD diff. + * + * Copyright (C) 2006 by Robert Sullivan + * Copyright (c) 2003 Todd C. Miller + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include "busybox.h" + +#define FSIZE_MAX 32768 + +/* + * Output flags + */ +#define D_HEADER 1 /* Print a header/footer between files */ +#define D_EMPTY1 2 /* Treat first file as empty (/dev/null) */ +#define D_EMPTY2 4 /* Treat second file as empty (/dev/null) */ + +/* + * Status values for print_status() and diffreg() return values + * Guide: + * D_SAME - files are the same + * D_DIFFER - files differ + * D_BINARY - binary files differ + * D_COMMON - subdirectory common to both dirs + * D_ONLY - file only exists in one dir + * D_MISMATCH1 - path1 a dir, path2 a file + * D_MISMATCH2 - path1 a file, path2 a dir + * D_ERROR - error occurred + * D_SKIPPED1 - skipped path1 as it is a special file + * D_SKIPPED2 - skipped path2 as it is a special file + */ + +#define D_SAME 0 +#define D_DIFFER (1<<0) +#define D_BINARY (1<<1) +#define D_COMMON (1<<2) +#define D_ONLY (1<<3) +#define D_MISMATCH1 (1<<4) +#define D_MISMATCH2 (1<<5) +#define D_ERROR (1<<6) +#define D_SKIPPED1 (1<<7) +#define D_SKIPPED2 (1<<8) + +/* Command line options */ +#define FLAG_a (1<<0) +#define FLAG_b (1<<1) +#define FLAG_d (1<<2) +#define FLAG_i (1<<3) +#define FLAG_L (1<<4) +#define FLAG_N (1<<5) +#define FLAG_q (1<<6) +#define FLAG_r (1<<7) +#define FLAG_s (1<<8) +#define FLAG_S (1<<9) +#define FLAG_t (1<<10) +#define FLAG_T (1<<11) +#define FLAG_U (1<<12) +#define FLAG_w (1<<13) + +/* The following variables should be static, but gcc currently + * creates a much bigger object if we do this. [which version of gcc? --vda] */ +/* 4.x, IIRC also 3.x --bernhard */ +/* Works for gcc 3.4.3. Sizes without and with "static": + # size busybox.t[34]/coreutils/diff.o + text data bss dec hex filename + 6969 8 305 7282 1c72 busybox.t3/coreutils/diff.o + 6969 8 305 7282 1c72 busybox.t4/coreutils/diff.o + --vda + */ +/* This is the default number of lines of context. */ +static int context = 3; +static int status; +static char *start; +static const char *label1; +static const char *label2; +static struct stat stb1, stb2; +USE_FEATURE_DIFF_DIR(static char **dl;) +USE_FEATURE_DIFF_DIR(static int dl_count;) + +struct cand { + int x; + int y; + int pred; +}; + +static struct line { + int serial; + int value; +} *file[2]; + +/* + * The following struct is used to record change information + * doing a "context" or "unified" diff. (see routine "change" to + * understand the highly mnemonic field names) + */ +struct context_vec { + int a; /* start line in old file */ + int b; /* end line in old file */ + int c; /* start line in new file */ + int d; /* end line in new file */ +}; + +static int *J; /* will be overlaid on class */ +static int *class; /* will be overlaid on file[0] */ +static int *klist; /* will be overlaid on file[0] after class */ +static int *member; /* will be overlaid on file[1] */ +static int clen; +static int len[2]; +static int pref, suff; /* length of prefix and suffix */ +static int slen[2]; +static bool anychange; +static long *ixnew; /* will be overlaid on file[1] */ +static long *ixold; /* will be overlaid on klist */ +static struct cand *clist; /* merely a free storage pot for candidates */ +static int clistlen; /* the length of clist */ +static struct line *sfile[2]; /* shortened by pruning common prefix/suffix */ +static struct context_vec *context_vec_start; +static struct context_vec *context_vec_end; +static struct context_vec *context_vec_ptr; + + +static void print_only(const char *path, size_t dirlen, const char *entry) +{ + if (dirlen > 1) + dirlen--; + printf("Only in %.*s: %s\n", (int) dirlen, path, entry); +} + + +static void print_status(int val, char *path1, char *path2, char *entry) +{ + const char * const _entry = entry ? entry : ""; + char * const _path1 = entry ? concat_path_file(path1, _entry) : path1; + char * const _path2 = entry ? concat_path_file(path2, _entry) : path2; + + switch (val) { + case D_ONLY: + print_only(path1, strlen(path1), entry); + break; + case D_COMMON: + printf("Common subdirectories: %s and %s\n", _path1, _path2); + break; + case D_BINARY: + printf("Binary files %s and %s differ\n", _path1, _path2); + break; + case D_DIFFER: + if (option_mask32 & FLAG_q) + printf("Files %s and %s differ\n", _path1, _path2); + break; + case D_SAME: + if (option_mask32 & FLAG_s) + printf("Files %s and %s are identical\n", _path1, _path2); + break; + case D_MISMATCH1: + printf("File %s is a %s while file %s is a %s\n", + _path1, "directory", _path2, "regular file"); + break; + case D_MISMATCH2: + printf("File %s is a %s while file %s is a %s\n", + _path1, "regular file", _path2, "directory"); + break; + case D_SKIPPED1: + printf("File %s is not a regular file or directory and was skipped\n", + _path1); + break; + case D_SKIPPED2: + printf("File %s is not a regular file or directory and was skipped\n", + _path2); + break; + } + if (entry) { + free(_path1); + free(_path2); + } +} +static void fiddle_sum(int *sum, int t) +{ + *sum = (int)(*sum * 127 + t); +} +/* + * Hash function taken from Robert Sedgewick, Algorithms in C, 3d ed., p 578. + */ +static int readhash(FILE * f) +{ + int i, t, space; + int sum; + + sum = 1; + space = 0; + if (!(option_mask32 & (FLAG_b | FLAG_w))) { + for (i = 0; (t = getc(f)) != '\n'; i++) { + if (t == EOF) { + if (i == 0) + return 0; + break; + } + fiddle_sum(&sum, t); + } + } else { + for (i = 0;;) { + switch (t = getc(f)) { + case '\t': + case '\r': + case '\v': + case '\f': + case ' ': + space++; + continue; + default: + if (space && !(option_mask32 & FLAG_w)) { + i++; + space = 0; + } + fiddle_sum(&sum, t); + i++; + continue; + case EOF: + if (i == 0) + return 0; + /* FALLTHROUGH */ + case '\n': + break; + } + break; + } + } + /* + * There is a remote possibility that we end up with a zero sum. + * Zero is used as an EOF marker, so return 1 instead. + */ + return (sum == 0 ? 1 : sum); +} + + +/* + * Check to see if the given files differ. + * Returns 0 if they are the same, 1 if different, and -1 on error. + */ +static int files_differ(FILE * f1, FILE * f2, int flags) +{ + size_t i, j; + + if ((flags & (D_EMPTY1 | D_EMPTY2)) || stb1.st_size != stb2.st_size + || (stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT) + ) { + return 1; + } + while (1) { + i = fread(bb_common_bufsiz1, 1, BUFSIZ/2, f1); + j = fread(bb_common_bufsiz1 + BUFSIZ/2, 1, BUFSIZ/2, f2); + if (i != j) + return 1; + if (i == 0) + return (ferror(f1) || ferror(f2)); + if (memcmp(bb_common_bufsiz1, + bb_common_bufsiz1 + BUFSIZ/2, i) != 0) + return 1; + } +} + + +static void prepare(int i, FILE * fd, off_t filesize) +{ + struct line *p; + int h; + size_t j, sz; + + rewind(fd); + + sz = (filesize <= FSIZE_MAX ? filesize : FSIZE_MAX) / 25; + if (sz < 100) + sz = 100; + + p = xmalloc((sz + 3) * sizeof(struct line)); + j = 0; + while ((h = readhash(fd))) { + if (j == sz) { + sz = sz * 3 / 2; + p = xrealloc(p, (sz + 3) * sizeof(struct line)); + } + p[++j].value = h; + } + len[i] = j; + file[i] = p; +} + + +static void prune(void) +{ + int i, j; + + for (pref = 0; pref < len[0] && pref < len[1] && + file[0][pref + 1].value == file[1][pref + 1].value; pref++) + ; + for (suff = 0; suff < len[0] - pref && suff < len[1] - pref && + file[0][len[0] - suff].value == file[1][len[1] - suff].value; + suff++) + ; + for (j = 0; j < 2; j++) { + sfile[j] = file[j] + pref; + slen[j] = len[j] - pref - suff; + for (i = 0; i <= slen[j]; i++) + sfile[j][i].serial = i; + } +} + + +static void equiv(struct line *a, int n, struct line *b, int m, int *c) +{ + int i, j; + + i = j = 1; + while (i <= n && j <= m) { + if (a[i].value < b[j].value) + a[i++].value = 0; + else if (a[i].value == b[j].value) + a[i++].value = j; + else + j++; + } + while (i <= n) + a[i++].value = 0; + b[m + 1].value = 0; + j = 0; + while (++j <= m) { + c[j] = -b[j].serial; + while (b[j + 1].value == b[j].value) { + j++; + c[j] = b[j].serial; + } + } + c[j] = -1; +} + + +static int isqrt(int n) +{ + int y, x; + + if (n == 0) + return 0; + x = 1; + do { + y = x; + x = n / x; + x += y; + x /= 2; + } while ((x - y) > 1 || (x - y) < -1); + + return x; +} + + +static int newcand(int x, int y, int pred) +{ + struct cand *q; + + if (clen == clistlen) { + clistlen = clistlen * 11 / 10; + clist = xrealloc(clist, clistlen * sizeof(struct cand)); + } + q = clist + clen; + q->x = x; + q->y = y; + q->pred = pred; + return clen++; +} + + +static int search(int *c, int k, int y) +{ + int i, j, l, t; + + if (clist[c[k]].y < y) /* quick look for typical case */ + return k + 1; + i = 0; + j = k + 1; + while (1) { + l = i + j; + if ((l >>= 1) <= i) + break; + t = clist[c[l]].y; + if (t > y) + j = l; + else if (t < y) + i = l; + else + return l; + } + return l + 1; +} + + +static int stone(int *a, int n, int *b, int *c) +{ + int i, k, y, j, l; + int oldc, tc, oldl; + unsigned int numtries; + +#if ENABLE_FEATURE_DIFF_MINIMAL + const unsigned int bound = + (option_mask32 & FLAG_d) ? UINT_MAX : MAX(256, isqrt(n)); +#else + const unsigned int bound = MAX(256, isqrt(n)); +#endif + k = 0; + c[0] = newcand(0, 0, 0); + for (i = 1; i <= n; i++) { + j = a[i]; + if (j == 0) + continue; + y = -b[j]; + oldl = 0; + oldc = c[0]; + numtries = 0; + do { + if (y <= clist[oldc].y) + continue; + l = search(c, k, y); + if (l != oldl + 1) + oldc = c[l - 1]; + if (l <= k) { + if (clist[c[l]].y <= y) + continue; + tc = c[l]; + c[l] = newcand(i, y, oldc); + oldc = tc; + oldl = l; + numtries++; + } else { + c[l] = newcand(i, y, oldc); + k++; + break; + } + } while ((y = b[++j]) > 0 && numtries < bound); + } + return k; +} + + +static void unravel(int p) +{ + struct cand *q; + int i; + + for (i = 0; i <= len[0]; i++) + J[i] = i <= pref ? i : i > len[0] - suff ? i + len[1] - len[0] : 0; + for (q = clist + p; q->y != 0; q = clist + q->pred) + J[q->x + pref] = q->y + pref; +} + + +static void unsort(struct line *f, int l, int *b) +{ + int *a, i; + + a = xmalloc((l + 1) * sizeof(int)); + for (i = 1; i <= l; i++) + a[f[i].serial] = f[i].value; + for (i = 1; i <= l; i++) + b[i] = a[i]; + free(a); +} + + +static int skipline(FILE * f) +{ + int i, c; + + for (i = 1; (c = getc(f)) != '\n' && c != EOF; i++) + continue; + return i; +} + + +/* + * Check does double duty: + * 1. ferret out any fortuitous correspondences due + * to confounding by hashing (which result in "jackpot") + * 2. collect random access indexes to the two files + */ +static void check(FILE * f1, FILE * f2) +{ + int i, j, jackpot, c, d; + long ctold, ctnew; + + rewind(f1); + rewind(f2); + j = 1; + ixold[0] = ixnew[0] = 0; + jackpot = 0; + ctold = ctnew = 0; + for (i = 1; i <= len[0]; i++) { + if (J[i] == 0) { + ixold[i] = ctold += skipline(f1); + continue; + } + while (j < J[i]) { + ixnew[j] = ctnew += skipline(f2); + j++; + } + if ((option_mask32 & FLAG_b) || (option_mask32 & FLAG_w) + || (option_mask32 & FLAG_i)) { + while (1) { + c = getc(f1); + d = getc(f2); + /* + * GNU diff ignores a missing newline + * in one file if bflag || wflag. + */ + if (((option_mask32 & FLAG_b) || (option_mask32 & FLAG_w)) && + ((c == EOF && d == '\n') || (c == '\n' && d == EOF))) { + break; + } + ctold++; + ctnew++; + if ((option_mask32 & FLAG_b) && isspace(c) && isspace(d)) { + do { + if (c == '\n') + break; + ctold++; + } while (isspace(c = getc(f1))); + do { + if (d == '\n') + break; + ctnew++; + } while (isspace(d = getc(f2))); + } else if (option_mask32 & FLAG_w) { + while (isspace(c) && c != '\n') { + c = getc(f1); + ctold++; + } + while (isspace(d) && d != '\n') { + d = getc(f2); + ctnew++; + } + } + if (c != d) { + jackpot++; + J[i] = 0; + if (c != '\n' && c != EOF) + ctold += skipline(f1); + if (d != '\n' && c != EOF) + ctnew += skipline(f2); + break; + } + if (c == '\n' || c == EOF) + break; + } + } else { + while (1) { + ctold++; + ctnew++; + if ((c = getc(f1)) != (d = getc(f2))) { + J[i] = 0; + if (c != '\n' && c != EOF) + ctold += skipline(f1); + if (d != '\n' && c != EOF) + ctnew += skipline(f2); + break; + } + if (c == '\n' || c == EOF) + break; + } + } + ixold[i] = ctold; + ixnew[j] = ctnew; + j++; + } + for (; j <= len[1]; j++) + ixnew[j] = ctnew += skipline(f2); +} + + +/* shellsort CACM #201 */ +static void sort(struct line *a, int n) +{ + struct line *ai, *aim, w; + int j, m = 0, k; + + if (n == 0) + return; + for (j = 1; j <= n; j *= 2) + m = 2 * j - 1; + for (m /= 2; m != 0; m /= 2) { + k = n - m; + for (j = 1; j <= k; j++) { + for (ai = &a[j]; ai > a; ai -= m) { + aim = &ai[m]; + if (aim < ai) + break; /* wraparound */ + if (aim->value > ai[0].value || + (aim->value == ai[0].value && aim->serial > ai[0].serial)) + break; + w.value = ai[0].value; + ai[0].value = aim->value; + aim->value = w.value; + w.serial = ai[0].serial; + ai[0].serial = aim->serial; + aim->serial = w.serial; + } + } + } +} + + +static void uni_range(int a, int b) +{ + if (a < b) + printf("%d,%d", a, b - a + 1); + else if (a == b) + printf("%d", b); + else + printf("%d,0", b); +} + + +static void fetch(long *f, int a, int b, FILE * lb, int ch) +{ + int i, j, c, lastc, col, nc; + + if (a > b) + return; + for (i = a; i <= b; i++) { + fseek(lb, f[i - 1], SEEK_SET); + nc = f[i] - f[i - 1]; + if (ch != '\0') { + putchar(ch); + if (option_mask32 & FLAG_T) + putchar('\t'); + } + col = 0; + for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) { + if ((c = getc(lb)) == EOF) { + printf("\n\\ No newline at end of file\n"); + return; + } + if (c == '\t' && (option_mask32 & FLAG_t)) { + do { + putchar(' '); + } while (++col & 7); + } else { + putchar(c); + col++; + } + } + } +} + + +static int asciifile(FILE * f) +{ +#if ENABLE_FEATURE_DIFF_BINARY + int i, cnt; +#endif + + if ((option_mask32 & FLAG_a) || f == NULL) + return 1; + +#if ENABLE_FEATURE_DIFF_BINARY + rewind(f); + cnt = fread(bb_common_bufsiz1, 1, BUFSIZ, f); + for (i = 0; i < cnt; i++) { + if (!isprint(bb_common_bufsiz1[i]) + && !isspace(bb_common_bufsiz1[i])) { + return 0; + } + } +#endif + return 1; +} + + +/* dump accumulated "unified" diff changes */ +static void dump_unified_vec(FILE * f1, FILE * f2) +{ + struct context_vec *cvp = context_vec_start; + int lowa, upb, lowc, upd; + int a, b, c, d; + char ch; + + if (context_vec_start > context_vec_ptr) + return; + + b = d = 0; /* gcc */ + lowa = MAX(1, cvp->a - context); + upb = MIN(len[0], context_vec_ptr->b + context); + lowc = MAX(1, cvp->c - context); + upd = MIN(len[1], context_vec_ptr->d + context); + + printf("@@ -"); + uni_range(lowa, upb); + printf(" +"); + uni_range(lowc, upd); + printf(" @@\n"); + + /* + * Output changes in "unified" diff format--the old and new lines + * are printed together. + */ + for (; cvp <= context_vec_ptr; cvp++) { + a = cvp->a; + b = cvp->b; + c = cvp->c; + d = cvp->d; + + /* + * c: both new and old changes + * d: only changes in the old file + * a: only changes in the new file + */ + if (a <= b && c <= d) + ch = 'c'; + else + ch = (a <= b) ? 'd' : 'a'; + if (ch == 'c' || ch == 'd') { + fetch(ixold, lowa, a - 1, f1, ' '); + fetch(ixold, a, b, f1, '-'); + } + if (ch == 'a') + fetch(ixnew, lowc, c - 1, f2, ' '); + if (ch == 'c' || ch == 'a') + fetch(ixnew, c, d, f2, '+'); + lowa = b + 1; + lowc = d + 1; + } + fetch(ixnew, d + 1, upd, f2, ' '); + + context_vec_ptr = context_vec_start - 1; +} + + +static void print_header(const char *file1, const char *file2) +{ + if (label1) + printf("--- %s\n", label1); + else + printf("--- %s\t%s", file1, ctime(&stb1.st_mtime)); + if (label2) + printf("+++ %s\n", label2); + else + printf("+++ %s\t%s", file2, ctime(&stb2.st_mtime)); +} + + +/* + * Indicate that there is a difference between lines a and b of the from file + * to get to lines c to d of the to file. If a is greater than b then there + * are no lines in the from file involved and this means that there were + * lines appended (beginning at b). If c is greater than d then there are + * lines missing from the to file. + */ +static void change(char *file1, FILE * f1, char *file2, FILE * f2, int a, + int b, int c, int d) +{ + static size_t max_context = 64; + + if ((a > b && c > d) || (option_mask32 & FLAG_q)) { + anychange = 1; + return; + } + + /* + * Allocate change records as needed. + */ + if (context_vec_ptr == context_vec_end - 1) { + ptrdiff_t offset = context_vec_ptr - context_vec_start; + + max_context <<= 1; + context_vec_start = xrealloc(context_vec_start, + max_context * sizeof(struct context_vec)); + context_vec_end = context_vec_start + max_context; + context_vec_ptr = context_vec_start + offset; + } + if (anychange == 0) { + /* + * Print the context/unidiff header first time through. + */ + print_header(file1, file2); + } else if (a > context_vec_ptr->b + (2 * context) + 1 && + c > context_vec_ptr->d + (2 * context) + 1) { + /* + * If this change is more than 'context' lines from the + * previous change, dump the record and reset it. + */ + dump_unified_vec(f1, f2); + } + context_vec_ptr++; + context_vec_ptr->a = a; + context_vec_ptr->b = b; + context_vec_ptr->c = c; + context_vec_ptr->d = d; + anychange = 1; +} + + +static void output(char *file1, FILE * f1, char *file2, FILE * f2) +{ + /* Note that j0 and j1 can't be used as they are defined in math.h. + * This also allows the rather amusing variable 'j00'... */ + int m, i0, i1, j00, j01; + + rewind(f1); + rewind(f2); + m = len[0]; + J[0] = 0; + J[m + 1] = len[1] + 1; + for (i0 = 1; i0 <= m; i0 = i1 + 1) { + while (i0 <= m && J[i0] == J[i0 - 1] + 1) + i0++; + j00 = J[i0 - 1] + 1; + i1 = i0 - 1; + while (i1 < m && J[i1 + 1] == 0) + i1++; + j01 = J[i1 + 1] - 1; + J[i1] = j01; + change(file1, f1, file2, f2, i0, i1, j00, j01); + } + if (m == 0) { + change(file1, f1, file2, f2, 1, 0, 1, len[1]); + } + if (anychange != 0 && !(option_mask32 & FLAG_q)) { + dump_unified_vec(f1, f2); + } +} + +/* + * The following code uses an algorithm due to Harold Stone, + * which finds a pair of longest identical subsequences in + * the two files. + * + * The major goal is to generate the match vector J. + * J[i] is the index of the line in file1 corresponding + * to line i file0. J[i] = 0 if there is no + * such line in file1. + * + * Lines are hashed so as to work in core. All potential + * matches are located by sorting the lines of each file + * on the hash (called ``value''). In particular, this + * collects the equivalence classes in file1 together. + * Subroutine equiv replaces the value of each line in + * file0 by the index of the first element of its + * matching equivalence in (the reordered) file1. + * To save space equiv squeezes file1 into a single + * array member in which the equivalence classes + * are simply concatenated, except that their first + * members are flagged by changing sign. + * + * Next the indices that point into member are unsorted into + * array class according to the original order of file0. + * + * The cleverness lies in routine stone. This marches + * through the lines of file0, developing a vector klist + * of "k-candidates". At step i a k-candidate is a matched + * pair of lines x,y (x in file0 y in file1) such that + * there is a common subsequence of length k + * between the first i lines of file0 and the first y + * lines of file1, but there is no such subsequence for + * any smaller y. x is the earliest possible mate to y + * that occurs in such a subsequence. + * + * Whenever any of the members of the equivalence class of + * lines in file1 matable to a line in file0 has serial number + * less than the y of some k-candidate, that k-candidate + * with the smallest such y is replaced. The new + * k-candidate is chained (via pred) to the current + * k-1 candidate so that the actual subsequence can + * be recovered. When a member has serial number greater + * that the y of all k-candidates, the klist is extended. + * At the end, the longest subsequence is pulled out + * and placed in the array J by unravel + * + * With J in hand, the matches there recorded are + * checked against reality to assure that no spurious + * matches have crept in due to hashing. If they have, + * they are broken, and "jackpot" is recorded--a harmless + * matter except that a true match for a spuriously + * mated line may now be unnecessarily reported as a change. + * + * Much of the complexity of the program comes simply + * from trying to minimize core utilization and + * maximize the range of doable problems by dynamically + * allocating what is needed and reusing what is not. + * The core requirements for problems larger than somewhat + * are (in words) 2*length(file0) + length(file1) + + * 3*(number of k-candidates installed), typically about + * 6n words for files of length n. + */ +static unsigned diffreg(char * ofile1, char * ofile2, int flags) +{ + char *file1 = ofile1; + char *file2 = ofile2; + FILE *f1 = stdin, *f2 = stdin; + unsigned rval; + int i; + + anychange = 0; + context_vec_ptr = context_vec_start - 1; + + if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode)) + return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2); + + rval = D_SAME; + + if (LONE_DASH(file1) && LONE_DASH(file2)) + goto closem; + + if (flags & D_EMPTY1) + f1 = xfopen(bb_dev_null, "r"); + else if (NOT_LONE_DASH(file1)) + f1 = xfopen(file1, "r"); + if (flags & D_EMPTY2) + f2 = xfopen(bb_dev_null, "r"); + else if (NOT_LONE_DASH(file2)) + f2 = xfopen(file2, "r"); + +/* We can't diff non-seekable stream - we use rewind(), fseek(). + * This can be fixed (volunteers?). + * Meanwhile we should check it here by stat'ing input fds, + * but I am lazy and check that in main() instead. + * Check in main won't catch "diffing fifos buried in subdirectories" + * failure scenario - not very likely in real life... */ + + i = files_differ(f1, f2, flags); + if (i == 0) + goto closem; + else if (i != 1) { /* 1 == ok */ + /* error */ + status |= 2; + goto closem; + } + + if (!asciifile(f1) || !asciifile(f2)) { + rval = D_BINARY; + status |= 1; + goto closem; + } + + prepare(0, f1, stb1.st_size); + prepare(1, f2, stb2.st_size); + prune(); + sort(sfile[0], slen[0]); + sort(sfile[1], slen[1]); + + member = (int *) file[1]; + equiv(sfile[0], slen[0], sfile[1], slen[1], member); + member = xrealloc(member, (slen[1] + 2) * sizeof(int)); + + class = (int *) file[0]; + unsort(sfile[0], slen[0], class); + class = xrealloc(class, (slen[0] + 2) * sizeof(int)); + + klist = xmalloc((slen[0] + 2) * sizeof(int)); + clen = 0; + clistlen = 100; + clist = xmalloc(clistlen * sizeof(struct cand)); + i = stone(class, slen[0], member, klist); + free(member); + free(class); + + J = xrealloc(J, (len[0] + 2) * sizeof(int)); + unravel(klist[i]); + free(clist); + free(klist); + + ixold = xrealloc(ixold, (len[0] + 2) * sizeof(long)); + ixnew = xrealloc(ixnew, (len[1] + 2) * sizeof(long)); + check(f1, f2); + output(file1, f1, file2, f2); + + closem: + if (anychange) { + status |= 1; + if (rval == D_SAME) + rval = D_DIFFER; + } + fclose_if_not_stdin(f1); + fclose_if_not_stdin(f2); + if (file1 != ofile1) + free(file1); + if (file2 != ofile2) + free(file2); + return rval; +} + + +#if ENABLE_FEATURE_DIFF_DIR +static void do_diff(char *dir1, char *path1, char *dir2, char *path2) +{ + int flags = D_HEADER; + int val; + + char *fullpath1 = concat_path_file(dir1, path1); + char *fullpath2 = concat_path_file(dir2, path2); + + if (stat(fullpath1, &stb1) != 0) { + flags |= D_EMPTY1; + memset(&stb1, 0, sizeof(stb1)); + if (ENABLE_FEATURE_CLEAN_UP) + free(fullpath1); + fullpath1 = concat_path_file(dir1, path2); + } + if (stat(fullpath2, &stb2) != 0) { + flags |= D_EMPTY2; + memset(&stb2, 0, sizeof(stb2)); + stb2.st_mode = stb1.st_mode; + if (ENABLE_FEATURE_CLEAN_UP) + free(fullpath2); + fullpath2 = concat_path_file(dir2, path1); + } + + if (stb1.st_mode == 0) + stb1.st_mode = stb2.st_mode; + + if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) { + printf("Common subdirectories: %s and %s\n", fullpath1, fullpath2); + return; + } + + if (!S_ISREG(stb1.st_mode) && !S_ISDIR(stb1.st_mode)) + val = D_SKIPPED1; + else if (!S_ISREG(stb2.st_mode) && !S_ISDIR(stb2.st_mode)) + val = D_SKIPPED2; + else + val = diffreg(fullpath1, fullpath2, flags); + + print_status(val, fullpath1, fullpath2, NULL); +} +#endif + + +#if ENABLE_FEATURE_DIFF_DIR +static int dir_strcmp(const void *p1, const void *p2) +{ + return strcmp(*(char *const *) p1, *(char *const *) p2); +} + + +/* This function adds a filename to dl, the directory listing. */ +static int add_to_dirlist(const char *filename, + struct stat ATTRIBUTE_UNUSED * sb, void *userdata, + int depth ATTRIBUTE_UNUSED) +{ + /* +2: with space for eventual trailing NULL */ + dl = xrealloc(dl, (dl_count+2) * sizeof(dl[0])); + dl[dl_count] = xstrdup(filename + (int)(ptrdiff_t)userdata); + dl_count++; + return TRUE; +} + + +/* This returns a sorted directory listing. */ +static char **get_dir(char *path) +{ + dl_count = 0; + dl = NULL; + + /* If -r has been set, then the recursive_action function will be + * used. Unfortunately, this outputs the root directory along with + * the recursed paths, so use void *userdata to specify the string + * length of the root directory - '(void*)(strlen(path)+)'. + * add_to_dirlist then removes root dir prefix. */ + + if (option_mask32 & FLAG_r) { + recursive_action(path, TRUE, TRUE, FALSE, add_to_dirlist, NULL, + (void*)(strlen(path)+1), 0); + } else { + DIR *dp; + struct dirent *ep; + + dp = warn_opendir(path); + while ((ep = readdir(dp))) { + if (!strcmp(ep->d_name, "..") || LONE_CHAR(ep->d_name, '.')) + continue; + add_to_dirlist(ep->d_name, NULL, (void*)(int)0, 0); + } + closedir(dp); + } + + /* Sort dl alphabetically. */ + qsort(dl, dl_count, sizeof(char *), dir_strcmp); + + dl[dl_count] = NULL; + return dl; +} + + +static void diffdir(char *p1, char *p2) +{ + char **dirlist1, **dirlist2; + char *dp1, *dp2; + int pos; + + /* Check for trailing slashes. */ + dp1 = last_char_is(p1, '/'); + if (dp1 != NULL) + *dp1 = '\0'; + dp2 = last_char_is(p2, '/'); + if (dp2 != NULL) + *dp2 = '\0'; + + /* Get directory listings for p1 and p2. */ + + dirlist1 = get_dir(p1); + dirlist2 = get_dir(p2); + + /* If -S was set, find the starting point. */ + if (start) { + while (*dirlist1 != NULL && strcmp(*dirlist1, start) < 0) + dirlist1++; + while (*dirlist2 != NULL && strcmp(*dirlist2, start) < 0) + dirlist2++; + if ((*dirlist1 == NULL) || (*dirlist2 == NULL)) + bb_error_msg(bb_msg_invalid_arg, "NULL", "-S"); + } + + /* Now that both dirlist1 and dirlist2 contain sorted directory + * listings, we can start to go through dirlist1. If both listings + * contain the same file, then do a normal diff. Otherwise, behaviour + * is determined by whether the -N flag is set. */ + while (*dirlist1 != NULL || *dirlist2 != NULL) { + dp1 = *dirlist1; + dp2 = *dirlist2; + pos = dp1 == NULL ? 1 : dp2 == NULL ? -1 : strcmp(dp1, dp2); + if (pos == 0) { + do_diff(p1, dp1, p2, dp2); + dirlist1++; + dirlist2++; + } else if (pos < 0) { + if (option_mask32 & FLAG_N) + do_diff(p1, dp1, p2, NULL); + else + print_only(p1, strlen(p1) + 1, dp1); + dirlist1++; + } else { + if (option_mask32 & FLAG_N) + do_diff(p1, NULL, p2, dp2); + else + print_only(p2, strlen(p2) + 1, dp2); + dirlist2++; + } + } +} +#endif + + +int diff_main(int argc, char **argv); +int diff_main(int argc, char **argv) +{ + bool gotstdin = 0; + char *U_opt; + char *f1, *f2; + llist_t *L_arg = NULL; + + /* exactly 2 params; collect multiple -L