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

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/Makefile.in b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/Makefile.in
new file mode 100644
index 0000000..76c3f88
--- /dev/null
+++ b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/Makefile.in
@@ -0,0 +1,61 @@
+#
+# Standard e2fsprogs prologue....
+#
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+top_builddir = ..
+my_dir = util
+INSTALL = @INSTALL@
+
+SRCS = $(srcdir)/subst.c
+
+@MCONFIG@
+
+.c.o:
+	$(E) "	CC $<"
+	$(Q) $(BUILD_CC) -c $(BUILD_CFLAGS) $< -o $@
+	$(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
+
+PROGS=		subst symlinks
+
+all:: $(PROGS) gen-tarball
+
+subst: subst.o
+	$(E) "	LD $@"
+	$(Q) $(BUILD_CC) $(BUILD_LDFLAGS) -o subst subst.o
+
+copy_sparse: copy_sparse.o
+	$(E) "	LD $@"
+	$(Q) $(BUILD_CC) $(BUILD_LDFLAGS) -o copy_sparse copy_sparse.o
+
+symlinks: symlinks.o
+	$(E) "	LD $@"
+	$(Q) $(BUILD_CC) $(BUILD_LDFLAGS) -o symlinks symlinks.o
+
+gen-tarball: $(srcdir)/gen-tarball.in $(top_builddir)/config.status
+	$(E) "	CONFIG.STATUS $@"
+	$(Q) cd $(top_builddir); CONFIG_FILES=util/gen-tarball ./config.status
+	$(Q) chmod +x gen-tarball
+
+tarballs: gen-tarball
+	sh gen-tarball debian
+	sh gen-tarball all
+	sh gen-tarball subset
+
+clean:
+	$(RM) -f $(PROGS) \#* *.s *.o *.a *~ core *.tar.gz gen-tarball \
+		copy-sparse
+
+mostlyclean: clean
+
+distclean: clean
+	$(RM) -f .depend Makefile $(srcdir)/TAGS $(srcdir)/Makefile.in.old
+
+# +++ Dependency line eater +++
+# 
+# Makefile dependencies follow.  This must be the last section in
+# the Makefile.in file
+#
+subst.o: $(srcdir)/subst.c
diff --git a/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/all.exclude b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/all.exclude
new file mode 100644
index 0000000..d7d03b2
--- /dev/null
+++ b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/all.exclude
@@ -0,0 +1,15 @@
+.git
+.hg
+.hgignore
+.pc
+patches
+README.subset
+build
+build[^/]*
+rpm.log
+TODO
+powerquest
+.exclude-file
+po/stamp-cat-id
+po/cat-id-tbl.c
+Meta
diff --git a/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/copy_sparse.c b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/copy_sparse.c
new file mode 100644
index 0000000..cbab273
--- /dev/null
+++ b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/copy_sparse.c
@@ -0,0 +1,228 @@
+/*
+ * copy_sparse.c -- copy a very large sparse files efficiently
+ * 	(requires root privileges)
+ *
+ * Copyright 2003, 2004 by Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+#ifndef __linux__
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void) {
+    fputs("This program is only supported on Linux!\n", stderr);
+    exit(EXIT_FAILURE);
+}
+#else
+#define _LARGEFILE64_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <time.h>
+#include <fcntl.h>
+#include <errno.h>
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+extern char *optarg;
+extern int optind;
+#endif
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/vfs.h>
+#include <sys/ioctl.h>
+#include <linux/fd.h>
+
+int verbose = 0;
+
+#define FIBMAP	   _IO(0x00,1)	/* bmap access */
+#define FIGETBSZ   _IO(0x00,2)	/* get the block size used for bmap */
+
+static unsigned long get_bmap(int fd, unsigned long block)
+{
+	int	ret;
+	unsigned long b;
+
+	b = block;
+	ret = ioctl(fd, FIBMAP, &b);
+	if (ret < 0) {
+		if (errno == EPERM) {
+			fprintf(stderr, "No permission to use FIBMAP ioctl; must have root privileges\n");
+			exit(1);
+		}
+		perror("FIBMAP");
+	}
+	return b;
+}
+
+static int full_read(int fd, char *buf, size_t count)
+{
+	int got, total = 0;
+	int pass = 0;
+
+	while (count > 0) {
+		got = read(fd, buf, count);
+		if (got == -1) {
+			if ((errno == EINTR) || (errno == EAGAIN))
+				continue;
+			return total ? total : -1;
+		}
+		if (got == 0) {
+			if (pass++ >= 3)
+				return total;
+			continue;
+		}
+		pass = 0;
+		buf += got;
+		total += got;
+		count -= got;
+	}
+	return total;
+}
+
+static void copy_sparse_file(const char *src, const char *dest)
+{
+	struct stat64	fileinfo;
+	long		lb, i, fd, ofd, bs, block, numblocks;
+	ssize_t		got, got2;
+	off64_t		offset = 0, should_be;
+	char		*buf;
+
+	if (verbose)
+		printf("Copying sparse file from %s to %s\n", src, dest);
+
+	if (strcmp(src, "-")) {
+		if (stat64(src, &fileinfo) < 0) {
+			perror("stat");
+			exit(1);
+		}
+		if (!S_ISREG(fileinfo.st_mode)) {
+			printf("%s: Not a regular file\n", src);
+			exit(1);
+		}
+		fd = open(src, O_RDONLY | O_LARGEFILE);
+		if (fd < 0) {
+			perror("open");
+			exit(1);
+		}
+		if (ioctl(fd, FIGETBSZ, &bs) < 0) {
+			perror("FIGETBSZ");
+			close(fd);
+			exit(1);
+		}
+		if (bs < 0) {
+			printf("%s: Invalid block size: %ld\n", src, bs);
+			exit(1);
+		}
+		if (verbose)
+			printf("Blocksize of file %s is %ld\n", src, bs);
+		numblocks = (fileinfo.st_size + (bs-1)) / bs;
+		if (verbose)
+			printf("File size of %s is %lld (%ld blocks)\n", src,
+			       (long long) fileinfo.st_size, numblocks);
+	} else {
+		fd = 0;
+		bs = 1024;
+	}
+
+	ofd = open(dest, O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0777);
+	if (ofd < 0) {
+		perror(dest);
+		exit(1);
+	}
+
+	buf = malloc(bs);
+	if (!buf) {
+		fprintf(stderr, "Couldn't allocate buffer");
+		exit(1);
+	}
+
+	for (lb = 0; !fd || lb < numblocks; lb++) {
+		if (fd) {
+			block = get_bmap(fd, lb);
+			if (!block)
+				continue;
+			should_be = ((off64_t) lb) * bs;
+			if (offset != should_be) {
+				if (verbose)
+					printf("Seeking to %lld\n", should_be);
+				if (lseek64(fd, should_be, SEEK_SET) == (off_t) -1) {
+					perror("lseek src");
+					exit(1);
+				}
+				if (lseek64(ofd, should_be, SEEK_SET) == (off_t) -1) {
+					perror("lseek dest");
+					exit(1);
+				}
+				offset = should_be;
+			}
+		}
+		got = full_read(fd, buf, bs);
+
+		if (fd == 0 && got == 0)
+			break;
+
+		if (got == bs) {
+			for (i=0; i < bs; i++)
+				if (buf[i])
+					break;
+			if (i == bs) {
+				lseek(ofd, bs, SEEK_CUR);
+				offset += bs;
+				continue;
+			}
+		}
+		got2 = write(ofd, buf, got);
+		if (got != got2) {
+			printf("short write\n");
+			exit(1);
+		}
+		offset += got;
+	}
+	offset = fileinfo.st_size;
+	if (fstat64(ofd, &fileinfo) < 0) {
+		perror("fstat");
+		exit(1);
+	}
+	if (fileinfo.st_size != offset) {
+		lseek64(ofd, offset-1, SEEK_CUR);
+		buf[0] = 0;
+		write(ofd, buf, 1);
+	}
+	close(fd);
+	close(ofd);
+}
+
+static void usage(const char *progname)
+{
+	fprintf(stderr, "Usage: %s [-v] source_file destination_file\n", progname);
+	exit(1);
+}
+
+int main(int argc, char**argv)
+{
+	int c;
+
+	while ((c = getopt(argc, argv, "v")) != EOF)
+		switch (c) {
+		case 'v':
+			verbose++;
+			break;
+		default:
+			usage(argv[0]);
+			break;
+		}
+	if (optind+2 != argc)
+		usage(argv[0]);
+	copy_sparse_file(argv[optind], argv[optind+1]);
+
+	return 0;
+}
+#endif
diff --git a/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/gcc-wall-cleanup b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/gcc-wall-cleanup
new file mode 100644
index 0000000..6148e46
--- /dev/null
+++ b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/gcc-wall-cleanup
@@ -0,0 +1,22 @@
+#!/bin/sed -f
+#
+# This script filters out gcc-wall crud that we're not interested in seeing.
+#
+/^cc /d
+/^kcc /d
+/^gcc /d
+/does not support `long long'/d
+/forbids long long integer constants/d
+/does not support the `ll' length modifier/d
+/does not support the `ll' printf length modifier/d
+/ANSI C forbids long long integer constants/d
+/traditional C rejects string concatenation/d
+/integer constant is unsigned in ANSI C, signed with -traditional/d
+/At top level:/d
+/In file included from/d
+/In function `.*':/d
+/zero-length format string/d
+/warning: missing initializer/d
+/warning: (near initialization for/d
+/^[ 	]*from/d
+
diff --git a/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/gen-tarball.in b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/gen-tarball.in
new file mode 100644
index 0000000..b82f12c
--- /dev/null
+++ b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/gen-tarball.in
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# This script is used to generate the distribution tarball
+#
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+top_dir=`cd $top_srcdir; pwd`
+base_ver=`echo @E2FSPROGS_VERSION@ | sed -e 's/-WIP//' -e 's/pre-//' -e 's/-PLUS//'`
+base_e2fsprogs=`basename $top_dir`
+exclude=/tmp/exclude
+GZIP=gzip
+
+#
+# This hack is needed because texi2dvi blows up horribly if there are 
+# any '~' chracters in the directory pathname.  So we kludge around it by
+# using a non-standard directory name for WIP releases.  dpkg-source
+# complains, but life goes on.
+#
+deb_pkgver=`echo @E2FSPROGS_PKGVER@ | sed -e 's/~/-/g'`
+    
+case $1 in
+    debian|ubuntu)
+	SRCROOT="e2fsprogs-$deb_pkgver"
+	rename_tarball="e2fsprogs_@E2FSPROGS_PKGVER@.orig.tar.gz"
+	list=all
+	;;
+    subset)
+	SRCROOT="e2fsprogs-libs-$base_ver"
+	list=subset
+	;;
+   all|*)
+	SRCROOT="e2fsprogs-$base_ver"
+	list=all
+	;;
+esac
+
+mv ../e2fsprogs.spec $top_srcdir/e2fsprogs.spec
+(cd $top_srcdir/.. ; find $base_e2fsprogs \( -name \*~ -o -name \*.orig \
+		-o -name CVS -o -name \*.rej -o -name Makefile.pq \
+		-o -name TAGS -o -name \*.old -o -name SCCS \
+		-o -name changed-files -o -name .#\* -o -name \*.tar.gz \
+		-o -name autom4te.cache \) \
+		-print) | sed -e "s/^$base_e2fsprogs/$SRCROOT/" > $exclude
+sed -e "s;^;$SRCROOT/;" < $srcdir/$list.exclude >> $exclude
+
+(cd $top_srcdir/.. ; rm -f $SRCROOT ; ln -sf $base_e2fsprogs $SRCROOT)
+
+(cd $top_srcdir/.. ; tar -c -h -v -f - -X $exclude $SRCROOT) \
+	 | $GZIP -9 -c > $SRCROOT.tar.gz
+$GZIP -l $SRCROOT.tar.gz
+
+(cd $top_srcdir/.. ; rm -f $SRCROOT)
+mv $top_srcdir/e2fsprogs.spec ../e2fsprogs.spec 
+if test -n "$rename_tarball"; then
+    mv $SRCROOT.tar.gz $rename_tarball
+fi
diff --git a/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/install-symlink.in b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/install-symlink.in
new file mode 100644
index 0000000..24341b8
--- /dev/null
+++ b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/install-symlink.in
@@ -0,0 +1,89 @@
+#!/bin/sh
+#
+# install-symlink source destination destdir
+#
+
+SYMLINKS=symlinks
+LN_S="@LN_S@"
+RM="@RM@"
+FORCE_RELATIVE=NO
+FORCE_ABSOLUTE=NO
+
+while echo $1 | grep -q -- ^- ;
+do
+	case $1 in
+		--relative)
+			FORCE_RELATIVE=YES
+			;;
+		--absolute)
+			FORCE_ABSOLUTE=YES
+			;;
+		--debian)
+			FORCE_ABSOLUTE=NO
+			FORCE_RELATIVE=NO
+			;;
+		--symlinks=*)
+			SYMLINKS=$(echo $1 | sed -e 's/--symlinks=//')
+			;;
+		*)
+			echo "Unknown option $1"
+			exit 1
+			;;
+	esac					     
+	shift;
+done
+
+
+FIX_SYMLINK="$SYMLINKS -c"
+
+SRC="$1"
+DEST="$2"
+DESTDIR="$3"
+
+if ! echo $SRC | grep -q ^/ ; then
+	echo $SRC: Source pathname must be absolute
+	exit 1
+fi
+
+if ! echo $DEST | grep -q ^/ ; then
+	echo $DEST: Destination pathname must be absolute
+	exit 1
+fi
+
+if ! test -e "$DESTDIR$SRC" ; then
+	echo $DESTDIR$SRC: file or directory does not exist
+	exit 1
+fi
+
+$RM -f "$DESTDIR$DEST"
+
+if test "$LN_S" != "ln -s" ; then
+	$LN_S "$DESTDIR$SRC" "$DESTDIR$DEST"
+	exit 0
+fi
+
+if test $(dirname "$SRC") = $(dirname "$DEST") ; then
+	$LN_S "$(basename "$SRC")" "$DESTDIR$DEST"
+	exit 0
+fi
+
+TOP_SRC=$(echo $SRC | awk -F/ '{print $2}')
+TOP_DEST=$(echo $DEST | awk -F/ '{print $2}')
+
+if test $FORCE_RELATIVE = YES ; then
+	TOP_SRC=FORCE
+	TOP_DEST=FORCE
+fi
+
+if test $FORCE_ABSOLUTE = YES ; then
+	TOP_SRC=FORCE
+	TOP_DEST=FORCE_ABSOLUTE
+fi
+
+if test $TOP_SRC != $TOP_DEST ; then
+	$LN_S "$SRC" "$DESTDIR$DEST"
+else
+	$LN_S "$DESTDIR$SRC" "$DESTDIR$DEST"
+	$FIX_SYMLINK "$DESTDIR$DEST"
+fi
+
diff --git a/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/libecho.c b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/libecho.c
new file mode 100644
index 0000000..352ce1e
--- /dev/null
+++ b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/libecho.c
@@ -0,0 +1,78 @@
+/*
+ * libecho.c
+ *
+ * For each argument on the command line, echo it.  Should expand
+ * DOS wildcards correctly.
+ *
+ * Syntax: libecho [-p prefix] list...
+ */
+#include <stdio.h>
+#include <io.h>
+#include <string.h>
+
+void echo_files(char *, char *);
+
+int
+main(int argc, char *argv[])
+{
+  int i;
+  char *prefix;
+
+  prefix = "";
+
+  if (argc < 2) {
+    fprintf(stderr, "Usage:  libecho [-p prefix] list...\n");
+    return 1;
+  }
+
+  for (i = 1 ; i < argc ; i++)
+    if (!stricmp(argv[i], "-p"))
+      prefix = argv[++i];
+    else
+      echo_files(prefix, argv[i]);
+
+  return 0;
+}
+
+void
+echo_files(char *prefix, char *f)
+{
+  long ff;
+  struct _finddata_t fdt;
+  char *slash;
+  char filepath[256];
+
+  /*
+   * We're unix based quite a bit here.  Look for normal slashes and
+   * make them reverse slashes.
+   */
+  while((slash = strrchr(f, '/')) != NULL)
+    *slash = '\\';
+
+  strcpy(filepath, f);
+
+  slash = strrchr(filepath, '\\');
+
+  if (slash) {
+    slash++;
+    *slash = 0;
+  } else {
+    filepath[0] = '\0';
+  }
+
+  ff = _findfirst(f, &fdt);
+
+  if (ff < 0) {
+    printf("%s%s\n", prefix, f);
+    return;
+  }
+
+  printf("%s%s%s\n", prefix, filepath, fdt.name);
+
+  for (;;) {
+    if (_findnext(ff, &fdt) < 0)
+      break;
+    printf("%s%s%s\n", prefix, filepath, fdt.name);
+  }
+  _findclose(ff);
+}
diff --git a/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/subset.exclude b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/subset.exclude
new file mode 100644
index 0000000..b988fa8
--- /dev/null
+++ b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/subset.exclude
@@ -0,0 +1,35 @@
+.git
+.hg
+.hgignore
+.pc
+patches
+build
+build[^/]*
+rpm.log
+TODO
+powerquest
+.exclude-subset
+po/stamp-cat-id
+po/cat-id-tbl.c
+Meta
+e2fsck
+ext2ed
+debugfs
+misc
+tests
+resize
+contrib
+po
+include
+debian
+lib/e2p
+lib/evms
+lib/ext2fs
+ABOUT-NLS
+README
+INSTALL
+INSTALL.dllbin
+INSTALL.elfbin
+RELEASE-NOTES
+e2fsprogs.lsm
+e2fsprogs.spec
diff --git a/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/subst.c b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/subst.c
new file mode 100644
index 0000000..20dd6f2
--- /dev/null
+++ b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/subst.c
@@ -0,0 +1,400 @@
+/*
+ * subst.c --- substitution program
+ *
+ * Subst is used as a quicky program to do @ substitutions
+ *
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <utime.h>
+
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+extern char *optarg;
+extern int optind;
+#endif
+
+
+struct subst_entry {
+	char *name;
+	char *value;
+	struct subst_entry *next;
+};
+
+static struct subst_entry *subst_table = 0;
+
+static int add_subst(char *name, char *value)
+{
+	struct subst_entry	*ent = 0;
+
+	ent = (struct subst_entry *) malloc(sizeof(struct subst_entry));
+	if (!ent)
+		goto fail;
+	ent->name = (char *) malloc(strlen(name)+1);
+	if (!ent->name)
+		goto fail;
+	ent->value = (char *) malloc(strlen(value)+1);
+	if (!ent->value)
+		goto fail;
+	strcpy(ent->name, name);
+	strcpy(ent->value, value);
+	ent->next = subst_table;
+	subst_table = ent;
+	return 0;
+fail:
+	if (ent) {
+		free(ent->name);
+		free(ent);
+	}
+	return ENOMEM;
+}
+
+static struct subst_entry *fetch_subst_entry(char *name)
+{
+	struct subst_entry *ent;
+
+	for (ent = subst_table; ent; ent = ent->next) {
+		if (strcmp(name, ent->name) == 0)
+			break;
+	}
+	return ent;
+}
+
+/*
+ * Given the starting and ending position of the replacement name,
+ * check to see if it is valid, and pull it out if it is.
+ */
+static char *get_subst_symbol(const char *begin, size_t len, char prefix)
+{
+	static char replace_name[128];
+	char *cp, *start;
+
+	start = replace_name;
+	if (prefix)
+		*start++ = prefix;
+
+	if (len > sizeof(replace_name)-2)
+		return NULL;
+	memcpy(start, begin, len);
+	start[len] = 0;
+
+	/*
+	 * The substitution variable must all be in the of [0-9A-Za-z_].
+	 * If it isn't, this must be an invalid symbol name.
+	 */
+	for (cp = start; *cp; cp++) {
+		if (!(*cp >= 'a' && *cp <= 'z') &&
+		    !(*cp >= 'A' && *cp <= 'Z') &&
+		    !(*cp >= '0' && *cp <= '9') &&
+		    !(*cp == '_'))
+			return NULL;
+	}
+	return (replace_name);
+}
+
+static void replace_string(char *begin, char *end, char *newstr)
+{
+	int	replace_len, len;
+
+	replace_len = strlen(newstr);
+	len = end - begin;
+	if (replace_len == 0)
+		memmove(begin, end+1, strlen(end)+1);
+	else if (replace_len != len+1)
+		memmove(end+(replace_len-len-1), end,
+			strlen(end)+1);
+	memcpy(begin, newstr, replace_len);
+}
+
+static void substitute_line(char *line)
+{
+	char	*ptr, *name_ptr, *end_ptr;
+	struct subst_entry *ent;
+	char	*replace_name;
+	size_t	len;
+
+	/*
+	 * Expand all @FOO@ substitutions
+	 */
+	ptr = line;
+	while (ptr) {
+		name_ptr = strchr(ptr, '@');
+		if (!name_ptr)
+			break;	/* No more */
+		if (*(++name_ptr) == '@') {
+			/*
+			 * Handle tytso@@mit.edu --> tytso@mit.edu
+			 */
+			memmove(name_ptr-1, name_ptr, strlen(name_ptr)+1);
+			ptr = name_ptr+1;
+			continue;
+		}
+		end_ptr = strchr(name_ptr, '@');
+		if (!end_ptr)
+			break;
+		len = end_ptr - name_ptr;
+		replace_name = get_subst_symbol(name_ptr, len, 0);
+		if (!replace_name) {
+			ptr = name_ptr;
+			continue;
+		}
+		ent = fetch_subst_entry(replace_name);
+		if (!ent) {
+			fprintf(stderr, "Unfound expansion: '%s'\n",
+				replace_name);
+			ptr = end_ptr + 1;
+			continue;
+		}
+#if 0
+		fprintf(stderr, "Replace name = '%s' with '%s'\n",
+		       replace_name, ent->value);
+#endif
+		ptr = name_ptr-1;
+		replace_string(ptr, end_ptr, ent->value);
+		if ((ent->value[0] == '@') &&
+		    (strlen(replace_name) == strlen(ent->value)-2) &&
+		    !strncmp(replace_name, ent->value+1,
+			     strlen(ent->value)-2))
+			/* avoid an infinite loop */
+			ptr += strlen(ent->value);
+	}
+	/*
+	 * Now do a second pass to expand ${FOO}
+	 */
+	ptr = line;
+	while (ptr) {
+		name_ptr = strchr(ptr, '$');
+		if (!name_ptr)
+			break;	/* No more */
+		if (*(++name_ptr) != '{') {
+			ptr = name_ptr;
+			continue;
+		}
+		name_ptr++;
+		end_ptr = strchr(name_ptr, '}');
+		if (!end_ptr)
+			break;
+		len = end_ptr - name_ptr;
+		replace_name = get_subst_symbol(name_ptr, len, '$');
+		if (!replace_name) {
+			ptr = name_ptr;
+			continue;
+		}
+		ent = fetch_subst_entry(replace_name);
+		if (!ent) {
+			ptr = end_ptr + 1;
+			continue;
+		}
+#if 0
+		fprintf(stderr, "Replace name = '%s' with '%s'\n",
+		       replace_name, ent->value);
+#endif
+		ptr = name_ptr-2;
+		replace_string(ptr, end_ptr, ent->value);
+	}
+}
+
+static void parse_config_file(FILE *f)
+{
+	char	line[2048];
+	char	*cp, *ptr;
+
+	while (!feof(f)) {
+		memset(line, 0, sizeof(line));
+		if (fgets(line, sizeof(line), f) == NULL)
+			break;
+		/*
+		 * Strip newlines and comments.
+		 */
+		cp = strchr(line, '\n');
+		if (cp)
+			*cp = 0;
+		cp = strchr(line, '#');
+		if (cp)
+			*cp = 0;
+		/*
+		 * Skip trailing and leading whitespace
+		 */
+		for (cp = line + strlen(line) - 1; cp >= line; cp--) {
+			if (*cp == ' ' || *cp == '\t')
+				*cp = 0;
+			else
+				break;
+		}
+		cp = line;
+		while (*cp && isspace(*cp))
+			cp++;
+		ptr = cp;
+		/*
+		 * Skip empty lines
+		 */
+		if (*ptr == 0)
+			continue;
+		/*
+		 * Ignore future extensions
+		 */
+		if (*ptr == '@')
+			continue;
+		/*
+		 * Parse substitutions
+		 */
+		for (cp = ptr; *cp; cp++)
+			if (isspace(*cp))
+				break;
+		*cp = 0;
+		for (cp++; *cp; cp++)
+			if (!isspace(*cp))
+				break;
+#if 0
+		printf("Substitute: '%s' for '%s'\n", ptr, cp ? cp : "<NULL>");
+#endif
+		add_subst(ptr, cp);
+	}
+}
+
+/*
+ * Return 0 if the files are different, 1 if the files are the same.
+ */
+static int compare_file(const char *outfn, const char *newfn)
+{
+	FILE	*old_f, *new_f;
+	char	oldbuf[2048], newbuf[2048], *oldcp, *newcp;
+	int	retval;
+
+	old_f = fopen(outfn, "r");
+	if (!old_f)
+		return 0;
+	new_f = fopen(newfn, "r");
+	if (!new_f) {
+		fclose(old_f);
+		return 0;
+	}
+
+	while (1) {
+		oldcp = fgets(oldbuf, sizeof(oldbuf), old_f);
+		newcp = fgets(newbuf, sizeof(newbuf), new_f);
+		if (!oldcp && !newcp) {
+			retval = 1;
+			break;
+		}
+		if (!oldcp || !newcp || strcmp(oldbuf, newbuf)) {
+			retval = 0;
+			break;
+		}
+	}
+	fclose(old_f);
+	fclose(new_f);
+	return retval;
+}
+
+
+
+int main(int argc, char **argv)
+{
+	char	line[2048];
+	int	c;
+	FILE	*in, *out;
+	char	*outfn = NULL, *newfn = NULL;
+	int	verbose = 0;
+	int	adjust_timestamp = 0;
+	struct stat stbuf;
+	struct utimbuf ut;
+
+	while ((c = getopt (argc, argv, "f:tv")) != EOF) {
+		switch (c) {
+		case 'f':
+			in = fopen(optarg, "r");
+			if (!in) {
+				perror(optarg);
+				exit(1);
+			}
+			parse_config_file(in);
+			fclose(in);
+			break;
+		case 't':
+			adjust_timestamp++;
+			break;
+		case 'v':
+			verbose++;
+			break;
+		default:
+			fprintf(stderr, "%s: [-f config-file] [file]\n",
+				argv[0]);
+			break;
+		}
+	}
+	if (optind < argc) {
+		in = fopen(argv[optind], "r");
+		if (!in) {
+			perror(argv[optind]);
+			exit(1);
+		}
+		optind++;
+	} else
+		in = stdin;
+
+	if (optind < argc) {
+		outfn = argv[optind];
+		newfn = (char *) malloc(strlen(outfn)+20);
+		if (!newfn) {
+			fprintf(stderr, "Memory error!  Exiting.\n");
+			exit(1);
+		}
+		strcpy(newfn, outfn);
+		strcat(newfn, ".new");
+		out = fopen(newfn, "w");
+		if (!out) {
+			perror(newfn);
+			exit(1);
+		}
+	} else {
+		out = stdout;
+		outfn = 0;
+	}
+
+	while (!feof(in)) {
+		if (fgets(line, sizeof(line), in) == NULL)
+			break;
+		substitute_line(line);
+		fputs(line, out);
+	}
+	fclose(in);
+	fclose(out);
+	if (outfn) {
+		struct stat st;
+		if (compare_file(outfn, newfn)) {
+			if (verbose)
+				printf("No change, keeping %s.\n", outfn);
+			if (adjust_timestamp) {
+				if (stat(outfn, &stbuf) == 0) {
+					if (verbose)
+						printf("Updating modtime for %s\n", outfn);
+					ut.actime = stbuf.st_atime;
+					ut.modtime = time(0);
+					if (utime(outfn, &ut) < 0)
+						perror("utime");
+				}
+			}
+			unlink(newfn);
+		} else {
+			if (verbose)
+				printf("Creating or replacing %s.\n", outfn);
+			rename(newfn, outfn);
+		}
+		/* set read-only to alert user it is a generated file */
+		if (stat(outfn, &st) == 0)
+			chmod(outfn, st.st_mode & ~0222);
+	}
+	return (0);
+}
+
+
diff --git a/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/subst.conf.in b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/subst.conf.in
new file mode 100644
index 0000000..64fde7a
--- /dev/null
+++ b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/subst.conf.in
@@ -0,0 +1,22 @@
+AWK			@AWK@
+SED			@SED@
+ET_DIR			@ET_DIR@
+SS_DIR			@SS_DIR@
+E2FSPROGS_MONTH		@E2FSPROGS_MONTH@
+E2FSPROGS_YEAR		@E2FSPROGS_YEAR@
+E2FSPROGS_VERSION	@E2FSPROGS_VERSION@
+SIZEOF_LONG_LONG	@SIZEOF_LONG_LONG@
+SIZEOF_LONG		@SIZEOF_LONG@
+SIZEOF_INT		@SIZEOF_INT@
+SIZEOF_SHORT		@SIZEOF_SHORT@
+datarootdir		@datarootdir@
+datadir			@datadir@
+root_sysconfdir		@root_sysconfdir@
+$datarootdir		@datarootdir@
+$root_prefix		@root_prefix@
+$prefix			@prefix@
+# Enable the documentation for the journal device mke2fs, tune2fs, and
+# e2fsck's man page
+JDEV			
+# Enable documentation for quota feature in mke2fs
+QUOTA_MAN_COMMENT	@QUOTA_MAN_COMMENT@
diff --git a/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/symlinks.c b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/symlinks.c
new file mode 100644
index 0000000..abb33f8
--- /dev/null
+++ b/ap/app/e2fsprogs/e2fsprogs-1.42.9/util/symlinks.c
@@ -0,0 +1,387 @@
+#define _FILE_OFFSET_BITS 64
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+
+#include <unistd.h>
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+#include <string.h>
+#include <fcntl.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <time.h>
+#include <stddef.h>
+#include <errno.h>
+
+#ifndef S_ISLNK
+#define S_ISLNK(mode) (((mode) & (_S_IFMT)) == (_S_IFLNK))
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
+#define progver "%s: scan/change symbolic links - v1.3 - by Mark Lord\n\n"
+static char *progname;
+static int verbose = 0, fix_links = 0, recurse = 0, delete = 0, shorten = 0,
+		testing = 0, single_fs = 1;
+
+/*
+ * tidypath removes excess slashes and "." references from a path string
+ */
+
+static int substr (char *s, char *old, char *new)
+{
+	char *tmp = NULL;
+	int oldlen = strlen(old), newlen = 0;
+
+	if (NULL == strstr(s, old))
+		return 0;
+
+	if (new)
+		newlen = strlen(new);
+
+	if (newlen > oldlen) {
+		if ((tmp = malloc(strlen(s))) == NULL) {
+			fprintf(stderr, "no memory\n");
+			exit (1);
+		}
+	}
+
+	while (NULL != (s = strstr(s, old))) {
+		char *p, *old_s = s;
+
+		if (new) {
+			if (newlen > oldlen)
+				old_s = strcpy(tmp, s);
+			p = new;
+			while (*p)
+				*s++ = *p++;
+		}
+		p = old_s + oldlen;
+		while ((*s++ = *p++));
+	}
+	if (tmp)
+		free(tmp);
+	return 1;
+}
+
+
+static int tidy_path (char *path)
+{
+	int tidied = 0;
+	char *s, *p;
+
+	s = path + strlen(path) - 1;
+	if (s[0] != '/') {	/* tmp trailing slash simplifies things */
+		s[1] = '/';
+		s[2] = '\0';
+	}
+	while (substr(path, "/./", "/"))
+		tidied = 1;
+	while (substr(path, "//", "/"))
+		tidied = 1;
+
+	while ((p = strstr(path,"/../")) != NULL) {
+		s = p+3;
+		for (p--; p != path; p--) if (*p == '/') break;
+		if (*p != '/')
+			break;
+		while ((*p++ = *s++));
+		tidied = 1;
+	}
+	if (*path == '\0')
+		strcpy(path,"/");
+	p = path + strlen(path) - 1;
+	if (p != path && *p == '/')
+		*p-- = '\0';	/* remove tmp trailing slash */
+	while (p != path && *p == '/') {	/* remove any others */
+		*p-- = '\0';
+		tidied = 1;
+	}
+	while (!strncmp(path,"./",2)) {
+		for (p = path, s = path+2; (*p++ = *s++););
+		tidied = 1;
+	}
+	return tidied;
+}
+
+static int shorten_path (char *path, char *abspath)
+{
+	static char dir[PATH_MAX];
+	int shortened = 0;
+	char *p;
+
+	/* get rid of unnecessary "../dir" sequences */
+	while (abspath && strlen(abspath) > 1 && (p = strstr(path,"../"))) {
+		/* find innermost occurance of "../dir", and save "dir" */
+		int slashes = 2;
+		char *a, *s, *d = dir;
+		while ((s = strstr(p+3, "../"))) {
+			++slashes;
+			p = s;
+		}
+		s = p+3;
+		*d++ = '/';
+		while (*s && *s != '/')
+			*d++ = *s++;
+		*d++ = '/';
+		*d = '\0';
+		if (!strcmp(dir,"//"))
+			break;
+		/* note: p still points at ../dir */
+		if (*s != '/' || !*++s)
+			break;
+		a = abspath + strlen(abspath) - 1;
+		while (slashes-- > 0) {
+			if (a <= abspath)
+				goto ughh;
+			while (*--a != '/') {
+				if (a <= abspath)
+					goto ughh;
+			}
+		}
+		if (strncmp(dir, a, strlen(dir)))
+			break;
+		while ((*p++ = *s++)); /* delete the ../dir */
+		shortened = 1;
+	}
+ughh:
+	return shortened;
+}
+
+
+static void fix_symlink (char *path, dev_t my_dev)
+{
+	static char lpath[PATH_MAX], new[PATH_MAX], abspath[PATH_MAX];
+	char *p, *np, *lp, *tail, *msg;
+	struct stat stbuf, lstbuf;
+	int c, fix_abs = 0, fix_messy = 0, fix_long = 0;
+
+	if ((c = readlink(path, lpath, sizeof(lpath))) == -1) {
+		perror(path);
+		return;
+	}
+	lpath[c] = '\0';	/* readlink does not null terminate it */
+
+	/* construct the absolute address of the link */
+	abspath[0] = '\0';
+	if (lpath[0] != '/') {
+		strcat(abspath,path);
+		c = strlen(abspath);
+		if ((c > 0) && (abspath[c-1] == '/'))
+			abspath[c-1] = '\0'; /* cut trailing / */
+		if ((p = strrchr(abspath,'/')) != NULL)
+			*p = '\0'; /* cut last component */
+		strcat(abspath,"/");
+	}
+	strcat(abspath,lpath);
+	(void) tidy_path(abspath);
+
+	/* check for various things */
+	if (stat(abspath, &stbuf) == -1) {
+		printf("dangling: %s -> %s\n", path, lpath);
+		if (delete) {
+			if (unlink (path)) {
+				perror(path); 
+			} else
+				printf("deleted:  %s -> %s\n", path, lpath);
+		}
+		return;
+	}
+
+	if (single_fs)
+		lstat(abspath, &lstbuf); /* if the above didn't fail, then this shouldn't */
+	
+	if (single_fs && lstbuf.st_dev != my_dev) {
+		msg = "other_fs:";
+	} else if (lpath[0] == '/') {
+		msg = "absolute:";
+		fix_abs = 1;
+	} else if (verbose) {
+		msg = "relative:";
+	} else
+		msg = NULL;
+	fix_messy = tidy_path(strcpy(new,lpath));
+	if (shorten)
+		fix_long = shorten_path(new, path);
+	if (!fix_abs) {
+		if (fix_messy)
+			msg = "messy:   ";
+		else if (fix_long)
+			msg = "lengthy: ";
+	}
+	if (msg != NULL)
+		printf("%s %s -> %s\n", msg, path, lpath);
+	if (!(fix_links || testing) || !(fix_messy || fix_abs || fix_long))
+		return;
+
+	if (fix_abs) {
+		/* convert an absolute link to relative: */
+		/* point tail at first part of lpath that differs from path */
+		/* point p    at first part of path  that differs from lpath */
+		(void) tidy_path(lpath);
+		tail = lp = lpath;
+		p = path;
+		while (*p && (*p == *lp)) {
+			if (*lp++ == '/') {
+				tail = lp;
+				while (*++p == '/');
+			}
+		}
+
+		/* now create new, with "../"s followed by tail */
+		np = new;
+		while (*p) {
+			if (*p++ == '/') {
+				*np++ = '.';
+				*np++ = '.';
+				*np++ = '/';
+				while (*p == '/') ++p;
+			}
+		}
+		strcpy (np, tail);
+		(void) tidy_path(new);
+		if (shorten) (void) shorten_path(new, path);
+	}
+	shorten_path(new,path);
+	if (!testing) {
+		if (unlink (path)) {
+			perror(path);
+			return;
+		}
+		if (symlink(new, path)) {
+			perror(path);
+			return;
+		}
+	}
+	printf("changed:  %s -> %s\n", path, new);
+}
+
+static void dirwalk (char *path, int pathlen, dev_t dev)
+{
+ 	char *name;
+	DIR *dfd;
+	static struct stat st;
+	static struct dirent *dp;
+
+	if ((dfd = opendir(path)) == NULL) {
+		perror(path);
+		return;
+	}
+
+	name = path + pathlen;
+	if (*(name-1) != '/')
+		*name++ = '/'; 
+
+	while ((dp = readdir(dfd)) != NULL ) {
+		strcpy(name, dp->d_name);
+                if (strcmp(name, ".") && strcmp(name,"..")) {
+			if (lstat(path, &st) == -1) {
+				perror(path);
+			} else if (st.st_dev == dev) {
+				if (S_ISLNK(st.st_mode)) {
+					fix_symlink (path, dev);
+				} else if (recurse && S_ISDIR(st.st_mode)) {
+					dirwalk(path, strlen(path), dev);
+				}
+			}
+		}
+	} 
+	closedir(dfd);
+	path[pathlen] = '\0';
+}
+
+static void usage_error (void)
+{
+	fprintf(stderr, progver, progname);
+	fprintf(stderr, "Usage:\t%s [-cdorstv] LINK|DIR ...\n\n", progname);
+	fprintf(stderr, "Flags:"
+		"\t-c == change absolute/messy links to relative\n"
+		"\t-d == delete dangling links\n"
+		"\t-o == warn about links across file systems\n"
+		"\t-r == recurse into subdirs\n"
+		"\t-s == shorten lengthy links (displayed in output only when -c not specified)\n"
+		"\t-t == show what would be done by -c\n"
+		"\t-v == verbose (show all symlinks)\n\n");
+	exit(1);
+}
+
+int main(int argc, char **argv)
+{
+#if defined (_GNU_SOURCE) && defined (__GLIBC__)
+	static char path[PATH_MAX+2];
+	char* cwd = get_current_dir_name();
+#else
+	static char path[PATH_MAX+2], cwd[PATH_MAX+2];
+#endif
+	int dircount = 0;
+	char c, *p;
+
+	if  ((progname = (char *) strrchr(*argv, '/')) == NULL)
+                progname = *argv;
+        else
+                progname++;
+
+#if defined (_GNU_SOURCE) && defined (__GLIBC__)
+	if (NULL == cwd) {
+		fprintf(stderr,"get_current_dir_name() failed\n");
+#else
+	if (NULL == getcwd(cwd,PATH_MAX)) {
+		fprintf(stderr,"getcwd() failed\n");
+#endif
+		exit (1);
+	}
+#if defined (_GNU_SOURCE) && defined (__GLIBC__)
+	cwd = realloc(cwd, strlen(cwd)+2);
+	if (cwd == NULL) {
+		fprintf(stderr, "realloc() failed\n");
+		exit (1);
+	}
+#endif
+	if (!*cwd || cwd[strlen(cwd)-1] != '/')
+		strcat(cwd,"/");
+
+	while (--argc) {
+		p = *++argv;
+		if (*p == '-') {
+			if (*++p == '\0')
+				usage_error();
+			while ((c = *p++)) {
+				     if (c == 'c')	fix_links = 1;
+				else if (c == 'd')	delete    = 1;
+				else if (c == 'o')	single_fs = 0;
+				else if (c == 'r')	recurse   = 1;
+				else if (c == 's')	shorten   = 1;
+				else if (c == 't')	testing   = 1;
+				else if (c == 'v')	verbose   = 1;
+				else			usage_error();
+			}
+		} else {
+			struct stat st;
+			if (*p == '/')
+				*path = '\0';
+			else
+				strcpy(path,cwd);
+			tidy_path(strcat(path, p));
+			if (lstat(path, &st) == -1)
+				perror(path);
+			else if (S_ISLNK(st.st_mode))
+				fix_symlink(path, st.st_dev);
+			else
+				dirwalk(path, strlen(path), st.st_dev);
+			++dircount;
+		}
+	}
+	if (dircount == 0)
+		usage_error();
+	exit (0);
+}