Merge "adb: support /oem partition"
diff --git a/adb/Android.mk b/adb/Android.mk
index 7cfbcb9..8171611 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -90,7 +90,7 @@
 LOCAL_CFLAGS := -DADB_HOST=0 $(LIBADB_CFLAGS)
 LOCAL_SRC_FILES := $(LIBADB_TEST_SRCS)
 LOCAL_STATIC_LIBRARIES := libadbd
-LOCAL_SHARED_LIBRARIES := liblog libbase libcutils
+LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
 include $(BUILD_NATIVE_TEST)
 
 include $(CLEAR_VARS)
@@ -98,11 +98,12 @@
 LOCAL_MODULE := adb_test
 LOCAL_CFLAGS := -DADB_HOST=1 $(LIBADB_CFLAGS)
 LOCAL_SRC_FILES := $(LIBADB_TEST_SRCS) services.cpp
-LOCAL_SHARED_LIBRARIES := liblog libbase
+LOCAL_SHARED_LIBRARIES := liblog
 LOCAL_STATIC_LIBRARIES := \
     libadb \
     libcrypto_static \
     libcutils \
+    libutils \
 
 ifeq ($(HOST_OS),linux)
   LOCAL_LDLIBS += -lrt -ldl -lpthread
diff --git a/adb/adb_io_test.cpp b/adb/adb_io_test.cpp
index 0c69bc9..330d9ce 100644
--- a/adb/adb_io_test.cpp
+++ b/adb/adb_io_test.cpp
@@ -24,7 +24,7 @@
 
 #include <string>
 
-#include "base/file.h"
+#include "utils/file.h"
 
 class TemporaryFile {
  public:
@@ -55,7 +55,7 @@
   TemporaryFile tf;
   ASSERT_NE(-1, tf.fd);
 
-  ASSERT_TRUE(android::base::WriteStringToFd(expected, tf.fd)) << strerror(errno);
+  ASSERT_TRUE(android::WriteStringToFd(expected, tf.fd)) << strerror(errno);
   ASSERT_EQ(0, lseek(tf.fd, SEEK_SET, 0));
 
   // Test reading the whole file.
@@ -69,7 +69,7 @@
   TemporaryFile tf;
   ASSERT_NE(-1, tf.fd);
 
-  ASSERT_TRUE(android::base::WriteStringToFd(expected, tf.fd)) << strerror(errno);
+  ASSERT_TRUE(android::WriteStringToFd(expected, tf.fd)) << strerror(errno);
   ASSERT_EQ(0, lseek(tf.fd, SEEK_SET, 0));
 
   // Test that not having enough data will fail.
@@ -83,7 +83,7 @@
   TemporaryFile tf;
   ASSERT_NE(-1, tf.fd);
 
-  ASSERT_TRUE(android::base::WriteStringToFd(input, tf.fd)) << strerror(errno);
+  ASSERT_TRUE(android::WriteStringToFd(input, tf.fd)) << strerror(errno);
   ASSERT_EQ(0, lseek(tf.fd, SEEK_SET, 0));
 
   // Test reading a partial file.
@@ -106,7 +106,7 @@
   ASSERT_EQ(0, lseek(tf.fd, SEEK_SET, 0));
 
   std::string s;
-  ASSERT_TRUE(android::base::ReadFdToString(tf.fd, &s));
+  ASSERT_TRUE(android::ReadFdToString(tf.fd, &s));
   EXPECT_STREQ(expected, s.c_str());
 }
 
@@ -123,7 +123,7 @@
   expected.pop_back();
 
   std::string s;
-  ASSERT_TRUE(android::base::ReadFdToString(tf.fd, &s));
+  ASSERT_TRUE(android::ReadFdToString(tf.fd, &s));
   EXPECT_EQ(expected, s);
 }
 
@@ -137,6 +137,6 @@
   ASSERT_EQ(0, lseek(tf.fd, SEEK_SET, 0));
 
   std::string s;
-  ASSERT_TRUE(android::base::ReadFdToString(tf.fd, &s));
+  ASSERT_TRUE(android::ReadFdToString(tf.fd, &s));
   EXPECT_STREQ(str, s.c_str());
 }
diff --git a/base/.clang-format b/base/.clang-format
deleted file mode 100644
index 2b83a1f..0000000
--- a/base/.clang-format
+++ /dev/null
@@ -1,11 +0,0 @@
-BasedOnStyle: Google
-AllowShortBlocksOnASingleLine: false
-AllowShortFunctionsOnASingleLine: false
-
-CommentPragmas: NOLINT:.*
-DerivePointerAlignment: false
-IndentWidth: 2
-PointerAlignment: Left
-TabWidth: 2
-UseTab: Never
-PenaltyExcessCharacter: 32
diff --git a/base/Android.mk b/base/Android.mk
deleted file mode 100644
index 3b64ab0..0000000
--- a/base/Android.mk
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-libbase_src_files := \
-    file.cpp \
-    stringprintf.cpp \
-
-libbase_test_src_files := \
-    file_test.cpp \
-    stringprintf_test.cpp \
-
-libbase_cppflags := \
-    -Wall \
-    -Wextra \
-    -Werror \
-
-# Device
-# ------------------------------------------------------------------------------
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbase
-LOCAL_CLANG := true
-LOCAL_SRC_FILES := $(libbase_src_files)
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
-LOCAL_CPPFLAGS := $(libbase_cppflags)
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-LOCAL_MULTILIB := both
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbase
-LOCAL_CLANG := true
-LOCAL_WHOLE_STATIC_LIBRARIES := libbase
-LOCAL_SHARED_LIBRARIES := liblog
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-LOCAL_MULTILIB := both
-include $(BUILD_SHARED_LIBRARY)
-
-# Host
-# ------------------------------------------------------------------------------
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbase
-LOCAL_CLANG := true
-LOCAL_SRC_FILES := $(libbase_src_files)
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
-LOCAL_CPPFLAGS := $(libbase_cppflags)
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-LOCAL_MULTILIB := both
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbase
-LOCAL_CLANG := true
-LOCAL_WHOLE_STATIC_LIBRARIES := libbase
-LOCAL_SHARED_LIBRARIES := liblog
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-LOCAL_MULTILIB := both
-include $(BUILD_HOST_SHARED_LIBRARY)
-
-# Tests
-# ------------------------------------------------------------------------------
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbase_test
-LOCAL_CLANG := true
-LOCAL_SRC_FILES := $(libbase_test_src_files)
-LOCAL_CPPFLAGS := $(libbase_cppflags)
-LOCAL_SHARED_LIBRARIES := libbase
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbase_test
-LOCAL_CLANG := true
-LOCAL_SRC_FILES := $(libbase_test_src_files)
-LOCAL_CPPFLAGS := $(libbase_cppflags)
-LOCAL_SHARED_LIBRARIES := libbase
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-include $(BUILD_HOST_NATIVE_TEST)
diff --git a/base/CPPLINT.cfg b/base/CPPLINT.cfg
deleted file mode 100644
index 5ee068e..0000000
--- a/base/CPPLINT.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-set noparent
-filter=-build/header_guard
diff --git a/base/include/base/macros.h b/base/include/base/macros.h
deleted file mode 100644
index b1ce7c6..0000000
--- a/base/include/base/macros.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UTILS_MACROS_H
-#define UTILS_MACROS_H
-
-#include <stddef.h>  // for size_t
-#include <unistd.h>  // for TEMP_FAILURE_RETRY
-
-// bionic and glibc both have TEMP_FAILURE_RETRY, but eg Mac OS' libc doesn't.
-#ifndef TEMP_FAILURE_RETRY
-#define TEMP_FAILURE_RETRY(exp)            \
-  ({                                       \
-    decltype(exp) _rc;                     \
-    do {                                   \
-      _rc = (exp);                         \
-    } while (_rc == -1 && errno == EINTR); \
-    _rc;                                   \
-  })
-#endif
-
-// A macro to disallow the copy constructor and operator= functions
-// This must be placed in the private: declarations for a class.
-//
-// For disallowing only assign or copy, delete the relevant operator or
-// constructor, for example:
-// void operator=(const TypeName&) = delete;
-// Note, that most uses of DISALLOW_ASSIGN and DISALLOW_COPY are broken
-// semantically, one should either use disallow both or neither. Try to
-// avoid these in new code.
-//
-// When building with C++11 toolchains, just use the language support
-// for explicitly deleted methods.
-#if __cplusplus >= 201103L
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
-  TypeName(const TypeName&) = delete;      \
-  void operator=(const TypeName&) = delete
-#else
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
-  TypeName(const TypeName&);               \
-  void operator=(const TypeName&)
-#endif
-
-// A macro to disallow all the implicit constructors, namely the
-// default constructor, copy constructor and operator= functions.
-//
-// This should be used in the private: declarations for a class
-// that wants to prevent anyone from instantiating it. This is
-// especially useful for classes containing only static methods.
-#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
-  TypeName();                                    \
-  DISALLOW_COPY_AND_ASSIGN(TypeName)
-
-// The arraysize(arr) macro returns the # of elements in an array arr.
-// The expression is a compile-time constant, and therefore can be
-// used in defining new arrays, for example.  If you use arraysize on
-// a pointer by mistake, you will get a compile-time error.
-//
-// One caveat is that arraysize() doesn't accept any array of an
-// anonymous type or a type defined inside a function.  In these rare
-// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below.  This is
-// due to a limitation in C++'s template system.  The limitation might
-// eventually be removed, but it hasn't happened yet.
-
-// This template function declaration is used in defining arraysize.
-// Note that the function doesn't need an implementation, as we only
-// use its type.
-template <typename T, size_t N>
-char(&ArraySizeHelper(T(&array)[N]))[N];  // NOLINT(readability/casting)
-
-#define arraysize(array) (sizeof(ArraySizeHelper(array)))
-
-// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize,
-// but can be used on anonymous types or types defined inside
-// functions.  It's less safe than arraysize as it accepts some
-// (although not all) pointers.  Therefore, you should use arraysize
-// whenever possible.
-//
-// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type
-// size_t.
-//
-// ARRAYSIZE_UNSAFE catches a few type errors.  If you see a compiler error
-//
-//   "warning: division by zero in ..."
-//
-// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer.
-// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays.
-//
-// The following comments are on the implementation details, and can
-// be ignored by the users.
-//
-// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in
-// the array) and sizeof(*(arr)) (the # of bytes in one array
-// element).  If the former is divisible by the latter, perhaps arr is
-// indeed an array, in which case the division result is the # of
-// elements in the array.  Otherwise, arr cannot possibly be an array,
-// and we generate a compiler error to prevent the code from
-// compiling.
-//
-// Since the size of bool is implementation-defined, we need to cast
-// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final
-// result has type size_t.
-//
-// This macro is not perfect as it wrongfully accepts certain
-// pointers, namely where the pointer size is divisible by the pointee
-// size.  Since all our code has to go through a 32-bit compiler,
-// where a pointer is 4 bytes, this means all pointers to a type whose
-// size is 3 or greater than 4 will be (righteously) rejected.
-#define ARRAYSIZE_UNSAFE(a)     \
-  ((sizeof(a) / sizeof(*(a))) / \
-    static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
-
-#define LIKELY(x) __builtin_expect((x), true)
-#define UNLIKELY(x) __builtin_expect((x), false)
-
-#define WARN_UNUSED __attribute__((warn_unused_result))
-
-// A deprecated function to call to create a false use of the parameter, for
-// example:
-//   int foo(int x) { UNUSED(x); return 10; }
-// to avoid compiler warnings. Going forward we prefer ATTRIBUTE_UNUSED.
-template <typename... T>
-void UNUSED(const T&...) {
-}
-
-// An attribute to place on a parameter to a function, for example:
-//   int foo(int x ATTRIBUTE_UNUSED) { return 10; }
-// to avoid compiler warnings.
-#define ATTRIBUTE_UNUSED __attribute__((__unused__))
-
-// The FALLTHROUGH_INTENDED macro can be used to annotate implicit fall-through
-// between switch labels:
-//  switch (x) {
-//    case 40:
-//    case 41:
-//      if (truth_is_out_there) {
-//        ++x;
-//        FALLTHROUGH_INTENDED;  // Use instead of/along with annotations in
-//                               // comments.
-//      } else {
-//        return x;
-//      }
-//    case 42:
-//      ...
-//
-//  As shown in the example above, the FALLTHROUGH_INTENDED macro should be
-//  followed by a semicolon. It is designed to mimic control-flow statements
-//  like 'break;', so it can be placed in most places where 'break;' can, but
-//  only if there are no statements on the execution path between it and the
-//  next switch label.
-//
-//  When compiled with clang in C++11 mode, the FALLTHROUGH_INTENDED macro is
-//  expanded to [[clang::fallthrough]] attribute, which is analysed when
-//  performing switch labels fall-through diagnostic ('-Wimplicit-fallthrough').
-//  See clang documentation on language extensions for details:
-//  http://clang.llvm.org/docs/LanguageExtensions.html#clang__fallthrough
-//
-//  When used with unsupported compilers, the FALLTHROUGH_INTENDED macro has no
-//  effect on diagnostics.
-//
-//  In either case this macro has no effect on runtime behavior and performance
-//  of code.
-#if defined(__clang__) && __cplusplus >= 201103L && defined(__has_warning)
-#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
-#define FALLTHROUGH_INTENDED [[clang::fallthrough]]  // NOLINT
-#endif
-#endif
-
-#ifndef FALLTHROUGH_INTENDED
-#define FALLTHROUGH_INTENDED \
-  do {                       \
-  } while (0)
-#endif
-
-#endif  // UTILS_MACROS_H
diff --git a/base/include/base/file.h b/include/utils/file.h
similarity index 89%
rename from base/include/base/file.h
rename to include/utils/file.h
index ef97742..a80afb1 100644
--- a/base/include/base/file.h
+++ b/include/utils/file.h
@@ -14,14 +14,13 @@
  * limitations under the License.
  */
 
-#ifndef BASE_FILE_H
-#define BASE_FILE_H
+#ifndef UTILS_FILE_H
+#define UTILS_FILE_H
 
-#include <sys/stat.h>
 #include <string>
+#include <sys/stat.h>
 
 namespace android {
-namespace base {
 
 bool ReadFdToString(int fd, std::string* content);
 bool ReadFileToString(const std::string& path, std::string* content);
@@ -34,7 +33,6 @@
                        mode_t mode, uid_t owner, gid_t group);
 #endif
 
-}  // namespace base
-}  // namespace android
+} // namespace android
 
-#endif  // BASE_FILE_H
+#endif
diff --git a/base/include/base/stringprintf.h b/include/utils/stringprintf.h
similarity index 82%
rename from base/include/base/stringprintf.h
rename to include/utils/stringprintf.h
index 195c1de..e7dbac7 100644
--- a/base/include/base/stringprintf.h
+++ b/include/utils/stringprintf.h
@@ -14,27 +14,25 @@
  * limitations under the License.
  */
 
-#ifndef BASE_STRINGPRINTF_H
-#define BASE_STRINGPRINTF_H
+#ifndef UTILS_STRINGPRINTF_H_
+#define UTILS_STRINGPRINTF_H_
 
 #include <stdarg.h>
 #include <string>
 
 namespace android {
-namespace base {
 
 // Returns a string corresponding to printf-like formatting of the arguments.
 std::string StringPrintf(const char* fmt, ...)
-    __attribute__((__format__(__printf__, 1, 2)));
+        __attribute__((__format__(__printf__, 1, 2)));
 
 // Appends a printf-like formatting of the arguments to 'dst'.
 void StringAppendF(std::string* dst, const char* fmt, ...)
-    __attribute__((__format__(__printf__, 2, 3)));
+        __attribute__((__format__(__printf__, 2, 3)));
 
 // Appends a printf-like formatting of the arguments to 'dst'.
 void StringAppendV(std::string* dst, const char* format, va_list ap);
 
-}  // namespace base
 }  // namespace android
 
-#endif  // BASE_STRINGPRINTF_H
+#endif
diff --git a/init/Android.mk b/init/Android.mk
index 5b8094f..ec2861b 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -27,7 +27,6 @@
     parser.cpp \
     util.cpp \
 
-LOCAL_STATIC_LIBRARIES := libbase
 LOCAL_MODULE := libinit
 include $(BUILD_STATIC_LIBRARY)
 
@@ -56,7 +55,7 @@
     libfs_mgr \
     liblogwrap \
     libcutils \
-    libbase \
+    libutils \
     liblog \
     libc \
     libselinux \
@@ -81,7 +80,7 @@
 
 LOCAL_SHARED_LIBRARIES += \
     libcutils \
-    libbase \
+    libutils \
 
 LOCAL_STATIC_LIBRARIES := libinit
 include $(BUILD_NATIVE_TEST)
diff --git a/init/bootchart.cpp b/init/bootchart.cpp
index 530eba8..cc31920 100644
--- a/init/bootchart.cpp
+++ b/init/bootchart.cpp
@@ -32,7 +32,7 @@
 
 #include <string>
 
-#include <base/file.h>
+#include <utils/file.h>
 
 #define LOG_ROOT        "/data/bootchart"
 #define LOG_STAT        LOG_ROOT"/proc_stat.log"
@@ -59,7 +59,7 @@
 
 static long long get_uptime_jiffies() {
     std::string uptime;
-    if (!android::base::ReadFileToString("/proc/uptime", &uptime)) {
+    if (!android::ReadFileToString("/proc/uptime", &uptime)) {
         return 0;
     }
     return 100LL * strtod(uptime.c_str(), NULL);
@@ -82,7 +82,7 @@
     }
 
     std::string kernel_cmdline;
-    android::base::ReadFileToString("/proc/cmdline", &kernel_cmdline);
+    android::ReadFileToString("/proc/cmdline", &kernel_cmdline);
 
     FILE* out = fopen(LOG_HEADER, "we");
     if (out == NULL) {
@@ -106,7 +106,7 @@
     do_log_uptime(log);
 
     std::string content;
-    if (android::base::ReadFileToString(procfile, &content)) {
+    if (android::ReadFileToString(procfile, &content)) {
         fprintf(log, "%s\n", content.c_str());
     }
 }
@@ -127,13 +127,13 @@
             // name from /proc/<pid>/cmdline.
             snprintf(filename, sizeof(filename), "/proc/%d/cmdline", pid);
             std::string cmdline;
-            android::base::ReadFileToString(filename, &cmdline);
+            android::ReadFileToString(filename, &cmdline);
             const char* full_name = cmdline.c_str(); // So we stop at the first NUL.
 
             // Read process stat line.
             snprintf(filename, sizeof(filename), "/proc/%d/stat", pid);
             std::string stat;
-            if (android::base::ReadFileToString(filename, &stat)) {
+            if (android::ReadFileToString(filename, &stat)) {
                 if (!cmdline.empty()) {
                     // Substitute the process name with its real name.
                     size_t open = stat.find('(');
@@ -155,7 +155,7 @@
     int timeout = 0;
 
     std::string start;
-    android::base::ReadFileToString(LOG_STARTFILE, &start);
+    android::ReadFileToString(LOG_STARTFILE, &start);
     if (!start.empty()) {
         timeout = atoi(start.c_str());
     } else {
@@ -164,7 +164,7 @@
         // timeout. this is useful when using -wipe-data since the /data
         // partition is fresh.
         std::string cmdline;
-        android::base::ReadFileToString("/proc/cmdline", &cmdline);
+        android::ReadFileToString("/proc/cmdline", &cmdline);
 #define KERNEL_OPTION  "androidboot.bootchart="
         if (strstr(cmdline.c_str(), KERNEL_OPTION) != NULL) {
             timeout = atoi(cmdline.c_str() + sizeof(KERNEL_OPTION) - 1);
@@ -226,7 +226,7 @@
 
     // Stop if /data/bootchart/stop contains 1.
     std::string stop;
-    if (android::base::ReadFileToString(LOG_STOPFILE, &stop) && stop == "1") {
+    if (android::ReadFileToString(LOG_STOPFILE, &stop) && stop == "1") {
         return -1;
     }
 
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 5d1ad29..543f89b 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -104,12 +104,6 @@
     }
 }
 
-int do_chdir(int nargs, char **args)
-{
-    chdir(args[1]);
-    return 0;
-}
-
 int do_chroot(int nargs, char **args)
 {
     chroot(args[1]);
diff --git a/init/init_parser.cpp b/init/init_parser.cpp
index 7f8e302..5ef54c8 100644
--- a/init/init_parser.cpp
+++ b/init/init_parser.cpp
@@ -121,7 +121,6 @@
     case 'c':
         if (!strcmp(s, "opy")) return K_copy;
         if (!strcmp(s, "apability")) return K_capability;
-        if (!strcmp(s, "hdir")) return K_chdir;
         if (!strcmp(s, "hroot")) return K_chroot;
         if (!strcmp(s, "lass")) return K_class;
         if (!strcmp(s, "lass_start")) return K_class_start;
diff --git a/init/keywords.h b/init/keywords.h
index 0b37e27..4af8c9e 100644
--- a/init/keywords.h
+++ b/init/keywords.h
@@ -1,7 +1,6 @@
 #ifndef KEYWORD
 int do_bootchart_init(int nargs, char **args);
 int do_chroot(int nargs, char **args);
-int do_chdir(int nargs, char **args);
 int do_class_start(int nargs, char **args);
 int do_class_stop(int nargs, char **args);
 int do_class_reset(int nargs, char **args);
@@ -46,7 +45,6 @@
     K_UNKNOWN,
 #endif
     KEYWORD(capability,  OPTION,  0, 0)
-    KEYWORD(chdir,       COMMAND, 1, do_chdir)
     KEYWORD(chroot,      COMMAND, 1, do_chroot)
     KEYWORD(class,       OPTION,  0, 0)
     KEYWORD(class_start, COMMAND, 1, do_class_start)
diff --git a/init/property_service.cpp b/init/property_service.cpp
index ddb8050..05c03d6 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -30,6 +30,8 @@
 #include <cutils/sockets.h>
 #include <cutils/multiuser.h>
 
+#include <utils/file.h>
+
 #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
 #include <sys/_system_properties.h>
 
diff --git a/init/readme.txt b/init/readme.txt
index 368eba1..0a85a95 100644
--- a/init/readme.txt
+++ b/init/readme.txt
@@ -164,9 +164,6 @@
 hostname <name>
    Set the host name.
 
-chdir <directory>
-   Change working directory.
-
 chmod <octal-mode> <path>
    Change file access permissions.
 
diff --git a/init/util.cpp b/init/util.cpp
index c805083..3dddb15 100644
--- a/init/util.cpp
+++ b/init/util.cpp
@@ -32,11 +32,11 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 
-#include <base/file.h>
-
 /* for ANDROID_SOCKET_* */
 #include <cutils/sockets.h>
 
+#include <utils/file.h>
+
 #include <private/android_filesystem_config.h>
 
 #include "init.h"
@@ -168,7 +168,7 @@
         return false;
     }
 
-    bool okay = android::base::ReadFdToString(fd, content);
+    bool okay = android::ReadFdToString(fd, content);
     TEMP_FAILURE_RETRY(close(fd));
     if (okay) {
         content->append("\n", 1);
@@ -181,7 +181,7 @@
     if (fd == -1) {
         return -errno;
     }
-    int result = android::base::WriteStringToFd(content, fd) ? 0 : -errno;
+    int result = android::WriteStringToFd(content, fd) ? 0 : -errno;
     TEMP_FAILURE_RETRY(close(fd));
     return result;
 }
diff --git a/libutils/Android.mk b/libutils/Android.mk
index e9c5f89..7bff14e 100644
--- a/libutils/Android.mk
+++ b/libutils/Android.mk
@@ -39,7 +39,9 @@
 	Tokenizer.cpp \
 	Unicode.cpp \
 	VectorImpl.cpp \
+	file.cpp \
 	misc.cpp \
+	stringprintf.cpp \
 
 host_commonCflags := -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -Werror
 
diff --git a/base/file.cpp b/libutils/file.cpp
similarity index 68%
rename from base/file.cpp
rename to libutils/file.cpp
index 118071e..0690bc2 100644
--- a/base/file.cpp
+++ b/libutils/file.cpp
@@ -14,23 +14,19 @@
  * limitations under the License.
  */
 
-#include "base/file.h"
+#define LOG_TAG "utils.file"
+#include <cutils/log.h>
+
+#include "utils/file.h"
 
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include <string>
+#include <utils/Compat.h> // For TEMP_FAILURE_RETRY on Darwin.
 
-#include "base/macros.h"  // For TEMP_FAILURE_RETRY on Darwin.
-#define LOG_TAG "base.file"
-#include "cutils/log.h"
-
-namespace android {
-namespace base {
-
-bool ReadFdToString(int fd, std::string* content) {
+bool android::ReadFdToString(int fd, std::string* content) {
   content->clear();
 
   char buf[BUFSIZ];
@@ -41,11 +37,10 @@
   return (n == 0) ? true : false;
 }
 
-bool ReadFileToString(const std::string& path, std::string* content) {
+bool android::ReadFileToString(const std::string& path, std::string* content) {
   content->clear();
 
-  int fd =
-      TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_CLOEXEC | O_NOFOLLOW));
+  int fd = TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_CLOEXEC | O_NOFOLLOW));
   if (fd == -1) {
     return false;
   }
@@ -54,7 +49,7 @@
   return result;
 }
 
-bool WriteStringToFd(const std::string& content, int fd) {
+bool android::WriteStringToFd(const std::string& content, int fd) {
   const char* p = content.data();
   size_t left = content.size();
   while (left > 0) {
@@ -77,18 +72,18 @@
 }
 
 #if !defined(_WIN32)
-bool WriteStringToFile(const std::string& content, const std::string& path,
-                       mode_t mode, uid_t owner, gid_t group) {
-  int fd = TEMP_FAILURE_RETRY(
-      open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW,
-           mode));
+bool android::WriteStringToFile(const std::string& content, const std::string& path,
+                                mode_t mode, uid_t owner, gid_t group) {
+  int fd = TEMP_FAILURE_RETRY(open(path.c_str(),
+                                   O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW,
+                                   mode));
   if (fd == -1) {
     ALOGE("android::WriteStringToFile open failed: %s", strerror(errno));
     return false;
   }
 
-  // We do an explicit fchmod here because we assume that the caller really
-  // meant what they said and doesn't want the umask-influenced mode.
+  // We do an explicit fchmod here because we assume that the caller really meant what they
+  // said and doesn't want the umask-influenced mode.
   if (fchmod(fd, mode) == -1) {
     ALOGE("android::WriteStringToFile fchmod failed: %s", strerror(errno));
     return CleanUpAfterFailedWrite(path);
@@ -106,10 +101,10 @@
 }
 #endif
 
-bool WriteStringToFile(const std::string& content, const std::string& path) {
-  int fd = TEMP_FAILURE_RETRY(
-      open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW,
-           DEFFILEMODE));
+bool android::WriteStringToFile(const std::string& content, const std::string& path) {
+  int fd = TEMP_FAILURE_RETRY(open(path.c_str(),
+                                   O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW,
+                                   DEFFILEMODE));
   if (fd == -1) {
     return false;
   }
@@ -118,6 +113,3 @@
   TEMP_FAILURE_RETRY(close(fd));
   return result || CleanUpAfterFailedWrite(path);
 }
-
-}  // namespace base
-}  // namespace android
diff --git a/base/stringprintf.cpp b/libutils/stringprintf.cpp
similarity index 84%
rename from base/stringprintf.cpp
rename to libutils/stringprintf.cpp
index d55ff52..5eaa293 100644
--- a/base/stringprintf.cpp
+++ b/libutils/stringprintf.cpp
@@ -14,16 +14,11 @@
  * limitations under the License.
  */
 
-#include "base/stringprintf.h"
+#include <utils/stringprintf.h>
 
 #include <stdio.h>
 
-#include <string>
-
-namespace android {
-namespace base {
-
-void StringAppendV(std::string* dst, const char* format, va_list ap) {
+void android::StringAppendV(std::string* dst, const char* format, va_list ap) {
   // First try with a small fixed size buffer
   char space[1024];
 
@@ -50,7 +45,7 @@
 
   // Increase the buffer size to the size requested by vsnprintf,
   // plus one for the closing \0.
-  int length = result + 1;
+  int length = result+1;
   char* buf = new char[length];
 
   // Restore the va_list before we use it again
@@ -65,7 +60,7 @@
   delete[] buf;
 }
 
-std::string StringPrintf(const char* fmt, ...) {
+std::string android::StringPrintf(const char* fmt, ...) {
   va_list ap;
   va_start(ap, fmt);
   std::string result;
@@ -74,12 +69,9 @@
   return result;
 }
 
-void StringAppendF(std::string* dst, const char* format, ...) {
+void android::StringAppendF(std::string* dst, const char* format, ...) {
   va_list ap;
   va_start(ap, format);
   StringAppendV(dst, format, ap);
   va_end(ap);
 }
-
-}  // namespace base
-}  // namespace android
diff --git a/libutils/tests/Android.mk b/libutils/tests/Android.mk
index 634f44f..ce288ca 100644
--- a/libutils/tests/Android.mk
+++ b/libutils/tests/Android.mk
@@ -26,9 +26,11 @@
     BasicHashtable_test.cpp \
     BlobCache_test.cpp \
     BitSet_test.cpp \
+    file_test.cpp \
     Looper_test.cpp \
     LruCache_test.cpp \
     String8_test.cpp \
+    stringprintf_test.cpp \
     Unicode_test.cpp \
     Vector_test.cpp \
 
diff --git a/base/file_test.cpp b/libutils/tests/file_test.cpp
similarity index 72%
rename from base/file_test.cpp
rename to libutils/tests/file_test.cpp
index 34b8755..cea18b6 100644
--- a/base/file_test.cpp
+++ b/libutils/tests/file_test.cpp
@@ -14,15 +14,12 @@
  * limitations under the License.
  */
 
-#include "base/file.h"
-
-#include <gtest/gtest.h>
+#include "utils/file.h"
 
 #include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
-
-#include <string>
+#include <gtest/gtest.h>
 
 class TemporaryFile {
  public:
@@ -51,14 +48,14 @@
 TEST(file, ReadFileToString_ENOENT) {
   std::string s("hello");
   errno = 0;
-  ASSERT_FALSE(android::base::ReadFileToString("/proc/does-not-exist", &s));
+  ASSERT_FALSE(android::ReadFileToString("/proc/does-not-exist", &s));
   EXPECT_EQ(ENOENT, errno);
-  EXPECT_EQ("", s);  // s was cleared.
+  EXPECT_EQ("", s); // s was cleared.
 }
 
 TEST(file, ReadFileToString_success) {
   std::string s("hello");
-  ASSERT_TRUE(android::base::ReadFileToString("/proc/version", &s)) << errno;
+  ASSERT_TRUE(android::ReadFileToString("/proc/version", &s)) << errno;
   EXPECT_GT(s.length(), 6U);
   EXPECT_EQ('\n', s[s.length() - 1]);
   s[5] = 0;
@@ -68,36 +65,34 @@
 TEST(file, WriteStringToFile) {
   TemporaryFile tf;
   ASSERT_TRUE(tf.fd != -1);
-  ASSERT_TRUE(android::base::WriteStringToFile("abc", tf.filename)) << errno;
+  ASSERT_TRUE(android::WriteStringToFile("abc", tf.filename)) << errno;
   std::string s;
-  ASSERT_TRUE(android::base::ReadFileToString(tf.filename, &s)) << errno;
+  ASSERT_TRUE(android::ReadFileToString(tf.filename, &s)) << errno;
   EXPECT_EQ("abc", s);
 }
 
 TEST(file, WriteStringToFile2) {
   TemporaryFile tf;
   ASSERT_TRUE(tf.fd != -1);
-  ASSERT_TRUE(android::base::WriteStringToFile("abc", tf.filename, 0660,
-                                               getuid(), getgid()))
-      << errno;
+  ASSERT_TRUE(android::WriteStringToFile("abc", tf.filename, 0660, getuid(), getgid())) << errno;
   struct stat sb;
   ASSERT_EQ(0, stat(tf.filename, &sb));
   ASSERT_EQ(0660U, (sb.st_mode & ~S_IFMT));
   ASSERT_EQ(getuid(), sb.st_uid);
   ASSERT_EQ(getgid(), sb.st_gid);
   std::string s;
-  ASSERT_TRUE(android::base::ReadFileToString(tf.filename, &s)) << errno;
+  ASSERT_TRUE(android::ReadFileToString(tf.filename, &s)) << errno;
   EXPECT_EQ("abc", s);
 }
 
 TEST(file, WriteStringToFd) {
   TemporaryFile tf;
   ASSERT_TRUE(tf.fd != -1);
-  ASSERT_TRUE(android::base::WriteStringToFd("abc", tf.fd));
+  ASSERT_TRUE(android::WriteStringToFd("abc", tf.fd));
 
   ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_SET)) << errno;
 
   std::string s;
-  ASSERT_TRUE(android::base::ReadFdToString(tf.fd, &s)) << errno;
+  ASSERT_TRUE(android::ReadFdToString(tf.fd, &s)) << errno;
   EXPECT_EQ("abc", s);
 }
diff --git a/base/stringprintf_test.cpp b/libutils/tests/stringprintf_test.cpp
similarity index 76%
rename from base/stringprintf_test.cpp
rename to libutils/tests/stringprintf_test.cpp
index 5cc2086..f995452 100644
--- a/base/stringprintf_test.cpp
+++ b/libutils/tests/stringprintf_test.cpp
@@ -14,27 +14,25 @@
  * limitations under the License.
  */
 
-#include "base/stringprintf.h"
+#include <utils/stringprintf.h>
 
 #include <gtest/gtest.h>
 
-#include <string>
-
 TEST(StringPrintfTest, HexSizeT) {
   size_t size = 0x00107e59;
-  EXPECT_EQ("00107e59", android::base::StringPrintf("%08zx", size));
-  EXPECT_EQ("0x00107e59", android::base::StringPrintf("0x%08zx", size));
+  EXPECT_EQ("00107e59", android::StringPrintf("%08zx", size));
+  EXPECT_EQ("0x00107e59", android::StringPrintf("0x%08zx", size));
 }
 
 TEST(StringPrintfTest, StringAppendF) {
   std::string s("a");
-  android::base::StringAppendF(&s, "b");
+  android::StringAppendF(&s, "b");
   EXPECT_EQ("ab", s);
 }
 
 TEST(StringPrintfTest, Errno) {
   errno = 123;
-  android::base::StringPrintf("hello %s", "world");
+  android::StringPrintf("hello %s", "world");
   EXPECT_EQ(123, errno);
 }
 
@@ -42,7 +40,7 @@
   char* buf = new char[n + 1];
   memset(buf, 'x', n);
   buf[n] = '\0';
-  std::string s(android::base::StringPrintf("%s", buf));
+  std::string s(android::StringPrintf("%s", buf));
   EXPECT_EQ(buf, s);
   delete[] buf;
 }
diff --git a/libzipfile/zipfile.c b/libzipfile/zipfile.c
index b903fcf..1032ecc 100644
--- a/libzipfile/zipfile.c
+++ b/libzipfile/zipfile.c
@@ -76,7 +76,7 @@
 };
 
 static int
-uninflate(unsigned char* out, int unlen, const unsigned char* in, int clen)
+inflate_wrapper(unsigned char* out, int unlen, const unsigned char* in, int clen)
 {
     z_stream zstream;
     int err = 0;
@@ -121,7 +121,7 @@
             memcpy(buf, entry->data, entry->uncompressedSize);
             return 0;
         case DEFLATED:
-            return uninflate(buf, bufsize, entry->data, entry->compressedSize);
+            return inflate_wrapper(buf, bufsize, entry->data, entry->compressedSize);
         default:
             return -1;
     }