summaryrefslogtreecommitdiff
Diffstat
-rw-r--r--AUTHORS4
-rw-r--r--Config.in338
-rw-r--r--Makefile51
-rw-r--r--Makefile.custom8
-rw-r--r--Makefile.flags30
-rw-r--r--Makefile.help4
-rw-r--r--README2
-rw-r--r--TODO2
-rw-r--r--android/librpc/libintl.h0
-rw-r--r--applets/Kbuild.src18
-rw-r--r--applets/applet_tables.c135
-rwxr-xr-xapplets/install.sh26
-rwxr-xr-xapplets/usage_compressed9
-rw-r--r--applets/usage_pod.c2
-rw-r--r--archival/Config.src4
-rw-r--r--archival/Kbuild.src2
-rw-r--r--archival/ar.c16
-rw-r--r--archival/bbunzip.c165
-rw-r--r--archival/bzip2.c2
-rw-r--r--archival/cpio.c58
-rw-r--r--archival/dpkg.c21
-rw-r--r--archival/dpkg_deb.c96
-rw-r--r--archival/gzip.c139
-rw-r--r--archival/libarchive/Kbuild.src17
-rw-r--r--archival/libarchive/bz/compress.c1
-rw-r--r--archival/libarchive/common.c9
-rw-r--r--archival/libarchive/data_extract_all.c118
-rw-r--r--archival/libarchive/data_extract_to_command.c5
-rw-r--r--archival/libarchive/decompress_bunzip2.c13
-rw-r--r--archival/libarchive/decompress_gunzip.c82
-rw-r--r--archival/libarchive/decompress_uncompress.c13
-rw-r--r--archival/libarchive/decompress_unlzma.c35
-rw-r--r--archival/libarchive/decompress_unxz.c8
-rw-r--r--archival/libarchive/filter_accept_list_reassign.c10
-rw-r--r--archival/libarchive/get_header_cpio.c9
-rw-r--r--archival/libarchive/get_header_tar.c122
-rw-r--r--archival/libarchive/get_header_tar_bz2.c2
-rw-r--r--archival/libarchive/get_header_tar_gz.c2
-rw-r--r--archival/libarchive/get_header_tar_lzma.c2
-rw-r--r--archival/libarchive/get_header_tar_xz.c21
-rw-r--r--archival/libarchive/init_handle.c4
-rw-r--r--archival/libarchive/lzo1x_9x.c1
-rw-r--r--archival/libarchive/open_transformer.c230
-rw-r--r--archival/libarchive/unpack_ar_archive.c2
-rw-r--r--archival/libarchive/unsafe_prefix.c36
-rw-r--r--archival/libarchive/unxz/xz_dec_lzma2.c3
-rw-r--r--archival/libarchive/unxz/xz_dec_stream.c2
-rw-r--r--archival/lzop.c55
-rw-r--r--archival/rpm.c5
-rw-r--r--archival/tar.c248
-rw-r--r--archival/unzip.c191
-rw-r--r--busybox-full.config484
-rw-r--r--busybox-full.sources22
-rw-r--r--busybox-minimal.sources4
-rw-r--r--configs/TEST_nommu_defconfig4
-rw-r--r--configs/TEST_noprintf_defconfig4
-rw-r--r--configs/TEST_rh9_defconfig4
-rw-r--r--configs/android2_defconfig5
-rw-r--r--configs/android_502_defconfig1140
-rw-r--r--configs/android_defconfig5
-rw-r--r--configs/android_ndk_defconfig188
-rw-r--r--configs/cygwin_defconfig5
-rw-r--r--configs/freebsd_defconfig4
-rw-r--r--console-tools/Config.src166
-rw-r--r--console-tools/Kbuild.src16
-rw-r--r--console-tools/chvt.c11
-rw-r--r--console-tools/clear.c9
-rw-r--r--console-tools/deallocvt.c10
-rw-r--r--console-tools/dumpkmap.c14
-rw-r--r--console-tools/fgconsole.c10
-rw-r--r--console-tools/kbd_mode.c10
-rw-r--r--console-tools/loadfont.c57
-rw-r--r--console-tools/loadkmap.c18
-rw-r--r--console-tools/openvt.c11
-rw-r--r--console-tools/reset.c13
-rw-r--r--console-tools/resize.c27
-rw-r--r--console-tools/setconsole.c18
-rw-r--r--console-tools/setkeycodes.c11
-rw-r--r--console-tools/setlogcons.c14
-rw-r--r--console-tools/showkey.c11
-rw-r--r--coreutils/Config.src746
-rw-r--r--coreutils/Kbuild.src86
-rw-r--r--coreutils/basename.c15
-rw-r--r--coreutils/cal.c18
-rw-r--r--coreutils/cat.c16
-rw-r--r--coreutils/catv.c32
-rw-r--r--coreutils/chgrp.c9
-rw-r--r--coreutils/chmod.c13
-rw-r--r--coreutils/chown.c27
-rw-r--r--coreutils/chroot.c10
-rw-r--r--coreutils/cksum.c13
-rw-r--r--coreutils/comm.c10
-rw-r--r--coreutils/cp.c53
-rw-r--r--coreutils/cut.c10
-rw-r--r--coreutils/date.c18
-rw-r--r--coreutils/dd.c232
-rw-r--r--coreutils/df.c104
-rw-r--r--coreutils/dirname.c10
-rw-r--r--coreutils/dos2unix.c52
-rw-r--r--coreutils/du.c74
-rw-r--r--coreutils/echo.c26
-rw-r--r--coreutils/env.c29
-rw-r--r--coreutils/expand.c31
-rw-r--r--coreutils/expr.c34
-rw-r--r--coreutils/false.c17
-rw-r--r--coreutils/fold.c9
-rw-r--r--coreutils/fsync.c9
-rw-r--r--coreutils/head.c19
-rw-r--r--coreutils/hostid.c5
-rw-r--r--coreutils/id.c11
-rw-r--r--coreutils/install.c72
-rw-r--r--coreutils/length.c.disabled31
-rw-r--r--coreutils/libcoreutils/getopt_mk_fifo_nod.c4
-rw-r--r--coreutils/ln.c10
-rw-r--r--coreutils/logname.c16
-rw-r--r--coreutils/ls.c107
-rw-r--r--coreutils/md5_sha1_sum.c145
-rw-r--r--coreutils/mkdir.c36
-rw-r--r--coreutils/mkfifo.c10
-rw-r--r--coreutils/mknod.c10
-rw-r--r--coreutils/mv.c29
-rw-r--r--coreutils/nice.c9
-rw-r--r--coreutils/nohup.c9
-rw-r--r--coreutils/od.c9
-rw-r--r--coreutils/od_bloaty.c249
-rw-r--r--coreutils/printenv.c9
-rw-r--r--coreutils/printf.c23
-rw-r--r--coreutils/pwd.c11
-rw-r--r--coreutils/readlink.c17
-rw-r--r--coreutils/realpath.c15
-rw-r--r--coreutils/rm.c19
-rw-r--r--coreutils/rmdir.c27
-rw-r--r--coreutils/seq.c9
-rw-r--r--coreutils/shuf.c153
-rw-r--r--coreutils/sleep.c44
-rw-r--r--coreutils/sort.c126
-rw-r--r--coreutils/split.c26
-rw-r--r--coreutils/stat.c91
-rw-r--r--coreutils/stty.c21
-rw-r--r--coreutils/sum.c16
-rw-r--r--coreutils/sync.c26
-rw-r--r--coreutils/tac.c14
-rw-r--r--coreutils/tail.c46
-rw-r--r--coreutils/tee.c21
-rw-r--r--coreutils/test.c116
-rw-r--r--coreutils/touch.c16
-rw-r--r--coreutils/tr.c30
-rw-r--r--coreutils/true.c17
-rw-r--r--coreutils/truncate.c87
-rw-r--r--coreutils/tty.c10
-rw-r--r--coreutils/uname.c39
-rw-r--r--coreutils/uniq.c14
-rw-r--r--coreutils/unlink.c33
-rw-r--r--coreutils/usleep.c9
-rw-r--r--coreutils/uudecode.c28
-rw-r--r--coreutils/uuencode.c9
-rw-r--r--coreutils/wc.c25
-rw-r--r--coreutils/who.c18
-rw-r--r--coreutils/whoami.c12
-rw-r--r--coreutils/yes.c17
-rw-r--r--debianutils/Config.src75
-rw-r--r--debianutils/Kbuild.src5
-rw-r--r--[-rwxr-xr-x]debianutils/mktemp.c10
-rw-r--r--debianutils/pipe_progress.c9
-rw-r--r--debianutils/run_parts.c45
-rw-r--r--debianutils/start_stop_daemon.c40
-rw-r--r--debianutils/which.c95
-rw-r--r--docs/busybox_footer.pod2
-rw-r--r--docs/cgi/env.html2
-rw-r--r--docs/ifupdown_design.txt2
-rw-r--r--docs/keep_data_small.txt14
-rw-r--r--docs/logging_and_backgrounding.txt2
-rw-r--r--docs/new-applet-HOWTO.txt104
-rw-r--r--docs/posix_conformance.txt1
-rw-r--r--docs/unit-tests.txt50
-rw-r--r--e2fsprogs/Config.src28
-rw-r--r--e2fsprogs/Kbuild.src6
-rw-r--r--e2fsprogs/chattr.c26
-rw-r--r--e2fsprogs/e2fs_lib.c4
-rw-r--r--e2fsprogs/fsck.c318
-rw-r--r--e2fsprogs/lsattr.c20
-rw-r--r--e2fsprogs/old_e2fsprogs/Config.src69
-rw-r--r--e2fsprogs/old_e2fsprogs/Kbuild.src18
-rw-r--r--e2fsprogs/old_e2fsprogs/README3
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/Kbuild.src26
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/blkid.h104
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/blkidP.h182
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/blkid_getsize.c179
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/cache.c125
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/dev.c213
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/devname.c367
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/devno.c222
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/list.c110
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/list.h73
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/probe.c726
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/probe.h374
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/read.c459
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/resolve.c139
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/save.c189
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/tag.c431
-rw-r--r--e2fsprogs/old_e2fsprogs/chattr.c220
-rw-r--r--e2fsprogs/old_e2fsprogs/e2fsbb.h43
-rw-r--r--e2fsprogs/old_e2fsprogs/e2fsck.c13516
-rw-r--r--e2fsprogs/old_e2fsprogs/e2fsck.h638
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/Kbuild.src18
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/e2p.h64
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/feature.c187
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/fgetsetflags.c70
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/fgetsetversion.c70
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/hashstr.c70
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/iod.c52
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/ls.c273
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/mntopts.c134
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/ostype.c72
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/parse_num.c65
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/pe.c32
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/pf.c74
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/ps.c27
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/uuid.c78
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/Kbuild.src26
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/alloc.c173
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/alloc_sb.c58
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/alloc_stats.c53
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/alloc_tables.c114
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/badblocks.c328
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/bb_compat.c64
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c262
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/bitmaps.c211
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/bitops.c90
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/bitops.h105
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/block.c437
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/bmap.c261
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/bmove.c155
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/brel.h86
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/brel_ma.c196
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/check_desc.c69
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/closefs.c380
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/cmp_bitmaps.c72
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/dblist.c260
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/dblist_dir.c76
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/dir_iterate.c219
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/dirblock.c132
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/dirhash.c234
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/dupfs.c95
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/e2image.h39
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/expanddir.c127
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext2_err.h116
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext2_ext_attr.h52
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h569
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext2_io.h112
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext2_types.h2
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h922
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext2fsP.h87
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext2fs_inline.c365
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext_attr.c101
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/fileio.c377
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/finddev.c199
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/flushb.c83
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/freefs.c127
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/gen_bitmap.c49
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c156
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/getsectsize.c58
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/getsize.c291
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/icount.c467
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/imager.c377
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ind_block.c69
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/initialize.c388
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/inline.c32
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/inode.c766
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/inode_io.c270
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/io_manager.c70
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/irel.h115
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/irel_ma.c367
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ismounted.c357
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/jfs_dat.h63
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/kernel-jbd.h235
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/kernel-list.h113
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/link.c135
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/lookup.c68
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/mkdir.c139
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c426
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/namei.c204
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/newdir.c72
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/openfs.c330
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/read_bb.c96
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/read_bb_file.c96
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c220
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/rs_bitmap.c106
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c294
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/sparse.c79
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/swapfs.c234
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/test_io.c380
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/unix_io.c703
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/unlink.c99
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/valid_blk.c57
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/version.c51
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/write_bb_file.c35
-rw-r--r--e2fsprogs/old_e2fsprogs/fsck.c1375
-rw-r--r--e2fsprogs/old_e2fsprogs/fsck.h16
-rw-r--r--e2fsprogs/old_e2fsprogs/lsattr.c129
-rw-r--r--e2fsprogs/old_e2fsprogs/mke2fs.c1333
-rw-r--r--e2fsprogs/old_e2fsprogs/tune2fs.c710
-rw-r--r--e2fsprogs/old_e2fsprogs/util.c263
-rw-r--r--e2fsprogs/old_e2fsprogs/util.h22
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/Kbuild.src16
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/compare.c55
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/gen_uuid.c304
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/pack.c69
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/parse.c80
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/unpack.c63
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/unparse.c77
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/uuid.h103
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/uuidP.h60
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/uuid_time.c161
-rw-r--r--e2fsprogs/tune2fs.c45
-rw-r--r--editors/awk.c139
-rw-r--r--editors/diff.c19
-rw-r--r--editors/ed.c9
-rw-r--r--editors/patch.c45
-rw-r--r--editors/patch_toybox.c7
-rw-r--r--editors/sed.c179
-rw-r--r--editors/vi.c929
-rwxr-xr-xexamples/android-build2
-rw-r--r--examples/mdev.conf2
-rw-r--r--examples/mdev_fat.conf12
-rwxr-xr-xexamples/udhcp/sample.bound18
-rwxr-xr-xexamples/udhcp/sample.renew18
-rwxr-xr-xexamples/undeb74
-rwxr-xr-xexamples/unrpm65
-rw-r--r--examples/var_service/README233
-rw-r--r--examples/var_service/README_distro_proposal.txt291
-rw-r--r--examples/var_service/dhcp_if/README5
-rwxr-xr-xexamples/var_service/dhcp_if/convert2ntpconf2
-rwxr-xr-xexamples/var_service/dhcp_if/dhcp_handler13
-rwxr-xr-xexamples/var_service/dhcp_if/finish17
-rwxr-xr-xexamples/var_service/dhcp_if/log/run2
-rw-r--r--examples/var_service/dhcp_if_pinger/README5
-rwxr-xr-xexamples/var_service/dhcp_if_pinger/run44
-rw-r--r--examples/var_service/dhcpd_if/README5
-rwxr-xr-xexamples/var_service/dhcpd_if/log/run21
-rwxr-xr-xexamples/var_service/dhcpd_if/p_log4
-rwxr-xr-xexamples/var_service/dhcpd_if/run23
-rw-r--r--examples/var_service/dhcpd_if/udhcpc.conf28
-rwxr-xr-xexamples/var_service/dhcpd_if/w_dumpleases3
-rwxr-xr-xexamples/var_service/dhcpd_if/w_dumpleases_countdown3
-rwxr-xr-xexamples/var_service/dhcpd_if/w_log4
-rw-r--r--examples/var_service/ftpd/README5
-rwxr-xr-xexamples/var_service/ftpd/log/run2
-rw-r--r--examples/var_service/fw/README5
-rwxr-xr-xexamples/var_service/fw/run50
-rw-r--r--examples/var_service/getty_tty1/README5
-rw-r--r--examples/var_service/gpm/README5
-rw-r--r--examples/var_service/httpd/README5
-rwxr-xr-xexamples/var_service/httpd/log/run2
-rw-r--r--examples/var_service/ifplugd_if/README5
-rwxr-xr-xexamples/var_service/ifplugd_if/log/run2
-rwxr-xr-xexamples/var_service/ifplugd_if/run3
-rw-r--r--examples/var_service/inetd/README5
-rwxr-xr-xexamples/var_service/inetd/log/run2
-rw-r--r--examples/var_service/nmeter/README5
-rw-r--r--examples/var_service/ntpd/README5
-rwxr-xr-xexamples/var_service/ntpd/log/run2
-rwxr-xr-xexamples/var_service/ntpd/ntp.script21
-rwxr-xr-xexamples/var_service/ntpd/p_log_important4
-rwxr-xr-xexamples/var_service/ntpd/run2
-rw-r--r--examples/var_service/supplicant_if/README5
-rwxr-xr-xexamples/var_service/supplicant_if/log/run21
-rwxr-xr-xexamples/var_service/supplicant_if/p_log4
-rwxr-xr-xexamples/var_service/supplicant_if/run21
-rwxr-xr-xexamples/var_service/supplicant_if/w_log4
-rw-r--r--examples/var_service/supplicant_if/wpa_supplicant.conf28
-rw-r--r--examples/var_service/tftpd/README5
-rwxr-xr-xexamples/var_service/tftpd/log/run2
-rw-r--r--examples/var_service/zcip_if/README5
-rwxr-xr-xexamples/var_service/zcip_if/convert2ipconf24
-rwxr-xr-xexamples/var_service/zcip_if/finish13
-rwxr-xr-xexamples/var_service/zcip_if/log/run21
-rwxr-xr-xexamples/var_service/zcip_if/p_log4
-rwxr-xr-xexamples/var_service/zcip_if/run20
-rwxr-xr-xexamples/var_service/zcip_if/w_log4
-rwxr-xr-xexamples/var_service/zcip_if/zcip_handler47
-rw-r--r--findutils/find.c263
-rw-r--r--findutils/grep.c130
-rw-r--r--findutils/xargs.c190
-rwxr-xr-xinclude/applets.h.sh23
-rw-r--r--include/applets.src.h368
-rw-r--r--include/bb_archive.h61
-rw-r--r--include/busybox.h19
-rw-r--r--include/grp_.h65
-rw-r--r--include/libbb.h419
-rw-r--r--include/platform.h104
-rw-r--r--include/pwd_.h53
-rw-r--r--include/shadow_.h26
-rw-r--r--init/bootchartd.c7
-rw-r--r--init/halt.c50
-rw-r--r--init/init.c144
-rw-r--r--libbb/Config.src174
-rw-r--r--libbb/Kbuild.src16
-rw-r--r--libbb/appletlib.c327
-rw-r--r--libbb/auto_string.c23
-rw-r--r--libbb/bb_askpass.c11
-rw-r--r--libbb/bb_pwd.c48
-rw-r--r--libbb/bbunit.c65
-rw-r--r--libbb/change_identity.c23
-rw-r--r--libbb/common_bufsiz.c83
-rw-r--r--libbb/compare_string_array.c82
-rw-r--r--libbb/copy_file.c41
-rw-r--r--libbb/copyfd.c87
-rw-r--r--libbb/correct_password.c96
-rw-r--r--libbb/dump.c51
-rw-r--r--libbb/execable.c86
-rw-r--r--libbb/executable.c101
-rw-r--r--libbb/fflush_stdout_and_exit.c15
-rw-r--r--libbb/getopt32.c82
-rw-r--r--libbb/getpty.c2
-rw-r--r--libbb/hash_md5_sha.c386
-rw-r--r--libbb/human_readable.c20
-rw-r--r--libbb/in_ether.c1
-rw-r--r--libbb/inet_common.c84
-rw-r--r--libbb/info_msg.c62
-rw-r--r--libbb/inode_hash.c38
-rw-r--r--libbb/kernel_version.c8
-rw-r--r--libbb/lineedit.c256
-rw-r--r--libbb/logenv.c24
-rw-r--r--libbb/login.c40
-rw-r--r--libbb/loop.c29
-rw-r--r--libbb/make_directory.c19
-rw-r--r--libbb/match_fstype.c7
-rw-r--r--libbb/messages.c9
-rw-r--r--libbb/missing_syscalls.c7
-rw-r--r--libbb/mode_string.c4
-rw-r--r--libbb/obscure.c40
-rw-r--r--libbb/parse_config.c4
-rw-r--r--libbb/parse_mode.c16
-rw-r--r--libbb/platform.c37
-rw-r--r--libbb/printable_string.c10
-rw-r--r--libbb/procps.c28
-rw-r--r--libbb/progress.c20
-rw-r--r--libbb/pw_encrypt.c21
-rw-r--r--libbb/read_key.c12
-rw-r--r--libbb/read_printf.c8
-rw-r--r--libbb/remove_file.c8
-rw-r--r--libbb/replace.c45
-rw-r--r--libbb/rtc.c54
-rw-r--r--libbb/run_shell.c29
-rw-r--r--libbb/skip_whitespace.c2
-rw-r--r--libbb/speed_table.c84
-rw-r--r--libbb/strrstr.c19
-rw-r--r--libbb/sysconf.c30
-rw-r--r--libbb/systemd_support.c62
-rw-r--r--libbb/time.c1
-rw-r--r--libbb/u_signal_names.c2
-rw-r--r--libbb/ubi.c43
-rw-r--r--libbb/udp_io.c14
-rw-r--r--libbb/update_passwd.c60
-rw-r--r--libbb/utmp.c58
-rw-r--r--libbb/verror_msg.c34
-rw-r--r--libbb/vfork_daemon_rexec.c47
-rw-r--r--libbb/xatonum.c40
-rw-r--r--libbb/xconnect.c34
-rw-r--r--libbb/xfunc_die.c26
-rw-r--r--libbb/xfuncs.c76
-rw-r--r--libbb/xfuncs_printf.c39
-rw-r--r--libbb/xreadlink.c11
-rw-r--r--libpwdgrp/pwd_grp.c1277
-rw-r--r--libpwdgrp/pwd_grp_internal.c61
-rw-r--r--libpwdgrp/uidgid_get.c44
-rw-r--r--loginutils/Config.src237
-rw-r--r--loginutils/Kbuild.src12
-rw-r--r--loginutils/README2
-rw-r--r--loginutils/add-remove-shell.c17
-rw-r--r--loginutils/addgroup.c44
-rw-r--r--loginutils/adduser.c84
-rw-r--r--loginutils/chpasswd.c51
-rw-r--r--loginutils/cryptpw.c46
-rw-r--r--loginutils/deluser.c75
-rw-r--r--loginutils/getty.c60
-rw-r--r--loginutils/login.c111
-rw-r--r--loginutils/passwd.c26
-rw-r--r--loginutils/su.c65
-rw-r--r--loginutils/sulogin.c46
-rw-r--r--loginutils/vlock.c16
-rw-r--r--mailutils/Config.src43
-rw-r--r--mailutils/mail.c2
-rw-r--r--mailutils/makemime.c10
-rw-r--r--mailutils/popmaildir.c22
-rw-r--r--mailutils/reformime.c20
-rw-r--r--mailutils/sendmail.c138
-rwxr-xr-xmake_single_applets.sh73
-rw-r--r--miscutils/Config.src584
-rw-r--r--miscutils/Kbuild.src39
-rw-r--r--miscutils/adjtimex.c42
-rw-r--r--miscutils/bbconfig.c24
-rw-r--r--miscutils/beep.c28
-rw-r--r--miscutils/chat.c74
-rw-r--r--miscutils/chrt.c10
-rw-r--r--miscutils/conspy.c20
-rw-r--r--miscutils/crond.c346
-rw-r--r--miscutils/crontab.c14
-rw-r--r--miscutils/dc.c95
-rw-r--r--miscutils/devfsd.c91
-rw-r--r--miscutils/devmem.c10
-rw-r--r--miscutils/eject.c46
-rw-r--r--miscutils/fbsplash.c34
-rw-r--r--miscutils/flash_eraseall.c12
-rw-r--r--miscutils/flash_lock_unlock.c19
-rw-r--r--miscutils/flashcp.c12
-rw-r--r--miscutils/hdparm.c131
-rw-r--r--miscutils/i2c_tools.c1343
-rw-r--r--miscutils/inotifyd.c20
-rw-r--r--miscutils/ionice.c16
-rw-r--r--miscutils/last.c39
-rw-r--r--miscutils/last_fancy.c25
-rw-r--r--miscutils/less.c482
-rw-r--r--miscutils/makedevs.c44
-rw-r--r--miscutils/man.c213
-rw-r--r--miscutils/microcom.c18
-rw-r--r--miscutils/mountpoint.c9
-rw-r--r--miscutils/mt.c11
-rw-r--r--miscutils/nandwrite.c74
-rw-r--r--miscutils/raidautorun.c11
-rw-r--r--miscutils/readahead.c21
-rw-r--r--miscutils/runlevel.c25
-rw-r--r--miscutils/rx.c12
-rw-r--r--miscutils/setserial.c8
-rw-r--r--miscutils/setsid.c28
-rw-r--r--miscutils/strings.c42
-rw-r--r--miscutils/taskset.c127
-rw-r--r--miscutils/time.c12
-rw-r--r--miscutils/timeout.c13
-rw-r--r--miscutils/ttysize.c12
-rw-r--r--miscutils/ubi_tools.c68
-rw-r--r--miscutils/ubirename.c94
-rw-r--r--miscutils/volname.c9
-rw-r--r--miscutils/wall.c8
-rw-r--r--miscutils/watchdog.c15
-rw-r--r--modutils/Config.src93
-rw-r--r--modutils/Kbuild.src7
-rw-r--r--modutils/depmod.c136
-rw-r--r--modutils/insmod.c14
-rw-r--r--modutils/lsmod.c22
-rw-r--r--modutils/modinfo.c160
-rw-r--r--modutils/modprobe-small.c480
-rw-r--r--modutils/modprobe.c210
-rw-r--r--modutils/modutils-24.c4
-rw-r--r--modutils/modutils.c101
-rw-r--r--modutils/modutils.h30
-rw-r--r--modutils/rmmod.c24
-rw-r--r--networking/Config.src941
-rw-r--r--networking/Kbuild.src39
-rw-r--r--networking/arp.c21
-rw-r--r--networking/arping.c62
-rw-r--r--networking/brctl.c94
-rw-r--r--networking/dnsd.c11
-rw-r--r--networking/ether-wake.c10
-rw-r--r--networking/ftpd.c227
-rw-r--r--networking/ftpgetput.c35
-rw-r--r--networking/hostname.c26
-rw-r--r--networking/httpd.c238
-rw-r--r--networking/ifconfig.c51
-rw-r--r--networking/ifenslave.c19
-rw-r--r--networking/ifplugd.c61
-rw-r--r--networking/ifupdown.c239
-rw-r--r--networking/inetd.c85
-rw-r--r--networking/interface.c33
-rw-r--r--networking/ip.c192
-rw-r--r--networking/ipcalc.c28
-rw-r--r--networking/isrv.c4
-rw-r--r--networking/isrv.h26
-rw-r--r--networking/isrv_identd.c52
-rw-r--r--networking/libiproute/Kbuild.src11
-rw-r--r--networking/libiproute/ip_common.h2
-rw-r--r--networking/libiproute/ip_parse_common_args.c2
-rw-r--r--networking/libiproute/ipaddress.c74
-rw-r--r--networking/libiproute/iplink.c196
-rw-r--r--networking/libiproute/ipneigh.c357
-rw-r--r--networking/libiproute/iproute.c172
-rw-r--r--networking/libiproute/iprule.c61
-rw-r--r--networking/libiproute/iptunnel.c37
-rw-r--r--networking/libiproute/libnetlink.c87
-rw-r--r--networking/libiproute/ll_map.c39
-rw-r--r--networking/libiproute/ll_map.h2
-rw-r--r--networking/libiproute/ll_proto.c4
-rw-r--r--networking/libiproute/ll_types.c4
-rw-r--r--networking/libiproute/rt_names.c93
-rw-r--r--networking/libiproute/rt_names.h11
-rw-r--r--networking/libiproute/rtm_map.c6
-rw-r--r--networking/libiproute/rtm_map.h2
-rw-r--r--networking/libiproute/utils.c48
-rw-r--r--networking/libiproute/utils.h12
-rw-r--r--networking/nameif.c12
-rw-r--r--networking/nbd-client.c7
-rw-r--r--networking/nc.c14
-rw-r--r--networking/nc_bloaty.c8
-rw-r--r--networking/netstat.c34
-rw-r--r--networking/nslookup.c9
-rw-r--r--networking/ntpd.c593
-rw-r--r--networking/ntpd.diff24
-rw-r--r--networking/ntpd_simple.c1008
-rw-r--r--networking/ping.c110
-rw-r--r--networking/pscan.c9
-rw-r--r--networking/route.c64
-rw-r--r--networking/slattach.c22
-rwxr-xr-xnetworking/ssl_helper-wolfssl/00cfg-wolfssl-3.6.822
-rwxr-xr-xnetworking/ssl_helper-wolfssl/00cfg-wolfssl-3.9.839
-rw-r--r--networking/ssl_helper-wolfssl/README27
-rw-r--r--networking/ssl_helper-wolfssl/ssl_helper.c480
-rwxr-xr-xnetworking/ssl_helper-wolfssl/ssl_helper.sh12
-rw-r--r--networking/ssl_helper/README16
-rw-r--r--networking/ssl_helper/ssl_helper.c406
-rwxr-xr-xnetworking/ssl_helper/ssl_helper.sh11
-rw-r--r--networking/tc.c59
-rw-r--r--networking/tcpudp.c102
-rw-r--r--networking/telnet.c46
-rw-r--r--networking/telnetd.IAC_test.sh87
-rw-r--r--networking/telnetd.c389
-rw-r--r--networking/telnetd.ctrlSQ.patch4
-rw-r--r--networking/tftp.c110
-rw-r--r--networking/traceroute.c287
-rw-r--r--networking/tunctl.c20
-rw-r--r--networking/udhcp/Config.src13
-rw-r--r--networking/udhcp/Kbuild.src4
-rw-r--r--networking/udhcp/arpping.c13
-rw-r--r--networking/udhcp/common.c40
-rw-r--r--networking/udhcp/common.h11
-rw-r--r--networking/udhcp/d6_dhcpc.c85
-rw-r--r--networking/udhcp/d6_packet.c12
-rw-r--r--networking/udhcp/d6_socket.c2
-rw-r--r--networking/udhcp/dhcpc.c298
-rw-r--r--networking/udhcp/dhcpd.c569
-rw-r--r--networking/udhcp/dhcpd.h35
-rw-r--r--networking/udhcp/dhcprelay.c8
-rw-r--r--networking/udhcp/domain_codec.c21
-rw-r--r--networking/udhcp/dumpleases.c31
-rw-r--r--networking/udhcp/files.c216
-rw-r--r--networking/udhcp/leases.c203
-rw-r--r--networking/udhcp/packet.c12
-rw-r--r--networking/udhcp/socket.c4
-rw-r--r--networking/udhcp/static_leases.c77
-rw-r--r--networking/vconfig.c11
-rw-r--r--networking/wget.c578
-rw-r--r--networking/whois.c147
-rw-r--r--networking/zcip.c536
-rw-r--r--printutils/Config.src18
-rw-r--r--printutils/Kbuild.src4
-rw-r--r--printutils/lpd.c19
-rw-r--r--printutils/lpr.c17
-rw-r--r--procps/Config.src140
-rw-r--r--procps/Kbuild.src17
-rw-r--r--procps/free.c94
-rw-r--r--procps/fuser.c15
-rw-r--r--procps/iostat.c9
-rw-r--r--procps/kill.c48
-rw-r--r--procps/mpstat.c18
-rw-r--r--procps/nmeter.c208
-rw-r--r--procps/pgrep.c24
-rw-r--r--procps/pidof.c29
-rw-r--r--procps/pmap.c4
-rw-r--r--procps/powertop.c16
-rw-r--r--procps/ps.c78
-rw-r--r--procps/pstree.c2
-rw-r--r--procps/pwdx.c4
-rw-r--r--procps/renice.c23
-rw-r--r--procps/sysctl.c12
-rw-r--r--procps/top.c268
-rw-r--r--procps/uptime.c15
-rw-r--r--procps/watch.c17
-rw-r--r--qemu_multiarch_testing/README63
-rwxr-xr-xqemu_multiarch_testing/extract_od_binary.sh6
-rwxr-xr-xqemu_multiarch_testing/hdc.dir/build50
-rwxr-xr-xqemu_multiarch_testing/hdc.dir/init9
-rwxr-xr-xqemu_multiarch_testing/make-hdc-img.sh30
-rwxr-xr-xqemu_multiarch_testing/parallel-build-hdc-img.sh40
-rw-r--r--runit/Config.src79
-rw-r--r--runit/Kbuild.src11
-rw-r--r--runit/chpst.c52
-rw-r--r--runit/runsv.c35
-rw-r--r--runit/runsvdir.c98
-rw-r--r--runit/sv.c141
-rw-r--r--runit/svlogd.c24
-rw-r--r--scripts/Makefile.build3
-rw-r--r--scripts/basic/docproc.c4
-rw-r--r--scripts/basic/fixdep.c2
-rwxr-xr-xscripts/gen_build_files.sh40
-rwxr-xr-xscripts/generate_BUFSIZ.sh137
-rw-r--r--scripts/kconfig/confdata.c3
-rwxr-xr-x[-rw-r--r--]scripts/kconfig/lxdialog/check-lxdialog.sh17
-rw-r--r--scripts/kconfig/util.c3
-rw-r--r--scripts/kconfig/zconf.hash.c_shipped14
-rwxr-xr-xscripts/randomtest26
-rwxr-xr-xscripts/randomtest.loop1
-rwxr-xr-xscripts/trylink81
-rw-r--r--selinux/Config.src113
-rw-r--r--selinux/Kbuild.src12
-rw-r--r--selinux/chcon.c20
-rw-r--r--selinux/getenforce.c10
-rw-r--r--selinux/getsebool.c10
-rw-r--r--selinux/load_policy.c10
-rw-r--r--selinux/matchpathcon.c11
-rw-r--r--selinux/runcon.c27
-rw-r--r--selinux/selinuxenabled.c11
-rw-r--r--selinux/sestatus.c10
-rw-r--r--selinux/setenforce.c10
-rw-r--r--selinux/setfiles.c49
-rw-r--r--selinux/setsebool.c11
-rw-r--r--shell/Config.src45
-rw-r--r--shell/Kbuild.src2
-rw-r--r--shell/ash.c88
-rw-r--r--shell/ash_test/.gitignore7
-rw-r--r--shell/ash_test/ash-glob/glob1.right2
-rwxr-xr-xshell/ash_test/ash-glob/glob1.tests2
-rw-r--r--shell/ash_test/ash-glob/glob2.right18
-rwxr-xr-xshell/ash_test/ash-glob/glob2.tests27
-rw-r--r--shell/ash_test/ash-glob/glob3.right2
-rwxr-xr-xshell/ash_test/ash-glob/glob3.tests2
-rw-r--r--shell/ash_test/ash-glob/glob_and_assign.right6
-rwxr-xr-xshell/ash_test/ash-glob/glob_and_assign.tests10
-rw-r--r--shell/ash_test/ash-glob/glob_dir.right19
-rwxr-xr-xshell/ash_test/ash-glob/glob_dir.tests25
-rw-r--r--shell/ash_test/ash-glob/glob_redir.right2
-rwxr-xr-xshell/ash_test/ash-glob/glob_redir.tests9
-rw-r--r--shell/ash_test/ash-heredoc/heredoc1.right1
-rwxr-xr-xshell/ash_test/ash-heredoc/heredoc1.tests3
-rw-r--r--shell/ash_test/ash-heredoc/heredoc2.right2
-rwxr-xr-xshell/ash_test/ash-heredoc/heredoc2.tests7
-rw-r--r--shell/ash_test/ash-heredoc/heredoc3.right1
-rwxr-xr-xshell/ash_test/ash-heredoc/heredoc3.tests9
-rw-r--r--shell/ash_test/ash-heredoc/heredoc4.right1
-rwxr-xr-xshell/ash_test/ash-heredoc/heredoc4.tests3
-rw-r--r--shell/ash_test/ash-heredoc/heredoc5.right (copied from shell/hush_test/hush-misc/heredoc2.right)0
-rwxr-xr-xshell/ash_test/ash-heredoc/heredoc5.tests (copied from shell/hush_test/hush-misc/heredoc2.tests)0
-rw-r--r--shell/ash_test/ash-heredoc/heredoc6.right2
-rwxr-xr-xshell/ash_test/ash-heredoc/heredoc6.tests4
-rw-r--r--shell/ash_test/ash-heredoc/heredoc7.right1
-rwxr-xr-xshell/ash_test/ash-heredoc/heredoc7.tests3
-rw-r--r--shell/ash_test/ash-heredoc/heredoc_huge.right (copied from shell/hush_test/hush-misc/heredoc_huge.right)0
-rwxr-xr-xshell/ash_test/ash-heredoc/heredoc_huge.tests (copied from shell/hush_test/hush-misc/heredoc_huge.tests)0
-rw-r--r--shell/ash_test/ash-misc/and-or.right18
-rwxr-xr-xshell/ash_test/ash-misc/and-or.tests34
-rw-r--r--shell/ash_test/ash-misc/assignment1.right9
-rwxr-xr-xshell/ash_test/ash-misc/assignment1.tests42
-rw-r--r--shell/ash_test/ash-misc/assignment3.right2
-rwxr-xr-xshell/ash_test/ash-misc/assignment3.tests5
-rw-r--r--shell/ash_test/ash-misc/assignment4.right1
-rwxr-xr-xshell/ash_test/ash-misc/assignment4.tests3
-rw-r--r--shell/ash_test/ash-misc/break1.right2
-rwxr-xr-xshell/ash_test/ash-misc/break1.tests2
-rw-r--r--shell/ash_test/ash-misc/break2.right3
-rwxr-xr-xshell/ash_test/ash-misc/break2.tests6
-rw-r--r--shell/ash_test/ash-misc/break3.right2
-rwxr-xr-xshell/ash_test/ash-misc/break3.tests2
-rw-r--r--shell/ash_test/ash-misc/break4.right6
-rwxr-xr-xshell/ash_test/ash-misc/break4.tests12
-rw-r--r--shell/ash_test/ash-misc/break5.right13
-rwxr-xr-xshell/ash_test/ash-misc/break5.tests4
-rw-r--r--shell/ash_test/ash-misc/builtin1.right2
-rwxr-xr-xshell/ash_test/ash-misc/builtin1.tests6
-rw-r--r--shell/ash_test/ash-misc/case1.right22
-rwxr-xr-xshell/ash_test/ash-misc/case1.tests40
-rw-r--r--shell/ash_test/ash-misc/colon.right2
-rwxr-xr-xshell/ash_test/ash-misc/colon.tests5
-rw-r--r--shell/ash_test/ash-misc/command.right1
-rwxr-xr-xshell/ash_test/ash-misc/command.tests1
-rw-r--r--shell/ash_test/ash-misc/command2.right2
-rwxr-xr-xshell/ash_test/ash-misc/command2.tests6
-rw-r--r--shell/ash_test/ash-misc/compound.right14
-rwxr-xr-xshell/ash_test/ash-misc/compound.tests21
-rw-r--r--shell/ash_test/ash-misc/continue1.right8
-rwxr-xr-xshell/ash_test/ash-misc/continue1.tests4
-rw-r--r--shell/ash_test/ash-misc/continue2.right1
-rwxr-xr-xshell/ash_test/ash-misc/continue2.tests3
-rw-r--r--shell/ash_test/ash-misc/continue3.right2
-rwxr-xr-xshell/ash_test/ash-misc/continue3.tests3
-rwxr-xr-x[-rw-r--r--]shell/ash_test/ash-misc/echo_write_error.tests0
-rw-r--r--shell/ash_test/ash-misc/empty_for.right1
-rwxr-xr-xshell/ash_test/ash-misc/empty_for.tests3
-rw-r--r--shell/ash_test/ash-misc/empty_for2.right4
-rwxr-xr-xshell/ash_test/ash-misc/empty_for2.tests6
-rw-r--r--shell/ash_test/ash-misc/errexit1.right (copied from shell/msh_test/msh-execution/many_continues.right)0
-rwxr-xr-xshell/ash_test/ash-misc/errexit1.tests5
-rw-r--r--shell/ash_test/ash-misc/eval1.right1
-rwxr-xr-xshell/ash_test/ash-misc/eval1.tests4
-rw-r--r--shell/ash_test/ash-misc/eval2.right3
-rwxr-xr-xshell/ash_test/ash-misc/eval2.tests4
-rw-r--r--shell/ash_test/ash-misc/exec.right2
-rwxr-xr-xshell/ash_test/ash-misc/exec.tests3
-rw-r--r--shell/ash_test/ash-misc/exit1.right1
-rwxr-xr-xshell/ash_test/ash-misc/exit1.tests4
-rw-r--r--shell/ash_test/ash-misc/exitcode1.right2
-rwxr-xr-xshell/ash_test/ash-misc/exitcode1.tests2
-rw-r--r--shell/ash_test/ash-misc/exitcode2.right4
-rwxr-xr-xshell/ash_test/ash-misc/exitcode2.tests12
-rw-r--r--shell/ash_test/ash-misc/exitcode_EACCES.right2
-rwxr-xr-xshell/ash_test/ash-misc/exitcode_EACCES.tests (copied from shell/msh_test/msh-execution/exitcode_EACCES.tests)0
-rw-r--r--shell/ash_test/ash-misc/exitcode_ENOENT.right2
-rwxr-xr-xshell/ash_test/ash-misc/exitcode_ENOENT.tests (copied from shell/msh_test/msh-execution/exitcode_ENOENT.tests)0
-rw-r--r--shell/ash_test/ash-misc/for.right (renamed from shell/msh_test/msh-parsing/argv0.right)0
-rwxr-xr-xshell/ash_test/ash-misc/for.tests5
-rw-r--r--shell/ash_test/ash-misc/for_with_bslashes.right8
-rwxr-xr-xshell/ash_test/ash-misc/for_with_bslashes.tests10
-rw-r--r--shell/ash_test/ash-misc/for_with_keywords.right4
-rwxr-xr-xshell/ash_test/ash-misc/for_with_keywords.tests2
-rw-r--r--shell/ash_test/ash-misc/func1.right6
-rwxr-xr-xshell/ash_test/ash-misc/func1.tests16
-rw-r--r--shell/ash_test/ash-misc/func2.right5
-rwxr-xr-xshell/ash_test/ash-misc/func2.tests9
-rw-r--r--shell/ash_test/ash-misc/func3.right4
-rwxr-xr-xshell/ash_test/ash-misc/func3.tests8
-rw-r--r--shell/ash_test/ash-misc/func4.right2
-rwxr-xr-xshell/ash_test/ash-misc/func4.tests7
-rw-r--r--shell/ash_test/ash-misc/func5.right6
-rwxr-xr-xshell/ash_test/ash-misc/func5.tests13
-rw-r--r--shell/ash_test/ash-misc/func6.right2
-rwxr-xr-xshell/ash_test/ash-misc/func6.tests11
-rw-r--r--shell/ash_test/ash-misc/func_args1.right5
-rwxr-xr-xshell/ash_test/ash-misc/func_args1.tests8
-rw-r--r--shell/ash_test/ash-misc/func_bash1.right12
-rwxr-xr-xshell/ash_test/ash-misc/func_bash1.tests28
-rw-r--r--shell/ash_test/ash-misc/func_local1.right3
-rwxr-xr-xshell/ash_test/ash-misc/func_local1.tests5
-rw-r--r--shell/ash_test/ash-misc/func_local2.right14
-rwxr-xr-xshell/ash_test/ash-misc/func_local2.tests7
-rw-r--r--shell/ash_test/ash-misc/group_in_braces.right5
-rwxr-xr-xshell/ash_test/ash-misc/group_in_braces.tests11
-rw-r--r--shell/ash_test/ash-misc/if_false_exitcode.right1
-rwxr-xr-xshell/ash_test/ash-misc/if_false_exitcode.tests2
-rw-r--r--shell/ash_test/ash-misc/local1.right4
-rwxr-xr-xshell/ash_test/ash-misc/local1.tests11
-rw-r--r--shell/ash_test/ash-misc/local2.right1
-rwxr-xr-xshell/ash_test/ash-misc/local2.tests1
-rw-r--r--shell/ash_test/ash-misc/nommu1.right7
-rwxr-xr-xshell/ash_test/ash-misc/nommu1.tests12
-rw-r--r--shell/ash_test/ash-misc/nommu2.right5
-rwxr-xr-xshell/ash_test/ash-misc/nommu2.tests5
-rw-r--r--shell/ash_test/ash-misc/nommu3.right2
-rwxr-xr-xshell/ash_test/ash-misc/nommu3.tests15
-rw-r--r--shell/ash_test/ash-misc/opts1.right2
-rwxr-xr-xshell/ash_test/ash-misc/opts1.tests5
-rw-r--r--shell/ash_test/ash-misc/pid.right1
-rwxr-xr-xshell/ash_test/ash-misc/pid.tests1
-rw-r--r--shell/ash_test/ash-misc/pipefail.right40
-rwxr-xr-xshell/ash_test/ash-misc/pipefail.tests45
-rw-r--r--shell/ash_test/ash-misc/read.right (renamed from shell/msh_test/msh-bugs/read.right)0
-rwxr-xr-xshell/ash_test/ash-misc/read.tests (renamed from shell/msh_test/msh-bugs/read.tests)0
-rw-r--r--shell/ash_test/ash-misc/return1.right1
-rwxr-xr-xshell/ash_test/ash-misc/return1.tests4
-rw-r--r--shell/ash_test/ash-misc/shift.right (renamed from shell/msh_test/msh-bugs/shift.right)0
-rwxr-xr-xshell/ash_test/ash-misc/shift.tests (renamed from shell/msh_test/msh-bugs/shift.tests)0
-rw-r--r--shell/ash_test/ash-misc/sigint1.right1
-rwxr-xr-xshell/ash_test/ash-misc/sigint1.tests41
-rw-r--r--shell/ash_test/ash-misc/source3.right2
-rwxr-xr-xshell/ash_test/ash-misc/source3.tests6
-rw-r--r--shell/ash_test/ash-misc/source5.right4
-rwxr-xr-xshell/ash_test/ash-misc/source5.tests8
-rw-r--r--shell/ash_test/ash-misc/tickquote1.right1
-rwxr-xr-xshell/ash_test/ash-misc/tickquote1.tests1
-rw-r--r--shell/ash_test/ash-misc/unicode1.right3
-rwxr-xr-xshell/ash_test/ash-misc/unicode1.tests13
-rw-r--r--shell/ash_test/ash-misc/until1.right3
-rwxr-xr-xshell/ash_test/ash-misc/until1.tests11
-rw-r--r--shell/ash_test/ash-misc/wait4.right1
-rwxr-xr-xshell/ash_test/ash-misc/wait4.tests2
-rw-r--r--shell/ash_test/ash-misc/wait5.right2
-rwxr-xr-xshell/ash_test/ash-misc/wait5.tests5
-rw-r--r--shell/ash_test/ash-misc/while1.right1
-rwxr-xr-xshell/ash_test/ash-misc/while1.tests2
-rw-r--r--shell/ash_test/ash-misc/while2.right2
-rwxr-xr-xshell/ash_test/ash-misc/while2.tests2
-rw-r--r--shell/ash_test/ash-misc/while4.right1
-rwxr-xr-xshell/ash_test/ash-misc/while4.tests6
-rw-r--r--shell/ash_test/ash-misc/while_in_subshell.right1
-rwxr-xr-xshell/ash_test/ash-misc/while_in_subshell.tests2
-rwxr-xr-xshell/ash_test/ash-quoting/dollar_repl_slash_bash1.tests2
-rw-r--r--shell/ash_test/ash-quoting/dollar_squote_bash1.right1
-rwxr-xr-xshell/ash_test/ash-quoting/dollar_squote_bash1.tests1
-rw-r--r--shell/ash_test/ash-quoting/dollar_squote_bash2.right6
-rwxr-xr-xshell/ash_test/ash-quoting/dollar_squote_bash2.tests10
-rwxr-xr-xshell/ash_test/ash-read/read_r.tests6
-rw-r--r--shell/ash_test/ash-redir/redir1.right (copied from shell/hush_test/hush-misc/redir1.right)0
-rwxr-xr-xshell/ash_test/ash-redir/redir1.tests (copied from shell/hush_test/hush-misc/redir1.tests)0
-rwxr-xr-xshell/ash_test/ash-redir/redir7.tests6
-rwxr-xr-xshell/ash_test/ash-redir/redir8.tests8
-rw-r--r--shell/ash_test/ash-redir/redir_escapednum.right (copied from shell/hush_test/hush-misc/redir2.right)0
-rwxr-xr-xshell/ash_test/ash-redir/redir_escapednum.tests (copied from shell/hush_test/hush-misc/redir2.tests)0
-rw-r--r--shell/ash_test/ash-redir/redir_expand.right (copied from shell/hush_test/hush-misc/redir4.right)0
-rwxr-xr-xshell/ash_test/ash-redir/redir_expand.tests (copied from shell/hush_test/hush-misc/redir4.tests)0
-rw-r--r--shell/ash_test/ash-redir/redir_leak.right6
-rwxr-xr-xshell/ash_test/ash-redir/redir_leak.tests10
-rw-r--r--shell/ash_test/ash-redir/redir_multi.right (copied from shell/hush_test/hush-misc/redir6.right)0
-rwxr-xr-xshell/ash_test/ash-redir/redir_multi.tests (copied from shell/hush_test/hush-misc/redir6.tests)0
-rw-r--r--shell/ash_test/ash-redir/redir_script.right1
-rwxr-xr-xshell/ash_test/ash-redir/redir_script.tests29
-rw-r--r--shell/ash_test/ash-redir/redir_space.right (copied from shell/hush_test/hush-parsing/redir_space.right)0
-rwxr-xr-xshell/ash_test/ash-redir/redir_space.tests (copied from shell/hush_test/hush-parsing/redir_space.tests)0
-rw-r--r--shell/ash_test/ash-signals/continue_and_trap1.right1
-rwxr-xr-xshell/ash_test/ash-signals/continue_and_trap1.tests7
-rw-r--r--shell/ash_test/ash-signals/return_in_trap1.right4
-rwxr-xr-xshell/ash_test/ash-signals/return_in_trap1.tests18
-rw-r--r--shell/ash_test/ash-signals/save-ret.right (copied from shell/hush_test/hush-trap/save-ret.right)0
-rwxr-xr-xshell/ash_test/ash-signals/save-ret.tests (copied from shell/hush_test/hush-trap/save-ret.tests)0
-rwxr-xr-xshell/ash_test/ash-signals/signal1.tests2
-rw-r--r--shell/ash_test/ash-signals/sigquit_exec.right2
-rwxr-xr-xshell/ash_test/ash-signals/sigquit_exec.tests4
-rw-r--r--shell/ash_test/ash-vars/empty.right3
-rwxr-xr-xshell/ash_test/ash-vars/empty.tests5
-rw-r--r--shell/ash_test/ash-vars/glob_and_vars.right1
-rwxr-xr-xshell/ash_test/ash-vars/glob_and_vars.tests2
-rw-r--r--shell/ash_test/ash-vars/param_expand_len.right12
-rwxr-xr-xshell/ash_test/ash-vars/param_expand_len.tests24
-rw-r--r--shell/ash_test/ash-vars/param_glob.right4
-rwxr-xr-xshell/ash_test/ash-vars/param_glob.tests9
-rw-r--r--shell/ash_test/ash-vars/param_subshell.right7
-rwxr-xr-xshell/ash_test/ash-vars/param_subshell.tests15
-rw-r--r--shell/ash_test/ash-vars/readonly1.right2
-rwxr-xr-xshell/ash_test/ash-vars/readonly1.tests7
-rw-r--r--shell/ash_test/ash-vars/star.right (renamed from shell/msh_test/msh-vars/star.right)0
-rwxr-xr-xshell/ash_test/ash-vars/star.tests (renamed from shell/msh_test/msh-vars/star.tests)0
-rw-r--r--shell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.right2
-rwxr-xr-xshell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.tests3
-rw-r--r--shell/ash_test/ash-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.right1
-rwxr-xr-xshell/ash_test/ash-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.tests2
-rw-r--r--shell/ash_test/ash-vars/var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.right1
-rwxr-xr-xshell/ash_test/ash-vars/var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.tests3
-rw-r--r--shell/ash_test/ash-vars/var-expand-tilde-in-parameter-expansion.right1
-rwxr-xr-xshell/ash_test/ash-vars/var-expand-tilde-in-parameter-expansion.tests2
-rw-r--r--shell/ash_test/ash-vars/var-pattern-replacement-in-parameter-expansion-1.right1
-rwxr-xr-xshell/ash_test/ash-vars/var-pattern-replacement-in-parameter-expansion-1.tests2
-rw-r--r--shell/ash_test/ash-vars/var-pattern-replacement-in-parameter-expansion-2.right1
-rwxr-xr-xshell/ash_test/ash-vars/var-pattern-replacement-in-parameter-expansion-2.tests2
-rw-r--r--shell/ash_test/ash-vars/var-pattern-replacement-in-parameter-expansion-3.right1
-rwxr-xr-xshell/ash_test/ash-vars/var-pattern-replacement-in-parameter-expansion-3.tests2
-rw-r--r--shell/ash_test/ash-vars/var-pattern-replacement-in-parameter-expansion-4.right1
-rwxr-xr-xshell/ash_test/ash-vars/var-pattern-replacement-in-parameter-expansion-4.tests2
-rw-r--r--shell/ash_test/ash-vars/var-pattern-replacement-in-parameter-expansion-5.right1
-rwxr-xr-xshell/ash_test/ash-vars/var-pattern-replacement-in-parameter-expansion-5.tests2
-rw-r--r--shell/ash_test/ash-vars/var-runtime-quote-detection.right1
-rwxr-xr-xshell/ash_test/ash-vars/var-runtime-quote-detection.tests1
-rw-r--r--shell/ash_test/ash-vars/var-utf8-length.right1
-rwxr-xr-xshell/ash_test/ash-vars/var-utf8-length.tests2
-rw-r--r--shell/ash_test/ash-vars/var1.right10
-rwxr-xr-xshell/ash_test/ash-vars/var1.tests19
-rw-r--r--shell/ash_test/ash-vars/var2.right3
-rwxr-xr-xshell/ash_test/ash-vars/var2.tests5
-rw-r--r--shell/ash_test/ash-vars/var3.right5
-rwxr-xr-xshell/ash_test/ash-vars/var3.tests1
-rw-r--r--shell/ash_test/ash-vars/var4.right1
-rwxr-xr-xshell/ash_test/ash-vars/var4.tests1
-rw-r--r--shell/ash_test/ash-vars/var5.right6
-rwxr-xr-xshell/ash_test/ash-vars/var5.tests14
-rw-r--r--shell/ash_test/ash-vars/var_bash1a.right6
-rwxr-xr-xshell/ash_test/ash-vars/var_bash1a.tests11
-rw-r--r--shell/ash_test/ash-vars/var_bash4.right25
-rwxr-xr-xshell/ash_test/ash-vars/var_bash4.tests52
-rw-r--r--shell/ash_test/ash-vars/var_bash5.right13
-rwxr-xr-xshell/ash_test/ash-vars/var_bash5.tests24
-rw-r--r--shell/ash_test/ash-vars/var_expand_in_assign.right (renamed from shell/msh_test/msh-bugs/var_expand_in_assign.right)0
-rwxr-xr-xshell/ash_test/ash-vars/var_expand_in_assign.tests (renamed from shell/msh_test/msh-bugs/var_expand_in_assign.tests)0
-rw-r--r--shell/ash_test/ash-vars/var_expand_in_redir.right (renamed from shell/msh_test/msh-bugs/var_expand_in_redir.right)0
-rwxr-xr-xshell/ash_test/ash-vars/var_expand_in_redir.tests (renamed from shell/msh_test/msh-bugs/var_expand_in_redir.tests)0
-rw-r--r--shell/ash_test/ash-vars/var_expand_on_ifs.right9
-rwxr-xr-xshell/ash_test/ash-vars/var_expand_on_ifs.tests11
-rw-r--r--shell/ash_test/ash-vars/var_in_pipes.right6
-rwxr-xr-xshell/ash_test/ash-vars/var_in_pipes.tests7
-rw-r--r--shell/ash_test/ash-vars/var_leaks.right (copied from shell/msh_test/msh-execution/many_continues.right)0
-rwxr-xr-xshell/ash_test/ash-vars/var_leaks.tests14
-rw-r--r--shell/ash_test/ash-vars/var_posix1.right30
-rwxr-xr-xshell/ash_test/ash-vars/var_posix1.tests37
-rw-r--r--shell/ash_test/ash-vars/var_serial.right5
-rwxr-xr-xshell/ash_test/ash-vars/var_serial.tests22
-rw-r--r--shell/ash_test/ash-vars/var_subst_in_for.right (renamed from shell/msh_test/msh-vars/var_subst_in_for.right)0
-rwxr-xr-xshell/ash_test/ash-vars/var_subst_in_for.tests40
-rw-r--r--shell/ash_test/ash-vars/var_unbackslash.right11
-rwxr-xr-xshell/ash_test/ash-vars/var_unbackslash.tests23
-rw-r--r--shell/ash_test/ash-vars/var_unbackslash1.right7
-rwxr-xr-xshell/ash_test/ash-vars/var_unbackslash1.tests35
-rw-r--r--shell/ash_test/ash-vars/var_wordsplit_ifs1.right41
-rwxr-xr-xshell/ash_test/ash-vars/var_wordsplit_ifs1.tests42
-rw-r--r--shell/ash_test/ash-vars/var_wordsplit_ifs2.right3
-rwxr-xr-xshell/ash_test/ash-vars/var_wordsplit_ifs2.tests13
-rw-r--r--shell/ash_test/ash-vars/var_wordsplit_ifs3.right12
-rwxr-xr-xshell/ash_test/ash-vars/var_wordsplit_ifs3.tests5
-rw-r--r--shell/ash_test/printenv.c1
-rwxr-xr-xshell/ash_test/run-all6
-rw-r--r--shell/hush.c2076
-rwxr-xr-xshell/hush_test/hush-glob/bash_brace1.tests2
-rw-r--r--shell/hush_test/hush-glob/glob3.right2
-rwxr-xr-xshell/hush_test/hush-glob/glob3.tests2
-rw-r--r--shell/hush_test/hush-glob/glob_dir.right19
-rwxr-xr-xshell/hush_test/hush-glob/glob_dir.tests25
-rw-r--r--shell/hush_test/hush-heredoc/heredoc1.right (renamed from shell/hush_test/hush-misc/heredoc1.right)0
-rwxr-xr-xshell/hush_test/hush-heredoc/heredoc1.tests (renamed from shell/hush_test/hush-misc/heredoc1.tests)0
-rw-r--r--shell/hush_test/hush-heredoc/heredoc2.right2
-rwxr-xr-xshell/hush_test/hush-heredoc/heredoc2.tests7
-rw-r--r--shell/hush_test/hush-heredoc/heredoc3.right (renamed from shell/hush_test/hush-misc/heredoc3.right)0
-rwxr-xr-xshell/hush_test/hush-heredoc/heredoc3.tests (renamed from shell/hush_test/hush-misc/heredoc3.tests)0
-rw-r--r--shell/hush_test/hush-heredoc/heredoc4.right1
-rwxr-xr-xshell/hush_test/hush-heredoc/heredoc4.tests3
-rw-r--r--shell/hush_test/hush-heredoc/heredoc5.right (renamed from shell/hush_test/hush-misc/heredoc2.right)0
-rwxr-xr-xshell/hush_test/hush-heredoc/heredoc5.tests (renamed from shell/hush_test/hush-misc/heredoc2.tests)0
-rw-r--r--shell/hush_test/hush-heredoc/heredoc6.right2
-rwxr-xr-xshell/hush_test/hush-heredoc/heredoc6.tests4
-rw-r--r--shell/hush_test/hush-heredoc/heredoc7.right1
-rwxr-xr-xshell/hush_test/hush-heredoc/heredoc7.tests3
-rw-r--r--shell/hush_test/hush-heredoc/heredoc_backslash1.right (renamed from shell/hush_test/hush-misc/heredoc_backslash1.right)0
-rwxr-xr-xshell/hush_test/hush-heredoc/heredoc_backslash1.tests (renamed from shell/hush_test/hush-misc/heredoc_backslash1.tests)0
-rw-r--r--shell/hush_test/hush-heredoc/heredoc_huge.right (renamed from shell/hush_test/hush-misc/heredoc_huge.right)0
-rwxr-xr-xshell/hush_test/hush-heredoc/heredoc_huge.tests (renamed from shell/hush_test/hush-misc/heredoc_huge.tests)0
-rw-r--r--shell/hush_test/hush-invert/invert.right10
-rwxr-xr-xshell/hush_test/hush-invert/invert.tests19
-rw-r--r--shell/hush_test/hush-misc/assignment2.right2
-rw-r--r--shell/hush_test/hush-misc/assignment2.rigth2
-rwxr-xr-xshell/hush_test/hush-misc/assignment2.tests1
-rw-r--r--shell/hush_test/hush-misc/eval1.right1
-rwxr-xr-xshell/hush_test/hush-misc/eval1.tests4
-rw-r--r--shell/hush_test/hush-misc/eval2.right3
-rwxr-xr-xshell/hush_test/hush-misc/eval2.tests4
-rw-r--r--shell/hush_test/hush-misc/exitcode1.right2
-rwxr-xr-xshell/hush_test/hush-misc/exitcode1.tests2
-rw-r--r--shell/hush_test/hush-misc/exitcode2.right4
-rwxr-xr-xshell/hush_test/hush-misc/exitcode2.tests12
-rw-r--r--shell/hush_test/hush-misc/exitcode_EACCES.right2
-rwxr-xr-xshell/hush_test/hush-misc/exitcode_EACCES.tests (renamed from shell/msh_test/msh-execution/exitcode_EACCES.tests)0
-rw-r--r--shell/hush_test/hush-misc/exitcode_ENOENT.right2
-rwxr-xr-xshell/hush_test/hush-misc/exitcode_ENOENT.tests (renamed from shell/msh_test/msh-execution/exitcode_ENOENT.tests)0
-rw-r--r--shell/hush_test/hush-misc/for.right (copied from shell/msh_test/msh-execution/many_continues.right)0
-rwxr-xr-xshell/hush_test/hush-misc/for.tests5
-rw-r--r--shell/hush_test/hush-misc/func6.right2
-rwxr-xr-xshell/hush_test/hush-misc/func6.tests11
-rwxr-xr-xshell/hush_test/hush-misc/func_args1.tests2
-rw-r--r--shell/hush_test/hush-misc/group_in_braces.right5
-rwxr-xr-xshell/hush_test/hush-misc/group_in_braces.tests11
-rw-r--r--shell/hush_test/hush-misc/last_amp.right2
-rwxr-xr-xshell/hush_test/hush-misc/last_amp.tests8
-rw-r--r--shell/hush_test/hush-misc/local1.right4
-rwxr-xr-xshell/hush_test/hush-misc/local1.tests11
-rw-r--r--shell/hush_test/hush-misc/nommu3.right2
-rwxr-xr-xshell/hush_test/hush-misc/nommu3.tests15
-rw-r--r--shell/hush_test/hush-misc/nulltick1.right3
-rwxr-xr-xshell/hush_test/hush-misc/nulltick1.tests3
-rw-r--r--shell/hush_test/hush-misc/source1.right7
-rwxr-xr-xshell/hush_test/hush-misc/source1.tests15
-rw-r--r--shell/hush_test/hush-misc/source2.right5
-rwxr-xr-xshell/hush_test/hush-misc/source2.tests11
-rw-r--r--shell/hush_test/hush-misc/source3.right2
-rwxr-xr-xshell/hush_test/hush-misc/source3.tests6
-rw-r--r--shell/hush_test/hush-misc/source4.right5
-rwxr-xr-xshell/hush_test/hush-misc/source4.tests10
-rw-r--r--shell/hush_test/hush-misc/source5.right4
-rwxr-xr-xshell/hush_test/hush-misc/source5.tests8
-rw-r--r--shell/hush_test/hush-misc/unicode1.right3
-rwxr-xr-xshell/hush_test/hush-misc/unicode1.tests13
-rw-r--r--shell/hush_test/hush-misc/wait1.right2
-rwxr-xr-xshell/hush_test/hush-misc/wait1.tests3
-rw-r--r--shell/hush_test/hush-misc/wait2.right2
-rwxr-xr-xshell/hush_test/hush-misc/wait2.tests4
-rw-r--r--shell/hush_test/hush-misc/wait3.right2
-rwxr-xr-xshell/hush_test/hush-misc/wait3.tests3
-rw-r--r--shell/hush_test/hush-misc/wait4.right1
-rwxr-xr-xshell/hush_test/hush-misc/wait4.tests2
-rw-r--r--shell/hush_test/hush-misc/wait5.right2
-rwxr-xr-xshell/hush_test/hush-misc/wait5.tests5
-rw-r--r--shell/hush_test/hush-quoting/dollar_repl_slash_bash1.right10
-rwxr-xr-xshell/hush_test/hush-quoting/dollar_repl_slash_bash1.tests21
-rwxr-xr-xshell/hush_test/hush-read/read_r.tests6
-rw-r--r--shell/hush_test/hush-redir/redir1.right (renamed from shell/hush_test/hush-misc/redir1.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir1.tests (renamed from shell/hush_test/hush-misc/redir1.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir2.right (copied from shell/msh_test/msh-execution/many_continues.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir2.tests5
-rw-r--r--shell/hush_test/hush-redir/redir3.right (renamed from shell/hush_test/hush-misc/redir3.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir3.tests (renamed from shell/hush_test/hush-misc/redir3.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir4.right (renamed from shell/msh_test/msh-execution/many_continues.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir4.tests72
-rw-r--r--shell/hush_test/hush-redir/redir5.right (renamed from shell/hush_test/hush-misc/redir5.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir5.tests (renamed from shell/hush_test/hush-misc/redir5.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir6.right2
-rwxr-xr-xshell/hush_test/hush-redir/redir6.tests3
-rw-r--r--shell/hush_test/hush-redir/redir7.right3
-rwxr-xr-xshell/hush_test/hush-redir/redir7.tests12
-rw-r--r--shell/hush_test/hush-redir/redir8.right3
-rwxr-xr-xshell/hush_test/hush-redir/redir8.tests15
-rw-r--r--shell/hush_test/hush-redir/redir9.right2
-rwxr-xr-xshell/hush_test/hush-redir/redir9.tests4
-rw-r--r--shell/hush_test/hush-redir/redirA.right2
-rwxr-xr-xshell/hush_test/hush-redir/redirA.tests11
-rw-r--r--shell/hush_test/hush-redir/redir_escapednum.right (copied from shell/hush_test/hush-misc/redir2.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir_escapednum.tests (renamed from shell/hush_test/hush-misc/redir2.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir_expand.right (renamed from shell/hush_test/hush-misc/redir4.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir_expand.tests (renamed from shell/hush_test/hush-misc/redir4.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir_leak.right6
-rwxr-xr-xshell/hush_test/hush-redir/redir_leak.tests10
-rw-r--r--shell/hush_test/hush-redir/redir_multi.right (renamed from shell/hush_test/hush-misc/redir6.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir_multi.tests (renamed from shell/hush_test/hush-misc/redir6.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir_script.right1
-rwxr-xr-xshell/hush_test/hush-redir/redir_script.tests29
-rw-r--r--shell/hush_test/hush-redir/redir_space.right (renamed from shell/hush_test/hush-parsing/redir_space.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir_space.tests (renamed from shell/hush_test/hush-parsing/redir_space.tests)0
-rw-r--r--shell/hush_test/hush-signals/catch.right (renamed from shell/hush_test/hush-trap/catch.right)0
-rwxr-xr-xshell/hush_test/hush-signals/catch.tests (renamed from shell/hush_test/hush-trap/catch.tests)0
-rw-r--r--shell/hush_test/hush-signals/continue_and_trap1.right1
-rwxr-xr-xshell/hush_test/hush-signals/continue_and_trap1.tests7
-rw-r--r--shell/hush_test/hush-signals/exit.right (renamed from shell/hush_test/hush-trap/exit.right)0
-rwxr-xr-xshell/hush_test/hush-signals/exit.tests (renamed from shell/hush_test/hush-trap/exit.tests)0
-rw-r--r--shell/hush_test/hush-signals/reap1.right (renamed from shell/hush_test/hush-misc/redir2.right)0
-rwxr-xr-xshell/hush_test/hush-signals/reap1.tests14
-rw-r--r--shell/hush_test/hush-signals/return_in_trap1.right4
-rwxr-xr-xshell/hush_test/hush-signals/return_in_trap1.tests18
-rw-r--r--shell/hush_test/hush-signals/save-ret.right (renamed from shell/hush_test/hush-trap/save-ret.right)0
-rwxr-xr-xshell/hush_test/hush-signals/save-ret.tests (renamed from shell/hush_test/hush-trap/save-ret.tests)0
-rw-r--r--shell/hush_test/hush-signals/savetrap.right (renamed from shell/hush_test/hush-trap/savetrap.right)0
-rwxr-xr-xshell/hush_test/hush-signals/savetrap.tests (renamed from shell/hush_test/hush-trap/savetrap.tests)0
-rw-r--r--shell/hush_test/hush-signals/sigint1.right1
-rwxr-xr-xshell/hush_test/hush-signals/sigint1.tests41
-rw-r--r--shell/hush_test/hush-signals/signal2.right3
-rwxr-xr-xshell/hush_test/hush-signals/signal2.tests18
-rw-r--r--shell/hush_test/hush-signals/signal3.right4
-rwxr-xr-xshell/hush_test/hush-signals/signal3.tests17
-rw-r--r--shell/hush_test/hush-signals/signal5.right12
-rwxr-xr-xshell/hush_test/hush-signals/signal5.tests14
-rw-r--r--shell/hush_test/hush-signals/signal6.right2
-rwxr-xr-xshell/hush_test/hush-signals/signal6.tests2
-rw-r--r--shell/hush_test/hush-signals/signal7.right (renamed from shell/hush_test/hush-trap/signal7.right)0
-rwxr-xr-xshell/hush_test/hush-signals/signal7.tests (renamed from shell/hush_test/hush-trap/signal7.tests)0
-rw-r--r--shell/hush_test/hush-signals/signal_read1.right (renamed from shell/hush_test/hush-trap/signal_read1.right)0
-rwxr-xr-xshell/hush_test/hush-signals/signal_read1.tests (renamed from shell/hush_test/hush-trap/signal_read1.tests)0
-rw-r--r--shell/hush_test/hush-signals/signal_read2.right (renamed from shell/hush_test/hush-trap/signal_read2.right)0
-rwxr-xr-xshell/hush_test/hush-signals/signal_read2.tests (renamed from shell/hush_test/hush-trap/signal_read2.tests)0
-rw-r--r--shell/hush_test/hush-signals/sigquit_exec.right2
-rwxr-xr-xshell/hush_test/hush-signals/sigquit_exec.tests4
-rw-r--r--shell/hush_test/hush-signals/subshell.right (renamed from shell/hush_test/hush-trap/subshell.right)0
-rwxr-xr-xshell/hush_test/hush-signals/subshell.tests (renamed from shell/hush_test/hush-trap/subshell.tests)0
-rw-r--r--shell/hush_test/hush-signals/usage.right (renamed from shell/hush_test/hush-trap/usage.right)0
-rwxr-xr-xshell/hush_test/hush-signals/usage.tests (renamed from shell/hush_test/hush-trap/usage.tests)0
-rw-r--r--shell/hush_test/hush-standalone/noexec_gets_no_env.right4
-rwxr-xr-xshell/hush_test/hush-standalone/noexec_gets_no_env.tests5
-rw-r--r--shell/hush_test/hush-standalone/nofork_trashes_getopt.right1
-rwxr-xr-xshell/hush_test/hush-standalone/nofork_trashes_getopt.tests6
-rw-r--r--shell/hush_test/hush-standalone/var_standalone1.right1
-rwxr-xr-xshell/hush_test/hush-standalone/var_standalone1.tests2
-rw-r--r--shell/hush_test/hush-vars/param_expand_len.right3
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_len.tests7
-rw-r--r--shell/hush_test/hush-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.right2
-rwxr-xr-xshell/hush_test/hush-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.tests3
-rw-r--r--shell/hush_test/hush-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.right1
-rwxr-xr-xshell/hush_test/hush-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.tests2
-rw-r--r--shell/hush_test/hush-vars/var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.right1
-rwxr-xr-xshell/hush_test/hush-vars/var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.tests3
-rw-r--r--shell/hush_test/hush-vars/var-pattern-replacement-in-parameter-expansion-1.right1
-rwxr-xr-xshell/hush_test/hush-vars/var-pattern-replacement-in-parameter-expansion-1.tests2
-rw-r--r--shell/hush_test/hush-vars/var-pattern-replacement-in-parameter-expansion-2.right1
-rwxr-xr-xshell/hush_test/hush-vars/var-pattern-replacement-in-parameter-expansion-2.tests2
-rw-r--r--shell/hush_test/hush-vars/var-pattern-replacement-in-parameter-expansion-3.right1
-rwxr-xr-xshell/hush_test/hush-vars/var-pattern-replacement-in-parameter-expansion-3.tests2
-rw-r--r--shell/hush_test/hush-vars/var-pattern-replacement-in-parameter-expansion-4.right1
-rwxr-xr-xshell/hush_test/hush-vars/var-pattern-replacement-in-parameter-expansion-4.tests2
-rw-r--r--shell/hush_test/hush-vars/var-pattern-replacement-in-parameter-expansion-5.right1
-rwxr-xr-xshell/hush_test/hush-vars/var-pattern-replacement-in-parameter-expansion-5.tests2
-rw-r--r--shell/hush_test/hush-vars/var-runtime-quote-detection.right1
-rwxr-xr-xshell/hush_test/hush-vars/var-runtime-quote-detection.tests1
-rw-r--r--shell/hush_test/hush-vars/var3.right7
-rwxr-xr-xshell/hush_test/hush-vars/var3.tests5
-rw-r--r--shell/hush_test/hush-vars/var4.right1
-rwxr-xr-xshell/hush_test/hush-vars/var4.tests1
-rw-r--r--shell/hush_test/hush-vars/var5.right6
-rwxr-xr-xshell/hush_test/hush-vars/var5.tests14
-rw-r--r--shell/hush_test/hush-vars/var6.right2
-rwxr-xr-xshell/hush_test/hush-vars/var6.tests4
-rw-r--r--shell/hush_test/hush-vars/var_unbackslash1.right7
-rwxr-xr-xshell/hush_test/hush-vars/var_unbackslash1.tests35
-rw-r--r--shell/hush_test/hush-vars/var_wordsplit_ifs1.right41
-rwxr-xr-xshell/hush_test/hush-vars/var_wordsplit_ifs1.tests42
-rw-r--r--shell/hush_test/hush-vars/var_wordsplit_ifs2.right3
-rwxr-xr-xshell/hush_test/hush-vars/var_wordsplit_ifs2.tests13
-rw-r--r--shell/hush_test/hush-vars/var_wordsplit_ifs3.right12
-rwxr-xr-xshell/hush_test/hush-vars/var_wordsplit_ifs3.tests5
-rwxr-xr-xshell/hush_test/run-all3
-rw-r--r--shell/math.c27
-rw-r--r--shell/math.h2
-rw-r--r--shell/msh_test/msh-bugs/noeol3.right1
-rwxr-xr-xshell/msh_test/msh-bugs/noeol3.tests2
-rw-r--r--shell/msh_test/msh-bugs/process_subst.right3
-rwxr-xr-xshell/msh_test/msh-bugs/process_subst.tests3
-rw-r--r--shell/msh_test/msh-bugs/starquoted.right8
-rwxr-xr-xshell/msh_test/msh-bugs/starquoted.tests8
-rw-r--r--shell/msh_test/msh-bugs/syntax_err.right2
-rwxr-xr-xshell/msh_test/msh-bugs/syntax_err.tests3
-rw-r--r--shell/msh_test/msh-execution/exitcode_EACCES.right2
-rw-r--r--shell/msh_test/msh-execution/exitcode_ENOENT.right2
-rwxr-xr-xshell/msh_test/msh-execution/many_continues.tests15
-rw-r--r--shell/msh_test/msh-execution/nested_break.right8
-rwxr-xr-xshell/msh_test/msh-execution/nested_break.tests17
-rw-r--r--shell/msh_test/msh-misc/tick.right2
-rwxr-xr-xshell/msh_test/msh-misc/tick.tests4
-rwxr-xr-xshell/msh_test/msh-parsing/argv0.tests4
-rw-r--r--shell/msh_test/msh-parsing/noeol.right1
-rwxr-xr-xshell/msh_test/msh-parsing/noeol.tests2
-rw-r--r--shell/msh_test/msh-parsing/noeol2.right1
-rwxr-xr-xshell/msh_test/msh-parsing/noeol2.tests7
-rw-r--r--shell/msh_test/msh-parsing/quote1.right1
-rwxr-xr-xshell/msh_test/msh-parsing/quote1.tests2
-rw-r--r--shell/msh_test/msh-parsing/quote2.right1
-rwxr-xr-xshell/msh_test/msh-parsing/quote2.tests2
-rw-r--r--shell/msh_test/msh-parsing/quote3.right3
-rwxr-xr-xshell/msh_test/msh-parsing/quote3.tests8
-rw-r--r--shell/msh_test/msh-parsing/quote4.right1
-rwxr-xr-xshell/msh_test/msh-parsing/quote4.tests2
-rw-r--r--shell/msh_test/msh-vars/var.right4
-rwxr-xr-xshell/msh_test/msh-vars/var.tests9
-rwxr-xr-xshell/msh_test/msh-vars/var_subst_in_for.tests40
-rwxr-xr-xshell/msh_test/run-all64
-rw-r--r--shell/random.c142
-rw-r--r--shell/random.h16
-rw-r--r--shell/shell_common.c6
-rw-r--r--shell/shell_common.h2
-rw-r--r--sysklogd/Config.src159
-rw-r--r--sysklogd/Kbuild.src4
-rw-r--r--sysklogd/klogd.c39
-rw-r--r--sysklogd/logger.c15
-rw-r--r--sysklogd/logread.c46
-rw-r--r--sysklogd/syslogd.c248
-rw-r--r--sysklogd/syslogd_and_logger.c1
-rwxr-xr-xtestsuite/ar.tests2
-rwxr-xr-xtestsuite/awk.tests24
-rwxr-xr-xtestsuite/busybox.tests16
-rwxr-xr-xtestsuite/bzcat.tests88
-rw-r--r--testsuite/bzcat/bzcat-does-not-remove-compressed-file (renamed from testsuite/bunzip2/bzcat-does-not-remove-compressed-file)0
-rwxr-xr-xtestsuite/cpio.tests27
-rwxr-xr-xtestsuite/dc.tests56
-rwxr-xr-xtestsuite/diff.tests23
-rw-r--r--testsuite/du/du-m-works2
-rwxr-xr-xtestsuite/find.tests76
-rwxr-xr-xtestsuite/grep.tests34
-rw-r--r--testsuite/gzip/gzip-compression-levels5
-rwxr-xr-xtestsuite/makedevs.tests2
-rwxr-xr-xtestsuite/md5sum.tests22
-rwxr-xr-xtestsuite/mdev.tests2
-rwxr-xr-xtestsuite/patch.tests45
-rw-r--r--testsuite/pwd/pwd-prints-working-directory5
-rwxr-xr-xtestsuite/readlink.tests11
-rwxr-xr-xtestsuite/sed.tests72
-rwxr-xr-xtestsuite/sha3sum.tests2
-rwxr-xr-xtestsuite/sort.tests55
-rwxr-xr-xtestsuite/tar.tests77
-rw-r--r--testsuite/tar.utf8.tar.bz23
-rwxr-xr-xtestsuite/test.tests20
-rwxr-xr-xtestsuite/unzip.tests24
-rw-r--r--testsuite/which/which-uses-default-path2
-rw-r--r--util-linux/Config.src644
-rw-r--r--util-linux/Kbuild.src37
-rw-r--r--util-linux/acpid.c36
-rw-r--r--util-linux/blkdiscard.c82
-rw-r--r--util-linux/blkid.c20
-rw-r--r--util-linux/blockdev.c9
-rw-r--r--util-linux/dmesg.c95
-rw-r--r--util-linux/fatattr.c105
-rw-r--r--util-linux/fbset.c63
-rw-r--r--util-linux/fdformat.c14
-rw-r--r--util-linux/fdisk.c351
-rw-r--r--util-linux/fdisk_gpt.c58
-rw-r--r--util-linux/fdisk_osf.c5
-rw-r--r--util-linux/fdisk_sgi.c29
-rw-r--r--util-linux/findfs.c16
-rw-r--r--util-linux/flock.c30
-rw-r--r--util-linux/freeramdisk.c30
-rw-r--r--util-linux/fsck_minix.c30
-rw-r--r--util-linux/fstrim.c27
-rw-r--r--util-linux/getopt.c31
-rw-r--r--util-linux/hexdump.c32
-rw-r--r--util-linux/hwclock.c50
-rw-r--r--util-linux/ipcrm.c13
-rw-r--r--util-linux/ipcs.c11
-rw-r--r--util-linux/losetup.c12
-rw-r--r--util-linux/lspci.c13
-rw-r--r--util-linux/lsusb.c13
-rw-r--r--util-linux/mdev.c141
-rw-r--r--util-linux/minix.h5
-rw-r--r--util-linux/mkfs_ext2.c33
-rw-r--r--util-linux/mkfs_minix.c34
-rw-r--r--util-linux/mkfs_reiser.c21
-rw-r--r--util-linux/mkfs_vfat.c23
-rw-r--r--util-linux/mkswap.c27
-rw-r--r--util-linux/more.c27
-rw-r--r--util-linux/mount.c187
-rw-r--r--util-linux/nsenter.c291
-rw-r--r--util-linux/pivot_root.c16
-rw-r--r--util-linux/rdate.c24
-rw-r--r--util-linux/rdev.c9
-rw-r--r--util-linux/readprofile.c20
-rw-r--r--util-linux/rev.c9
-rw-r--r--util-linux/rtcwake.c79
-rw-r--r--util-linux/script.c26
-rw-r--r--util-linux/scriptreplay.c10
-rw-r--r--util-linux/setarch.c79
-rw-r--r--util-linux/swaponoff.c311
-rw-r--r--util-linux/switch_root.c25
-rw-r--r--util-linux/uevent.c130
-rw-r--r--util-linux/umount.c43
-rw-r--r--util-linux/unshare.c379
-rw-r--r--util-linux/volume_id/bcache.c110
-rw-r--r--util-linux/volume_id/get_devname.c10
-rw-r--r--util-linux/volume_id/luks.c2
-rw-r--r--util-linux/volume_id/ubifs.c125
-rw-r--r--util-linux/volume_id/volume_id.c6
-rw-r--r--util-linux/volume_id/volume_id_internal.h4
1303 files changed, 32187 insertions, 57138 deletions
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
new file mode 100644
index 0000000..7731466
--- a/dev/null
+++ b/miscutils/i2c_tools.c
@@ -0,0 +1,1343 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Minimal i2c-tools implementation for busybox.
+ * Parts of code ported from i2c-tools:
+ * http://www.lm-sensors.org/wiki/I2CTools.
+ *
+ * Copyright (C) 2014 by Bartosz Golaszewski <bartekgola@gmail.com>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+//config:config I2CGET
+//config: bool "i2cget"
+//config: default y
+//config: select PLATFORM_LINUX
+//config: help
+//config: Read from I2C/SMBus chip registers.
+//config:
+//config:config I2CSET
+//config: bool "i2cset"
+//config: default y
+//config: select PLATFORM_LINUX
+//config: help
+//config: Set I2C registers.
+//config:
+//config:config I2CDUMP
+//config: bool "i2cdump"
+//config: default y
+//config: select PLATFORM_LINUX
+//config: help
+//config: Examine I2C registers.
+//config:
+//config:config I2CDETECT
+//config: bool "i2cdetect"
+//config: default y
+//config: select PLATFORM_LINUX
+//config: help
+//config: Detect I2C chips.
+//config:
+
+//applet:IF_I2CGET(APPLET(i2cget, BB_DIR_USR_SBIN, BB_SUID_DROP))
+//applet:IF_I2CSET(APPLET(i2cset, BB_DIR_USR_SBIN, BB_SUID_DROP))
+//applet:IF_I2CDUMP(APPLET(i2cdump, BB_DIR_USR_SBIN, BB_SUID_DROP))
+//applet:IF_I2CDETECT(APPLET(i2cdetect, BB_DIR_USR_SBIN, BB_SUID_DROP))
+
+//kbuild:lib-$(CONFIG_I2CGET) += i2c_tools.o
+//kbuild:lib-$(CONFIG_I2CSET) += i2c_tools.o
+//kbuild:lib-$(CONFIG_I2CDUMP) += i2c_tools.o
+//kbuild:lib-$(CONFIG_I2CDETECT) += i2c_tools.o
+
+/*
+ * Unsupported stuff:
+ *
+ * - upstream i2c-tools can also look-up i2c busses by name, we only accept
+ * numbers,
+ * - bank and bankreg parameters for i2cdump are not supported because of
+ * their limited usefulness (see i2cdump manual entry for more info),
+ * - i2cdetect doesn't look for bus info in /proc as it does in upstream, but
+ * it shouldn't be a problem in modern kernels.
+ */
+
+#include "libbb.h"
+#include "common_bufsiz.h"
+
+#include <linux/i2c.h>
+#include <linux/i2c-dev.h>
+
+#define I2CDUMP_NUM_REGS 256
+
+#define I2CDETECT_MODE_AUTO 0
+#define I2CDETECT_MODE_QUICK 1
+#define I2CDETECT_MODE_READ 2
+
+/*
+ * This is needed for ioctl_or_perror_and_die() since it only accepts pointers.
+ */
+static ALWAYS_INLINE void *itoptr(int i)
+{
+ return (void*)(intptr_t)i;
+}
+
+static int32_t i2c_smbus_access(int fd, char read_write, uint8_t cmd,
+ int size, union i2c_smbus_data *data)
+{
+ struct i2c_smbus_ioctl_data args;
+
+ args.read_write = read_write;
+ args.command = cmd;
+ args.size = size;
+ args.data = data;
+
+ return ioctl(fd, I2C_SMBUS, &args);
+}
+
+static int32_t i2c_smbus_read_byte(int fd)
+{
+ union i2c_smbus_data data;
+ int err;
+
+ err = i2c_smbus_access(fd, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &data);
+ if (err < 0)
+ return err;
+
+ return data.byte;
+}
+
+#if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP
+static int32_t i2c_smbus_write_byte(int fd, uint8_t val)
+{
+ return i2c_smbus_access(fd, I2C_SMBUS_WRITE,
+ val, I2C_SMBUS_BYTE, NULL);
+}
+
+static int32_t i2c_smbus_read_byte_data(int fd, uint8_t cmd)
+{
+ union i2c_smbus_data data;
+ int err;
+
+ err = i2c_smbus_access(fd, I2C_SMBUS_READ, cmd,
+ I2C_SMBUS_BYTE_DATA, &data);
+ if (err < 0)
+ return err;
+
+ return data.byte;
+}
+
+static int32_t i2c_smbus_read_word_data(int fd, uint8_t cmd)
+{
+ union i2c_smbus_data data;
+ int err;
+
+ err = i2c_smbus_access(fd, I2C_SMBUS_READ, cmd,
+ I2C_SMBUS_WORD_DATA, &data);
+ if (err < 0)
+ return err;
+
+ return data.word;
+}
+#endif /* ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP */
+
+#if ENABLE_I2CSET
+static int32_t i2c_smbus_write_byte_data(int file,
+ uint8_t cmd, uint8_t value)
+{
+ union i2c_smbus_data data;
+
+ data.byte = value;
+
+ return i2c_smbus_access(file, I2C_SMBUS_WRITE, cmd,
+ I2C_SMBUS_BYTE_DATA, &data);
+}
+
+static int32_t i2c_smbus_write_word_data(int file, uint8_t cmd, uint16_t value)
+{
+ union i2c_smbus_data data;
+
+ data.word = value;
+
+ return i2c_smbus_access(file, I2C_SMBUS_WRITE, cmd,
+ I2C_SMBUS_WORD_DATA, &data);
+}
+
+static int32_t i2c_smbus_write_block_data(int file, uint8_t cmd,
+ uint8_t length, const uint8_t *values)
+{
+ union i2c_smbus_data data;
+
+ if (length > I2C_SMBUS_BLOCK_MAX)
+ length = I2C_SMBUS_BLOCK_MAX;
+
+ memcpy(data.block+1, values, length);
+ data.block[0] = length;
+
+ return i2c_smbus_access(file, I2C_SMBUS_WRITE, cmd,
+ I2C_SMBUS_BLOCK_DATA, &data);
+}
+
+static int32_t i2c_smbus_write_i2c_block_data(int file, uint8_t cmd,
+ uint8_t length, const uint8_t *values)
+{
+ union i2c_smbus_data data;
+
+ if (length > I2C_SMBUS_BLOCK_MAX)
+ length = I2C_SMBUS_BLOCK_MAX;
+
+ memcpy(data.block+1, values, length);
+ data.block[0] = length;
+
+ return i2c_smbus_access(file, I2C_SMBUS_WRITE, cmd,
+ I2C_SMBUS_I2C_BLOCK_BROKEN, &data);
+}
+#endif /* ENABLE_I2CSET */
+
+#if ENABLE_I2CDUMP
+/*
+ * Returns the number of bytes read, vals must hold at
+ * least I2C_SMBUS_BLOCK_MAX bytes.
+ */
+static int32_t i2c_smbus_read_block_data(int fd, uint8_t cmd, uint8_t *vals)
+{
+ union i2c_smbus_data data;
+ int i, err;
+
+ err = i2c_smbus_access(fd, I2C_SMBUS_READ, cmd,
+ I2C_SMBUS_BLOCK_DATA, &data);
+ if (err < 0)
+ return err;
+
+ for (i = 1; i <= data.block[0]; i++)
+ *vals++ = data.block[i];
+ return data.block[0];
+}
+
+static int32_t i2c_smbus_read_i2c_block_data(int fd, uint8_t cmd,
+ uint8_t len, uint8_t *vals)
+{
+ union i2c_smbus_data data;
+ int i, err;
+
+ if (len > I2C_SMBUS_BLOCK_MAX)
+ len = I2C_SMBUS_BLOCK_MAX;
+ data.block[0] = len;
+
+ err = i2c_smbus_access(fd, I2C_SMBUS_READ, cmd,
+ len == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :
+ I2C_SMBUS_I2C_BLOCK_DATA, &data);
+ if (err < 0)
+ return err;
+
+ for (i = 1; i <= data.block[0]; i++)
+ *vals++ = data.block[i];
+ return data.block[0];
+}
+#endif /* ENABLE_I2CDUMP */
+
+#if ENABLE_I2CDETECT
+static int32_t i2c_smbus_write_quick(int fd, uint8_t val)
+{
+ return i2c_smbus_access(fd, val, 0, I2C_SMBUS_QUICK, NULL);
+}
+#endif /* ENABLE_I2CDETECT */
+
+static int i2c_bus_lookup(const char *bus_str)
+{
+ return xstrtou_range(bus_str, 10, 0, 0xfffff);
+}
+
+#if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP
+static int i2c_parse_bus_addr(const char *addr_str)
+{
+ /* Slave address must be in range 0x03 - 0x77. */
+ return xstrtou_range(addr_str, 16, 0x03, 0x77);
+}
+
+static void i2c_set_pec(int fd, int pec)
+{
+ ioctl_or_perror_and_die(fd, I2C_PEC,
+ itoptr(pec ? 1 : 0),
+ "can't set PEC");
+}
+
+static void i2c_set_slave_addr(int fd, int addr, int force)
+{
+ ioctl_or_perror_and_die(fd, force ? I2C_SLAVE_FORCE : I2C_SLAVE,
+ itoptr(addr),
+ "can't set address to 0x%02x", addr);
+}
+#endif /* ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP */
+
+#if ENABLE_I2CGET || ENABLE_I2CSET
+static int i2c_parse_data_addr(const char *data_addr)
+{
+ /* Data address must be an 8 bit integer. */
+ return xstrtou_range(data_addr, 16, 0, 0xff);
+}
+#endif /* ENABLE_I2CGET || ENABLE_I2CSET */
+
+/*
+ * Opens the device file associated with given i2c bus.
+ *
+ * Upstream i2c-tools also support opening devices by i2c bus name
+ * but we drop it here for size reduction.
+ */
+static int i2c_dev_open(int i2cbus)
+{
+ char filename[sizeof("/dev/i2c-%d") + sizeof(int)*3];
+ int fd;
+
+ sprintf(filename, "/dev/i2c-%d", i2cbus);
+ fd = open(filename, O_RDWR);
+ if (fd < 0) {
+ if (errno == ENOENT) {
+ filename[8] = '/'; /* change to "/dev/i2c/%d" */
+ fd = xopen(filename, O_RDWR);
+ } else {
+ bb_perror_msg_and_die("can't open '%s'", filename);
+ }
+ }
+
+ return fd;
+}
+
+/* Size reducing helpers for xxx_check_funcs(). */
+static void get_funcs_matrix(int fd, unsigned long *funcs)
+{
+ ioctl_or_perror_and_die(fd, I2C_FUNCS, funcs,
+ "can't get adapter functionality matrix");
+}
+
+#if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP
+static void check_funcs_test_end(int funcs, int pec, const char *err)
+{
+ if (pec && !(funcs & (I2C_FUNC_SMBUS_PEC | I2C_FUNC_I2C)))
+ bb_error_msg("warning: adapter does not support PEC");
+
+ if (err)
+ bb_error_msg_and_die(
+ "adapter has no %s capability", err);
+}
+#endif /* ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP */
+
+/*
+ * The below functions emit an error message and exit if the adapter doesn't
+ * support desired functionalities.
+ */
+#if ENABLE_I2CGET || ENABLE_I2CDUMP
+static void check_read_funcs(int fd, int mode, int data_addr, int pec)
+{
+ unsigned long funcs;
+ const char *err = NULL;
+
+ get_funcs_matrix(fd, &funcs);
+ switch (mode) {
+ case I2C_SMBUS_BYTE:
+ if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE)) {
+ err = "SMBus receive byte";
+ break;
+ }
+ if (data_addr >= 0 && !(funcs & I2C_FUNC_SMBUS_WRITE_BYTE))
+ err = "SMBus send byte";
+ break;
+ case I2C_SMBUS_BYTE_DATA:
+ if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA))
+ err = "SMBus read byte";
+ break;
+ case I2C_SMBUS_WORD_DATA:
+ if (!(funcs & I2C_FUNC_SMBUS_READ_WORD_DATA))
+ err = "SMBus read word";
+ break;
+#if ENABLE_I2CDUMP
+ case I2C_SMBUS_BLOCK_DATA:
+ if (!(funcs & I2C_FUNC_SMBUS_READ_BLOCK_DATA))
+ err = "SMBus block read";
+ break;
+
+ case I2C_SMBUS_I2C_BLOCK_DATA:
+ if (!(funcs & I2C_FUNC_SMBUS_READ_I2C_BLOCK))
+ err = "I2C block read";
+ break;
+#endif /* ENABLE_I2CDUMP */
+ default:
+ bb_error_msg_and_die("internal error");
+ }
+ check_funcs_test_end(funcs, pec, err);
+}
+#endif /* ENABLE_I2CGET || ENABLE_I2CDUMP */
+
+#if ENABLE_I2CSET
+static void check_write_funcs(int fd, int mode, int pec)
+{
+ unsigned long funcs;
+ const char *err = NULL;
+
+ get_funcs_matrix(fd, &funcs);
+ switch (mode) {
+ case I2C_SMBUS_BYTE:
+ if (!(funcs & I2C_FUNC_SMBUS_WRITE_BYTE))
+ err = "SMBus send byte";
+ break;
+
+ case I2C_SMBUS_BYTE_DATA:
+ if (!(funcs & I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
+ err = "SMBus write byte";
+ break;
+
+ case I2C_SMBUS_WORD_DATA:
+ if (!(funcs & I2C_FUNC_SMBUS_WRITE_WORD_DATA))
+ err = "SMBus write word";
+ break;
+
+ case I2C_SMBUS_BLOCK_DATA:
+ if (!(funcs & I2C_FUNC_SMBUS_WRITE_BLOCK_DATA))
+ err = "SMBus block write";
+ break;
+ case I2C_SMBUS_I2C_BLOCK_DATA:
+ if (!(funcs & I2C_FUNC_SMBUS_WRITE_I2C_BLOCK))
+ err = "I2C block write";
+ break;
+ }
+ check_funcs_test_end(funcs, pec, err);
+}
+#endif /* ENABLE_I2CSET */
+
+static void confirm_or_abort(void)
+{
+ fprintf(stderr, "Continue? [y/N] ");
+ fflush_all();
+ if (!bb_ask_confirmation())
+ bb_error_msg_and_die("aborting");
+}
+
+/*
+ * Return only if user confirms the action, abort otherwise.
+ *
+ * The messages displayed here are much less elaborate than their i2c-tools
+ * counterparts - this is done for size reduction.
+ */
+static void confirm_action(int bus_addr, int mode, int data_addr, int pec)
+{
+ bb_error_msg("WARNING! This program can confuse your I2C bus");
+
+ /* Don't let the user break his/her EEPROMs */
+ if (bus_addr >= 0x50 && bus_addr <= 0x57 && pec) {
+ bb_error_msg_and_die("this is I2C not smbus - using PEC on I2C "
+ "devices may result in data loss, aborting");
+ }
+
+ if (mode == I2C_SMBUS_BYTE && data_addr >= 0 && pec)
+ bb_error_msg("WARNING! May interpret a write byte command "
+ "with PEC as a write byte data command");
+
+ if (pec)
+ bb_error_msg("PEC checking enabled");
+
+ confirm_or_abort();
+}
+
+#if ENABLE_I2CGET
+//usage:#define i2cget_trivial_usage
+//usage: "[-f] [-y] BUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]"
+//usage:#define i2cget_full_usage "\n\n"
+//usage: "Read from I2C/SMBus chip registers\n"
+//usage: "\n I2CBUS i2c bus number"
+//usage: "\n ADDRESS 0x03 - 0x77"
+//usage: "\nMODE is:"
+//usage: "\n b read byte data (default)"
+//usage: "\n w read word data"
+//usage: "\n c write byte/read byte"
+//usage: "\n Append p for SMBus PEC"
+//usage: "\n"
+//usage: "\n -f force access"
+//usage: "\n -y disable interactive mode"
+int i2cget_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int i2cget_main(int argc UNUSED_PARAM, char **argv)
+{
+ const unsigned opt_f = (1 << 0), opt_y = (1 << 1);
+ const char *const optstr = "fy";
+
+ int bus_num, bus_addr, data_addr = -1, status;
+ int mode = I2C_SMBUS_BYTE, pec = 0, fd;
+ unsigned opts;
+
+ opt_complementary = "-2:?4"; /* from 2 to 4 args */
+ opts = getopt32(argv, optstr);
+ argv += optind;
+
+ bus_num = i2c_bus_lookup(argv[0]);
+ bus_addr = i2c_parse_bus_addr(argv[1]);
+
+ if (argv[2]) {
+ data_addr = i2c_parse_data_addr(argv[2]);
+ mode = I2C_SMBUS_BYTE_DATA;
+ if (argv[3]) {
+ switch (argv[3][0]) {
+ case 'b': /* Already set */ break;
+ case 'w': mode = I2C_SMBUS_WORD_DATA; break;
+ case 'c': mode = I2C_SMBUS_BYTE; break;
+ default:
+ bb_error_msg("invalid mode");
+ bb_show_usage();
+ }
+ pec = argv[3][1] == 'p';
+ }
+ }
+
+ fd = i2c_dev_open(bus_num);
+ check_read_funcs(fd, mode, data_addr, pec);
+ i2c_set_slave_addr(fd, bus_addr, opts & opt_f);
+
+ if (!(opts & opt_y))
+ confirm_action(bus_addr, mode, data_addr, pec);
+
+ if (pec)
+ i2c_set_pec(fd, 1);
+
+ switch (mode) {
+ case I2C_SMBUS_BYTE:
+ if (data_addr >= 0) {
+ status = i2c_smbus_write_byte(fd, data_addr);
+ if (status < 0)
+ bb_error_msg("warning - write failed");
+ }
+ status = i2c_smbus_read_byte(fd);
+ break;
+ case I2C_SMBUS_WORD_DATA:
+ status = i2c_smbus_read_word_data(fd, data_addr);
+ break;
+ default: /* I2C_SMBUS_BYTE_DATA */
+ status = i2c_smbus_read_byte_data(fd, data_addr);
+ }
+ close(fd);
+
+ if (status < 0)
+ bb_perror_msg_and_die("read failed");
+
+ printf("0x%0*x\n", mode == I2C_SMBUS_WORD_DATA ? 4 : 2, status);
+
+ return 0;
+}
+#endif /* ENABLE_I2CGET */
+
+#if ENABLE_I2CSET
+//usage:#define i2cset_trivial_usage
+//usage: "[-f] [-y] [-m MASK] BUS CHIP-ADDR DATA-ADDR [VALUE] ... [MODE]"
+//usage:#define i2cset_full_usage "\n\n"
+//usage: "Set I2C registers\n"
+//usage: "\n I2CBUS i2c bus number"
+//usage: "\n ADDRESS 0x03 - 0x77"
+//usage: "\nMODE is:"
+//usage: "\n c byte, no value"
+//usage: "\n b byte data (default)"
+//usage: "\n w word data"
+//usage: "\n i I2C block data"
+//usage: "\n s SMBus block data"
+//usage: "\n Append p for SMBus PEC"
+//usage: "\n"
+//usage: "\n -f force access"
+//usage: "\n -y disable interactive mode"
+//usage: "\n -r read back and compare the result"
+//usage: "\n -m MASK mask specifying which bits to write"
+int i2cset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int i2cset_main(int argc, char **argv)
+{
+ const unsigned opt_f = (1 << 0), opt_y = (1 << 1),
+ opt_m = (1 << 2), opt_r = (1 << 3);
+ const char *const optstr = "fym:r";
+
+ int bus_num, bus_addr, data_addr, mode = I2C_SMBUS_BYTE, pec = 0;
+ int val, blen = 0, mask = 0, fd, status;
+ unsigned char block[I2C_SMBUS_BLOCK_MAX];
+ char *opt_m_arg = NULL;
+ unsigned opts;
+
+ opt_complementary = "-3"; /* from 3 to ? args */
+ opts = getopt32(argv, optstr, &opt_m_arg);
+ argv += optind;
+ argc -= optind;
+
+ bus_num = i2c_bus_lookup(argv[0]);
+ bus_addr = i2c_parse_bus_addr(argv[1]);
+ data_addr = i2c_parse_data_addr(argv[2]);
+
+ if (argv[3]) {
+ if (!argv[4] && argv[3][0] != 'c') {
+ mode = I2C_SMBUS_BYTE_DATA; /* Implicit b */
+ } else {
+ switch (argv[argc-1][0]) {
+ case 'c': /* Already set */ break;
+ case 'b': mode = I2C_SMBUS_BYTE_DATA; break;
+ case 'w': mode = I2C_SMBUS_WORD_DATA; break;
+ case 's': mode = I2C_SMBUS_BLOCK_DATA; break;
+ case 'i': mode = I2C_SMBUS_I2C_BLOCK_DATA; break;
+ default:
+ bb_error_msg("invalid mode");
+ bb_show_usage();
+ }
+
+ pec = argv[argc-1][1] == 'p';
+ if (mode == I2C_SMBUS_BLOCK_DATA ||
+ mode == I2C_SMBUS_I2C_BLOCK_DATA) {
+ if (pec && mode == I2C_SMBUS_I2C_BLOCK_DATA)
+ bb_error_msg_and_die(
+ "PEC not supported for I2C "
+ "block writes");
+ if (opts & opt_m)
+ bb_error_msg_and_die(
+ "mask not supported for block "
+ "writes");
+ }
+ }
+ }
+
+ /* Prepare the value(s) to be written according to current mode. */
+ switch (mode) {
+ case I2C_SMBUS_BYTE_DATA:
+ val = xstrtou_range(argv[3], 0, 0, 0xff);
+ break;
+ case I2C_SMBUS_WORD_DATA:
+ val = xstrtou_range(argv[3], 0, 0, 0xffff);
+ break;
+ case I2C_SMBUS_BLOCK_DATA:
+ case I2C_SMBUS_I2C_BLOCK_DATA:
+ for (blen = 3; blen < (argc - 1); blen++)
+ block[blen] = xstrtou_range(argv[blen], 0, 0, 0xff);
+ val = -1;
+ break;
+ default:
+ val = -1;
+ break;
+ }
+
+ if (opts & opt_m) {
+ mask = xstrtou_range(opt_m_arg, 0, 0,
+ (mode == I2C_SMBUS_BYTE ||
+ mode == I2C_SMBUS_BYTE_DATA) ? 0xff : 0xffff);
+ }
+
+ fd = i2c_dev_open(bus_num);
+ check_write_funcs(fd, mode, pec);
+ i2c_set_slave_addr(fd, bus_addr, opts & opt_f);
+
+ if (!(opts & opt_y))
+ confirm_action(bus_addr, mode, data_addr, pec);
+
+ /*
+ * If we're using mask - read the current value here and adjust the
+ * value to be written.
+ */
+ if (opts & opt_m) {
+ int tmpval;
+
+ switch (mode) {
+ case I2C_SMBUS_BYTE:
+ tmpval = i2c_smbus_read_byte(fd);
+ break;
+ case I2C_SMBUS_WORD_DATA:
+ tmpval = i2c_smbus_read_word_data(fd, data_addr);
+ break;
+ default:
+ tmpval = i2c_smbus_read_byte_data(fd, data_addr);
+ }
+
+ if (tmpval < 0)
+ bb_perror_msg_and_die("can't read old value");
+
+ val = (val & mask) | (tmpval & ~mask);
+
+ if (!(opts & opt_y)) {
+ bb_error_msg("old value 0x%0*x, write mask "
+ "0x%0*x, will write 0x%0*x to register "
+ "0x%02x",
+ mode == I2C_SMBUS_WORD_DATA ? 4 : 2, tmpval,
+ mode == I2C_SMBUS_WORD_DATA ? 4 : 2, mask,
+ mode == I2C_SMBUS_WORD_DATA ? 4 : 2, val,
+ data_addr);
+ confirm_or_abort();
+ }
+ }
+
+ if (pec)
+ i2c_set_pec(fd, 1);
+
+ switch (mode) {
+ case I2C_SMBUS_BYTE:
+ status = i2c_smbus_write_byte(fd, data_addr);
+ break;
+ case I2C_SMBUS_WORD_DATA:
+ status = i2c_smbus_write_word_data(fd, data_addr, val);
+ break;
+ case I2C_SMBUS_BLOCK_DATA:
+ status = i2c_smbus_write_block_data(fd, data_addr,
+ blen, block);
+ break;
+ case I2C_SMBUS_I2C_BLOCK_DATA:
+ status = i2c_smbus_write_i2c_block_data(fd, data_addr,
+ blen, block);
+ break;
+ default: /* I2C_SMBUS_BYTE_DATA */
+ status = i2c_smbus_write_byte_data(fd, data_addr, val);
+ break;
+ }
+ if (status < 0)
+ bb_perror_msg_and_die("write failed");
+
+ if (pec)
+ i2c_set_pec(fd, 0); /* Clear PEC. */
+
+ /* No readback required - we're done. */
+ if (!(opts & opt_r))
+ return 0;
+
+ switch (mode) {
+ case I2C_SMBUS_BYTE:
+ status = i2c_smbus_read_byte(fd);
+ val = data_addr;
+ break;
+ case I2C_SMBUS_WORD_DATA:
+ status = i2c_smbus_read_word_data(fd, data_addr);
+ break;
+ default: /* I2C_SMBUS_BYTE_DATA */
+ status = i2c_smbus_read_byte_data(fd, data_addr);
+ }
+
+ if (status < 0) {
+ puts("Warning - readback failed");
+ } else
+ if (status != val) {
+ printf("Warning - data mismatch - wrote "
+ "0x%0*x, read back 0x%0*x\n",
+ mode == I2C_SMBUS_WORD_DATA ? 4 : 2, val,
+ mode == I2C_SMBUS_WORD_DATA ? 4 : 2, status);
+ } else {
+ printf("Value 0x%0*x written, readback matched\n",
+ mode == I2C_SMBUS_WORD_DATA ? 4 : 2, val);
+ }
+
+ return 0;
+}
+#endif /* ENABLE_I2CSET */
+
+#if ENABLE_I2CDUMP
+static int read_block_data(int buf_fd, int mode, int *block)
+{
+ uint8_t cblock[I2C_SMBUS_BLOCK_MAX + I2CDUMP_NUM_REGS];
+ int res, blen = 0, tmp, i;
+
+ if (mode == I2C_SMBUS_BLOCK_DATA) {
+ blen = i2c_smbus_read_block_data(buf_fd, 0, cblock);
+ if (blen <= 0)
+ goto fail;
+ } else {
+ for (res = 0; res < I2CDUMP_NUM_REGS; res += tmp) {
+ tmp = i2c_smbus_read_i2c_block_data(
+ buf_fd, res, I2C_SMBUS_BLOCK_MAX,
+ cblock + res);
+ if (tmp <= 0) {
+ blen = tmp;
+ goto fail;
+ }
+ }
+
+ if (res >= I2CDUMP_NUM_REGS)
+ res = I2CDUMP_NUM_REGS;
+
+ for (i = 0; i < res; i++)
+ block[i] = cblock[i];
+
+ if (mode != I2C_SMBUS_BLOCK_DATA)
+ for (i = res; i < I2CDUMP_NUM_REGS; i++)
+ block[i] = -1;
+ }
+
+ return blen;
+
+ fail:
+ bb_error_msg_and_die("block read failed: %d", blen);
+}
+
+/* Dump all but word data. */
+static void dump_data(int bus_fd, int mode, unsigned first,
+ unsigned last, int *block, int blen)
+{
+ int i, j, res;
+
+ puts(" 0 1 2 3 4 5 6 7 8 9 a b c d e f"
+ " 0123456789abcdef");
+
+ for (i = 0; i < I2CDUMP_NUM_REGS; i += 0x10) {
+ if (mode == I2C_SMBUS_BLOCK_DATA && i >= blen)
+ break;
+ if (i/16 < first/16)
+ continue;
+ if (i/16 > last/16)
+ break;
+
+ printf("%02x: ", i);
+ for (j = 0; j < 16; j++) {
+ fflush_all();
+ /* Skip unwanted registers */
+ if (i+j < first || i+j > last) {
+ printf(" ");
+ if (mode == I2C_SMBUS_WORD_DATA) {
+ printf(" ");
+ j++;
+ }
+ continue;
+ }
+
+ switch (mode) {
+ case I2C_SMBUS_BYTE_DATA:
+ res = i2c_smbus_read_byte_data(bus_fd, i+j);
+ block[i+j] = res;
+ break;
+ case I2C_SMBUS_WORD_DATA:
+ res = i2c_smbus_read_word_data(bus_fd, i+j);
+ if (res < 0) {
+ block[i+j] = res;
+ block[i+j+1] = res;
+ } else {
+ block[i+j] = res & 0xff;
+ block[i+j+1] = res >> 8;
+ }
+ break;
+ case I2C_SMBUS_BYTE:
+ res = i2c_smbus_read_byte(bus_fd);
+ block[i+j] = res;
+ break;
+ default:
+ res = block[i+j];
+ }
+
+ if (mode == I2C_SMBUS_BLOCK_DATA &&
+ i+j >= blen) {
+ printf(" ");
+ } else if (res < 0) {
+ printf("XX ");
+ if (mode == I2C_SMBUS_WORD_DATA)
+ printf("XX ");
+ } else {
+ printf("%02x ", block[i+j]);
+ if (mode == I2C_SMBUS_WORD_DATA)
+ printf("%02x ", block[i+j+1]);
+ }
+
+ if (mode == I2C_SMBUS_WORD_DATA)
+ j++;
+ }
+ printf(" ");
+
+ for (j = 0; j < 16; j++) {
+ if (mode == I2C_SMBUS_BLOCK_DATA && i+j >= blen)
+ break;
+ /* Skip unwanted registers */
+ if (i+j < first || i+j > last) {
+ bb_putchar(' ');
+ continue;
+ }
+
+ res = block[i+j];
+ if (res < 0) {
+ bb_putchar('X');
+ } else if (res == 0x00 || res == 0xff) {
+ bb_putchar('.');
+ } else if (res < 32 || res >= 127) {
+ bb_putchar('?');
+ } else {
+ bb_putchar(res);
+ }
+ }
+ bb_putchar('\n');
+ }
+}
+
+static void dump_word_data(int bus_fd, unsigned first, unsigned last)
+{
+ int i, j, rv;
+
+ /* Word data. */
+ puts(" 0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f");
+ for (i = 0; i < 256; i += 8) {
+ if (i/8 < first/8)
+ continue;
+ if (i/8 > last/8)
+ break;
+
+ printf("%02x: ", i);
+ for (j = 0; j < 8; j++) {
+ /* Skip unwanted registers. */
+ if (i+j < first || i+j > last) {
+ printf(" ");
+ continue;
+ }
+
+ rv = i2c_smbus_read_word_data(bus_fd, i+j);
+ if (rv < 0)
+ printf("XXXX ");
+ else
+ printf("%04x ", rv & 0xffff);
+ }
+ bb_putchar('\n');
+ }
+}
+
+//usage:#define i2cdump_trivial_usage
+//usage: "[-f] [-r FIRST-LAST] [-y] BUS ADDR [MODE]"
+//usage:#define i2cdump_full_usage "\n\n"
+//usage: "Examine I2C registers\n"
+//usage: "\n I2CBUS i2c bus number"
+//usage: "\n ADDRESS 0x03 - 0x77"
+//usage: "\nMODE is:"
+//usage: "\n b byte (default)"
+//usage: "\n w word"
+//usage: "\n W word on even register addresses"
+//usage: "\n i I2C block"
+//usage: "\n s SMBus block"
+//usage: "\n c consecutive byte"
+//usage: "\n Append p for SMBus PEC"
+//usage: "\n"
+//usage: "\n -f force access"
+//usage: "\n -y disable interactive mode"
+//usage: "\n -r limit the number of registers being accessed"
+int i2cdump_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int i2cdump_main(int argc UNUSED_PARAM, char **argv)
+{
+ const unsigned opt_f = (1 << 0), opt_y = (1 << 1),
+ opt_r = (1 << 2);
+ const char *const optstr = "fyr:";
+
+ int bus_num, bus_addr, mode = I2C_SMBUS_BYTE_DATA, even = 0, pec = 0;
+ unsigned first = 0x00, last = 0xff, opts;
+ int block[I2CDUMP_NUM_REGS];
+ char *opt_r_str, *dash;
+ int fd, res;
+
+ opt_complementary = "-2:?3"; /* from 2 to 3 args */
+ opts = getopt32(argv, optstr, &opt_r_str);
+ argv += optind;
+
+ bus_num = i2c_bus_lookup(argv[0]);
+ bus_addr = i2c_parse_bus_addr(argv[1]);
+
+ if (argv[2]) {
+ switch (argv[2][0]) {
+ case 'b': /* Already set. */ break;
+ case 'c': mode = I2C_SMBUS_BYTE; break;
+ case 'w': mode = I2C_SMBUS_WORD_DATA; break;
+ case 'W':
+ mode = I2C_SMBUS_WORD_DATA;
+ even = 1;
+ break;
+ case 's': mode = I2C_SMBUS_BLOCK_DATA; break;
+ case 'i': mode = I2C_SMBUS_I2C_BLOCK_DATA; break;
+ default:
+ bb_error_msg_and_die("invalid mode");
+ }
+
+ if (argv[2][1] == 'p') {
+ if (argv[2][0] == 'W' || argv[2][0] == 'i') {
+ bb_error_msg_and_die(
+ "pec not supported for -W and -i");
+ } else {
+ pec = 1;
+ }
+ }
+ }
+
+ if (opts & opt_r) {
+ first = strtol(opt_r_str, &dash, 0);
+ if (dash == opt_r_str || *dash != '-' || first > 0xff)
+ bb_error_msg_and_die("invalid range");
+ last = xstrtou_range(++dash, 0, first, 0xff);
+
+ /* Range is not available for every mode. */
+ switch (mode) {
+ case I2C_SMBUS_BYTE:
+ case I2C_SMBUS_BYTE_DATA:
+ break;
+ case I2C_SMBUS_WORD_DATA:
+ if (!even || (!(first % 2) && last % 2))
+ break;
+ /* Fall through */
+ default:
+ bb_error_msg_and_die(
+ "range not compatible with selected mode");
+ }
+ }
+
+ fd = i2c_dev_open(bus_num);
+ check_read_funcs(fd, mode, -1 /* data_addr */, pec);
+ i2c_set_slave_addr(fd, bus_addr, opts & opt_f);
+
+ if (pec)
+ i2c_set_pec(fd, 1);
+
+ if (!(opts & opt_y))
+ confirm_action(bus_addr, mode, -1 /* data_addr */, pec);
+
+ /* All but word data. */
+ if (mode != I2C_SMBUS_WORD_DATA || even) {
+ int blen = 0;
+
+ if (mode == I2C_SMBUS_BLOCK_DATA || mode == I2C_SMBUS_I2C_BLOCK_DATA)
+ blen = read_block_data(fd, mode, block);
+
+ if (mode == I2C_SMBUS_BYTE) {
+ res = i2c_smbus_write_byte(fd, first);
+ if (res < 0)
+ bb_perror_msg_and_die("write start address");
+ }
+
+ dump_data(fd, mode, first, last, block, blen);
+ } else {
+ dump_word_data(fd, first, last);
+ }
+
+ return 0;
+}
+#endif /* ENABLE_I2CDUMP */
+
+#if ENABLE_I2CDETECT
+enum adapter_type {
+ ADT_DUMMY = 0,
+ ADT_ISA,
+ ADT_I2C,
+ ADT_SMBUS,
+};
+
+struct adap_desc {
+ const char *funcs;
+ const char *algo;
+};
+
+static const struct adap_desc adap_descs[] = {
+ { .funcs = "dummy",
+ .algo = "Dummy bus", },
+ { .funcs = "isa",
+ .algo = "ISA bus", },
+ { .funcs = "i2c",
+ .algo = "I2C adapter", },
+ { .funcs = "smbus",
+ .algo = "SMBus adapter", },
+};
+
+struct i2c_func
+{
+ long value;
+ const char* name;
+};
+
+static const struct i2c_func i2c_funcs_tab[] = {
+ { .value = I2C_FUNC_I2C,
+ .name = "I2C" },
+ { .value = I2C_FUNC_SMBUS_QUICK,
+ .name = "SMBus quick command" },
+ { .value = I2C_FUNC_SMBUS_WRITE_BYTE,
+ .name = "SMBus send byte" },
+ { .value = I2C_FUNC_SMBUS_READ_BYTE,
+ .name = "SMBus receive byte" },
+ { .value = I2C_FUNC_SMBUS_WRITE_BYTE_DATA,
+ .name = "SMBus write byte" },
+ { .value = I2C_FUNC_SMBUS_READ_BYTE_DATA,
+ .name = "SMBus read byte" },
+ { .value = I2C_FUNC_SMBUS_WRITE_WORD_DATA,
+ .name = "SMBus write word" },
+ { .value = I2C_FUNC_SMBUS_READ_WORD_DATA,
+ .name = "SMBus read word" },
+ { .value = I2C_FUNC_SMBUS_PROC_CALL,
+ .name = "SMBus process call" },
+ { .value = I2C_FUNC_SMBUS_WRITE_BLOCK_DATA,
+ .name = "SMBus block write" },
+ { .value = I2C_FUNC_SMBUS_READ_BLOCK_DATA,
+ .name = "SMBus block read" },
+ { .value = I2C_FUNC_SMBUS_BLOCK_PROC_CALL,
+ .name = "SMBus block process call" },
+ { .value = I2C_FUNC_SMBUS_PEC,
+ .name = "SMBus PEC" },
+ { .value = I2C_FUNC_SMBUS_WRITE_I2C_BLOCK,
+ .name = "I2C block write" },
+ { .value = I2C_FUNC_SMBUS_READ_I2C_BLOCK,
+ .name = "I2C block read" },
+ { .value = 0, .name = NULL }
+};
+
+static enum adapter_type i2cdetect_get_funcs(int bus)
+{
+ enum adapter_type ret;
+ unsigned long funcs;
+ int fd;
+
+ fd = i2c_dev_open(bus);
+
+ get_funcs_matrix(fd, &funcs);
+ if (funcs & I2C_FUNC_I2C)
+ ret = ADT_I2C;
+ else if (funcs & (I2C_FUNC_SMBUS_BYTE |
+ I2C_FUNC_SMBUS_BYTE_DATA |
+ I2C_FUNC_SMBUS_WORD_DATA))
+ ret = ADT_SMBUS;
+ else
+ ret = ADT_DUMMY;
+
+ close(fd);
+
+ return ret;
+}
+
+static void NORETURN list_i2c_busses_and_exit(void)
+{
+ const char *const i2cdev_path = "/sys/class/i2c-dev";
+
+ char path[NAME_MAX], name[128];
+ struct dirent *de, *subde;
+ enum adapter_type adt;
+ DIR *dir, *subdir;
+ int rv, bus;
+ char *pos;
+ FILE *fp;
+
+ /*
+ * XXX Upstream i2cdetect also looks for i2c bus info in /proc/bus/i2c,
+ * but we won't bother since it's only useful on older kernels (before
+ * 2.6.5). We expect sysfs to be present and mounted at /sys/.
+ */
+
+ dir = xopendir(i2cdev_path);
+ while ((de = readdir(dir))) {
+ if (de->d_name[0] == '.')
+ continue;
+
+ /* Simple version for ISA chips. */
+ snprintf(path, NAME_MAX, "%s/%s/name",
+ i2cdev_path, de->d_name);
+ fp = fopen(path, "r");
+ if (fp == NULL) {
+ snprintf(path, NAME_MAX,
+ "%s/%s/device/name",
+ i2cdev_path, de->d_name);
+ fp = fopen(path, "r");
+ }
+
+ /* Non-ISA chips require the hard-way. */
+ if (fp == NULL) {
+ snprintf(path, NAME_MAX,
+ "%s/%s/device/name",
+ i2cdev_path, de->d_name);
+ subdir = opendir(path);
+ if (subdir == NULL)
+ continue;
+
+ while ((subde = readdir(subdir))) {
+ if (subde->d_name[0] == '.')
+ continue;
+
+ if (is_prefixed_with(subde->d_name, "i2c-")) {
+ snprintf(path, NAME_MAX,
+ "%s/%s/device/%s/name",
+ i2cdev_path, de->d_name,
+ subde->d_name);
+ fp = fopen(path, "r");
+ break;
+ }
+ }
+ }
+
+ if (fp != NULL) {
+ /*
+ * Get the rest of the info and display a line
+ * for a single bus.
+ */
+ memset(name, 0, sizeof(name));
+ pos = fgets(name, sizeof(name), fp);
+ fclose(fp);
+ if (pos == NULL)
+ continue;
+
+ pos = strchr(name, '\n');
+ if (pos != NULL)
+ *pos = '\0';
+
+ rv = sscanf(de->d_name, "i2c-%d", &bus);
+ if (rv != 1)
+ continue;
+
+ if (is_prefixed_with(name, "ISA"))
+ adt = ADT_ISA;
+ else
+ adt = i2cdetect_get_funcs(bus);
+
+ printf(
+ "i2c-%d\t%-10s\t%-32s\t%s\n",
+ bus, adap_descs[adt].funcs,
+ name, adap_descs[adt].algo);
+ }
+ }
+
+ exit(EXIT_SUCCESS);
+}
+
+static void NORETURN no_support(const char *cmd)
+{
+ bb_error_msg_and_die("bus doesn't support %s", cmd);
+}
+
+static void will_skip(const char *cmd)
+{
+ bb_error_msg(
+ "warning: can't use %s command, "
+ "will skip some addresses", cmd);
+}
+
+//usage:#define i2cdetect_trivial_usage
+//usage: "[-F I2CBUS] [-l] [-y] [-a] [-q|-r] I2CBUS [FIRST LAST]"
+//usage:#define i2cdetect_full_usage "\n\n"
+//usage: "Detect I2C chips.\n"
+//usage: "\n I2CBUS i2c bus number"
+//usage: "\n FIRST and LAST limit the probing range"
+//usage: "\n"
+//usage: "\n -l output list of installed busses"
+//usage: "\n -y disable interactive mode"
+//usage: "\n -a force scanning of non-regular addresses"
+//usage: "\n -q use smbus quick write commands for probing (default)"
+//usage: "\n -r use smbus read byte commands for probing"
+//usage: "\n -F display list of functionalities"
+int i2cdetect_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
+{
+ const unsigned opt_y = (1 << 0), opt_a = (1 << 1),
+ opt_q = (1 << 2), opt_r = (1 << 3),
+ opt_F = (1 << 4), opt_l = (1 << 5);
+ const char *const optstr = "yaqrFl";
+
+ int fd, bus_num, i, j, mode = I2CDETECT_MODE_AUTO, status, cmd;
+ unsigned first = 0x03, last = 0x77, opts;
+ unsigned long funcs;
+
+ opt_complementary = "q--r:r--q:" /* mutually exclusive */
+ "?3"; /* up to 3 args */
+ opts = getopt32(argv, optstr);
+ argv += optind;
+
+ if (opts & opt_l)
+ list_i2c_busses_and_exit();
+
+ if (!argv[0])
+ bb_show_usage();
+
+ bus_num = i2c_bus_lookup(argv[0]);
+ fd = i2c_dev_open(bus_num);
+ get_funcs_matrix(fd, &funcs);
+
+ if (opts & opt_F) {
+ /* Only list the functionalities. */
+ printf("Functionalities implemented by bus #%d\n", bus_num);
+ for (i = 0; i2c_funcs_tab[i].value; i++) {
+ printf("%-32s %s\n", i2c_funcs_tab[i].name,
+ funcs & i2c_funcs_tab[i].value ? "yes" : "no");
+ }
+
+ return EXIT_SUCCESS;
+ }
+
+ if (opts & opt_r)
+ mode = I2CDETECT_MODE_READ;
+ else if (opts & opt_q)
+ mode = I2CDETECT_MODE_QUICK;
+
+ if (opts & opt_a) {
+ first = 0x00;
+ last = 0x7f;
+ }
+
+ /* Read address range. */
+ if (argv[1]) {
+ first = xstrtou_range(argv[1], 16, first, last);
+ if (argv[2])
+ last = xstrtou_range(argv[2], 16, first, last);
+ }
+
+ if (!(funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE))) {
+ no_support("detection commands");
+ } else
+ if (mode == I2CDETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK)) {
+ no_support("SMBus quick write");
+ } else
+ if (mode == I2CDETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) {
+ no_support("SMBus receive byte");
+ }
+
+ if (mode == I2CDETECT_MODE_AUTO) {
+ if (!(funcs & I2C_FUNC_SMBUS_QUICK))
+ will_skip("SMBus quick write");
+ if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE))
+ will_skip("SMBus receive byte");
+ }
+
+ if (!(opts & opt_y))
+ confirm_action(-1, -1, -1, 0);
+
+ puts(" 0 1 2 3 4 5 6 7 8 9 a b c d e f");
+ for (i = 0; i < 128; i += 16) {
+ printf("%02x: ", i);
+ for (j = 0; j < 16; j++) {
+ fflush_all();
+
+ cmd = mode;
+ if (mode == I2CDETECT_MODE_AUTO) {
+ if ((i+j >= 0x30 && i+j <= 0x37) ||
+ (i+j >= 0x50 && i+j <= 0x5F))
+ cmd = I2CDETECT_MODE_READ;
+ else
+ cmd = I2CDETECT_MODE_QUICK;
+ }
+
+ /* Skip unwanted addresses. */
+ if (i+j < first
+ || i+j > last
+ || (cmd == I2CDETECT_MODE_READ && !(funcs & I2C_FUNC_SMBUS_READ_BYTE))
+ || (cmd == I2CDETECT_MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_QUICK)))
+ {
+ printf(" ");
+ continue;
+ }
+
+ status = ioctl(fd, I2C_SLAVE, itoptr(i + j));
+ if (status < 0) {
+ if (errno == EBUSY) {
+ printf("UU ");
+ continue;
+ }
+
+ bb_perror_msg_and_die(
+ "can't set address to 0x%02x", i + j);
+ }
+
+ switch (cmd) {
+ case I2CDETECT_MODE_READ:
+ /*
+ * This is known to lock SMBus on various
+ * write-only chips (mainly clock chips).
+ */
+ status = i2c_smbus_read_byte(fd);
+ break;
+ default: /* I2CDETECT_MODE_QUICK: */
+ /*
+ * This is known to corrupt the Atmel
+ * AT24RF08 EEPROM.
+ */
+ status = i2c_smbus_write_quick(fd,
+ I2C_SMBUS_WRITE);
+ break;
+ }
+
+ if (status < 0)
+ printf("-- ");
+ else
+ printf("%02x ", i+j);
+ }
+ bb_putchar('\n');
+ }
+
+ return 0;
+}
+#endif /* ENABLE_I2CDETECT */