Merge change 5784

* changes:
  Implement a token table and an arena allocator.
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
index 1a14842..ad4bd74 100644
--- a/include/private/android_filesystem_config.h
+++ b/include/private/android_filesystem_config.h
@@ -62,6 +62,7 @@
 #define AID_NET_BT        3002  /* bluetooth: create sco, rfcomm or l2cap sockets */
 #define AID_INET          3003  /* can create AF_INET and AF_INET6 sockets */
 #define AID_NET_RAW       3004  /* can create raw INET sockets */
+#define AID_NET_ADMIN     3005  /* can configure interfaces and routing tables. */
 
 #define AID_MISC          9998  /* access to misc storage */
 #define AID_NOBODY        9999
@@ -101,6 +102,7 @@
     { "keystore",  AID_KEYSTORE, },
     { "inet",      AID_INET, },
     { "net_raw",   AID_NET_RAW, },
+    { "net_admin", AID_NET_ADMIN, },
     { "misc",      AID_MISC, },
     { "nobody",    AID_NOBODY, },
 };
@@ -135,7 +137,7 @@
     { 00750, AID_ROOT,   AID_SHELL,  "sbin" },
     { 00755, AID_ROOT,   AID_SHELL,  "system/bin" },
     { 00755, AID_ROOT,   AID_SHELL,  "system/xbin" },
-    { 00777, AID_ROOT,   AID_ROOT,   "system/etc/ppp" }, /* REMOVE */
+    { 00755, AID_ROOT,   AID_ROOT,   "system/etc/ppp" },
     { 00777, AID_ROOT,   AID_ROOT,   "sdcard" },
     { 00755, AID_ROOT,   AID_ROOT,   0 },
 };
@@ -147,20 +149,18 @@
 ** and will allow partial matches.
 */
 static struct fs_path_config android_files[] = {
-    { 00555, AID_ROOT,      AID_ROOT,      "system/etc/ppp/ip-up" },
-    { 00555, AID_ROOT,      AID_ROOT,      "system/etc/ppp/ip-down" },
     { 00440, AID_ROOT,      AID_SHELL,     "system/etc/init.goldfish.rc" },
     { 00550, AID_ROOT,      AID_SHELL,     "system/etc/init.goldfish.sh" },
     { 00440, AID_ROOT,      AID_SHELL,     "system/etc/init.trout.rc" },
     { 00550, AID_ROOT,      AID_SHELL,     "system/etc/init.ril" },
     { 00550, AID_ROOT,      AID_SHELL,     "system/etc/init.testmenu" },
-    { 00550, AID_ROOT,      AID_SHELL,     "system/etc/init.gprs-pppd" },
     { 00550, AID_DHCP,      AID_SHELL,     "system/etc/dhcpcd/dhcpcd-run-hooks" },
     { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/dbus.conf" },
     { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluez/main.conf" },
     { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluez/input.conf" },
     { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluez/audio.conf" },
-    { 00440, AID_RADIO,     AID_AUDIO,     "/system/etc/AudioPara4.csv" },
+    { 00440, AID_RADIO,     AID_AUDIO,     "system/etc/AudioPara4.csv" },
+    { 00555, AID_ROOT,      AID_ROOT,      "system/etc/ppp/*" },
     { 00644, AID_SYSTEM,    AID_SYSTEM,    "data/app/*" },
     { 00644, AID_SYSTEM,    AID_SYSTEM,    "data/app-private/*" },
     { 00644, AID_APP,       AID_APP,       "data/data/*" },
diff --git a/init/devices.c b/init/devices.c
index 9b341d6..e76d354 100644
--- a/init/devices.c
+++ b/init/devices.c
@@ -140,7 +140,8 @@
     { "/dev/qmi2",          0640,   AID_RADIO,      AID_RADIO,      0 },
         /* CDMA radio interface MUX */
     { "/dev/ts0710mux",     0640,   AID_RADIO,      AID_RADIO,      1 },
-    { "/dev/tun",           0640,   AID_VPN  ,      AID_VPN,        0 },
+    { "/dev/ppp",           0660,   AID_RADIO,      AID_VPN,        0 },
+    { "/dev/tun",           0640,   AID_VPN,        AID_VPN,        0 },
     { NULL, 0, 0, 0, 0 },
 };
 
diff --git a/init/property_service.c b/init/property_service.c
index 48ca3ea..23a8821 100644
--- a/init/property_service.c
+++ b/init/property_service.c
@@ -67,6 +67,8 @@
     { "wlan.",		AID_SYSTEM },
     { "dhcp.",		AID_SYSTEM },
     { "dhcp.",		AID_DHCP },
+    { "vpn.",		AID_SYSTEM },
+    { "vpn.",		AID_VPN },
     { "debug.",		AID_SHELL },
     { "log.",		AID_SHELL },
     { "service.adb.root",	AID_SHELL },
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index 44e343c..e66b1c3 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -6,16 +6,9 @@
 copy_from := \
 	etc/dbus.conf \
 	etc/init.goldfish.sh \
-	etc/ppp/ip-up \
-	etc/ppp/ip-down \
-	etc/ppp/peers/common \
-	etc/racoon/racoon.conf \
+	etc/ppp/ip-up-vpn \
 	etc/hosts
 
-dont_copy := \
-	etc/init.gprs-pppd \
-	etc/ppp/chap-secrets
-
 copy_to := $(addprefix $(TARGET_OUT)/,$(copy_from))
 copy_from := $(addprefix $(LOCAL_PATH)/,$(copy_from))
 
diff --git a/rootdir/etc/init.gprs-pppd b/rootdir/etc/init.gprs-pppd
deleted file mode 100755
index 521eec9..0000000
--- a/rootdir/etc/init.gprs-pppd
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/system/bin/sh
-# An unforunate wrapper script 
-# so that the exit code of pppd may be retrieved
-
-
-# this is a workaround for issue #651747
-#trap "/system/bin/sleep 1;exit 0" TERM
-
-
-PPPD_PID=
-
-/system/bin/setprop "net.gprs.ppp-exit" ""
-
-/system/bin/log -t pppd "Starting pppd"
-
-/system/bin/pppd $*
-
-PPPD_EXIT=$?
-PPPD_PID=$!
-
-/system/bin/log -t pppd "pppd exited with $PPPD_EXIT"
-
-/system/bin/setprop "net.gprs.ppp-exit" "$PPPD_EXIT"
diff --git a/rootdir/etc/ppp/chap-secrets b/rootdir/etc/ppp/chap-secrets
deleted file mode 100644
index 6546b0f..0000000
--- a/rootdir/etc/ppp/chap-secrets
+++ /dev/null
@@ -1,2 +0,0 @@
-* * bogus
-
diff --git a/rootdir/etc/ppp/ip-down b/rootdir/etc/ppp/ip-down
deleted file mode 100755
index 58d21e5..0000000
--- a/rootdir/etc/ppp/ip-down
+++ /dev/null
@@ -1 +0,0 @@
-#!/system/bin/sh
diff --git a/rootdir/etc/ppp/ip-up b/rootdir/etc/ppp/ip-up
deleted file mode 100755
index 8c8f12c..0000000
--- a/rootdir/etc/ppp/ip-up
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/system/bin/sh
-
-# Use interface name if linkname is not available
-
-/system/bin/setprop "net.dns1" "$DNS1"
-/system/bin/setprop "net.dns2" "$DNS2"
-
-# Retrieve the default gateway from /proc/net/route
-RTAB=`cat /proc/net/route`
-flag=-1; i=0;
-for l in $RTAB; do
-    if (exp flag==1) then DGW=$l; flag=0; fi;
-    if (exp i%11 == 1) then
-        if (exp $l=="00000000") then flag=1; fi;
-    fi;
-    i=`exp i+1`;
-done
-FH=${DGW%????}
-LH=${DGW#????}
-A=`exp 0x${LH#??}`
-B=`exp 0x${LH%??}`
-C=`exp 0x${FH#??}`
-D=`exp 0x${FH%??}`
-GATEWAY="$A.$B.$C.$D"
-VPNSERVER=`getprop "net.vpn.server_ip"`
-
-# Protect the route to vpn server
-/system/bin/route add -net $VPNSERVER netmask 255.255.255.255 gw $GATEWAY
-
-# Route all traffic to vpn connection
-/system/bin/route add -net 0.0.0.0 netmask 128.0.0.0 gw $IPREMOTE
-/system/bin/route add -net 128.0.0.0 netmask 128.0.0.0 gw $IPREMOTE
-
diff --git a/rootdir/etc/ppp/peers/common b/rootdir/etc/ppp/peers/common
deleted file mode 100755
index 4183841..0000000
--- a/rootdir/etc/ppp/peers/common
+++ /dev/null
@@ -1,10 +0,0 @@
-ipcp-accept-local
-ipcp-accept-remote
-refuse-eap
-noccp
-noauth
-idle 1800
-mtu 1400
-mru 1400
-nodefaultroute
-usepeerdns
diff --git a/rootdir/etc/racoon/racoon.conf b/rootdir/etc/racoon/racoon.conf
deleted file mode 100644
index eb50a2d..0000000
--- a/rootdir/etc/racoon/racoon.conf
+++ /dev/null
@@ -1,35 +0,0 @@
-#path certificate "";
-path certificate "/";
-
-sainfo anonymous {
-   encryption_algorithm aes, 3des;
-   authentication_algorithm hmac_sha1, hmac_md5;
-   compression_algorithm deflate;
-   lifetime time 3600 sec;
-}
-
-remote anonymous {
-   exchange_mode main;
-   doi ipsec_doi;
-   situation identity_only;
-   ike_frag on;
-   generate_policy on;
-   my_identifier asn1dn;
-   nat_traversal on; # always use NAT-T
-   ca_type x509 "ca.crt";
-   certificate_type x509 "user.crt" "user.key";
-   verify_identifier off;
-   verify_cert on;
-   nonce_size 16;
-   initial_contact on;
-   proposal_check obey;
-
-   proposal {
-      authentication_method rsasig;
-      hash_algorithm sha1;
-      encryption_algorithm 3des;
-      lifetime time 3600 sec;
-      dh_group 2;
-   }
-}
-
diff --git a/vold/format.c b/vold/format.c
index a1faf7a..d4e2327 100755
--- a/vold/format.c
+++ b/vold/format.c
@@ -39,12 +39,13 @@
     if (!strcmp(type, FORMAT_TYPE_FAT32)) {
         char *args[6];
         args[0] = MKDOSFS_PATH;
-        args[1] = "-c 32";
-        args[2] = "-n 2";
-        args[3] = "-O android";
-        args[4] = devpath;
-        args[5] = NULL;
-        rc = logwrap(5, args, 1);
+        args[1] = "-F 32";
+        args[2] = "-c 32";
+        args[3] = "-n 2";
+        args[4] = "-O android";
+        args[5] = devpath;
+        args[6] = NULL;
+        rc = logwrap(6, args, 1);
     } else {
         char *args[7];
         args[0] = MKE2FS_PATH;