Merge "Add OWNERS file"
diff --git a/adb/client/adb_install.cpp b/adb/client/adb_install.cpp
index 7f37c45..079a975 100644
--- a/adb/client/adb_install.cpp
+++ b/adb/client/adb_install.cpp
@@ -226,18 +226,8 @@
static int install_app_legacy(int argc, const char** argv, bool use_fastdeploy,
bool use_localagent) {
- static const char* const DATA_DEST = "/data/local/tmp/%s";
- static const char* const SD_DEST = "/sdcard/tmp/%s";
- const char* where = DATA_DEST;
-
printf("Performing Push Install\n");
- for (int i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-s")) {
- where = SD_DEST;
- }
- }
-
// Find last APK argument.
// All other arguments passed through verbatim.
int last_apk = -1;
@@ -256,7 +246,7 @@
int result = -1;
std::vector<const char*> apk_file = {argv[last_apk]};
std::string apk_dest =
- android::base::StringPrintf(where, android::base::Basename(argv[last_apk]).c_str());
+ "/data/local/tmp/" + android::base::Basename(argv[last_apk]);
if (use_fastdeploy == true) {
TemporaryFile metadataTmpFile;
diff --git a/adb/client/commandline.cpp b/adb/client/commandline.cpp
index c11052d..95e66ae 100644
--- a/adb/client/commandline.cpp
+++ b/adb/client/commandline.cpp
@@ -146,10 +146,8 @@
" install [-lrtsdg] [--instant] PACKAGE\n"
" install-multiple [-lrtsdpg] [--instant] PACKAGE...\n"
" push package(s) to the device and install them\n"
- " -l: forward lock application\n"
" -r: replace existing application\n"
" -t: allow test packages\n"
- " -s: install application on sdcard\n"
" -d: allow version code downgrade (debuggable packages only)\n"
" -p: partial application install (install-multiple only)\n"
" -g: grant all runtime permissions\n"
diff --git a/adb/client/fastdeploy.cpp b/adb/client/fastdeploy.cpp
index 45f3cca..e82f15a 100644
--- a/adb/client/fastdeploy.cpp
+++ b/adb/client/fastdeploy.cpp
@@ -228,11 +228,12 @@
android::base::StringPrintf(kAgentExtractCommandPattern, packageName.c_str());
std::vector<char> extractErrorBuffer;
- int statusCode;
- DeployAgentFileCallback cb(outputFp, &extractErrorBuffer, &statusCode);
+ DeployAgentFileCallback cb(outputFp, &extractErrorBuffer);
int returnCode = send_shell_command(extractCommand, false, &cb);
if (returnCode != 0) {
- error_exit("Executing %s returned %d", extractCommand.c_str(), returnCode);
+ fprintf(stderr, "Executing %s returned %d\n", extractCommand.c_str(), returnCode);
+ fprintf(stderr, "%*s\n", int(extractErrorBuffer.size()), extractErrorBuffer.data());
+ error_exit("Aborting");
}
}
diff --git a/adb/client/fastdeploycallbacks.cpp b/adb/client/fastdeploycallbacks.cpp
index 6c9a21f..23a0aca 100644
--- a/adb/client/fastdeploycallbacks.cpp
+++ b/adb/client/fastdeploycallbacks.cpp
@@ -35,8 +35,7 @@
class DeployAgentBufferCallback : public StandardStreamsCallbackInterface {
public:
- DeployAgentBufferCallback(std::vector<char>* outBuffer, std::vector<char>* errBuffer,
- int* statusCode);
+ DeployAgentBufferCallback(std::vector<char>* outBuffer, std::vector<char>* errBuffer);
virtual void OnStdout(const char* buffer, int length);
virtual void OnStderr(const char* buffer, int length);
@@ -45,27 +44,17 @@
private:
std::vector<char>* mpOutBuffer;
std::vector<char>* mpErrBuffer;
- int* mpStatusCode;
};
int capture_shell_command(const char* command, std::vector<char>* outBuffer,
std::vector<char>* errBuffer) {
- int statusCode;
- DeployAgentBufferCallback cb(outBuffer, errBuffer, &statusCode);
- int ret = send_shell_command(command, false, &cb);
-
- if (ret == 0) {
- return statusCode;
- } else {
- return ret;
- }
+ DeployAgentBufferCallback cb(outBuffer, errBuffer);
+ return send_shell_command(command, false, &cb);
}
-DeployAgentFileCallback::DeployAgentFileCallback(FILE* outputFile, std::vector<char>* errBuffer,
- int* statusCode) {
+DeployAgentFileCallback::DeployAgentFileCallback(FILE* outputFile, std::vector<char>* errBuffer) {
mpOutFile = outputFile;
mpErrBuffer = errBuffer;
- mpStatusCode = statusCode;
mBytesWritten = 0;
}
@@ -84,10 +73,7 @@
}
int DeployAgentFileCallback::Done(int status) {
- if (mpStatusCode != NULL) {
- *mpStatusCode = status;
- }
- return 0;
+ return status;
}
int DeployAgentFileCallback::getBytesWritten() {
@@ -95,11 +81,9 @@
}
DeployAgentBufferCallback::DeployAgentBufferCallback(std::vector<char>* outBuffer,
- std::vector<char>* errBuffer,
- int* statusCode) {
+ std::vector<char>* errBuffer) {
mpOutBuffer = outBuffer;
mpErrBuffer = errBuffer;
- mpStatusCode = statusCode;
}
void DeployAgentBufferCallback::OnStdout(const char* buffer, int length) {
@@ -111,8 +95,5 @@
}
int DeployAgentBufferCallback::Done(int status) {
- if (mpStatusCode != NULL) {
- *mpStatusCode = status;
- }
- return 0;
+ return status;
}
diff --git a/adb/client/fastdeploycallbacks.h b/adb/client/fastdeploycallbacks.h
index b428b50..7e049c5 100644
--- a/adb/client/fastdeploycallbacks.h
+++ b/adb/client/fastdeploycallbacks.h
@@ -21,7 +21,7 @@
class DeployAgentFileCallback : public StandardStreamsCallbackInterface {
public:
- DeployAgentFileCallback(FILE* outputFile, std::vector<char>* errBuffer, int* statusCode);
+ DeployAgentFileCallback(FILE* outputFile, std::vector<char>* errBuffer);
virtual void OnStdout(const char* buffer, int length);
virtual void OnStderr(const char* buffer, int length);
@@ -33,7 +33,6 @@
FILE* mpOutFile;
std::vector<char>* mpErrBuffer;
int mBytesWritten;
- int* mpStatusCode;
};
int capture_shell_command(const char* command, std::vector<char>* outBuffer,
diff --git a/base/file.cpp b/base/file.cpp
index d5bb7fe..2f4a517 100644
--- a/base/file.cpp
+++ b/base/file.cpp
@@ -22,6 +22,7 @@
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
diff --git a/base/logging.cpp b/base/logging.cpp
index bd09069..f89168c 100644
--- a/base/logging.cpp
+++ b/base/logging.cpp
@@ -417,6 +417,14 @@
}
std::string msg(data_->ToString());
+ if (data_->GetSeverity() == FATAL) {
+#ifdef __ANDROID__
+ // Set the bionic abort message early to avoid liblog doing it
+ // with the individual lines, so that we get the whole message.
+ android_set_abort_message(msg.c_str());
+#endif
+ }
+
{
// Do the actual logging with the lock held.
std::lock_guard<std::mutex> lock(LoggingLock());
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index fee0857..b717aef 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -1541,7 +1541,7 @@
return false;
}
auto path = find_item_given_name("super_empty.img");
- if (path.empty()) {
+ if (path.empty() || access(path.c_str(), R_OK)) {
return false;
}
auto metadata = android::fs_mgr::ReadFromImageFile(path);
diff --git a/fs_mgr/README.overlayfs.md b/fs_mgr/README.overlayfs.md
index 2d42d6c..fbb5f5d 100644
--- a/fs_mgr/README.overlayfs.md
+++ b/fs_mgr/README.overlayfs.md
@@ -89,6 +89,18 @@
if higher than 4.6.
- *adb enable-verity* will free up overlayfs and as a bonus the
device will be reverted pristine to before any content was updated.
+ Update engine does not take advantage of this, will perform a full OTA.
+- Update engine will not run if *fs_mgr_overlayfs_is_setup*() reports
+ true as adb remount overrides are incompatable with an OTA for
+ multiple reasons.
+ NB: This is not a problem for fastbootd or recovery as overrides are
+ disabled for those special boot scenarios.
+- For implementation simplicity on retrofit dynamic partition devices,
+ take the whole alternate super (eg: if "*a*" slot, then the whole of
+ "*system_b*").
+ Since landing a filesystem on the alternate super physical device
+ without differentiating if it is setup to support logical or physical,
+ the alternate slot metadata and previous content will be lost.
- If dynamic partitions runs out of space, resizing a logical
partition larger may fail because of the scratch partition.
If this happens, either fastboot flashall or adb enable-verity can
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 750ed71..60ce452 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -83,6 +83,8 @@
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
using android::base::Realpath;
+using android::base::StartsWith;
+using android::base::unique_fd;
using android::dm::DeviceMapper;
using android::dm::DmDeviceState;
using android::fs_mgr::AvbHandle;
@@ -525,26 +527,15 @@
}
}
-/*
- * Mark the given block device as read-only, using the BLKROSET ioctl.
- * Return 0 on success, and -1 on error.
- */
-int fs_mgr_set_blk_ro(const char *blockdev)
-{
- int fd;
- int rc = -1;
- int ON = 1;
-
- fd = TEMP_FAILURE_RETRY(open(blockdev, O_RDONLY | O_CLOEXEC));
+// Mark the given block device as read-only, using the BLKROSET ioctl.
+bool fs_mgr_set_blk_ro(const std::string& blockdev) {
+ unique_fd fd(TEMP_FAILURE_RETRY(open(blockdev.c_str(), O_RDONLY | O_CLOEXEC)));
if (fd < 0) {
- // should never happen
- return rc;
+ return false;
}
- rc = ioctl(fd, BLKROSET, &ON);
- close(fd);
-
- return rc;
+ int ON = 1;
+ return ioctl(fd, BLKROSET, &ON) == 0;
}
// Orange state means the device is unlocked, see the following link for details.
@@ -712,82 +703,65 @@
return 0;
}
-static int translate_ext_labels(struct fstab_rec *rec)
-{
- DIR *blockdir = NULL;
- struct dirent *ent;
- char *label;
- size_t label_len;
- int ret = -1;
-
- if (strncmp(rec->blk_device, "LABEL=", 6))
- return 0;
-
- label = rec->blk_device + 6;
- label_len = strlen(label);
-
- if (label_len > 16) {
- LERROR << "FS label is longer than allowed by filesystem";
- goto out;
+static bool TranslateExtLabels(fstab_rec* rec) {
+ if (!StartsWith(rec->blk_device, "LABEL=")) {
+ return true;
}
+ std::string label = rec->blk_device + 6;
+ if (label.size() > 16) {
+ LERROR << "FS label is longer than allowed by filesystem";
+ return false;
+ }
- blockdir = opendir("/dev/block");
+ auto blockdir = std::unique_ptr<DIR, decltype(&closedir)>{opendir("/dev/block"), closedir};
if (!blockdir) {
LERROR << "couldn't open /dev/block";
- goto out;
+ return false;
}
- while ((ent = readdir(blockdir))) {
- int fd;
- char super_buf[1024];
- struct ext4_super_block *sb;
-
+ struct dirent* ent;
+ while ((ent = readdir(blockdir.get()))) {
if (ent->d_type != DT_BLK)
continue;
- fd = openat(dirfd(blockdir), ent->d_name, O_RDONLY);
+ unique_fd fd(TEMP_FAILURE_RETRY(
+ openat(dirfd(blockdir.get()), ent->d_name, O_RDONLY | O_CLOEXEC)));
if (fd < 0) {
LERROR << "Cannot open block device /dev/block/" << ent->d_name;
- goto out;
+ return false;
}
+ ext4_super_block super_block;
if (TEMP_FAILURE_RETRY(lseek(fd, 1024, SEEK_SET)) < 0 ||
- TEMP_FAILURE_RETRY(read(fd, super_buf, 1024)) != 1024) {
- /* Probably a loopback device or something else without a readable
- * superblock.
- */
- close(fd);
+ TEMP_FAILURE_RETRY(read(fd, &super_block, sizeof(super_block))) !=
+ sizeof(super_block)) {
+ // Probably a loopback device or something else without a readable superblock.
continue;
}
- sb = (struct ext4_super_block *)super_buf;
- if (sb->s_magic != EXT4_SUPER_MAGIC) {
+ if (super_block.s_magic != EXT4_SUPER_MAGIC) {
LINFO << "/dev/block/" << ent->d_name << " not ext{234}";
continue;
}
- if (!strncmp(label, sb->s_volume_name, label_len)) {
- char *new_blk_device;
+ if (label == super_block.s_volume_name) {
+ char* new_blk_device;
if (asprintf(&new_blk_device, "/dev/block/%s", ent->d_name) < 0) {
LERROR << "Could not allocate block device string";
- goto out;
+ return false;
}
- LINFO << "resolved label " << rec->blk_device << " to "
- << new_blk_device;
+ LINFO << "resolved label " << rec->blk_device << " to " << new_blk_device;
free(rec->blk_device);
rec->blk_device = new_blk_device;
- ret = 0;
- break;
+ return true;
}
}
-out:
- closedir(blockdir);
- return ret;
+ return false;
}
static bool needs_block_encryption(const struct fstab_rec* rec)
@@ -966,9 +940,8 @@
LERROR << rec->fs_type << " does not implement checkpoints.";
}
} else if (fs_mgr_is_checkpoint_blk(rec)) {
- android::base::unique_fd fd(
- TEMP_FAILURE_RETRY(open(rec->blk_device, O_RDONLY | O_CLOEXEC)));
- if (!fd) {
+ unique_fd fd(TEMP_FAILURE_RETRY(open(rec->blk_device, O_RDONLY | O_CLOEXEC)));
+ if (fd < 0) {
PERROR << "Cannot open device " << rec->blk_device;
return false;
}
@@ -1032,8 +1005,9 @@
for (i = 0; i < fstab->num_entries; i++) {
/* Don't mount entries that are managed by vold or not for the mount mode*/
if ((fstab->recs[i].fs_mgr_flags & (MF_VOLDMANAGED | MF_RECOVERYONLY)) ||
- ((mount_mode == MOUNT_MODE_LATE) && !fs_mgr_is_latemount(&fstab->recs[i])) ||
- ((mount_mode == MOUNT_MODE_EARLY) && fs_mgr_is_latemount(&fstab->recs[i]))) {
+ ((mount_mode == MOUNT_MODE_LATE) && !fs_mgr_is_latemount(&fstab->recs[i])) ||
+ ((mount_mode == MOUNT_MODE_EARLY) && fs_mgr_is_latemount(&fstab->recs[i])) ||
+ fs_mgr_is_first_stage_mount(&fstab->recs[i])) {
continue;
}
@@ -1055,8 +1029,7 @@
/* Translate LABEL= file system labels into block devices */
if (is_extfs(fstab->recs[i].fs_type)) {
- int tret = translate_ext_labels(&fstab->recs[i]);
- if (tret < 0) {
+ if (!TranslateExtLabels(&fstab->recs[i])) {
LERROR << "Could not translate label to block device";
continue;
}
@@ -1157,12 +1130,12 @@
if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) &&
strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) {
- int fd = open(fstab->recs[top_idx].key_loc, O_WRONLY);
+ unique_fd fd(TEMP_FAILURE_RETRY(
+ open(fstab->recs[top_idx].key_loc, O_WRONLY | O_CLOEXEC)));
if (fd >= 0) {
LINFO << __FUNCTION__ << "(): also wipe "
<< fstab->recs[top_idx].key_loc;
wipe_block_device(fd, get_file_size(fd));
- close(fd);
} else {
PERROR << __FUNCTION__ << "(): "
<< fstab->recs[top_idx].key_loc << " wouldn't open";
diff --git a/fs_mgr/fs_mgr_dm_linear.cpp b/fs_mgr/fs_mgr_dm_linear.cpp
index fe0e039..3f075ef 100644
--- a/fs_mgr/fs_mgr_dm_linear.cpp
+++ b/fs_mgr/fs_mgr_dm_linear.cpp
@@ -51,12 +51,20 @@
using DmTargetZero = android::dm::DmTargetZero;
using DmTargetLinear = android::dm::DmTargetLinear;
-bool GetPhysicalPartitionDevicePath(const LpMetadataBlockDevice& block_device,
- std::string* result) {
+static bool GetPhysicalPartitionDevicePath(const LpMetadata& metadata,
+ const LpMetadataBlockDevice& block_device,
+ const std::string& super_device,
+ std::string* result) {
// Note: device-mapper will not accept symlinks, so we must use realpath
// here.
std::string name = GetBlockDevicePartitionName(block_device);
std::string path = "/dev/block/by-name/" + name;
+ // If the super device is the source of this block device's metadata,
+ // make sure we use the correct super device (and not just "super",
+ // which might not exist.)
+ if (GetMetadataSuperBlockDevice(metadata) == &block_device) {
+ path = super_device;
+ }
if (!android::base::Realpath(path, result)) {
PERROR << "realpath: " << path;
return false;
@@ -65,7 +73,7 @@
}
static bool CreateDmTable(const LpMetadata& metadata, const LpMetadataPartition& partition,
- DmTable* table) {
+ const std::string& super_device, DmTable* table) {
uint64_t sector = 0;
for (size_t i = 0; i < partition.num_extents; i++) {
const auto& extent = metadata.extents[partition.first_extent_index + i];
@@ -77,7 +85,7 @@
case LP_TARGET_TYPE_LINEAR: {
const auto& block_device = metadata.block_devices[extent.target_source];
std::string path;
- if (!GetPhysicalPartitionDevicePath(block_device, &path)) {
+ if (!GetPhysicalPartitionDevicePath(metadata, block_device, super_device, &path)) {
LOG(ERROR) << "Unable to complete device-mapper table, unknown block device";
return false;
}
@@ -102,11 +110,11 @@
static bool CreateLogicalPartition(const LpMetadata& metadata, const LpMetadataPartition& partition,
bool force_writable, const std::chrono::milliseconds& timeout_ms,
- std::string* path) {
+ const std::string& super_device, std::string* path) {
DeviceMapper& dm = DeviceMapper::Instance();
DmTable table;
- if (!CreateDmTable(metadata, partition, &table)) {
+ if (!CreateDmTable(metadata, partition, super_device, &table)) {
return false;
}
if (force_writable) {
@@ -137,7 +145,7 @@
LOG(ERROR) << "Could not read partition table.";
return true;
}
- return CreateLogicalPartitions(*metadata.get());
+ return CreateLogicalPartitions(*metadata.get(), block_device);
}
std::unique_ptr<LpMetadata> ReadCurrentMetadata(const std::string& block_device) {
@@ -145,14 +153,14 @@
return ReadMetadata(block_device.c_str(), slot);
}
-bool CreateLogicalPartitions(const LpMetadata& metadata) {
+bool CreateLogicalPartitions(const LpMetadata& metadata, const std::string& super_device) {
for (const auto& partition : metadata.partitions) {
if (!partition.num_extents) {
LINFO << "Skipping zero-length logical partition: " << GetPartitionName(partition);
continue;
}
std::string path;
- if (!CreateLogicalPartition(metadata, partition, false, {}, &path)) {
+ if (!CreateLogicalPartition(metadata, partition, false, {}, super_device, &path)) {
LERROR << "Could not create logical partition: " << GetPartitionName(partition);
return false;
}
@@ -171,7 +179,7 @@
for (const auto& partition : metadata->partitions) {
if (GetPartitionName(partition) == partition_name) {
return CreateLogicalPartition(*metadata.get(), partition, force_writable, timeout_ms,
- path);
+ block_device, path);
}
}
LERROR << "Could not find any partition with name: " << partition_name;
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 31b0944..0fde22e 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -57,7 +57,7 @@
struct flag_list {
const char *name;
- int flag;
+ unsigned int flag;
};
static struct flag_list mount_flags[] = {
@@ -102,6 +102,7 @@
{"formattable", MF_FORMATTABLE},
{"slotselect", MF_SLOTSELECT},
{"nofail", MF_NOFAIL},
+ {"first_stage_mount", MF_FIRST_STAGE_MOUNT},
{"latemount", MF_LATEMOUNT},
{"reservedsize=", MF_RESERVEDSIZE},
{"quota", MF_QUOTA},
@@ -998,6 +999,10 @@
return fstab->fs_mgr_flags & MF_NOFAIL;
}
+int fs_mgr_is_first_stage_mount(const struct fstab_rec* fstab) {
+ return fstab->fs_mgr_flags & MF_FIRST_STAGE_MOUNT;
+}
+
int fs_mgr_is_latemount(const struct fstab_rec* fstab) {
return fstab->fs_mgr_flags & MF_LATEMOUNT;
}
diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp
index 57e984d..649c8bf 100644
--- a/fs_mgr/fs_mgr_overlayfs.cpp
+++ b/fs_mgr/fs_mgr_overlayfs.cpp
@@ -74,7 +74,7 @@
return false;
}
-bool fs_mgr_overlayfs_mount_all(const std::vector<const fstab_rec*>&) {
+bool fs_mgr_overlayfs_mount_all(const std::vector<fstab_rec*>&) {
return false;
}
@@ -82,7 +82,7 @@
return {};
}
-std::vector<std::string> fs_mgr_overlayfs_required_devices(const std::vector<const fstab_rec*>&) {
+std::vector<std::string> fs_mgr_overlayfs_required_devices(const std::vector<fstab_rec*>&) {
return {};
}
@@ -96,6 +96,10 @@
return false;
}
+bool fs_mgr_overlayfs_is_setup() {
+ return false;
+}
+
#else // ALLOW_ADBD_DISABLE_VERITY == 0
namespace {
@@ -382,8 +386,10 @@
return SlotNumberForSlotSuffix(fs_mgr_get_slot_suffix());
}
+const auto kPhysicalDevice = "/dev/block/by-name/"s;
+
std::string fs_mgr_overlayfs_super_device(uint32_t slot_number) {
- return "/dev/block/by-name/" + fs_mgr_get_super_partition_name(slot_number);
+ return kPhysicalDevice + fs_mgr_get_super_partition_name(slot_number);
}
bool fs_mgr_overlayfs_has_logical(const fstab* fstab) {
@@ -641,19 +647,50 @@
std::string fs_mgr_overlayfs_scratch_device() {
if (!scratch_device_cache.empty()) return scratch_device_cache;
- auto& dm = DeviceMapper::Instance();
- const auto partition_name = android::base::Basename(kScratchMountPoint);
- std::string path;
- if (!dm.GetDmDevicePathByName(partition_name, &path)) return "";
+ // Is this a multiple super device (retrofit)?
+ auto slot_number = fs_mgr_overlayfs_slot_number();
+ auto super_device = fs_mgr_overlayfs_super_device(slot_number);
+ auto path = fs_mgr_overlayfs_super_device(slot_number == 0);
+ if (super_device == path) {
+ // Create from within single super device;
+ auto& dm = DeviceMapper::Instance();
+ const auto partition_name = android::base::Basename(kScratchMountPoint);
+ if (!dm.GetDmDevicePathByName(partition_name, &path)) return "";
+ }
return scratch_device_cache = path;
}
-// Create and mount kScratchMountPoint storage if we have logical partitions
-bool fs_mgr_overlayfs_setup_scratch(const fstab* fstab, bool* change) {
- if (fs_mgr_overlayfs_already_mounted(kScratchMountPoint, false)) return true;
- auto mnt_type = fs_mgr_overlayfs_scratch_mount_type();
- auto scratch_device = fs_mgr_overlayfs_scratch_device();
- auto partition_create = !fs_mgr_rw_access(scratch_device);
+bool fs_mgr_overlayfs_make_scratch(const std::string& scratch_device, const std::string& mnt_type) {
+ // Force mkfs by design for overlay support of adb remount, simplify and
+ // thus do not rely on fsck to correct problems that could creep in.
+ auto command = ""s;
+ if (mnt_type == "f2fs") {
+ command = kMkF2fs + " -w 4096 -f -d1 -l" + android::base::Basename(kScratchMountPoint);
+ } else if (mnt_type == "ext4") {
+ command = kMkExt4 + " -b 4096 -t ext4 -m 0 -O has_journal -M " + kScratchMountPoint;
+ } else {
+ errno = ESRCH;
+ LERROR << mnt_type << " has no mkfs cookbook";
+ return false;
+ }
+ command += " " + scratch_device;
+ auto ret = system(command.c_str());
+ if (ret) {
+ LERROR << "make " << mnt_type << " filesystem on " << scratch_device << " return=" << ret;
+ return false;
+ }
+ return true;
+}
+
+bool fs_mgr_overlayfs_create_scratch(const fstab* fstab, std::string* scratch_device,
+ bool* partition_exists, bool* change) {
+ *scratch_device = fs_mgr_overlayfs_scratch_device();
+ *partition_exists = fs_mgr_rw_access(*scratch_device);
+ auto partition_create = !*partition_exists;
+ // Do we need to create a logical "scratch" partition?
+ if (!partition_create && android::base::StartsWith(*scratch_device, kPhysicalDevice)) {
+ return true;
+ }
auto slot_number = fs_mgr_overlayfs_slot_number();
auto super_device = fs_mgr_overlayfs_super_device(slot_number);
if (!fs_mgr_rw_access(super_device)) return false;
@@ -665,9 +702,9 @@
}
const auto partition_name = android::base::Basename(kScratchMountPoint);
auto partition = builder->FindPartition(partition_name);
- auto partition_exists = partition != nullptr;
+ *partition_exists = partition != nullptr;
auto changed = false;
- if (!partition_exists) {
+ if (!*partition_exists) {
partition = builder->AddPartition(partition_name, LP_PARTITION_ATTR_NONE);
if (!partition) {
LERROR << "create " << partition_name;
@@ -703,7 +740,7 @@
}
if (!partition_create) DestroyLogicalPartition(partition_name, 10s);
changed = true;
- partition_exists = false;
+ *partition_exists = false;
}
}
}
@@ -720,39 +757,36 @@
if (changed || partition_create) {
if (!CreateLogicalPartition(super_device, slot_number, partition_name, true, 0s,
- &scratch_device))
+ scratch_device))
return false;
if (change) *change = true;
}
+ return true;
+}
+// Create and mount kScratchMountPoint storage if we have logical partitions
+bool fs_mgr_overlayfs_setup_scratch(const fstab* fstab, bool* change) {
+ if (fs_mgr_overlayfs_already_mounted(kScratchMountPoint, false)) return true;
+
+ std::string scratch_device;
+ bool partition_exists;
+ if (!fs_mgr_overlayfs_create_scratch(fstab, &scratch_device, &partition_exists, change)) {
+ return false;
+ }
+
+ // If the partition exists, assume first that it can be mounted.
+ auto mnt_type = fs_mgr_overlayfs_scratch_mount_type();
if (partition_exists) {
if (fs_mgr_overlayfs_mount_scratch(scratch_device, mnt_type)) {
if (change) *change = true;
return true;
}
- // partition existed, but was not initialized;
+ // partition existed, but was not initialized; fall through to make it.
errno = 0;
}
- // Force mkfs by design for overlay support of adb remount, simplify and
- // thus do not rely on fsck to correct problems that could creep in.
- auto command = ""s;
- if (mnt_type == "f2fs") {
- command = kMkF2fs + " -w 4096 -f -d1 -l" + android::base::Basename(kScratchMountPoint);
- } else if (mnt_type == "ext4") {
- command = kMkExt4 + " -b 4096 -t ext4 -m 0 -O has_journal -M " + kScratchMountPoint;
- } else {
- errno = ESRCH;
- LERROR << mnt_type << " has no mkfs cookbook";
- return false;
- }
- command += " " + scratch_device;
- auto ret = system(command.c_str());
- if (ret) {
- LERROR << "make " << mnt_type << " filesystem on " << scratch_device << " return=" << ret;
- return false;
- }
+ if (!fs_mgr_overlayfs_make_scratch(scratch_device, mnt_type)) return false;
if (change) *change = true;
@@ -762,6 +796,7 @@
bool fs_mgr_overlayfs_scratch_can_be_mounted(const std::string& scratch_device) {
if (scratch_device.empty()) return false;
if (fs_mgr_overlayfs_already_mounted(kScratchMountPoint, false)) return false;
+ if (android::base::StartsWith(scratch_device, kPhysicalDevice)) return true;
if (fs_mgr_rw_access(scratch_device)) return true;
auto slot_number = fs_mgr_overlayfs_slot_number();
auto super_device = fs_mgr_overlayfs_super_device(slot_number);
@@ -805,7 +840,7 @@
return ret;
}
-bool fs_mgr_overlayfs_mount_all(const std::vector<const fstab_rec*>& fsrecs) {
+bool fs_mgr_overlayfs_mount_all(const std::vector<fstab_rec*>& fsrecs) {
std::vector<fstab_rec> recs;
for (const auto& rec : fsrecs) recs.push_back(*rec);
fstab fstab = {static_cast<int>(fsrecs.size()), &recs[0]};
@@ -828,8 +863,7 @@
return {};
}
-std::vector<std::string> fs_mgr_overlayfs_required_devices(
- const std::vector<const fstab_rec*>& fsrecs) {
+std::vector<std::string> fs_mgr_overlayfs_required_devices(const std::vector<fstab_rec*>& fsrecs) {
std::vector<fstab_rec> recs;
for (const auto& rec : fsrecs) recs.push_back(*rec);
fstab fstab = {static_cast<int>(fsrecs.size()), &recs[0]};
@@ -924,6 +958,17 @@
return ret;
}
+bool fs_mgr_overlayfs_is_setup() {
+ if (fs_mgr_overlayfs_already_mounted(kScratchMountPoint, false)) return true;
+ std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
+ fs_mgr_free_fstab);
+ if (fs_mgr_overlayfs_invalid(fstab.get())) return false;
+ for (const auto& mount_point : fs_mgr_candidate_list(fstab.get())) {
+ if (fs_mgr_overlayfs_already_mounted(mount_point)) return true;
+ }
+ return false;
+}
+
#endif // ALLOW_ADBD_DISABLE_VERITY != 0
bool fs_mgr_has_shared_blocks(const std::string& mount_point, const std::string& dev) {
diff --git a/fs_mgr/fs_mgr_priv.h b/fs_mgr/fs_mgr_priv.h
index 711446c..faef34b 100644
--- a/fs_mgr/fs_mgr_priv.h
+++ b/fs_mgr/fs_mgr_priv.h
@@ -118,6 +118,8 @@
#define MF_LOGICAL 0x10000000
#define MF_CHECKPOINT_BLK 0x20000000
#define MF_CHECKPOINT_FS 0x40000000
+#define MF_FIRST_STAGE_MOUNT \
+ 0x80000000
// clang-format on
#define DM_BUF_SIZE 4096
@@ -130,7 +132,7 @@
const std::chrono::milliseconds relative_timeout,
FileWaitMode wait_mode = FileWaitMode::Exists);
-int fs_mgr_set_blk_ro(const char* blockdev);
+bool fs_mgr_set_blk_ro(const std::string& blockdev);
bool fs_mgr_update_for_slotselect(Fstab* fstab);
bool fs_mgr_is_device_unlocked();
const std::string& get_android_dt_dir();
diff --git a/fs_mgr/include/fs_mgr_dm_linear.h b/fs_mgr/include/fs_mgr_dm_linear.h
index 66abfca..f065071 100644
--- a/fs_mgr/include/fs_mgr_dm_linear.h
+++ b/fs_mgr/include/fs_mgr_dm_linear.h
@@ -43,7 +43,7 @@
// Create block devices for all logical partitions in the given metadata. The
// metadata must have been read from the current slot.
-bool CreateLogicalPartitions(const LpMetadata& metadata);
+bool CreateLogicalPartitions(const LpMetadata& metadata, const std::string& block_device);
// Create block devices for all logical partitions. This is a convenience
// method for ReadMetadata and CreateLogicalPartitions.
diff --git a/fs_mgr/include/fs_mgr_overlayfs.h b/fs_mgr/include/fs_mgr_overlayfs.h
index deaf4cb..0dd9121 100644
--- a/fs_mgr/include/fs_mgr_overlayfs.h
+++ b/fs_mgr/include/fs_mgr_overlayfs.h
@@ -22,13 +22,13 @@
#include <vector>
bool fs_mgr_overlayfs_mount_all(fstab* fstab);
-bool fs_mgr_overlayfs_mount_all(const std::vector<const fstab_rec*>& fstab);
+bool fs_mgr_overlayfs_mount_all(const std::vector<fstab_rec*>& fstab);
std::vector<std::string> fs_mgr_overlayfs_required_devices(fstab* fstab);
-std::vector<std::string> fs_mgr_overlayfs_required_devices(
- const std::vector<const fstab_rec*>& fstab);
+std::vector<std::string> fs_mgr_overlayfs_required_devices(const std::vector<fstab_rec*>& fstab);
bool fs_mgr_overlayfs_setup(const char* backing = nullptr, const char* mount_point = nullptr,
bool* change = nullptr);
bool fs_mgr_overlayfs_teardown(const char* mount_point = nullptr, bool* change = nullptr);
+bool fs_mgr_overlayfs_is_setup();
bool fs_mgr_has_shared_blocks(const std::string& mount_point, const std::string& dev);
std::string fs_mgr_get_context(const std::string& mount_point);
diff --git a/fs_mgr/include_fstab/fstab/fstab.h b/fs_mgr/include_fstab/fstab/fstab.h
index 80bdb87..4706028 100644
--- a/fs_mgr/include_fstab/fstab/fstab.h
+++ b/fs_mgr/include_fstab/fstab/fstab.h
@@ -84,6 +84,7 @@
int fs_mgr_is_formattable(const struct fstab_rec* fstab);
int fs_mgr_is_slotselect(const struct fstab_rec* fstab);
int fs_mgr_is_nofail(const struct fstab_rec* fstab);
+int fs_mgr_is_first_stage_mount(const struct fstab_rec* fstab);
int fs_mgr_is_latemount(const struct fstab_rec* fstab);
int fs_mgr_is_quota(const struct fstab_rec* fstab);
int fs_mgr_is_logical(const struct fstab_rec* fstab);
diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh
index c7c86eb..561debb 100755
--- a/fs_mgr/tests/adb-remount-test.sh
+++ b/fs_mgr/tests/adb-remount-test.sh
@@ -378,6 +378,11 @@
M=`adb_sh cat /proc/mounts | sed -n 's@\([^ ]*\) /mnt/scratch \([^ ]*\) .*@\2 on \1@p'`
[ -n "${M}" ] &&
echo "${BLUE}[ INFO ]${NORMAL} scratch filesystem ${M}"
+uses_dynamic_scratch=true
+if [ "${M}" != "${M##*/dev/block/by-name/}" ]; then
+ uses_dynamic_scratch=false
+ scratch_partition="${M##*/dev/block/by-name/}"
+fi
scratch_size=`adb_sh df -k /mnt/scratch </dev/null 2>/dev/null |
while read device kblocks used available use mounted on; do
if [ "/mnt/scratch" = "\${mounted}" ]; then
@@ -453,16 +458,30 @@
fastboot flash vendor ||
( fastboot reboot && false) ||
die "fastboot flash vendor"
-# check ${scratch_partition} via fastboot
-fastboot_getvar partition-type:${scratch_partition} raw &&
- fastboot_getvar has-slot:${scratch_partition} no &&
- fastboot_getvar is-logical:${scratch_partition} yes ||
+fastboot_getvar partition-type:${scratch_partition} raw ||
( fastboot reboot && false) ||
die "fastboot can not see ${scratch_partition} parameters"
-echo "${BLUE}[ INFO ]${NORMAL} expect fastboot erase ${scratch_partition} to fail" >&2
-fastboot erase ${scratch_partition} &&
- ( fastboot reboot || true) &&
- die "fastboot can erase ${scratch_partition}"
+if ${uses_dynamic_scratch}; then
+ # check ${scratch_partition} via fastboot
+ fastboot_getvar has-slot:${scratch_partition} no &&
+ fastboot_getvar is-logical:${scratch_partition} yes ||
+ ( fastboot reboot && false) ||
+ die "fastboot can not see ${scratch_partition} parameters"
+else
+ fastboot_getvar is-logical:${scratch_partition} no ||
+ ( fastboot reboot && false) ||
+ die "fastboot can not see ${scratch_partition} parameters"
+fi
+if ! ${uses_dynamic_scratch}; then
+ fastboot reboot-bootloader ||
+ die "Reboot into fastboot"
+fi
+if ${uses_dynamic_scratch}; then
+ echo "${BLUE}[ INFO ]${NORMAL} expect fastboot erase ${scratch_partition} to fail" >&2
+ fastboot erase ${scratch_partition} &&
+ ( fastboot reboot || true) &&
+ die "fastboot can erase ${scratch_partition}"
+fi
echo "${BLUE}[ INFO ]${NORMAL} expect fastboot format ${scratch_partition} to fail" >&2
fastboot format ${scratch_partition} &&
( fastboot reboot || true) &&
@@ -507,12 +526,13 @@
echo "${GREEN}[ RUN ]${NORMAL} test fastboot flash to ${scratch_partition}" >&2
-adb reboot-fastboot &&
- dd if=/dev/zero of=/tmp/adb-remount-test.img bs=4096 count=16 2>/dev/null &&
+adb reboot-fastboot ||
+ die "Reboot into fastbootd"
+dd if=/dev/zero of=/tmp/adb-remount-test.img bs=4096 count=16 2>/dev/null &&
fastboot_wait 2m ||
( rm /tmp/adb-remount-test.img && false) ||
die "reboot into fastboot"
-fastboot flash ${scratch_partition} /tmp/adb-remount-test.img
+fastboot flash --force ${scratch_partition} /tmp/adb-remount-test.img
err=${?}
rm /tmp/adb-remount-test.img
fastboot reboot ||
diff --git a/init/Android.bp b/init/Android.bp
index ea66ac6..e7b8516 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -19,6 +19,7 @@
cpp_std: "experimental",
sanitize: {
misc_undefined: ["signed-integer-overflow"],
+ address: false, // TODO(b/120561310): Fix ASAN to work without /proc mounted and re-enable.
},
cflags: [
"-DLOG_UEVENTS=0",
diff --git a/init/Android.mk b/init/Android.mk
index 0e6ee0b..bdd0301 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -104,7 +104,6 @@
LOCAL_REQUIRED_MODULES := \
init_second_stage \
-LOCAL_POST_INSTALL_CMD := ln -sf /system/bin/init $(TARGET_ROOT_OUT)/init
include $(BUILD_PHONY_PACKAGE)
include $(CLEAR_VARS)
diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp
index d35329e..6ae1123 100644
--- a/init/first_stage_mount.cpp
+++ b/init/first_stage_mount.cpp
@@ -84,7 +84,7 @@
bool need_dm_verity_;
- std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> device_tree_fstab_;
+ std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab_;
std::string lp_metadata_partition_;
std::vector<fstab_rec*> mount_fstab_recs_;
std::set<std::string> required_devices_partition_names_;
@@ -132,15 +132,29 @@
// Class Definitions
// -----------------
FirstStageMount::FirstStageMount()
- : need_dm_verity_(false), device_tree_fstab_(fs_mgr_read_fstab_dt(), fs_mgr_free_fstab) {
- if (device_tree_fstab_) {
- // Stores device_tree_fstab_->recs[] into mount_fstab_recs_ (vector<fstab_rec*>)
- // for easier manipulation later, e.g., range-base for loop.
- for (int i = 0; i < device_tree_fstab_->num_entries; i++) {
- mount_fstab_recs_.push_back(&device_tree_fstab_->recs[i]);
+ : need_dm_verity_(false),
+ fstab_(fs_mgr_read_fstab_dt(), fs_mgr_free_fstab),
+ uevent_listener_(16 * 1024 * 1024) {
+ // Stores fstab_->recs[] into mount_fstab_recs_ (vector<fstab_rec*>)
+ // for easier manipulation later, e.g., range-base for loop.
+ if (fstab_) {
+ // DT Fstab predated having a first_stage_mount fs_mgr flag, so if it exists, we use it.
+ for (int i = 0; i < fstab_->num_entries; i++) {
+ mount_fstab_recs_.push_back(&fstab_->recs[i]);
}
} else {
- LOG(INFO) << "Failed to read fstab from device tree";
+ // Fstab found in first stage ramdisk, which should be a copy of the normal fstab.
+ // Mounts intended for first stage are explicitly flagged as such.
+ fstab_.reset(fs_mgr_read_fstab_default());
+ if (fstab_) {
+ for (int i = 0; i < fstab_->num_entries; i++) {
+ if (fs_mgr_is_first_stage_mount(&fstab_->recs[i])) {
+ mount_fstab_recs_.push_back(&fstab_->recs[i]);
+ }
+ }
+ } else {
+ LOG(INFO) << "Failed to read fstab from device tree";
+ }
}
auto boot_devices = fs_mgr_get_boot_devices();
@@ -252,9 +266,10 @@
}
bool FirstStageMount::InitDmLinearBackingDevices(const android::fs_mgr::LpMetadata& metadata) {
- auto partition_names = GetBlockDevicePartitionNames(metadata);
+ auto partition_names = android::fs_mgr::GetBlockDevicePartitionNames(metadata);
for (const auto& partition_name : partition_names) {
- if (partition_name == lp_metadata_partition_) {
+ const auto super_device = android::fs_mgr::GetMetadataSuperBlockDevice(metadata);
+ if (partition_name == android::fs_mgr::GetBlockDevicePartitionName(*super_device)) {
continue;
}
required_devices_partition_names_.emplace(partition_name);
@@ -292,7 +307,7 @@
if (!InitDmLinearBackingDevices(*metadata.get())) {
return false;
}
- return android::fs_mgr::CreateLogicalPartitions(*metadata.get());
+ return android::fs_mgr::CreateLogicalPartitions(*metadata.get(), lp_metadata_partition_);
}
ListenerAction FirstStageMount::HandleBlockDevice(const std::string& name, const Uevent& uevent) {
@@ -411,7 +426,7 @@
}
// heads up for instantiating required device(s) for overlayfs logic
- const auto devices = fs_mgr_overlayfs_required_devices(device_tree_fstab_.get());
+ const auto devices = fs_mgr_overlayfs_required_devices(mount_fstab_recs_);
for (auto const& device : devices) {
if (android::base::StartsWith(device, "/dev/block/by-name/")) {
required_devices_partition_names_.emplace(basename(device.c_str()));
@@ -423,7 +438,7 @@
}
}
- fs_mgr_overlayfs_mount_all(device_tree_fstab_.get());
+ fs_mgr_overlayfs_mount_all(mount_fstab_recs_);
return true;
}
diff --git a/init/uevent_listener.cpp b/init/uevent_listener.cpp
index d6765b7..62cd2be 100644
--- a/init/uevent_listener.cpp
+++ b/init/uevent_listener.cpp
@@ -86,9 +86,8 @@
}
}
-UeventListener::UeventListener() {
- // is 16MB enough? udev uses 128MB!
- device_fd_.reset(uevent_open_socket(16 * 1024 * 1024, true));
+UeventListener::UeventListener(size_t uevent_socket_rcvbuf_size) {
+ device_fd_.reset(uevent_open_socket(uevent_socket_rcvbuf_size, true));
if (device_fd_ == -1) {
LOG(FATAL) << "Could not open uevent socket";
}
diff --git a/init/uevent_listener.h b/init/uevent_listener.h
index 5b453fe..aea094e 100644
--- a/init/uevent_listener.h
+++ b/init/uevent_listener.h
@@ -41,7 +41,7 @@
class UeventListener {
public:
- UeventListener();
+ UeventListener(size_t uevent_socket_rcvbuf_size);
void RegenerateUevents(const ListenerCallback& callback) const;
ListenerAction RegenerateUeventsForPath(const std::string& path,
diff --git a/init/ueventd.cpp b/init/ueventd.cpp
index 66491dd..7545d53 100644
--- a/init/ueventd.cpp
+++ b/init/ueventd.cpp
@@ -233,29 +233,26 @@
SelabelInitialize();
std::vector<std::unique_ptr<UeventHandler>> uevent_handlers;
- UeventListener uevent_listener;
- {
- // Keep the current product name base configuration so we remain backwards compatible and
- // allow it to override everything.
- // TODO: cleanup platform ueventd.rc to remove vendor specific device node entries (b/34968103)
- auto hardware = android::base::GetProperty("ro.hardware", "");
+ // Keep the current product name base configuration so we remain backwards compatible and
+ // allow it to override everything.
+ // TODO: cleanup platform ueventd.rc to remove vendor specific device node entries (b/34968103)
+ auto hardware = android::base::GetProperty("ro.hardware", "");
- auto ueventd_configuration =
- ParseConfig({"/ueventd.rc", "/vendor/ueventd.rc", "/odm/ueventd.rc",
- "/ueventd." + hardware + ".rc"});
+ auto ueventd_configuration = ParseConfig({"/ueventd.rc", "/vendor/ueventd.rc",
+ "/odm/ueventd.rc", "/ueventd." + hardware + ".rc"});
- uevent_handlers.emplace_back(std::make_unique<DeviceHandler>(
- std::move(ueventd_configuration.dev_permissions),
- std::move(ueventd_configuration.sysfs_permissions),
- std::move(ueventd_configuration.subsystems), fs_mgr_get_boot_devices(), true));
- uevent_handlers.emplace_back(std::make_unique<FirmwareHandler>(
- std::move(ueventd_configuration.firmware_directories)));
+ uevent_handlers.emplace_back(std::make_unique<DeviceHandler>(
+ std::move(ueventd_configuration.dev_permissions),
+ std::move(ueventd_configuration.sysfs_permissions),
+ std::move(ueventd_configuration.subsystems), fs_mgr_get_boot_devices(), true));
+ uevent_handlers.emplace_back(std::make_unique<FirmwareHandler>(
+ std::move(ueventd_configuration.firmware_directories)));
- if (ueventd_configuration.enable_modalias_handling) {
- uevent_handlers.emplace_back(std::make_unique<ModaliasHandler>());
- }
+ if (ueventd_configuration.enable_modalias_handling) {
+ uevent_handlers.emplace_back(std::make_unique<ModaliasHandler>());
}
+ UeventListener uevent_listener(ueventd_configuration.uevent_socket_rcvbuf_size);
if (access(COLDBOOT_DONE, F_OK) != 0) {
ColdBoot cold_boot(uevent_listener, uevent_handlers);
diff --git a/init/ueventd_parser.cpp b/init/ueventd_parser.cpp
index 677938e..aac3fe5 100644
--- a/init/ueventd_parser.cpp
+++ b/init/ueventd_parser.cpp
@@ -19,9 +19,13 @@
#include <grp.h>
#include <pwd.h>
+#include <android-base/parseint.h>
+
#include "keyword_map.h"
#include "parser.h"
+using android::base::ParseByteCount;
+
namespace android {
namespace init {
@@ -101,6 +105,22 @@
return Success();
}
+Result<Success> ParseUeventSocketRcvbufSizeLine(std::vector<std::string>&& args,
+ size_t* uevent_socket_rcvbuf_size) {
+ if (args.size() != 2) {
+ return Error() << "uevent_socket_rcvbuf_size lines take exactly one parameter";
+ }
+
+ size_t parsed_size;
+ if (!ParseByteCount(args[1], &parsed_size)) {
+ return Error() << "could not parse size '" << args[1] << "' for uevent_socket_rcvbuf_line";
+ }
+
+ *uevent_socket_rcvbuf_size = parsed_size;
+
+ return Success();
+}
+
class SubsystemParser : public SectionParser {
public:
SubsystemParser(std::vector<Subsystem>* subsystems) : subsystems_(subsystems) {}
@@ -202,6 +222,9 @@
parser.AddSingleLineParser("modalias_handling",
std::bind(ParseModaliasHandlingLine, _1,
&ueventd_configuration.enable_modalias_handling));
+ parser.AddSingleLineParser("uevent_socket_rcvbuf_size",
+ std::bind(ParseUeventSocketRcvbufSizeLine, _1,
+ &ueventd_configuration.uevent_socket_rcvbuf_size));
for (const auto& config : configs) {
parser.ParseConfig(config);
diff --git a/init/ueventd_parser.h b/init/ueventd_parser.h
index 7d30edf..d476dec 100644
--- a/init/ueventd_parser.h
+++ b/init/ueventd_parser.h
@@ -31,6 +31,7 @@
std::vector<Permissions> dev_permissions;
std::vector<std::string> firmware_directories;
bool enable_modalias_handling = false;
+ size_t uevent_socket_rcvbuf_size = 0;
};
UeventdConfiguration ParseConfig(const std::vector<std::string>& configs);
diff --git a/init/ueventd_parser_test.cpp b/init/ueventd_parser_test.cpp
index c3af341..9c1cedf 100644
--- a/init/ueventd_parser_test.cpp
+++ b/init/ueventd_parser_test.cpp
@@ -138,6 +138,15 @@
TestUeventdFile(ueventd_file, {{}, {}, {}, firmware_directories});
}
+TEST(ueventd_parser, UeventSocketRcvbufSize) {
+ auto ueventd_file = R"(
+uevent_socket_rcvbuf_size 8k
+uevent_socket_rcvbuf_size 8M
+)";
+
+ TestUeventdFile(ueventd_file, {{}, {}, {}, {}, false, 8 * 1024 * 1024});
+}
+
TEST(ueventd_parser, AllTogether) {
auto ueventd_file = R"(
@@ -169,6 +178,8 @@
/sys/devices/virtual/*/input poll_delay 0660 root input
firmware_directories /more
+uevent_socket_rcvbuf_size 6M
+
#ending comment
)";
@@ -197,8 +208,10 @@
"/more",
};
- TestUeventdFile(ueventd_file,
- {subsystems, sysfs_permissions, permissions, firmware_directories});
+ size_t uevent_socket_rcvbuf_size = 6 * 1024 * 1024;
+
+ TestUeventdFile(ueventd_file, {subsystems, sysfs_permissions, permissions, firmware_directories,
+ false, uevent_socket_rcvbuf_size});
}
// All of these lines are ill-formed, so test that there is 0 output.
@@ -213,6 +226,8 @@
/sys/devices/platform/trusty.* trusty_version 0440 baduidbad log
/sys/devices/platform/trusty.* trusty_version 0440 root baduidbad
+uevent_socket_rcvbuf_size blah
+
subsystem #no name
)";
diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp
index ee52f5e..db59569 100644
--- a/libcutils/fs_config.cpp
+++ b/libcutils/fs_config.cpp
@@ -108,7 +108,9 @@
// although the developer is advised to restrict the scope to the /vendor or
// oem/ file-system since the intent is to provide support for customized
// portions of a separate vendor.img or oem.img. Has to remain open so that
-// customization can also land on /system/vendor, /system/oem or /system/odm.
+// customization can also land on /system/vendor, /system/oem, /system/odm,
+// /system/product or /system/product_services.
+//
// We expect build-time checking or filtering when constructing the associated
// fs_config_* files (see build/tools/fs_config/fs_config_generate.c)
static const char ven_conf_dir[] = "/vendor/etc/fs_config_dirs";
@@ -117,11 +119,17 @@
static const char oem_conf_file[] = "/oem/etc/fs_config_files";
static const char odm_conf_dir[] = "/odm/etc/fs_config_dirs";
static const char odm_conf_file[] = "/odm/etc/fs_config_files";
+static const char product_conf_dir[] = "/product/etc/fs_config_dirs";
+static const char product_conf_file[] = "/product/etc/fs_config_files";
+static const char product_services_conf_dir[] = "/product_services/etc/fs_config_dirs";
+static const char product_services_conf_file[] = "/product_services/etc/fs_config_files";
static const char* conf[][2] = {
- {sys_conf_file, sys_conf_dir},
- {ven_conf_file, ven_conf_dir},
- {oem_conf_file, oem_conf_dir},
- {odm_conf_file, odm_conf_dir},
+ {sys_conf_file, sys_conf_dir},
+ {ven_conf_file, ven_conf_dir},
+ {oem_conf_file, oem_conf_dir},
+ {odm_conf_file, odm_conf_dir},
+ {product_conf_file, product_conf_dir},
+ {product_services_conf_file, product_services_conf_dir},
};
// Do not use android_files to grant Linux capabilities. Use ambient capabilities in their
@@ -150,7 +158,11 @@
{ 00444, AID_ROOT, AID_ROOT, 0, oem_conf_dir + 1 },
{ 00444, AID_ROOT, AID_ROOT, 0, oem_conf_file + 1 },
{ 00600, AID_ROOT, AID_ROOT, 0, "product/build.prop" },
+ { 00444, AID_ROOT, AID_ROOT, 0, product_conf_dir + 1 },
+ { 00444, AID_ROOT, AID_ROOT, 0, product_conf_file + 1 },
{ 00600, AID_ROOT, AID_ROOT, 0, "product_services/build.prop" },
+ { 00444, AID_ROOT, AID_ROOT, 0, product_services_conf_dir + 1 },
+ { 00444, AID_ROOT, AID_ROOT, 0, product_services_conf_file + 1 },
{ 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" },
{ 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump32" },
{ 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump64" },
@@ -236,10 +248,10 @@
return fd;
}
-// if path is "odm/<stuff>", "oem/<stuff>", "product/<stuff>" or
-// "vendor/<stuff>"
+// if path is "odm/<stuff>", "oem/<stuff>", "product/<stuff>",
+// "product_services/<stuff>" or "vendor/<stuff>"
static bool is_partition(const char* path, size_t len) {
- static const char* partitions[] = {"odm/", "oem/", "product/", "vendor/"};
+ static const char* partitions[] = {"odm/", "oem/", "product/", "product_services/", "vendor/"};
for (size_t i = 0; i < (sizeof(partitions) / sizeof(partitions[0])); ++i) {
size_t plen = strlen(partitions[i]);
if (len <= plen) continue;
diff --git a/libprocinfo/include/procinfo/process_map.h b/libprocinfo/include/procinfo/process_map.h
index 0fc4201..981241e 100644
--- a/libprocinfo/include/procinfo/process_map.h
+++ b/libprocinfo/include/procinfo/process_map.h
@@ -17,6 +17,7 @@
#pragma once
#include <stdlib.h>
+#include <string.h>
#include <sys/mman.h>
#include <sys/types.h>
diff --git a/libstats/include/stats_event_list.h b/libstats/include/stats_event_list.h
index a9832db..41ca79b 100644
--- a/libstats/include/stats_event_list.h
+++ b/libstats/include/stats_event_list.h
@@ -26,7 +26,7 @@
int write_to_logger(android_log_context context, log_id_t id);
void note_log_drop();
void stats_log_close();
-
+int android_log_write_char_array(android_log_context ctx, const char* value, size_t len);
#ifdef __cplusplus
}
#endif
@@ -244,6 +244,14 @@
return ret >= 0;
}
+ bool AppendCharArray(const char* value, size_t len) {
+ int retval = android_log_write_char_array(ctx, value, len);
+ if (retval < 0) {
+ ret = retval;
+ }
+ return ret >= 0;
+ }
+
android_log_list_element read() { return android_log_read_next(ctx); }
android_log_list_element peek() { return android_log_peek_next(ctx); }
};
diff --git a/libstats/stats_event_list.c b/libstats/stats_event_list.c
index 72770d4..f4a7e94 100644
--- a/libstats/stats_event_list.c
+++ b/libstats/stats_event_list.c
@@ -193,3 +193,47 @@
errno = save_errno;
return ret;
}
+
+static inline void copy4LE(uint8_t* buf, uint32_t val) {
+ buf[0] = val & 0xFF;
+ buf[1] = (val >> 8) & 0xFF;
+ buf[2] = (val >> 16) & 0xFF;
+ buf[3] = (val >> 24) & 0xFF;
+}
+
+// Note: this function differs from android_log_write_string8_len in that the length passed in
+// should be treated as actual length and not max length.
+int android_log_write_char_array(android_log_context ctx, const char* value, size_t actual_len) {
+ size_t needed;
+ ssize_t len = actual_len;
+ android_log_context_internal* context;
+
+ context = (android_log_context_internal*)ctx;
+ if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
+ return -EBADF;
+ }
+ if (context->overflow) {
+ return -EIO;
+ }
+ if (!value) {
+ value = "";
+ len = 0;
+ }
+ needed = sizeof(uint8_t) + sizeof(int32_t) + len;
+ if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
+ /* Truncate string for delivery */
+ len = MAX_EVENT_PAYLOAD - context->pos - 1 - sizeof(int32_t);
+ if (len <= 0) {
+ context->overflow = true;
+ return -EIO;
+ }
+ }
+ context->count[context->list_nest_depth]++;
+ context->storage[context->pos + 0] = EVENT_TYPE_STRING;
+ copy4LE(&context->storage[context->pos + 1], len);
+ if (len) {
+ memcpy(&context->storage[context->pos + 5], value, len);
+ }
+ context->pos += needed;
+ return len;
+}
diff --git a/libsysutils/Android.bp b/libsysutils/Android.bp
index 29d23c8..da5d86c 100644
--- a/libsysutils/Android.bp
+++ b/libsysutils/Android.bp
@@ -1,4 +1,4 @@
-cc_library_shared {
+cc_library {
name: "libsysutils",
vendor_available: true,
vndk: {
diff --git a/libunwindstack/Elf.cpp b/libunwindstack/Elf.cpp
index 4d72ead..5b586a2 100644
--- a/libunwindstack/Elf.cpp
+++ b/libunwindstack/Elf.cpp
@@ -140,6 +140,10 @@
return true;
}
+bool Elf::GetBuildID(std::string* build_id) {
+ return valid_ && interface_->GetBuildID(build_id);
+}
+
void Elf::GetLastError(ErrorData* data) {
if (valid_) {
*data = interface_->last_error();
diff --git a/libunwindstack/ElfInterface.cpp b/libunwindstack/ElfInterface.cpp
index f59a472..d0af94a 100644
--- a/libunwindstack/ElfInterface.cpp
+++ b/libunwindstack/ElfInterface.cpp
@@ -237,6 +237,56 @@
}
}
+template <typename NhdrType>
+bool ElfInterface::ReadBuildID(std::string* build_id) {
+ // Ensure there is no overflow in any of the calulations below.
+ uint64_t tmp;
+ if (__builtin_add_overflow(gnu_build_id_offset_, gnu_build_id_size_, &tmp)) {
+ return false;
+ }
+
+ uint64_t offset = 0;
+ while (offset < gnu_build_id_size_) {
+ if (gnu_build_id_size_ - offset < sizeof(NhdrType)) {
+ return false;
+ }
+ NhdrType hdr;
+ if (!memory_->ReadFully(gnu_build_id_offset_ + offset, &hdr, sizeof(hdr))) {
+ return false;
+ }
+ offset += sizeof(hdr);
+
+ if (gnu_build_id_size_ - offset < hdr.n_namesz) {
+ return false;
+ }
+ if (hdr.n_namesz > 0) {
+ std::string name(hdr.n_namesz, '\0');
+ if (!memory_->ReadFully(gnu_build_id_offset_ + offset, &(name[0]), hdr.n_namesz)) {
+ return false;
+ }
+
+ // Trim trailing \0 as GNU is stored as a C string in the ELF file.
+ if (name.back() == '\0')
+ name.resize(name.size() - 1);
+
+ // Align hdr.n_namesz to next power multiple of 4. See man 5 elf.
+ offset += (hdr.n_namesz + 3) & ~3;
+
+ if (name == "GNU" && hdr.n_type == NT_GNU_BUILD_ID) {
+ if (gnu_build_id_size_ - offset < hdr.n_descsz) {
+ return false;
+ }
+ build_id->resize(hdr.n_descsz);
+ return memory_->ReadFully(gnu_build_id_offset_ + offset, &(*build_id)[0],
+ hdr.n_descsz);
+ }
+ }
+ // Align hdr.n_descsz to next power multiple of 4. See man 5 elf.
+ offset += (hdr.n_descsz + 3) & ~3;
+ }
+ return false;
+}
+
template <typename EhdrType, typename ShdrType>
void ElfInterface::ReadSectionHeaders(const EhdrType& ehdr) {
uint64_t offset = ehdr.e_shoff;
@@ -308,6 +358,15 @@
// In order to read soname, keep track of address to offset mapping.
strtabs_.push_back(std::make_pair<uint64_t, uint64_t>(static_cast<uint64_t>(shdr.sh_addr),
static_cast<uint64_t>(shdr.sh_offset)));
+ } else if (shdr.sh_type == SHT_NOTE) {
+ if (shdr.sh_name < sec_size) {
+ std::string name;
+ if (memory_->ReadString(sec_offset + shdr.sh_name, &name) &&
+ name == ".note.gnu.build-id") {
+ gnu_build_id_offset_ = shdr.sh_offset;
+ gnu_build_id_size_ = shdr.sh_size;
+ }
+ }
}
}
}
@@ -492,6 +551,9 @@
template void ElfInterface::ReadSectionHeaders<Elf32_Ehdr, Elf32_Shdr>(const Elf32_Ehdr&);
template void ElfInterface::ReadSectionHeaders<Elf64_Ehdr, Elf64_Shdr>(const Elf64_Ehdr&);
+template bool ElfInterface::ReadBuildID<Elf32_Nhdr>(std::string*);
+template bool ElfInterface::ReadBuildID<Elf64_Nhdr>(std::string*);
+
template bool ElfInterface::GetSonameWithTemplate<Elf32_Dyn>(std::string*);
template bool ElfInterface::GetSonameWithTemplate<Elf64_Dyn>(std::string*);
diff --git a/libunwindstack/Global.cpp b/libunwindstack/Global.cpp
index 7a3de01..fdfd705 100644
--- a/libunwindstack/Global.cpp
+++ b/libunwindstack/Global.cpp
@@ -15,6 +15,7 @@
*/
#include <stdint.h>
+#include <string.h>
#include <sys/mman.h>
#include <string>
diff --git a/libunwindstack/Maps.cpp b/libunwindstack/Maps.cpp
index 8729871..a9fb859 100644
--- a/libunwindstack/Maps.cpp
+++ b/libunwindstack/Maps.cpp
@@ -19,6 +19,7 @@
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
+#include <string.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
diff --git a/libunwindstack/Memory.cpp b/libunwindstack/Memory.cpp
index a30d65e..9904fef 100644
--- a/libunwindstack/Memory.cpp
+++ b/libunwindstack/Memory.cpp
@@ -16,6 +16,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <string.h>
#include <sys/mman.h>
#include <sys/ptrace.h>
#include <sys/stat.h>
diff --git a/libunwindstack/RegsArm.cpp b/libunwindstack/RegsArm.cpp
index de22bde..885dc94 100644
--- a/libunwindstack/RegsArm.cpp
+++ b/libunwindstack/RegsArm.cpp
@@ -15,6 +15,7 @@
*/
#include <stdint.h>
+#include <string.h>
#include <functional>
diff --git a/libunwindstack/RegsArm64.cpp b/libunwindstack/RegsArm64.cpp
index a68f6e0..e9787aa 100644
--- a/libunwindstack/RegsArm64.cpp
+++ b/libunwindstack/RegsArm64.cpp
@@ -15,6 +15,7 @@
*/
#include <stdint.h>
+#include <string.h>
#include <functional>
diff --git a/libunwindstack/RegsMips.cpp b/libunwindstack/RegsMips.cpp
index 2e6908c..14a4e31 100644
--- a/libunwindstack/RegsMips.cpp
+++ b/libunwindstack/RegsMips.cpp
@@ -15,6 +15,7 @@
*/
#include <stdint.h>
+#include <string.h>
#include <functional>
diff --git a/libunwindstack/RegsMips64.cpp b/libunwindstack/RegsMips64.cpp
index 0b835a1..3f67d92 100644
--- a/libunwindstack/RegsMips64.cpp
+++ b/libunwindstack/RegsMips64.cpp
@@ -15,6 +15,7 @@
*/
#include <stdint.h>
+#include <string.h>
#include <functional>
diff --git a/libunwindstack/RegsX86_64.cpp b/libunwindstack/RegsX86_64.cpp
index ebad3f4..74cd1cb 100644
--- a/libunwindstack/RegsX86_64.cpp
+++ b/libunwindstack/RegsX86_64.cpp
@@ -15,6 +15,7 @@
*/
#include <stdint.h>
+#include <string.h>
#include <functional>
diff --git a/libunwindstack/Symbols.cpp b/libunwindstack/Symbols.cpp
index 14ebdbb..e3c15a2 100644
--- a/libunwindstack/Symbols.cpp
+++ b/libunwindstack/Symbols.cpp
@@ -17,6 +17,7 @@
#include <elf.h>
#include <stdint.h>
+#include <algorithm>
#include <string>
#include <unwindstack/Memory.h>
diff --git a/libunwindstack/include/unwindstack/Elf.h b/libunwindstack/include/unwindstack/Elf.h
index e5b0a89..27f7201 100644
--- a/libunwindstack/include/unwindstack/Elf.h
+++ b/libunwindstack/include/unwindstack/Elf.h
@@ -65,6 +65,8 @@
bool GetGlobalVariable(const std::string& name, uint64_t* memory_address);
+ bool GetBuildID(std::string* build_id);
+
uint64_t GetRelPc(uint64_t pc, const MapInfo* map_info);
bool Step(uint64_t rel_pc, uint64_t adjusted_rel_pc, Regs* regs, Memory* process_memory,
diff --git a/libunwindstack/include/unwindstack/ElfInterface.h b/libunwindstack/include/unwindstack/ElfInterface.h
index a45eba8..52992d9 100644
--- a/libunwindstack/include/unwindstack/ElfInterface.h
+++ b/libunwindstack/include/unwindstack/ElfInterface.h
@@ -62,6 +62,8 @@
virtual bool GetGlobalVariable(const std::string& name, uint64_t* memory_address) = 0;
+ virtual bool GetBuildID(std::string* build_id) = 0;
+
virtual bool Step(uint64_t rel_pc, Regs* regs, Memory* process_memory, bool* finished);
virtual bool IsValidPc(uint64_t pc);
@@ -85,6 +87,8 @@
uint64_t debug_frame_size() { return debug_frame_size_; }
uint64_t gnu_debugdata_offset() { return gnu_debugdata_offset_; }
uint64_t gnu_debugdata_size() { return gnu_debugdata_size_; }
+ uint64_t gnu_build_id_offset() { return gnu_build_id_offset_; }
+ uint64_t gnu_build_id_size() { return gnu_build_id_size_; }
DwarfSection* eh_frame() { return eh_frame_.get(); }
DwarfSection* debug_frame() { return debug_frame_.get(); }
@@ -123,6 +127,9 @@
template <typename EhdrType>
static void GetMaxSizeWithTemplate(Memory* memory, uint64_t* size);
+ template <typename NhdrType>
+ bool ReadBuildID(std::string* build_id);
+
Memory* memory_;
std::unordered_map<uint64_t, LoadInfo> pt_loads_;
@@ -143,6 +150,9 @@
uint64_t gnu_debugdata_offset_ = 0;
uint64_t gnu_debugdata_size_ = 0;
+ uint64_t gnu_build_id_offset_ = 0;
+ uint64_t gnu_build_id_size_ = 0;
+
uint8_t soname_type_ = SONAME_UNKNOWN;
std::string soname_;
@@ -182,6 +192,10 @@
return ElfInterface::GetGlobalVariableWithTemplate<Elf32_Sym>(name, memory_address);
}
+ bool GetBuildID(std::string* build_id) {
+ return ElfInterface::ReadBuildID<Elf32_Nhdr>(build_id);
+ }
+
static void GetMaxSize(Memory* memory, uint64_t* size) {
GetMaxSizeWithTemplate<Elf32_Ehdr>(memory, size);
}
@@ -212,6 +226,10 @@
return ElfInterface::GetGlobalVariableWithTemplate<Elf64_Sym>(name, memory_address);
}
+ bool GetBuildID(std::string* build_id) {
+ return ElfInterface::ReadBuildID<Elf64_Nhdr>(build_id);
+ }
+
static void GetMaxSize(Memory* memory, uint64_t* size) {
GetMaxSizeWithTemplate<Elf64_Ehdr>(memory, size);
}
diff --git a/libunwindstack/tests/ElfFake.h b/libunwindstack/tests/ElfFake.h
index a3bf5ce..c2bd0f6 100644
--- a/libunwindstack/tests/ElfFake.h
+++ b/libunwindstack/tests/ElfFake.h
@@ -72,6 +72,9 @@
bool GetFunctionName(uint64_t, std::string*, uint64_t*) override;
bool GetGlobalVariable(const std::string&, uint64_t*) override;
+ bool GetBuildID(std::string*) override {
+ return false;
+ }
bool Step(uint64_t, Regs*, Memory*, bool*) override;
diff --git a/libunwindstack/tests/ElfInterfaceTest.cpp b/libunwindstack/tests/ElfInterfaceTest.cpp
index 9326bff..6023dc4 100644
--- a/libunwindstack/tests/ElfInterfaceTest.cpp
+++ b/libunwindstack/tests/ElfInterfaceTest.cpp
@@ -116,6 +116,21 @@
void InitSym(uint64_t offset, uint32_t value, uint32_t size, uint32_t name_offset,
uint64_t sym_offset, const char* name);
+ template <typename Ehdr, typename Shdr, typename Nhdr, typename ElfInterfaceType>
+ void BuildID();
+
+ template <typename Ehdr, typename Shdr, typename Nhdr, typename ElfInterfaceType>
+ void BuildIDTwoNotes();
+
+ template <typename Ehdr, typename Shdr, typename Nhdr, typename ElfInterfaceType>
+ void BuildIDSectionTooSmallForName();
+
+ template <typename Ehdr, typename Shdr, typename Nhdr, typename ElfInterfaceType>
+ void BuildIDSectionTooSmallForDesc();
+
+ template <typename Ehdr, typename Shdr, typename Nhdr, typename ElfInterfaceType>
+ void BuildIDSectionTooSmallForHeader();
+
MemoryFake memory_;
};
@@ -898,7 +913,7 @@
Ehdr ehdr = {};
ehdr.e_shoff = offset;
- ehdr.e_shnum = 6;
+ ehdr.e_shnum = 7;
ehdr.e_shentsize = sizeof(Shdr);
ehdr.e_shstrndx = 2;
memory_.SetMemory(0, &ehdr, sizeof(ehdr));
@@ -958,10 +973,19 @@
memory_.SetMemory(offset, &shdr, sizeof(shdr));
offset += ehdr.e_shentsize;
+ memset(&shdr, 0, sizeof(shdr));
+ shdr.sh_type = SHT_NOTE;
+ shdr.sh_name = 0x500;
+ shdr.sh_offset = 0xb000;
+ shdr.sh_size = 0xf00;
+ memory_.SetMemory(offset, &shdr, sizeof(shdr));
+ offset += ehdr.e_shentsize;
+
memory_.SetMemory(0xf100, ".debug_frame", sizeof(".debug_frame"));
memory_.SetMemory(0xf200, ".gnu_debugdata", sizeof(".gnu_debugdata"));
memory_.SetMemory(0xf300, ".eh_frame", sizeof(".eh_frame"));
memory_.SetMemory(0xf400, ".eh_frame_hdr", sizeof(".eh_frame_hdr"));
+ memory_.SetMemory(0xf500, ".note.gnu.build-id", sizeof(".note.gnu.build-id"));
uint64_t load_bias = 0;
ASSERT_TRUE(elf->Init(&load_bias));
@@ -974,6 +998,8 @@
EXPECT_EQ(0x800U, elf->eh_frame_size());
EXPECT_EQ(0xa000U, elf->eh_frame_hdr_offset());
EXPECT_EQ(0xf00U, elf->eh_frame_hdr_size());
+ EXPECT_EQ(0xb000U, elf->gnu_build_id_offset());
+ EXPECT_EQ(0xf00U, elf->gnu_build_id_size());
}
TEST_F(ElfInterfaceTest, init_section_headers_offsets32) {
@@ -1153,4 +1179,321 @@
EXPECT_FALSE(elf->IsValidPc(0x2a00));
}
+template <typename Ehdr, typename Shdr, typename Nhdr, typename ElfInterfaceType>
+void ElfInterfaceTest::BuildID() {
+ std::unique_ptr<ElfInterfaceType> elf(new ElfInterfaceType(&memory_));
+
+ uint64_t offset = 0x2000;
+
+ Ehdr ehdr = {};
+ ehdr.e_shoff = offset;
+ ehdr.e_shnum = 3;
+ ehdr.e_shentsize = sizeof(Shdr);
+ ehdr.e_shstrndx = 2;
+ memory_.SetMemory(0, &ehdr, sizeof(ehdr));
+
+ offset += ehdr.e_shentsize;
+
+ char note_section[128];
+ Nhdr note_header = {};
+ note_header.n_namesz = 4; // "GNU"
+ note_header.n_descsz = 8; // "BUILDID"
+ note_header.n_type = NT_GNU_BUILD_ID;
+ memcpy(¬e_section, ¬e_header, sizeof(note_header));
+ size_t note_offset = sizeof(note_header);
+ memcpy(¬e_section[note_offset], "GNU", sizeof("GNU"));
+ note_offset += sizeof("GNU");
+ memcpy(¬e_section[note_offset], "BUILDID", sizeof("BUILDID"));
+ note_offset += sizeof("BUILDID");
+
+ Shdr shdr = {};
+ shdr.sh_type = SHT_NOTE;
+ shdr.sh_name = 0x500;
+ shdr.sh_offset = 0xb000;
+ shdr.sh_size = sizeof(note_section);
+ memory_.SetMemory(offset, &shdr, sizeof(shdr));
+ offset += ehdr.e_shentsize;
+
+ // The string data for section header names.
+ memset(&shdr, 0, sizeof(shdr));
+ shdr.sh_type = SHT_STRTAB;
+ shdr.sh_name = 0x20000;
+ shdr.sh_offset = 0xf000;
+ shdr.sh_size = 0x1000;
+ memory_.SetMemory(offset, &shdr, sizeof(shdr));
+ offset += ehdr.e_shentsize;
+
+ memory_.SetMemory(0xf500, ".note.gnu.build-id", sizeof(".note.gnu.build-id"));
+ memory_.SetMemory(0xb000, note_section, sizeof(note_section));
+
+ uint64_t load_bias = 0;
+ ASSERT_TRUE(elf->Init(&load_bias));
+ std::string build_id;
+ ASSERT_TRUE(elf->GetBuildID(&build_id));
+ EXPECT_STREQ(build_id.c_str(), "BUILDID");
+}
+
+template <typename Ehdr, typename Shdr, typename Nhdr, typename ElfInterfaceType>
+void ElfInterfaceTest::BuildIDTwoNotes() {
+ std::unique_ptr<ElfInterfaceType> elf(new ElfInterfaceType(&memory_));
+
+ uint64_t offset = 0x2000;
+
+ Ehdr ehdr = {};
+ ehdr.e_shoff = offset;
+ ehdr.e_shnum = 3;
+ ehdr.e_shentsize = sizeof(Shdr);
+ ehdr.e_shstrndx = 2;
+ memory_.SetMemory(0, &ehdr, sizeof(ehdr));
+
+ offset += ehdr.e_shentsize;
+
+ char note_section[128];
+ Nhdr note_header = {};
+ note_header.n_namesz = 8; // "WRONG" aligned to 4
+ note_header.n_descsz = 8; // "BUILDID"
+ note_header.n_type = NT_GNU_BUILD_ID;
+ memcpy(¬e_section, ¬e_header, sizeof(note_header));
+ size_t note_offset = sizeof(note_header);
+ memcpy(¬e_section[note_offset], "WRONG", sizeof("WRONG"));
+ note_offset += 8;
+ memcpy(¬e_section[note_offset], "BUILDID", sizeof("BUILDID"));
+ note_offset += sizeof("BUILDID");
+
+ note_header.n_namesz = 4; // "GNU"
+ note_header.n_descsz = 8; // "BUILDID"
+ note_header.n_type = NT_GNU_BUILD_ID;
+ memcpy(¬e_section[note_offset], ¬e_header, sizeof(note_header));
+ note_offset += sizeof(note_header);
+ memcpy(¬e_section[note_offset], "GNU", sizeof("GNU"));
+ note_offset += sizeof("GNU");
+ memcpy(¬e_section[note_offset], "BUILDID", sizeof("BUILDID"));
+ note_offset += sizeof("BUILDID");
+
+ Shdr shdr = {};
+ shdr.sh_type = SHT_NOTE;
+ shdr.sh_name = 0x500;
+ shdr.sh_offset = 0xb000;
+ shdr.sh_size = sizeof(note_section);
+ memory_.SetMemory(offset, &shdr, sizeof(shdr));
+ offset += ehdr.e_shentsize;
+
+ // The string data for section header names.
+ memset(&shdr, 0, sizeof(shdr));
+ shdr.sh_type = SHT_STRTAB;
+ shdr.sh_name = 0x20000;
+ shdr.sh_offset = 0xf000;
+ shdr.sh_size = 0x1000;
+ memory_.SetMemory(offset, &shdr, sizeof(shdr));
+ offset += ehdr.e_shentsize;
+
+ memory_.SetMemory(0xf500, ".note.gnu.build-id", sizeof(".note.gnu.build-id"));
+ memory_.SetMemory(0xb000, note_section, sizeof(note_section));
+
+ uint64_t load_bias = 0;
+ ASSERT_TRUE(elf->Init(&load_bias));
+ std::string build_id;
+ ASSERT_TRUE(elf->GetBuildID(&build_id));
+ EXPECT_STREQ(build_id.c_str(), "BUILDID");
+}
+
+template <typename Ehdr, typename Shdr, typename Nhdr, typename ElfInterfaceType>
+void ElfInterfaceTest::BuildIDSectionTooSmallForName () {
+ std::unique_ptr<ElfInterfaceType> elf(new ElfInterfaceType(&memory_));
+
+ uint64_t offset = 0x2000;
+
+ Ehdr ehdr = {};
+ ehdr.e_shoff = offset;
+ ehdr.e_shnum = 3;
+ ehdr.e_shentsize = sizeof(Shdr);
+ ehdr.e_shstrndx = 2;
+ memory_.SetMemory(0, &ehdr, sizeof(ehdr));
+
+ offset += ehdr.e_shentsize;
+
+ char note_section[128];
+ Nhdr note_header = {};
+ note_header.n_namesz = 4; // "GNU"
+ note_header.n_descsz = 8; // "BUILDID"
+ note_header.n_type = NT_GNU_BUILD_ID;
+ memcpy(¬e_section, ¬e_header, sizeof(note_header));
+ size_t note_offset = sizeof(note_header);
+ memcpy(¬e_section[note_offset], "GNU", sizeof("GNU"));
+ note_offset += sizeof("GNU");
+ memcpy(¬e_section[note_offset], "BUILDID", sizeof("BUILDID"));
+ note_offset += sizeof("BUILDID");
+
+ Shdr shdr = {};
+ shdr.sh_type = SHT_NOTE;
+ shdr.sh_name = 0x500;
+ shdr.sh_offset = 0xb000;
+ shdr.sh_size = sizeof(note_header) + 1;
+ memory_.SetMemory(offset, &shdr, sizeof(shdr));
+ offset += ehdr.e_shentsize;
+
+ // The string data for section header names.
+ memset(&shdr, 0, sizeof(shdr));
+ shdr.sh_type = SHT_STRTAB;
+ shdr.sh_name = 0x20000;
+ shdr.sh_offset = 0xf000;
+ shdr.sh_size = 0x1000;
+ memory_.SetMemory(offset, &shdr, sizeof(shdr));
+ offset += ehdr.e_shentsize;
+
+ memory_.SetMemory(0xf500, ".note.gnu.build-id", sizeof(".note.gnu.build-id"));
+ memory_.SetMemory(0xb000, note_section, sizeof(note_section));
+
+ uint64_t load_bias = 0;
+ ASSERT_TRUE(elf->Init(&load_bias));
+ std::string build_id;
+ ASSERT_FALSE(elf->GetBuildID(&build_id));
+}
+
+template <typename Ehdr, typename Shdr, typename Nhdr, typename ElfInterfaceType>
+void ElfInterfaceTest::BuildIDSectionTooSmallForDesc () {
+ std::unique_ptr<ElfInterfaceType> elf(new ElfInterfaceType(&memory_));
+
+ uint64_t offset = 0x2000;
+
+ Ehdr ehdr = {};
+ ehdr.e_shoff = offset;
+ ehdr.e_shnum = 3;
+ ehdr.e_shentsize = sizeof(Shdr);
+ ehdr.e_shstrndx = 2;
+ memory_.SetMemory(0, &ehdr, sizeof(ehdr));
+
+ offset += ehdr.e_shentsize;
+
+ char note_section[128];
+ Nhdr note_header = {};
+ note_header.n_namesz = 4; // "GNU"
+ note_header.n_descsz = 8; // "BUILDID"
+ note_header.n_type = NT_GNU_BUILD_ID;
+ memcpy(¬e_section, ¬e_header, sizeof(note_header));
+ size_t note_offset = sizeof(note_header);
+ memcpy(¬e_section[note_offset], "GNU", sizeof("GNU"));
+ note_offset += sizeof("GNU");
+ memcpy(¬e_section[note_offset], "BUILDID", sizeof("BUILDID"));
+ note_offset += sizeof("BUILDID");
+
+ Shdr shdr = {};
+ shdr.sh_type = SHT_NOTE;
+ shdr.sh_name = 0x500;
+ shdr.sh_offset = 0xb000;
+ shdr.sh_size = sizeof(note_header) + sizeof("GNU") + 1;
+ memory_.SetMemory(offset, &shdr, sizeof(shdr));
+ offset += ehdr.e_shentsize;
+
+ // The string data for section header names.
+ memset(&shdr, 0, sizeof(shdr));
+ shdr.sh_type = SHT_STRTAB;
+ shdr.sh_name = 0x20000;
+ shdr.sh_offset = 0xf000;
+ shdr.sh_size = 0x1000;
+ memory_.SetMemory(offset, &shdr, sizeof(shdr));
+ offset += ehdr.e_shentsize;
+
+ memory_.SetMemory(0xf500, ".note.gnu.build-id", sizeof(".note.gnu.build-id"));
+ memory_.SetMemory(0xb000, note_section, sizeof(note_section));
+
+ uint64_t load_bias = 0;
+ ASSERT_TRUE(elf->Init(&load_bias));
+ std::string build_id;
+ ASSERT_FALSE(elf->GetBuildID(&build_id));
+}
+
+template <typename Ehdr, typename Shdr, typename Nhdr, typename ElfInterfaceType>
+void ElfInterfaceTest::BuildIDSectionTooSmallForHeader () {
+ std::unique_ptr<ElfInterfaceType> elf(new ElfInterfaceType(&memory_));
+
+ uint64_t offset = 0x2000;
+
+ Ehdr ehdr = {};
+ ehdr.e_shoff = offset;
+ ehdr.e_shnum = 3;
+ ehdr.e_shentsize = sizeof(Shdr);
+ ehdr.e_shstrndx = 2;
+ memory_.SetMemory(0, &ehdr, sizeof(ehdr));
+
+ offset += ehdr.e_shentsize;
+
+ char note_section[128];
+ Nhdr note_header = {};
+ note_header.n_namesz = 4; // "GNU"
+ note_header.n_descsz = 8; // "BUILDID"
+ note_header.n_type = NT_GNU_BUILD_ID;
+ memcpy(¬e_section, ¬e_header, sizeof(note_header));
+ size_t note_offset = sizeof(note_header);
+ memcpy(¬e_section[note_offset], "GNU", sizeof("GNU"));
+ note_offset += sizeof("GNU");
+ memcpy(¬e_section[note_offset], "BUILDID", sizeof("BUILDID"));
+ note_offset += sizeof("BUILDID");
+
+ Shdr shdr = {};
+ shdr.sh_type = SHT_NOTE;
+ shdr.sh_name = 0x500;
+ shdr.sh_offset = 0xb000;
+ shdr.sh_size = sizeof(note_header) - 1;
+ memory_.SetMemory(offset, &shdr, sizeof(shdr));
+ offset += ehdr.e_shentsize;
+
+ // The string data for section header names.
+ memset(&shdr, 0, sizeof(shdr));
+ shdr.sh_type = SHT_STRTAB;
+ shdr.sh_name = 0x20000;
+ shdr.sh_offset = 0xf000;
+ shdr.sh_size = 0x1000;
+ memory_.SetMemory(offset, &shdr, sizeof(shdr));
+ offset += ehdr.e_shentsize;
+
+ memory_.SetMemory(0xf500, ".note.gnu.build-id", sizeof(".note.gnu.build-id"));
+ memory_.SetMemory(0xb000, note_section, sizeof(note_section));
+
+ uint64_t load_bias = 0;
+ ASSERT_TRUE(elf->Init(&load_bias));
+ std::string build_id;
+ ASSERT_FALSE(elf->GetBuildID(&build_id));
+}
+
+TEST_F(ElfInterfaceTest, build_id32) {
+ BuildID<Elf32_Ehdr, Elf32_Shdr, Elf32_Nhdr, ElfInterface32>();
+}
+
+TEST_F(ElfInterfaceTest, build_id64) {
+ BuildID<Elf64_Ehdr, Elf64_Shdr, Elf64_Nhdr, ElfInterface64>();
+}
+
+TEST_F(ElfInterfaceTest, build_id_two_notes32) {
+ BuildIDTwoNotes<Elf32_Ehdr, Elf32_Shdr, Elf32_Nhdr, ElfInterface32>();
+}
+
+TEST_F(ElfInterfaceTest, build_id_two_notes64) {
+ BuildIDTwoNotes<Elf64_Ehdr, Elf64_Shdr, Elf64_Nhdr, ElfInterface64>();
+}
+
+TEST_F(ElfInterfaceTest, build_id_section_too_small_for_name32) {
+ BuildIDSectionTooSmallForName<Elf32_Ehdr, Elf32_Shdr, Elf32_Nhdr, ElfInterface32>();
+}
+
+TEST_F(ElfInterfaceTest, build_id_section_too_small_for_name64) {
+ BuildIDSectionTooSmallForName<Elf64_Ehdr, Elf64_Shdr, Elf64_Nhdr, ElfInterface64>();
+}
+
+TEST_F(ElfInterfaceTest, build_id_section_too_small_for_desc32) {
+ BuildIDSectionTooSmallForDesc<Elf32_Ehdr, Elf32_Shdr, Elf32_Nhdr, ElfInterface32>();
+}
+
+TEST_F(ElfInterfaceTest, build_id_section_too_small_for_desc64) {
+ BuildIDSectionTooSmallForDesc<Elf64_Ehdr, Elf64_Shdr, Elf64_Nhdr, ElfInterface64>();
+}
+
+TEST_F(ElfInterfaceTest, build_id_section_too_small_for_header32) {
+ BuildIDSectionTooSmallForHeader<Elf32_Ehdr, Elf32_Shdr, Elf32_Nhdr, ElfInterface32>();
+}
+
+TEST_F(ElfInterfaceTest, build_id_section_too_small_for_header64) {
+ BuildIDSectionTooSmallForHeader<Elf64_Ehdr, Elf64_Shdr, Elf64_Nhdr, ElfInterface64>();
+}
+
} // namespace unwindstack
diff --git a/libunwindstack/tests/ElfTest.cpp b/libunwindstack/tests/ElfTest.cpp
index ccf8927..7766218 100644
--- a/libunwindstack/tests/ElfTest.cpp
+++ b/libunwindstack/tests/ElfTest.cpp
@@ -311,6 +311,7 @@
void InitHeaders(uint64_t) override {}
bool GetSoname(std::string*) override { return false; }
bool GetFunctionName(uint64_t, std::string*, uint64_t*) override { return false; }
+ bool GetBuildID(std::string*) override { return false; }
MOCK_METHOD4(Step, bool(uint64_t, Regs*, Memory*, bool*));
MOCK_METHOD2(GetGlobalVariable, bool(const std::string&, uint64_t*));
diff --git a/libunwindstack/tools/unwind_info.cpp b/libunwindstack/tools/unwind_info.cpp
index aebeb95..3f2dfb0 100644
--- a/libunwindstack/tools/unwind_info.cpp
+++ b/libunwindstack/tools/unwind_info.cpp
@@ -123,6 +123,15 @@
printf("Soname: %s\n", soname.c_str());
}
+ std::string build_id;
+ if (elf.GetBuildID(&build_id)) {
+ printf("Build ID: ");
+ for (size_t i = 0; i < build_id.size(); ++i) {
+ printf("%02hhx", build_id[i]);
+ }
+ printf("\n");
+ }
+
ElfInterface* interface = elf.interface();
if (elf.machine_type() == EM_ARM) {
DumpArm(&elf, reinterpret_cast<ElfInterfaceArm*>(interface));
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index aad00ad..f88f6b9 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -9,6 +9,10 @@
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
+# The init symlink must be a post install command of a file that is to TARGET_ROOT_OUT.
+# Since init.rc is required for init and satisfies that requirement, we hijack it to create the symlink.
+LOCAL_POST_INSTALL_CMD := ln -sf /system/bin/init $(TARGET_ROOT_OUT)/init
+
include $(BUILD_PREBUILT)
#######################################
diff --git a/rootdir/ueventd.rc b/rootdir/ueventd.rc
index d47506c..d90a1ce 100644
--- a/rootdir/ueventd.rc
+++ b/rootdir/ueventd.rc
@@ -1,7 +1,5 @@
firmware_directories /etc/firmware/ /odm/firmware/ /vendor/firmware/ /firmware/image/
-
-subsystem adf
- devname uevent_devname
+uevent_socket_rcvbuf_size 16M
subsystem graphics
devname uevent_devpath
@@ -11,26 +9,10 @@
devname uevent_devpath
dirname /dev/dri
-subsystem oncrpc
- devname uevent_devpath
- dirname /dev/oncrpc
-
-subsystem adsp
- devname uevent_devpath
- dirname /dev/adsp
-
-subsystem msm_camera
- devname uevent_devpath
- dirname /dev/msm_camera
-
subsystem input
devname uevent_devpath
dirname /dev/input
-subsystem mtd
- devname uevent_devpath
- dirname /dev/mtd
-
subsystem sound
devname uevent_devpath
dirname /dev/snd
@@ -58,73 +40,25 @@
/dev/pmsg0 0222 root log
-# the msm hw3d client device node is world writable/readable.
-/dev/msm_hw3dc 0666 root root
-
-# gpu driver for adreno200 is globally accessible
-/dev/kgsl 0666 root root
-
# kms driver for drm based gpu
/dev/dri/* 0666 root graphics
# these should not be world writable
/dev/diag 0660 radio radio
-/dev/diag_arm9 0660 radio radio
/dev/ttyMSM0 0600 bluetooth bluetooth
/dev/uhid 0660 uhid uhid
/dev/uinput 0660 uhid uhid
-/dev/alarm 0664 system radio
/dev/rtc0 0640 system system
/dev/tty0 0660 root system
/dev/graphics/* 0660 root graphics
-/dev/msm_hw3dm 0660 system graphics
/dev/input/* 0660 root input
/dev/v4l-touch* 0660 root input
-/dev/eac 0660 root audio
-/dev/cam 0660 root camera
-/dev/pmem 0660 system graphics
-/dev/pmem_adsp* 0660 system audio
-/dev/pmem_camera* 0660 system camera
-/dev/oncrpc/* 0660 root system
-/dev/adsp/* 0660 system audio
/dev/snd/* 0660 system audio
-/dev/mt9t013 0660 system system
-/dev/msm_camera/* 0660 system system
-/dev/akm8976_daemon 0640 compass system
-/dev/akm8976_aot 0640 compass system
-/dev/akm8973_daemon 0640 compass system
-/dev/akm8973_aot 0640 compass system
-/dev/bma150 0640 compass system
-/dev/cm3602 0640 compass system
-/dev/akm8976_pffd 0640 compass system
-/dev/lightsensor 0640 system system
-/dev/msm_pcm_out* 0660 system audio
-/dev/msm_pcm_in* 0660 system audio
-/dev/msm_pcm_ctl* 0660 system audio
-/dev/msm_snd* 0660 system audio
/dev/msm_mp3* 0660 system audio
-/dev/audience_a1026* 0660 system audio
-/dev/tpa2018d1* 0660 system audio
-/dev/msm_audpre 0660 system audio
-/dev/msm_audio_ctl 0660 system audio
-/dev/htc-acoustic 0660 system audio
-/dev/vdec 0660 system audio
-/dev/q6venc 0660 system audio
-/dev/snd/dsp 0660 system audio
-/dev/snd/dsp1 0660 system audio
-/dev/snd/mixer 0660 system audio
-/dev/smd0 0640 radio radio
-/dev/qmi 0640 radio radio
-/dev/qmi0 0640 radio radio
-/dev/qmi1 0640 radio radio
-/dev/qmi2 0640 radio radio
-/dev/bus/usb/* 0660 root usb
-/dev/mtp_usb 0660 root mtp
/dev/usb_accessory 0660 root usb
/dev/tun 0660 system vpn
# CDMA radio interface MUX
-/dev/ts0710mux* 0640 radio radio
/dev/ppp 0660 radio vpn
# sysfs properties
@@ -134,6 +68,3 @@
/sys/devices/virtual/usb_composite/* enable 0664 root system
/sys/devices/system/cpu/cpu* cpufreq/scaling_max_freq 0664 system system
/sys/devices/system/cpu/cpu* cpufreq/scaling_min_freq 0664 system system
-
-# DVB API device nodes
-/dev/dvb* 0660 root system
diff --git a/shell_and_utilities/README.md b/shell_and_utilities/README.md
index d8cf867..ffda3a5 100644
--- a/shell_and_utilities/README.md
+++ b/shell_and_utilities/README.md
@@ -1,5 +1,4 @@
-Android's shell and utilities
-=============================
+# Android's shell and utilities
Since IceCreamSandwich Android has used
[mksh](https://www.mirbsd.org/mksh.htm) as its shell. Before then it used
@@ -34,8 +33,7 @@
full list for a release by running `toybox` directly.
-Android 2.3 (Gingerbread)
--------------------------
+## Android 2.3 (Gingerbread)
BSD: cat dd newfs\_msdos
@@ -46,8 +44,7 @@
umount uptime vmstat watchprops wipe
-Android 4.0 (IceCreamSandwich)
-------------------------------
+## Android 4.0 (IceCreamSandwich)
BSD: cat dd newfs\_msdos
@@ -58,8 +55,7 @@
touch umount uptime vmstat watchprops wipe
-Android 4.1-4.3 (JellyBean)
----------------------------
+## Android 4.1-4.3 (JellyBean)
BSD: cat cp dd du grep newfs\_msdos
@@ -71,8 +67,7 @@
sync top touch umount uptime vmstat watchprops wipe
-Android 4.4 (KitKat)
---------------------
+## Android 4.4 (KitKat)
BSD: cat cp dd du grep newfs\_msdos
@@ -84,8 +79,7 @@
stop swapoff swapon sync top touch umount uptime vmstat watchprops wipe
-Android 5.0 (Lollipop)
-----------------------
+## Android 5.0 (Lollipop)
BSD: cat chown cp dd du grep kill ln mv printenv rm rmdir sleep sync
@@ -97,8 +91,7 @@
top touch umount uptime vmstat watchprops wipe
-Android 6.0 (Marshmallow)
--------------------------
+## Android 6.0 (Marshmallow)
BSD: dd du grep
@@ -118,8 +111,7 @@
vmstat wc which whoami xargs yes
-Android 7.0 (Nougat)
---------------------
+## Android 7.0 (Nougat)
BSD: dd grep
@@ -140,8 +132,7 @@
uptime usleep vmstat wc which whoami xargs xxd yes
-Android 8.0 (Oreo)
-------------------
+## Android 8.0 (Oreo)
BSD: dd grep
@@ -164,8 +155,8 @@
tty ulimit umount uname uniq unix2dos uptime usleep uudecode uuencode
vmstat wc which whoami xargs xxd yes zcat
-Android P
----------
+
+## Android 9.0 (Pie)
BSD: dd grep
@@ -190,8 +181,8 @@
umount uname uniq unix2dos uptime usleep uudecode uuencode vmstat wc
which whoami xargs xxd yes zcat
-Android Q
----------
+
+## Android Q
BSD: grep fsck\_msdos newfs\_msdos
@@ -201,17 +192,22 @@
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
-dmesg dos2unix du echo env expand expr fallocate false file find flock
-fmt free getenforce groups gunzip gzip head hostname hwclock id ifconfig
-inotifyd insmod ionice iorenice kill killall ln load\_policy log logname
-losetup ls lsmod lsof lspci lsusb md5sum microcom mkdir mkfifo mknod
-mkswap mktemp modinfo modprobe more mount mountpoint mv nc netcat netstat
-nice nl nohup nsenter od paste patch pgrep pidof pkill pmap printenv
-printf ps pwd readlink realpath renice restorecon rm rmdir rmmod runcon
-sed sendevent seq setenforce setprop setsid sha1sum sha224sum sha256sum
-sha384sum sha512sum sleep sort split start stat stop strings stty swapoff
-swapon sync sysctl tac tail tar taskset tee time timeout top touch tr
-true truncate tty ulimit umount uname uniq unix2dos unshare uptime usleep
-uudecode uuencode vmstat wc which whoami xargs xxd yes zcat
+toybox: acpi base64 basename bc blkid blockdev cal cat chattr chcon chgrp
+chmod chown chroot chrt cksum clear cmp comm cp cpio cut date dd df
+diff dirname dmesg dos2unix du echo egrep env expand expr fallocate
+false fgrep file find flock fmt free freeramdisk fsfreeze getconf
+getenforce getfattr grep groups gunzip gzip head help hostname hwclock
+i2cdetect i2cdump i2cget i2cset iconv id ifconfig inotifyd insmod
+install ionice iorenice iotop kill killall ln load\_policy log logname
+losetup ls lsattr lsmod lsof lspci lsusb makedevs md5sum microcom
+mkdir mkfifo mknod mkswap mktemp modinfo modprobe more mount mountpoint
+mv nbd-client nc netcat netstat nice nl nohup nproc nsenter od partprobe
+paste patch pgrep pidof ping ping6 pivot\_root pkill pmap printenv
+printf prlimit ps pwd pwdx readlink realpath renice restorecon rev
+rfkill rm rmdir rmmod runcon sed sendevent seq setenforce setfattr
+setprop setsid sha1sum sha224sum sha256sum sha384sum sha512sum sleep
+sort split start stat stop strings stty swapoff swapon sync sysctl
+tac tail tar taskset tee time timeout top touch tr traceroute traceroute6
+true truncate tty tunctl ulimit umount uname uniq unix2dos unlink
+unshare uptime usleep uudecode uuencode uuidgen vconfig vmstat watch
+wc which whoami xargs xxd yes zcat