Merge "bootstat: add reboot,longkey sub-reason to known set"
diff --git a/adb/daemon/include/adbd/usb.h b/adb/daemon/include/adbd/usb.h
index 85a5711..fca3c58 100644
--- a/adb/daemon/include/adbd/usb.h
+++ b/adb/daemon/include/adbd/usb.h
@@ -16,8 +16,6 @@
* limitations under the License.
*/
-#include <linux/usb/functionfs.h>
-
#include <atomic>
#include <condition_variable>
#include <mutex>
@@ -64,9 +62,5 @@
};
usb_handle *create_usb_handle(unsigned num_bufs, unsigned io_size);
-
-struct usb_functionfs_event;
-const char* ffs_event_to_string(enum usb_functionfs_event_type type);
-bool read_functionfs_setup(android::base::borrowed_fd fd, usb_functionfs_event* event);
bool open_functionfs(android::base::unique_fd* control, android::base::unique_fd* bulk_out,
android::base::unique_fd* bulk_in);
diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp
index 48fa771..f4aa9fb 100644
--- a/adb/daemon/usb.cpp
+++ b/adb/daemon/usb.cpp
@@ -66,6 +66,25 @@
static constexpr size_t kUsbWriteQueueDepth = 8;
static constexpr size_t kUsbWriteSize = 4 * PAGE_SIZE;
+static const char* to_string(enum usb_functionfs_event_type type) {
+ switch (type) {
+ case FUNCTIONFS_BIND:
+ return "FUNCTIONFS_BIND";
+ case FUNCTIONFS_UNBIND:
+ return "FUNCTIONFS_UNBIND";
+ case FUNCTIONFS_ENABLE:
+ return "FUNCTIONFS_ENABLE";
+ case FUNCTIONFS_DISABLE:
+ return "FUNCTIONFS_DISABLE";
+ case FUNCTIONFS_SETUP:
+ return "FUNCTIONFS_SETUP";
+ case FUNCTIONFS_SUSPEND:
+ return "FUNCTIONFS_SUSPEND";
+ case FUNCTIONFS_RESUME:
+ return "FUNCTIONFS_RESUME";
+ }
+}
+
enum class TransferDirection : uint64_t {
READ = 0,
WRITE = 1,
@@ -150,12 +169,12 @@
};
struct UsbFfsConnection : public Connection {
- UsbFfsConnection(unique_fd* control, unique_fd read, unique_fd write,
+ UsbFfsConnection(unique_fd control, unique_fd read, unique_fd write,
std::promise<void> destruction_notifier)
: worker_started_(false),
stopped_(false),
destruction_notifier_(std::move(destruction_notifier)),
- control_fd_(control),
+ control_fd_(std::move(control)),
read_fd_(std::move(read)),
write_fd_(std::move(write)) {
LOG(INFO) << "UsbFfsConnection constructed";
@@ -164,6 +183,11 @@
PLOG(FATAL) << "failed to create eventfd";
}
+ monitor_event_fd_.reset(eventfd(0, EFD_CLOEXEC));
+ if (monitor_event_fd_ == -1) {
+ PLOG(FATAL) << "failed to create eventfd";
+ }
+
aio_context_ = ScopedAioContext::Create(kUsbReadQueueDepth + kUsbWriteQueueDepth);
}
@@ -175,6 +199,7 @@
// We need to explicitly close our file descriptors before we notify our destruction,
// because the thread listening on the future will immediately try to reopen the endpoint.
aio_context_.reset();
+ control_fd_.reset();
read_fd_.reset();
write_fd_.reset();
@@ -221,6 +246,13 @@
PLOG(FATAL) << "failed to notify worker eventfd to stop UsbFfsConnection";
}
CHECK_EQ(static_cast<size_t>(rc), sizeof(notify));
+
+ rc = adb_write(monitor_event_fd_.get(), ¬ify, sizeof(notify));
+ if (rc < 0) {
+ PLOG(FATAL) << "failed to notify monitor eventfd to stop UsbFfsConnection";
+ }
+
+ CHECK_EQ(static_cast<size_t>(rc), sizeof(notify));
}
private:
@@ -239,24 +271,33 @@
monitor_thread_ = std::thread([this]() {
adb_thread_setname("UsbFfs-monitor");
+ bool bound = false;
bool enabled = false;
bool running = true;
while (running) {
adb_pollfd pfd[2] = {
- {.fd = control_fd_->get(), .events = POLLIN, .revents = 0},
+ { .fd = control_fd_.get(), .events = POLLIN, .revents = 0 },
+ { .fd = monitor_event_fd_.get(), .events = POLLIN, .revents = 0 },
};
- int rc = TEMP_FAILURE_RETRY(adb_poll(pfd, 2, -1));
+ // If we don't see our first bind within a second, try again.
+ int timeout_ms = bound ? -1 : 1000;
+
+ int rc = TEMP_FAILURE_RETRY(adb_poll(pfd, 2, timeout_ms));
if (rc == -1) {
PLOG(FATAL) << "poll on USB control fd failed";
+ } else if (rc == 0) {
+ LOG(WARNING) << "timed out while waiting for FUNCTIONFS_BIND, trying again";
+ break;
}
if (pfd[1].revents) {
- // We were told to die, continue reading until FUNCTIONFS_UNBIND.
+ // We were told to die.
+ break;
}
struct usb_functionfs_event event;
- rc = TEMP_FAILURE_RETRY(adb_read(control_fd_->get(), &event, sizeof(event)));
+ rc = TEMP_FAILURE_RETRY(adb_read(control_fd_.get(), &event, sizeof(event)));
if (rc == -1) {
PLOG(FATAL) << "failed to read functionfs event";
} else if (rc == 0) {
@@ -268,15 +309,32 @@
}
LOG(INFO) << "USB event: "
- << ffs_event_to_string(
- static_cast<usb_functionfs_event_type>(event.type));
+ << to_string(static_cast<usb_functionfs_event_type>(event.type));
switch (event.type) {
case FUNCTIONFS_BIND:
- LOG(FATAL) << "received FUNCTIONFS_BIND after already opened?";
+ if (bound) {
+ LOG(WARNING) << "received FUNCTIONFS_BIND while already bound?";
+ running = false;
+ break;
+ }
+
+ if (enabled) {
+ LOG(WARNING) << "received FUNCTIONFS_BIND while already enabled?";
+ running = false;
+ break;
+ }
+
+ bound = true;
break;
case FUNCTIONFS_ENABLE:
+ if (!bound) {
+ LOG(WARNING) << "received FUNCTIONFS_ENABLE while not bound?";
+ running = false;
+ break;
+ }
+
if (enabled) {
LOG(WARNING) << "received FUNCTIONFS_ENABLE while already enabled?";
running = false;
@@ -288,6 +346,10 @@
break;
case FUNCTIONFS_DISABLE:
+ if (!bound) {
+ LOG(WARNING) << "received FUNCTIONFS_DISABLE while not bound?";
+ }
+
if (!enabled) {
LOG(WARNING) << "received FUNCTIONFS_DISABLE while not enabled?";
}
@@ -301,12 +363,44 @@
LOG(WARNING) << "received FUNCTIONFS_UNBIND while still enabled?";
}
+ if (!bound) {
+ LOG(WARNING) << "received FUNCTIONFS_UNBIND when not bound?";
+ }
+
+ bound = false;
running = false;
break;
case FUNCTIONFS_SETUP: {
- read_functionfs_setup(*control_fd_, &event);
- break;
+ LOG(INFO) << "received FUNCTIONFS_SETUP control transfer: bRequestType = "
+ << static_cast<int>(event.u.setup.bRequestType)
+ << ", bRequest = " << static_cast<int>(event.u.setup.bRequest)
+ << ", wValue = " << static_cast<int>(event.u.setup.wValue)
+ << ", wIndex = " << static_cast<int>(event.u.setup.wIndex)
+ << ", wLength = " << static_cast<int>(event.u.setup.wLength);
+
+ if ((event.u.setup.bRequestType & USB_DIR_IN)) {
+ LOG(INFO) << "acking device-to-host control transfer";
+ ssize_t rc = adb_write(control_fd_.get(), "", 0);
+ if (rc != 0) {
+ PLOG(ERROR) << "failed to write empty packet to host";
+ break;
+ }
+ } else {
+ std::string buf;
+ buf.resize(event.u.setup.wLength + 1);
+
+ ssize_t rc = adb_read(control_fd_.get(), buf.data(), buf.size());
+ if (rc != event.u.setup.wLength) {
+ LOG(ERROR)
+ << "read " << rc
+ << " bytes when trying to read control request, expected "
+ << event.u.setup.wLength;
+ }
+
+ LOG(INFO) << "control request contents: " << buf;
+ break;
+ }
}
}
}
@@ -332,12 +426,6 @@
uint64_t dummy;
ssize_t rc = adb_read(worker_event_fd_.get(), &dummy, sizeof(dummy));
if (rc == -1) {
- if (errno == EINTR) {
- // We were interrupted either to stop, or because of a backtrace.
- // Check stopped_ again to see if we need to exit.
- continue;
- }
-
PLOG(FATAL) << "failed to read from eventfd";
} else if (rc == 0) {
LOG(FATAL) << "hit EOF on eventfd";
@@ -374,7 +462,6 @@
}
worker_thread_.join();
- worker_started_ = false;
}
void PrepareReadBlock(IoBlock* block, uint64_t id) {
@@ -605,13 +692,10 @@
std::once_flag error_flag_;
unique_fd worker_event_fd_;
+ unique_fd monitor_event_fd_;
ScopedAioContext aio_context_;
-
- // We keep a pointer to the control fd, so that we can reuse it to avoid USB reconfiguration,
- // and still be able to reset it to force a reopen after FUNCTIONFS_UNBIND or running into an
- // unexpected situation.
- unique_fd* control_fd_;
+ unique_fd control_fd_;
unique_fd read_fd_;
unique_fd write_fd_;
@@ -640,16 +724,15 @@
static void usb_ffs_open_thread() {
adb_thread_setname("usb ffs open");
- unique_fd control;
- unique_fd bulk_out;
- unique_fd bulk_in;
-
while (true) {
if (gFfsAioSupported.has_value() && !gFfsAioSupported.value()) {
LOG(INFO) << "failed to use nonblocking ffs, falling back to legacy";
return usb_init_legacy();
}
+ unique_fd control;
+ unique_fd bulk_out;
+ unique_fd bulk_in;
if (!open_functionfs(&control, &bulk_out, &bulk_in)) {
std::this_thread::sleep_for(1s);
continue;
@@ -660,7 +743,7 @@
std::promise<void> destruction_notifier;
std::future<void> future = destruction_notifier.get_future();
transport->SetConnection(std::make_unique<UsbFfsConnection>(
- &control, std::move(bulk_out), std::move(bulk_in),
+ std::move(control), std::move(bulk_out), std::move(bulk_in),
std::move(destruction_notifier)));
register_transport(transport);
future.wait();
diff --git a/adb/daemon/usb_ffs.cpp b/adb/daemon/usb_ffs.cpp
index 5fbca3b..a64ce40 100644
--- a/adb/daemon/usb_ffs.cpp
+++ b/adb/daemon/usb_ffs.cpp
@@ -248,56 +248,6 @@
};
// clang-format on
-const char* ffs_event_to_string(enum usb_functionfs_event_type type) {
- switch (type) {
- case FUNCTIONFS_BIND:
- return "FUNCTIONFS_BIND";
- case FUNCTIONFS_UNBIND:
- return "FUNCTIONFS_UNBIND";
- case FUNCTIONFS_ENABLE:
- return "FUNCTIONFS_ENABLE";
- case FUNCTIONFS_DISABLE:
- return "FUNCTIONFS_DISABLE";
- case FUNCTIONFS_SETUP:
- return "FUNCTIONFS_SETUP";
- case FUNCTIONFS_SUSPEND:
- return "FUNCTIONFS_SUSPEND";
- case FUNCTIONFS_RESUME:
- return "FUNCTIONFS_RESUME";
- }
-}
-
-bool read_functionfs_setup(borrowed_fd fd, usb_functionfs_event* event) {
- LOG(INFO) << "received FUNCTIONFS_SETUP control transfer: bRequestType = "
- << static_cast<int>(event->u.setup.bRequestType)
- << ", bRequest = " << static_cast<int>(event->u.setup.bRequest)
- << ", wValue = " << static_cast<int>(event->u.setup.wValue)
- << ", wIndex = " << static_cast<int>(event->u.setup.wIndex)
- << ", wLength = " << static_cast<int>(event->u.setup.wLength);
-
- if ((event->u.setup.bRequestType & USB_DIR_IN)) {
- LOG(INFO) << "acking device-to-host control transfer";
- ssize_t rc = adb_write(fd.get(), "", 0);
- if (rc != 0) {
- PLOG(ERROR) << "failed to write empty packet to host";
- return false;
- }
- } else {
- std::string buf;
- buf.resize(event->u.setup.wLength + 1);
-
- ssize_t rc = adb_read(fd.get(), buf.data(), buf.size());
- if (rc != event->u.setup.wLength) {
- LOG(ERROR) << "read " << rc << " bytes when trying to read control request, expected "
- << event->u.setup.wLength;
- }
-
- LOG(INFO) << "control request contents: " << buf;
- }
-
- return true;
-}
-
bool open_functionfs(android::base::unique_fd* out_control, android::base::unique_fd* out_bulk_out,
android::base::unique_fd* out_bulk_in) {
unique_fd control, bulk_out, bulk_in;
@@ -347,37 +297,11 @@
PLOG(ERROR) << "failed to write USB strings";
return false;
}
-
- // Signal init after we've written our descriptors.
+ // Signal only when writing the descriptors to ffs
android::base::SetProperty("sys.usb.ffs.ready", "1");
*out_control = std::move(control);
}
- // Read until we get FUNCTIONFS_BIND from the control endpoint.
- while (true) {
- struct usb_functionfs_event event;
- ssize_t rc = TEMP_FAILURE_RETRY(adb_read(*out_control, &event, sizeof(event)));
-
- if (rc == -1) {
- PLOG(FATAL) << "failed to read from FFS control fd";
- } else if (rc == 0) {
- LOG(WARNING) << "hit EOF on functionfs control fd during initialization";
- } else if (rc != sizeof(event)) {
- LOG(FATAL) << "read functionfs event of unexpected size, expected " << sizeof(event)
- << ", got " << rc;
- }
-
- LOG(INFO) << "USB event: "
- << ffs_event_to_string(static_cast<usb_functionfs_event_type>(event.type));
- if (event.type == FUNCTIONFS_BIND) {
- break;
- } else if (event.type == FUNCTIONFS_SETUP) {
- read_functionfs_setup(*out_control, &event);
- } else {
- continue;
- }
- }
-
bulk_out.reset(adb_open(USB_FFS_ADB_OUT, O_RDONLY));
if (bulk_out < 0) {
PLOG(ERROR) << "cannot open bulk-out endpoint " << USB_FFS_ADB_OUT;
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 44cac4b..d9b1b85 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -588,7 +588,12 @@
if (!ReadFstabFromFile(fstab_file, &fstab)) {
return Error() << "Could not read fstab";
}
- auto mount_fstab_return_code = fs_mgr_mount_all(&fstab, mount_mode);
+
+ auto mount_fstab_return_code =
+ CallFunctionAndHandleProperties(fs_mgr_mount_all, &fstab, mount_mode);
+ if (!mount_fstab_return_code) {
+ return Error() << "Could not call fs_mgr_mount_all(): " << mount_fstab_return_code.error();
+ }
property_set(prop_name, std::to_string(t.duration().count()));
if (import_rc && SelinuxGetVendorAndroidVersion() <= __ANDROID_API_Q__) {
@@ -599,7 +604,7 @@
if (queue_event) {
/* queue_fs_event will queue event based on mount_fstab return code
* and return processed return code*/
- auto queue_fs_result = queue_fs_event(mount_fstab_return_code);
+ auto queue_fs_result = queue_fs_event(*mount_fstab_return_code);
if (!queue_fs_result) {
return Error() << "queue_fs_event() failed: " << queue_fs_result.error();
}
@@ -615,8 +620,13 @@
return Error() << "Could not read fstab";
}
- if (auto result = fs_mgr_umount_all(&fstab); result != 0) {
- return Error() << "umount_fstab() failed " << result;
+ auto result = CallFunctionAndHandleProperties(fs_mgr_umount_all, &fstab);
+ if (!result) {
+ return Error() << "Could not call fs_mgr_mount_all() " << result.error();
+ }
+
+ if (*result != 0) {
+ return Error() << "fs_mgr_mount_all() failed: " << *result;
}
return {};
}
@@ -627,8 +637,13 @@
return Error() << "Could not read fstab '" << args[1] << "'";
}
- if (!fs_mgr_swapon_all(fstab)) {
- return Error() << "fs_mgr_swapon_all() failed";
+ auto result = CallFunctionAndHandleProperties(fs_mgr_swapon_all, fstab);
+ if (!result) {
+ return Error() << "Could not call fs_mgr_swapon_all() " << result.error();
+ }
+
+ if (*result == 0) {
+ return Error() << "fs_mgr_swapon_all() failed.";
}
return {};
diff --git a/init/init.cpp b/init/init.cpp
index 1412e4a..0d3b99f 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -198,6 +198,14 @@
if (property_triggers_enabled) ActionManager::GetInstance().QueuePropertyChange(name, value);
+ // We always record how long init waited for ueventd to tell us cold boot finished.
+ // If we aren't waiting on this property, it means that ueventd finished before we even started
+ // to wait.
+ if (name == kColdBootDoneProp) {
+ auto time_waited = waiting_for_prop ? waiting_for_prop->duration().count() : 0;
+ property_set("ro.boottime.init.cold_boot_wait", std::to_string(time_waited));
+ }
+
if (waiting_for_prop) {
if (wait_prop_name == name && wait_prop_value == value) {
LOG(INFO) << "Wait for property '" << wait_prop_name << "=" << wait_prop_value
@@ -331,23 +339,10 @@
}
static Result<void> wait_for_coldboot_done_action(const BuiltinArguments& args) {
- Timer t;
-
- LOG(VERBOSE) << "Waiting for " COLDBOOT_DONE "...";
-
- // Historically we had a 1s timeout here because we weren't otherwise
- // tracking boot time, and many OEMs made their sepolicy regular
- // expressions too expensive (http://b/19899875).
-
- // Now we're tracking boot time, just log the time taken to a system
- // property. We still panic if it takes more than a minute though,
- // because any build that slow isn't likely to boot at all, and we'd
- // rather any test lab devices fail back to the bootloader.
- if (wait_for_file(COLDBOOT_DONE, 60s) < 0) {
- LOG(FATAL) << "Timed out waiting for " COLDBOOT_DONE;
+ if (!start_waiting_for_property(kColdBootDoneProp, "true")) {
+ LOG(FATAL) << "Could not wait for '" << kColdBootDoneProp << "'";
}
- property_set("ro.boottime.init.cold_boot_wait", std::to_string(t.duration().count()));
return {};
}
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 14bb819..1520c9f 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -39,6 +39,7 @@
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
+#include <atomic>
#include <map>
#include <memory>
#include <mutex>
@@ -52,6 +53,7 @@
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
+#include <android-base/unique_fd.h>
#include <property_info_parser/property_info_parser.h>
#include <property_info_serializer/property_info_serializer.h>
#include <selinux/android.h>
@@ -59,7 +61,6 @@
#include <selinux/selinux.h>
#include "debug_ramdisk.h"
-#include "epoll.h"
#include "init.h"
#include "persistent_properties.h"
#include "property_type.h"
@@ -76,6 +77,7 @@
using android::base::StringPrintf;
using android::base::Timer;
using android::base::Trim;
+using android::base::unique_fd;
using android::base::WriteStringToFile;
using android::properties::BuildTrie;
using android::properties::ParsePropertyInfoFile;
@@ -1006,5 +1008,42 @@
}
}
+Result<int> CallFunctionAndHandlePropertiesImpl(const std::function<int()>& f) {
+ unique_fd reader;
+ unique_fd writer;
+ if (!Socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, &reader, &writer)) {
+ return ErrnoError() << "Could not create socket pair";
+ }
+
+ int result = 0;
+ std::atomic<bool> end = false;
+ auto thread = std::thread{[&f, &result, &end, &writer] {
+ result = f();
+ end = true;
+ send(writer, "1", 1, 0);
+ }};
+
+ Epoll epoll;
+ if (auto result = epoll.Open(); !result) {
+ return Error() << "Could not create epoll: " << result.error();
+ }
+ if (auto result = epoll.RegisterHandler(property_set_fd, handle_property_set_fd); !result) {
+ return Error() << "Could not register epoll handler for property fd: " << result.error();
+ }
+
+ // No-op function, just used to break from loop.
+ if (auto result = epoll.RegisterHandler(reader, [] {}); !result) {
+ return Error() << "Could not register epoll handler for ending thread:" << result.error();
+ }
+
+ while (!end) {
+ epoll.Wait({});
+ }
+
+ thread.join();
+
+ return result;
+}
+
} // namespace init
} // namespace android
diff --git a/init/property_service.h b/init/property_service.h
index 7f9f844..dc47b4d 100644
--- a/init/property_service.h
+++ b/init/property_service.h
@@ -18,9 +18,11 @@
#include <sys/socket.h>
+#include <functional>
#include <string>
#include "epoll.h"
+#include "result.h"
namespace android {
namespace init {
@@ -37,5 +39,13 @@
void load_persist_props();
void StartPropertyService(Epoll* epoll);
+template <typename F, typename... Args>
+Result<int> CallFunctionAndHandleProperties(F&& f, Args&&... args) {
+ Result<int> CallFunctionAndHandlePropertiesImpl(const std::function<int()>& f);
+
+ auto func = [&] { return f(args...); };
+ return CallFunctionAndHandlePropertiesImpl(func);
+}
+
} // namespace init
} // namespace android
diff --git a/init/ueventd.cpp b/init/ueventd.cpp
index f550bc2..3b9de0f 100644
--- a/init/ueventd.cpp
+++ b/init/ueventd.cpp
@@ -214,7 +214,7 @@
WaitForSubProcesses();
- close(open(COLDBOOT_DONE, O_WRONLY | O_CREAT | O_CLOEXEC, 0000));
+ android::base::SetProperty(kColdBootDoneProp, "true");
LOG(INFO) << "Coldboot took " << cold_boot_timer.duration().count() / 1000.0f << " seconds";
}
@@ -256,7 +256,7 @@
}
UeventListener uevent_listener(ueventd_configuration.uevent_socket_rcvbuf_size);
- if (access(COLDBOOT_DONE, F_OK) != 0) {
+ if (!android::base::GetBoolProperty(kColdBootDoneProp, false)) {
ColdBoot cold_boot(uevent_listener, uevent_handlers);
cold_boot.Run();
}
diff --git a/init/util.h b/init/util.h
index 770084b..1929cb5 100644
--- a/init/util.h
+++ b/init/util.h
@@ -30,14 +30,14 @@
#include "result.h"
-#define COLDBOOT_DONE "/dev/.coldboot_done"
-
using android::base::boot_clock;
using namespace std::chrono_literals;
namespace android {
namespace init {
+static const char kColdBootDoneProp[] = "ro.cold_boot_done";
+
int CreateSocket(const char* name, int type, bool passcred, mode_t perm, uid_t uid, gid_t gid,
const char* socketcon);
diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp
index 5b5f2eb..897a169 100644
--- a/libcutils/fs_config.cpp
+++ b/libcutils/fs_config.cpp
@@ -39,6 +39,8 @@
#include <private/android_filesystem_config.h>
#include <utils/Compat.h>
+#include "fs_config.h"
+
#ifndef O_BINARY
#define O_BINARY 0
#endif
@@ -47,6 +49,7 @@
using android::base::StartsWith;
#define ALIGN(x, alignment) (((x) + ((alignment)-1)) & ~((alignment)-1))
+#define CAP_MASK_LONG(cap_name) (1ULL << (cap_name))
// Rules for directories.
// These rules are applied based on "first match", so they
diff --git a/libcutils/fs_config.h b/libcutils/fs_config.h
new file mode 100644
index 0000000..66ad48b
--- /dev/null
+++ b/libcutils/fs_config.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+// Binary format for the runtime <partition>/etc/fs_config_(dirs|files) filesystem override files.
+struct fs_path_config_from_file {
+ uint16_t len;
+ uint16_t mode;
+ uint16_t uid;
+ uint16_t gid;
+ uint64_t capabilities;
+ char prefix[];
+} __attribute__((__aligned__(sizeof(uint64_t))));
+
+struct fs_path_config {
+ unsigned mode;
+ unsigned uid;
+ unsigned gid;
+ uint64_t capabilities;
+ const char* prefix;
+};
diff --git a/libcutils/fs_config_test.cpp b/libcutils/fs_config_test.cpp
index c26315f..9627152 100644
--- a/libcutils/fs_config_test.cpp
+++ b/libcutils/fs_config_test.cpp
@@ -25,7 +25,8 @@
#include <android-base/strings.h>
#include <private/android_filesystem_config.h>
-#include <private/fs_config.h>
+
+#include "fs_config.h"
extern const fs_path_config* __for_testing_only__android_dirs;
extern const fs_path_config* __for_testing_only__android_files;
diff --git a/libcutils/include/private/fs_config.h b/libcutils/include/private/fs_config.h
index 603cf1a..8a9a1ff 100644
--- a/libcutils/include/private/fs_config.h
+++ b/libcutils/include/private/fs_config.h
@@ -19,44 +19,17 @@
** by the device side of adb.
*/
-#ifndef _LIBS_CUTILS_PRIVATE_FS_CONFIG_H
-#define _LIBS_CUTILS_PRIVATE_FS_CONFIG_H
+#pragma once
#include <stdint.h>
#include <sys/cdefs.h>
-#include <sys/types.h>
#if defined(__BIONIC__)
#include <linux/capability.h>
#else // defined(__BIONIC__)
-#include "android_filesystem_capability.h"
+#include <private/android_filesystem_capability.h>
#endif // defined(__BIONIC__)
-#define CAP_MASK_LONG(cap_name) (1ULL << (cap_name))
-
-/*
- * binary format for the runtime <partition>/etc/fs_config_(dirs|files)
- * filesystem override files.
- */
-
-/* The following structure is stored little endian */
-struct fs_path_config_from_file {
- uint16_t len;
- uint16_t mode;
- uint16_t uid;
- uint16_t gid;
- uint64_t capabilities;
- char prefix[];
-} __attribute__((__aligned__(sizeof(uint64_t))));
-
-struct fs_path_config {
- unsigned mode;
- unsigned uid;
- unsigned gid;
- uint64_t capabilities;
- const char* prefix;
-};
-
/* Rules for directories and files has moved to system/code/libcutils/fs_config.c */
__BEGIN_DECLS
@@ -75,5 +48,3 @@
unsigned* mode, uint64_t* capabilities);
__END_DECLS
-
-#endif /* _LIBS_CUTILS_PRIVATE_FS_CONFIG_H */
diff --git a/logd/tests/logd_test.cpp b/logd/tests/logd_test.cpp
index 447b067..b6c33d7 100644
--- a/logd/tests/logd_test.cpp
+++ b/logd/tests/logd_test.cpp
@@ -952,7 +952,7 @@
void __android_log_btwrite_multiple__helper(int count) {
#ifdef __ANDROID__
log_time ts(CLOCK_MONOTONIC);
-
+ usleep(100);
log_time ts1(CLOCK_MONOTONIC);
// We fork to create a unique pid for the submitted log messages