[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/app/busybox/src/applets/Kbuild.src b/ap/app/busybox/src/applets/Kbuild.src
new file mode 100644
index 0000000..b612399
--- /dev/null
+++ b/ap/app/busybox/src/applets/Kbuild.src
@@ -0,0 +1,47 @@
+# Makefile for busybox
+#
+# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
+#
+# Licensed under GPLv2, see file LICENSE in this source tree.
+
+obj-y :=
+obj-y += applets.o
+
+hostprogs-y:=
+hostprogs-y += usage usage_pod applet_tables
+
+always:= $(hostprogs-y)
+
+# Generated files need additional love
+
+# This trick decreases amount of rebuilds
+# if tree is merely renamed/copied
+ifeq ($(srctree),$(objtree))
+srctree_slash =
+else
+srctree_slash = $(srctree)/
+endif
+
+HOSTCFLAGS_usage.o = -I$(srctree_slash)include -Iinclude
+HOSTCFLAGS_usage_pod.o = -I$(srctree_slash)include -Iinclude
+
+applets/applets.o: include/usage_compressed.h include/applet_tables.h
+
+applets/applet_tables: .config include/applets.h
+applets/usage:         .config include/applets.h
+applets/usage_pod:     .config include/applet_tables.h include/applets.h
+
+quiet_cmd_gen_usage_compressed = GEN     include/usage_compressed.h
+      cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets
+
+include/usage_compressed.h: applets/usage $(srctree_slash)applets/usage_compressed
+	$(call cmd,gen_usage_compressed)
+
+quiet_cmd_gen_applet_tables = GEN     include/applet_tables.h
+      cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h include/NUM_APPLETS.h
+
+include/applet_tables.h: applets/applet_tables
+	$(call cmd,gen_applet_tables)
+
+include/NUM_APPLETS.h: applets/applet_tables
+	$(call cmd,gen_applet_tables)
diff --git a/ap/app/busybox/src/applets/applet_tables.c b/ap/app/busybox/src/applets/applet_tables.c
new file mode 100644
index 0000000..152d5f4
--- /dev/null
+++ b/ap/app/busybox/src/applets/applet_tables.c
@@ -0,0 +1,157 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Applet table generator.
+ * Runs on host and produces include/applet_tables.h
+ *
+ * Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#undef ARRAY_SIZE
+#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
+
+#include "../include/autoconf.h"
+#include "../include/applet_metadata.h"
+
+struct bb_applet {
+	const char *name;
+	const char *main;
+	enum bb_install_loc_t install_loc;
+	enum bb_suid_t need_suid;
+	/* true if instead of fork(); exec("applet"); waitpid();
+	 * one can do fork(); exit(applet_main(argc,argv)); waitpid(); */
+	unsigned char noexec;
+	/* Even nicer */
+	/* true if instead of fork(); exec("applet"); waitpid();
+	 * one can simply call applet_main(argc,argv); */
+	unsigned char nofork;
+};
+
+/* Define struct bb_applet applets[] */
+#include "../include/applets.h"
+
+enum { NUM_APPLETS = ARRAY_SIZE(applets) };
+
+static int offset[NUM_APPLETS];
+
+static int cmp_name(const void *a, const void *b)
+{
+	const struct bb_applet *aa = a;
+	const struct bb_applet *bb = b;
+	return strcmp(aa->name, bb->name);
+}
+
+int main(int argc, char **argv)
+{
+	int i;
+	int ofs;
+	unsigned MAX_APPLET_NAME_LEN = 1;
+
+	qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name);
+
+	ofs = 0;
+	for (i = 0; i < NUM_APPLETS; i++) {
+		offset[i] = ofs;
+		ofs += strlen(applets[i].name) + 1;
+	}
+	/* We reuse 4 high-order bits of offset array for other purposes,
+	 * so if they are indeed needed, refuse to proceed */
+	if (ofs > 0xfff)
+		return 1;
+	if (!argv[1])
+		return 1;
+
+	i = open(argv[1], O_WRONLY | O_TRUNC | O_CREAT, 0666);
+	if (i < 0)
+		return 1;
+	dup2(i, 1);
+
+	/* Keep in sync with include/busybox.h! */
+
+	printf("/* This is a generated file, don't edit */\n\n");
+
+	printf("#define NUM_APPLETS %u\n", NUM_APPLETS);
+	if (NUM_APPLETS == 1) {
+		printf("#define SINGLE_APPLET_STR \"%s\"\n", applets[0].name);
+		printf("#define SINGLE_APPLET_MAIN %s_main\n", applets[0].main);
+	}
+	printf("\n");
+
+	//printf("#ifndef SKIP_definitions\n");
+	printf("const char applet_names[] ALIGN1 = \"\"\n");
+	for (i = 0; i < NUM_APPLETS; i++) {
+		printf("\"%s\" \"\\0\"\n", applets[i].name);
+		if (MAX_APPLET_NAME_LEN < strlen(applets[i].name))
+			MAX_APPLET_NAME_LEN = strlen(applets[i].name);
+	}
+	printf(";\n\n");
+
+	printf("#ifndef SKIP_applet_main\n");
+	printf("int (*const applet_main[])(int argc, char **argv) = {\n");
+	for (i = 0; i < NUM_APPLETS; i++) {
+		printf("%s_main,\n", applets[i].main);
+	}
+	printf("};\n");
+	printf("#endif\n\n");
+
+	printf("const uint16_t applet_nameofs[] ALIGN2 = {\n");
+	for (i = 0; i < NUM_APPLETS; i++) {
+		printf("0x%04x,\n",
+			offset[i]
+#if ENABLE_FEATURE_PREFER_APPLETS
+			+ (applets[i].nofork << 12)
+			+ (applets[i].noexec << 13)
+#endif
+#if ENABLE_FEATURE_SUID
+			+ (applets[i].need_suid << 14) /* 2 bits */
+#endif
+		);
+	}
+	printf("};\n\n");
+
+#if ENABLE_FEATURE_INSTALLER
+	printf("const uint8_t applet_install_loc[] ALIGN1 = {\n");
+	i = 0;
+	while (i < NUM_APPLETS) {
+		int v = applets[i].install_loc; /* 3 bits */
+		if (++i < NUM_APPLETS)
+			v |= applets[i].install_loc << 4; /* 3 bits */
+		printf("0x%02x,\n", v);
+		i++;
+	}
+	printf("};\n");
+#endif
+	//printf("#endif /* SKIP_definitions */\n");
+	printf("\n");
+	printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
+
+	if (argv[2]) {
+		char line_old[80];
+		char line_new[80];
+		FILE *fp;
+
+		line_old[0] = 0;
+		fp = fopen(argv[2], "r");
+		if (fp) {
+			fgets(line_old, sizeof(line_old), fp);
+			fclose(fp);
+		}
+		sprintf(line_new, "#define NUM_APPLETS %u\n", NUM_APPLETS);
+		if (strcmp(line_old, line_new) != 0) {
+			fp = fopen(argv[2], "w");
+			if (!fp)
+				return 1;
+			fputs(line_new, fp);
+		}
+	}
+
+	return 0;
+}
diff --git a/ap/app/busybox/src/applets/applets.c b/ap/app/busybox/src/applets/applets.c
new file mode 100644
index 0000000..98c2b44
--- /dev/null
+++ b/ap/app/busybox/src/applets/applets.c
@@ -0,0 +1,16 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Stub for linking busybox binary against libbusybox.
+ *
+ * Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+#include "busybox.h"
+
+#if ENABLE_BUILD_LIBBUSYBOX
+int main(int argc UNUSED_PARAM, char **argv)
+{
+	return lbb_main(argv);
+}
+#endif
diff --git a/ap/app/busybox/src/applets/busybox.mkll b/ap/app/busybox/src/applets/busybox.mkll
new file mode 100755
index 0000000..68dbf21
--- /dev/null
+++ b/ap/app/busybox/src/applets/busybox.mkll
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Make busybox links list file.
+
+# input $1: full path to Config.h
+# input $2: full path to applets.h
+# output (stdout): list of pathnames that should be linked to busybox
+
+# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
+
+export LC_ALL=POSIX
+export LC_CTYPE=POSIX
+
+CONFIG_H=${1:-include/autoconf.h}
+APPLETS_H=${2:-include/applets.h}
+$HOSTCC -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
+  awk '/^[ \t]*LINK/{
+	dir=substr($2,7)
+	gsub("_","/",dir)
+	if(dir=="/ROOT") dir=""
+	file=$3
+	gsub("\"","",file)
+	if (file=="busybox") next
+	print tolower(dir) "/" file
+  }'
diff --git a/ap/app/busybox/src/applets/individual.c b/ap/app/busybox/src/applets/individual.c
new file mode 100644
index 0000000..4c468df
--- /dev/null
+++ b/ap/app/busybox/src/applets/individual.c
@@ -0,0 +1,24 @@
+/* Minimal wrapper to build an individual busybox applet.
+ *
+ * Copyright 2005 Rob Landley <rob@landley.net
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+
+const char *applet_name;
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "usage.h"
+
+int main(int argc, char **argv)
+{
+	applet_name = argv[0];
+	return APPLET_main(argc, argv);
+}
+
+void bb_show_usage(void)
+{
+	fputs(APPLET_full_usage "\n", stdout);
+	exit(EXIT_FAILURE);
+}
diff --git a/ap/app/busybox/src/applets/install.sh b/ap/app/busybox/src/applets/install.sh
new file mode 100755
index 0000000..95b4719
--- /dev/null
+++ b/ap/app/busybox/src/applets/install.sh
@@ -0,0 +1,113 @@
+#!/bin/sh
+
+export LC_ALL=POSIX
+export LC_CTYPE=POSIX
+
+prefix=$1
+if [ -z "$prefix" ]; then
+	echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--scriptwrapper]"
+	exit 1
+fi
+
+h=`sort busybox.links | uniq`
+
+linkopts=""
+scriptwrapper="n"
+cleanup="0"
+noclobber="0"
+case "$2" in
+	--hardlinks)     linkopts="-f";;
+	--symlinks)      linkopts="-fs";;
+	--scriptwrapper) scriptwrapper="y";swrapall="y";;
+	--sw-sh-hard)    scriptwrapper="y";linkopts="-f";;
+	--sw-sh-sym)     scriptwrapper="y";linkopts="-fs";;
+	--cleanup)       cleanup="1";;
+	--noclobber)     noclobber="1";;
+	"")              h="";;
+	*)               echo "Unknown install option: $2"; exit 1;;
+esac
+
+if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
+	# get the target dir for the libs
+	# assume it starts with lib
+	libdir=$($CC -print-file-name=libc.so | \
+		 sed -n 's%^.*\(/lib[^\/]*\)/libc.so%\1%p')
+	if test -z "$libdir"; then
+		libdir=/lib
+	fi
+
+	mkdir -p "$prefix/$libdir" || exit 1
+	for i in $DO_INSTALL_LIBS; do
+		rm -f "$prefix/$libdir/$i" || exit 1
+		if [ -f "$i" ]; then
+			cp -pPR "$i" "$prefix/$libdir/" || exit 1
+			chmod 0644 "$prefix/$libdir/$i" || exit 1
+		fi
+	done
+fi
+
+if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then
+	inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
+	sub_shell_it=`
+		cd "$prefix"
+		for d in usr/sbin usr/bin sbin bin; do
+			pd=$PWD
+			if [ -d "$d" ]; then
+				cd "$d"
+				ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f
+			fi
+			cd "$pd"
+		done
+		`
+	exit 0
+fi
+
+rm -f "$prefix/bin/busybox" || exit 1
+mkdir -p "$prefix/bin" || exit 1
+install -m 755 busybox "$prefix/bin/busybox" || exit 1
+
+for i in $h; do
+	appdir=`dirname "$i"`
+	mkdir -p "$prefix/$appdir" || exit 1
+	if [ "$scriptwrapper" = "y" ]; then
+		if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then
+			ln $linkopts busybox "$prefix/$i" || exit 1
+		else
+			rm -f "$prefix/$i"
+			echo "#!/bin/busybox" >"$prefix/$i"
+			chmod +x "$prefix/$i"
+		fi
+		echo "	$prefix/$i"
+	else
+		if [ "$2" = "--hardlinks" ]; then
+			bb_path="$prefix/bin/busybox"
+		else
+			case "$appdir" in
+			/)
+				bb_path="bin/busybox"
+			;;
+			/bin)
+				bb_path="busybox"
+			;;
+			/sbin)
+				bb_path="../bin/busybox"
+			;;
+			/usr/bin | /usr/sbin)
+				bb_path="../../bin/busybox"
+			;;
+			*)
+				echo "Unknown installation directory: $appdir"
+				exit 1
+			;;
+			esac
+		fi
+		if [ "$noclobber" = "0" ] || [ ! -e "$prefix/$i" ]; then
+			echo "  $prefix/$i -> $bb_path"
+			ln $linkopts "$bb_path" "$prefix/$i" || exit 1
+		else
+			echo "  $prefix/$i already exists"
+		fi
+	fi
+done
+
+exit 0
diff --git a/ap/app/busybox/src/applets/usage.c b/ap/app/busybox/src/applets/usage.c
new file mode 100644
index 0000000..94520ff
--- /dev/null
+++ b/ap/app/busybox/src/applets/usage.c
@@ -0,0 +1,55 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2008 Denys Vlasenko.
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "autoconf.h"
+
+/* Since we can't use platform.h, have to do this again by hand: */
+#if ENABLE_NOMMU
+# define BB_MMU 0
+# define USE_FOR_NOMMU(...) __VA_ARGS__
+# define USE_FOR_MMU(...)
+#else
+# define BB_MMU 1
+# define USE_FOR_NOMMU(...)
+# define USE_FOR_MMU(...) __VA_ARGS__
+#endif
+
+#include "usage.h"
+#define MAKE_USAGE(aname, usage) { aname, usage },
+static struct usage_data {
+	const char *aname;
+	const char *usage;
+} usage_array[] = {
+#include "applets.h"
+};
+
+static int compare_func(const void *a, const void *b)
+{
+	const struct usage_data *ua = a;
+	const struct usage_data *ub = b;
+	return strcmp(ua->aname, ub->aname);
+}
+
+int main(void)
+{
+	int i;
+	int num_messages = sizeof(usage_array) / sizeof(usage_array[0]);
+
+	if (num_messages == 0)
+		return 0;
+
+	qsort(usage_array,
+		num_messages, sizeof(usage_array[0]),
+		compare_func);
+	for (i = 0; i < num_messages; i++)
+		write(STDOUT_FILENO, usage_array[i].usage, strlen(usage_array[i].usage) + 1);
+
+	return 0;
+}
diff --git a/ap/app/busybox/src/applets/usage_compressed b/ap/app/busybox/src/applets/usage_compressed
new file mode 100755
index 0000000..af66bc5
--- /dev/null
+++ b/ap/app/busybox/src/applets/usage_compressed
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+target="$1"
+loc="$2"
+
+test "$target" || exit 1
+test "$loc" || loc=.
+test -x "$loc/usage" || exit 1
+test "$SED" || SED=sed
+test "$DD" || DD=dd
+
+# Some people were bitten by their system lacking a (proper) od
+od -v -t x1 </dev/null >/dev/null
+if test $? != 0; then
+	echo 'od tool is not installed or cannot accept "-v -t x1" options'
+	exit 1
+fi
+
+exec >"$target.$$"
+
+echo '#define UNPACKED_USAGE "" \'
+"$loc/usage" | od -v -t x1 \
+| $SED -e 's/^[^ ]*//' \
+	-e 's/ //g' \
+	-e '/^$/d' \
+	-e 's/\(..\)/\\x\1/g' \
+	-e 's/^/"/' \
+	-e 's/$/" \\/'
+echo ''
+
+echo '#define PACKED_USAGE \'
+## Breaks on big-endian systems!
+## # Extra effort to avoid using "od -t x1": -t is not available
+## # in non-CONFIG_DESKTOPed busybox od
+##
+## "$loc/usage" | bzip2 -1 | od -v -x \
+## | $SED -e 's/^[^ ]*//' \
+##	-e 's/ //g' \
+##	-e '/^$/d' \
+##	-e 's/\(..\)\(..\)/0x\2,0x\1,/g'
+##	-e 's/$/ \\/'
+"$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -t x1 \
+| $SED -e 's/^[^ ]*//' \
+	-e 's/ //g' \
+	-e '/^$/d' \
+	-e 's/\(..\)/0x\1,/g' \
+	-e 's/$/ \\/'
+echo ''
+
+mv -- "$target.$$" "$target"
diff --git a/ap/app/busybox/src/applets/usage_pod.c b/ap/app/busybox/src/applets/usage_pod.c
new file mode 100644
index 0000000..0b1c4aa
--- /dev/null
+++ b/ap/app/busybox/src/applets/usage_pod.c
@@ -0,0 +1,111 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2009 Denys Vlasenko.
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+#include <unistd.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "autoconf.h"
+
+#define SKIP_applet_main
+#define ALIGN1 /* nothing, just to placate applet_tables.h */
+#define ALIGN2 /* nothing, just to placate applet_tables.h */
+#include "applet_tables.h"
+
+/* Since we can't use platform.h, have to do this again by hand: */
+#if ENABLE_NOMMU
+# define BB_MMU 0
+# define USE_FOR_NOMMU(...) __VA_ARGS__
+# define USE_FOR_MMU(...)
+#else
+# define BB_MMU 1
+# define USE_FOR_NOMMU(...)
+# define USE_FOR_MMU(...) __VA_ARGS__
+#endif
+
+#include "usage.h"
+#define MAKE_USAGE(aname, usage) { aname, usage },
+static struct usage_data {
+	const char *aname;
+	const char *usage;
+} usage_array[] = {
+#include "applets.h"
+};
+
+static int compare_func(const void *a, const void *b)
+{
+	const struct usage_data *ua = a;
+	const struct usage_data *ub = b;
+	return strcmp(ua->aname, ub->aname);
+}
+
+int main(void)
+{
+	int col, len2;
+
+	int i;
+	int num_messages = sizeof(usage_array) / sizeof(usage_array[0]);
+
+	if (num_messages == 0)
+		return 0;
+
+	qsort(usage_array,
+		num_messages, sizeof(usage_array[0]),
+		compare_func);
+
+	col = 0;
+	for (i = 0; i < num_messages; i++) {
+		len2 = strlen(usage_array[i].aname) + 2;
+		if (col >= 76 - len2) {
+			printf(",\n");
+			col = 0;
+		}
+		if (col == 0) {
+			col = 6;
+			printf("\t");
+		} else {
+			printf(", ");
+		}
+		printf(usage_array[i].aname);
+		col += len2;
+	}
+	printf("\n\n");
+
+	printf("=head1 COMMAND DESCRIPTIONS\n\n");
+	printf("=over 4\n\n");
+
+	for (i = 0; i < num_messages; i++) {
+		if (usage_array[i].aname[0] >= 'a' && usage_array[i].aname[0] <= 'z'
+		 && usage_array[i].usage[0] != NOUSAGE_STR[0]
+		) {
+			printf("=item B<%s>\n\n", usage_array[i].aname);
+			if (usage_array[i].usage[0])
+				printf("%s %s\n\n", usage_array[i].aname, usage_array[i].usage);
+			else
+				printf("%s\n\n", usage_array[i].aname);
+		}
+	}
+	return 0;
+}
+
+/* TODO: we used to make options bold with B<> and output an example too:
+
+=item B<cat>
+
+cat [B<-u>] [FILE]...
+
+Concatenate FILE(s) and print them to stdout
+
+Options:
+        -u      Use unbuffered i/o (ignored)
+
+Example:
+        $ cat /proc/uptime
+        110716.72 17.67
+
+*/