Merge "Split shell_and_utilities into partition parts."
diff --git a/fs_mgr/libdm/dm.cpp b/fs_mgr/libdm/dm.cpp
index 57c1270..e8bae60 100644
--- a/fs_mgr/libdm/dm.cpp
+++ b/fs_mgr/libdm/dm.cpp
@@ -51,23 +51,18 @@
         return false;
     }
 
-    std::unique_ptr<struct dm_ioctl, decltype(&free)> io(
-            static_cast<struct dm_ioctl*>(malloc(sizeof(struct dm_ioctl))), free);
-    if (io == nullptr) {
-        LOG(ERROR) << "Failed to allocate dm_ioctl";
-        return false;
-    }
-    InitIo(io.get(), name);
+    struct dm_ioctl io;
+    InitIo(&io, name);
 
-    if (ioctl(fd_, DM_DEV_CREATE, io.get())) {
-        PLOG(ERROR) << "DM_DEV_CREATE failed to create [" << name << "]";
+    if (ioctl(fd_, DM_DEV_CREATE, &io)) {
+        PLOG(ERROR) << "DM_DEV_CREATE failed for [" << name << "]";
         return false;
     }
 
     // Check to make sure the newly created device doesn't already have targets
     // added or opened by someone
-    CHECK(io->target_count == 0) << "Unexpected targets for newly created [" << name << "] device";
-    CHECK(io->open_count == 0) << "Unexpected opens for newly created [" << name << "] device";
+    CHECK(io.target_count == 0) << "Unexpected targets for newly created [" << name << "] device";
+    CHECK(io.open_count == 0) << "Unexpected opens for newly created [" << name << "] device";
 
     // Creates a new device mapper device with the name passed in
     return true;
@@ -84,22 +79,17 @@
         return false;
     }
 
-    std::unique_ptr<struct dm_ioctl, decltype(&free)> io(
-            static_cast<struct dm_ioctl*>(malloc(sizeof(struct dm_ioctl))), free);
-    if (io == nullptr) {
-        LOG(ERROR) << "Failed to allocate dm_ioctl";
-        return false;
-    }
-    InitIo(io.get(), name);
+    struct dm_ioctl io;
+    InitIo(&io, name);
 
-    if (ioctl(fd_, DM_DEV_REMOVE, io.get())) {
-        PLOG(ERROR) << "DM_DEV_REMOVE failed to create [" << name << "]";
+    if (ioctl(fd_, DM_DEV_REMOVE, &io)) {
+        PLOG(ERROR) << "DM_DEV_REMOVE failed for [" << name << "]";
         return false;
     }
 
     // Check to make sure appropriate uevent is generated so ueventd will
     // do the right thing and remove the corresponding device node and symlinks.
-    CHECK(io->flags & DM_UEVENT_GENERATED_FLAG)
+    CHECK(io.flags & DM_UEVENT_GENERATED_FLAG)
             << "Didn't generate uevent for [" << name << "] removal";
 
     return true;
@@ -147,7 +137,7 @@
     io->data_start = sizeof(*io);
 
     if (ioctl(fd_, DM_LIST_VERSIONS, io)) {
-        PLOG(ERROR) << "Failed to get DM_LIST_VERSIONS from kernel";
+        PLOG(ERROR) << "DM_LIST_VERSIONS failed";
         return false;
     }
 
@@ -209,7 +199,7 @@
     io->data_start = sizeof(*io);
 
     if (ioctl(fd_, DM_LIST_DEVICES, io)) {
-        PLOG(ERROR) << "Failed to get DM_LIST_DEVICES from kernel";
+        PLOG(ERROR) << "DM_LIST_DEVICES failed";
         return false;
     }
 
diff --git a/fs_mgr/tools/dmctl.cpp b/fs_mgr/tools/dmctl.cpp
index b40b83a..e82c718 100644
--- a/fs_mgr/tools/dmctl.cpp
+++ b/fs_mgr/tools/dmctl.cpp
@@ -49,14 +49,14 @@
 
 static int DmCreateCmdHandler(int argc, char** argv) {
     if (argc < 1) {
-        std::cerr << "DmCreateCmdHandler: atleast 'name' MUST be provided for target device";
+        std::cerr << "Usage: dmctl create <name> [table-args]" << std::endl;
         return -EINVAL;
     }
 
     std::string name = argv[0];
     DeviceMapper& dm = DeviceMapper::Instance();
     if (!dm.CreateDevice(name)) {
-        std::cerr << "DmCreateCmdHandler: Failed to create " << name << " device";
+        std::cerr << "Failed to create device-mapper device with name: " << name << std::endl;
         return -EIO;
     }
 
@@ -71,14 +71,14 @@
 
 static int DmDeleteCmdHandler(int argc, char** argv) {
     if (argc < 1) {
-        std::cerr << "DmCreateCmdHandler: atleast 'name' MUST be provided for target device";
+        std::cerr << "Usage: dmctl delete <name>" << std::endl;
         return -EINVAL;
     }
 
     std::string name = argv[0];
     DeviceMapper& dm = DeviceMapper::Instance();
     if (!dm.DeleteDevice(name)) {
-        std::cerr << "DmCreateCmdHandler: Failed to create " << name << " device";
+        std::cerr << "Failed to delete [" << name << "]" << std::endl;
         return -EIO;
     }
 
diff --git a/init/Android.bp b/init/Android.bp
index da0895f..cf7637f 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -227,41 +227,39 @@
         "liblog",
         "libcutils",
     ],
+    srcs: [
+        "action.cpp",
+        "action_manager.cpp",
+        "action_parser.cpp",
+        "capabilities.cpp",
+        "descriptors.cpp",
+        "epoll.cpp",
+        "keychords.cpp",
+        "import_parser.cpp",
+        "host_import_parser.cpp",
+        "host_init_verifier.cpp",
+        "host_init_stubs.cpp",
+        "parser.cpp",
+        "rlimit_parser.cpp",
+        "tokenizer.cpp",
+        "service.cpp",
+        "subcontext.cpp",
+        "subcontext.proto",
+        "util.cpp",
+    ],
     proto: {
         type: "lite",
     },
+    generated_headers: [
+        "generated_stub_builtin_function_map",
+        "generated_android_ids"
+    ],
     target: {
-        linux: {
-            srcs: [
-                "action.cpp",
-                "action_manager.cpp",
-                "action_parser.cpp",
-                "capabilities.cpp",
-                "descriptors.cpp",
-                "epoll.cpp",
-                "keychords.cpp",
-                "import_parser.cpp",
-                "host_import_parser.cpp",
-                "host_init_verifier.cpp",
-                "host_init_stubs.cpp",
-                "parser.cpp",
-                "rlimit_parser.cpp",
-                "tokenizer.cpp",
-                "service.cpp",
-                "subcontext.cpp",
-                "subcontext.proto",
-                "util.cpp",
-            ],
-            generated_headers: [
-                "generated_stub_builtin_function_map",
-                "generated_android_ids",
-            ],
-        },
         android: {
             enabled: false,
         },
         darwin: {
-            srcs: ["mac_init_verifier.cpp"],
+            enabled: false,
         },
     },
 }
diff --git a/init/mac_init_verifier.cpp b/init/mac_init_verifier.cpp
deleted file mode 100644
index 646509e..0000000
--- a/init/mac_init_verifier.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// Copyright (C) 2018 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.
-//
-
-int main() {
-    return 0;
-}
diff --git a/shell_and_utilities/README.md b/shell_and_utilities/README.md
index b15be1f..e310e6b 100644
--- a/shell_and_utilities/README.md
+++ b/shell_and_utilities/README.md
@@ -193,13 +193,15 @@
 Android Q
 ---------
 
+BSD: fsck\_msdos newfs\_msdos
+
 bzip2: bzcat bzip2 bunzip2
 
 one-true-awk: awk
 
 PCRE: egrep fgrep grep
 
-toolbox: getevent getprop newfs\_msdos
+toolbox: getevent getprop
 
 toybox: acpi base64 basename blockdev cal cat chcon chgrp chmod chown
 chroot chrt cksum clear cmp comm cp cpio cut date dd df diff dirname