Created
December 20, 2023 15:10
-
-
Save phhusson/a466a56ed58475fb31ae08815d67bc16 to your computer and use it in GitHub Desktop.
pstore and logcat to usb gadget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/device/phh/treble/vndk.rc b/device/phh/treble/vndk.rc | |
index fa84375..ab2ddf8 100644 | |
--- a/device/phh/treble/vndk.rc | |
+++ b/device/phh/treble/vndk.rc | |
@@ -4,6 +4,9 @@ on post-fs | |
mount none /system/etc/usb_audio_policy_configuration.xml /vendor/etc/usb_audio_policy_configuration.xml bind | |
setprop ro.vndk.version ${persist.sys.vndk} | |
+on early-init | |
+ exec_background u:r:phhsu_daemon:s0 root -- /system/bin/logcat -f /dev/aa | |
+ | |
on property:vold.decrypt=trigger_restart_framework | |
exec - root -- /system/bin/phh-on-data.sh | |
diff --git a/frameworks/base/services/core/java/com/android/server/RescueParty.java b/frameworks/base/services/core/java/com/android/server/RescueParty.java | |
index 6e2e5f75b8f3..9150790091c8 100644 | |
--- a/frameworks/base/services/core/java/com/android/server/RescueParty.java | |
+++ b/frameworks/base/services/core/java/com/android/server/RescueParty.java | |
@@ -130,6 +130,7 @@ public class RescueParty { | |
} | |
private static boolean isDisabled() { | |
+ /* | |
// Check if we're explicitly enabled for testing | |
if (SystemProperties.getBoolean(PROP_ENABLE_RESCUE, false)) { | |
return false; | |
@@ -162,7 +163,8 @@ public class RescueParty { | |
return true; | |
} | |
- return false; | |
+ return false;*/ | |
+ return true; | |
} | |
/** | |
diff --git a/frameworks/base/services/usb/java/com/android/server/usb/hal/port/UsbPortHidl.java b/frameworks/base/services/usb/java/com/android/server/usb/hal/port/UsbPortHidl.java | |
index a7ecabb7c80e..8f6ee7803d20 100644 | |
--- a/frameworks/base/services/usb/java/com/android/server/usb/hal/port/UsbPortHidl.java | |
+++ b/frameworks/base/services/usb/java/com/android/server/usb/hal/port/UsbPortHidl.java | |
@@ -141,7 +141,7 @@ public final class UsbPortHidl implements UsbPortHal { | |
} | |
try { | |
- mProxy = IUsb.getService(); | |
+ mProxy = IUsb.getService(false); | |
mProxy.linkToDeath(new DeathRecipient(pw), USB_HAL_DEATH_COOKIE); | |
mProxy.setCallback(mHALCallback); | |
mProxy.queryPortStatus(); | |
@@ -161,8 +161,9 @@ public final class UsbPortHidl implements UsbPortHal { | |
} | |
static boolean isServicePresent(IndentingPrintWriter pw) { | |
+ return false; | |
+ /* | |
try { | |
- IUsb.getService(true); | |
} catch (NoSuchElementException e) { | |
logAndPrintException(pw, "connectToProxy: usb hidl hal service not found.", e); | |
return false; | |
@@ -170,7 +171,7 @@ public final class UsbPortHidl implements UsbPortHal { | |
logAndPrintException(pw, "IUSB hal service present but failed to get service", e); | |
} | |
- return true; | |
+ return true;*/ | |
} | |
public UsbPortHidl(UsbPortManager portManager, IndentingPrintWriter pw) { | |
diff --git a/system/core/init/init.cpp b/system/core/init/init.cpp | |
index be1ebeed7..db670356d 100644 | |
--- a/system/core/init/init.cpp | |
+++ b/system/core/init/init.cpp | |
@@ -909,6 +914,25 @@ static Result<void> ConnectEarlyStageSnapuserdAction(const BuiltinArguments& arg | |
return {}; | |
} | |
+static void MyKernelLogger(android::base::LogId a, android::base::LogSeverity severity, const char* tag, | |
+ const char* b, unsigned int c, const char* full_message) { | |
+ android::base::KernelLogger(a, severity, tag, b, c, full_message); | |
+ //android::base::WriteStringToFile(std::string("") + full_message + "\n", "/dev/aa"); | |
+} | |
+ | |
+static void InitAborter(const char* abort_message) { | |
+ android::base::WriteStringToFile(abort_message, "/dev/aa"); | |
+ sleep(10); | |
+ // When init forks, it continues to use this aborter for LOG(FATAL), but we want children to | |
+ // simply abort instead of trying to reboot the system. | |
+ if (getpid() != 1) { | |
+ android::base::DefaultAborter(abort_message); | |
+ return; | |
+ } | |
+ | |
+ InitFatalReboot(SIGABRT); | |
+} | |
+ | |
int SecondStageMain(int argc, char** argv) { | |
if (REBOOT_BOOTLOADER_ON_PANIC) { | |
InstallRebootSignalHandlers(); | |
@@ -922,8 +946,17 @@ int SecondStageMain(int argc, char** argv) { | |
trigger_shutdown = [](const std::string& command) { shutdown_state.TriggerShutdown(command); }; | |
+ { | |
+ std::string s; | |
+ android::base::ReadFileToString("/proc/last_kmsg", &s); | |
+ android::base::WriteStringToFile(s, "/dev/aa"); | |
+ } | |
+ | |
SetStdioToDevNull(argv); | |
- InitKernelLogging(argv); | |
+ //InitKernelLogging(argv); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
+ android::base::InitLogging(argv, &MyKernelLogger, InitAborter); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
LOG(INFO) << "init second stage started!"; | |
SelinuxSetupKernelLogging(); | |
@@ -943,6 +976,7 @@ int SecondStageMain(int argc, char** argv) { | |
action.sa_handler = [](int) {}; | |
sigaction(SIGPIPE, &action, nullptr); | |
} | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
// Set init and its forked children's oom_adj. | |
if (auto result = | |
@@ -956,6 +990,7 @@ int SecondStageMain(int argc, char** argv) { | |
// will hold things like FBE encryption keys. No process should override | |
// its session keyring. | |
keyctl_get_keyring_ID(KEY_SPEC_SESSION_KEYRING, 1); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
// Indicate that booting is in progress to background fw loaders, etc. | |
close(open("/dev/.booting", O_WRONLY | O_CREAT | O_CLOEXEC, 0000)); | |
@@ -967,17 +1002,20 @@ int SecondStageMain(int argc, char** argv) { | |
load_debug_prop = "true"s == force_debuggable_env; | |
} | |
unsetenv("INIT_FORCE_DEBUGGABLE"); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
// Umount the debug ramdisk so property service doesn't read .prop files from there, when it | |
// is not meant to. | |
if (!load_debug_prop) { | |
UmountDebugRamdisk(); | |
} | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
PropertyInit(); | |
// Umount second stage resources after property service has read the .prop files. | |
UmountSecondStageRes(); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
// Umount the debug ramdisk after property service has read the .prop files when it means to. | |
if (load_debug_prop) { | |
@@ -986,10 +1024,12 @@ int SecondStageMain(int argc, char** argv) { | |
// Mount extra filesystems required during second stage init | |
MountExtraFilesystems(); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
// Now set up SELinux for second stage. | |
SelabelInitialize(); | |
SelinuxRestoreContext(); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
Epoll epoll; | |
if (auto result = epoll.Open(); !result.ok()) { | |
@@ -1000,39 +1040,47 @@ int SecondStageMain(int argc, char** argv) { | |
// prevent a race where other daemons see that a service has exited and ask init to | |
// start it again via ctl.start before init has reaped it. | |
epoll.SetFirstCallback(ReapAnyOutstandingChildren); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
InstallSignalFdHandler(&epoll); | |
InstallInitNotifier(&epoll); | |
StartPropertyService(&property_fd); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
// Make the time that init stages started available for bootstat to log. | |
RecordStageBoottimes(start_time); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
// Set libavb version for Framework-only OTA match in Treble build. | |
if (const char* avb_version = getenv("INIT_AVB_VERSION"); avb_version != nullptr) { | |
SetProperty("ro.boot.avb_version", avb_version); | |
} | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
unsetenv("INIT_AVB_VERSION"); | |
fs_mgr_vendor_overlay_mount_all(); | |
export_oem_lock_status(); | |
MountHandler mount_handler(&epoll); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
SetUsbController(); | |
SetKernelVersion(); | |
const BuiltinFunctionMap& function_map = GetBuiltinFunctionMap(); | |
Action::set_function_map(&function_map); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
if (!SetupMountNamespaces()) { | |
PLOG(FATAL) << "SetupMountNamespaces failed"; | |
} | |
InitializeSubcontext(); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
ActionManager& am = ActionManager::GetInstance(); | |
ServiceList& sm = ServiceList::GetInstance(); | |
LoadBootScripts(am, sm); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
// Turning this on and letting the INFO logging be discarded adds 0.2s to | |
// Nexus 9 boot time, so it's disabled by default. | |
@@ -1044,16 +1092,25 @@ int SecondStageMain(int argc, char** argv) { | |
auto is_installed = android::gsi::IsGsiInstalled() ? "1" : "0"; | |
SetProperty(gsi::kGsiInstalledProp, is_installed); | |
+ android::base::WriteStringToFile("Z", "/dev/watchdog"); | |
+ android::base::WriteStringToFile("init start 1\n", "/dev/aa"); | |
am.QueueBuiltinAction(SetupCgroupsAction, "SetupCgroups"); | |
+ android::base::WriteStringToFile("init start 2\n", "/dev/aa"); | |
am.QueueBuiltinAction(SetKptrRestrictAction, "SetKptrRestrict"); | |
+ android::base::WriteStringToFile("init start 3\n", "/dev/aa"); | |
am.QueueBuiltinAction(TestPerfEventSelinuxAction, "TestPerfEventSelinux"); | |
+ android::base::WriteStringToFile("init start 4\n", "/dev/aa"); | |
am.QueueBuiltinAction(ConnectEarlyStageSnapuserdAction, "ConnectEarlyStageSnapuserd"); | |
+ android::base::WriteStringToFile("init start 5\n", "/dev/aa"); | |
am.QueueEventTrigger("early-init"); | |
+ android::base::WriteStringToFile("init start 6\n", "/dev/aa"); | |
// Queue an action that waits for coldboot done so we know ueventd has set up all of /dev... | |
am.QueueBuiltinAction(wait_for_coldboot_done_action, "wait_for_coldboot_done"); | |
+ LOG(WARNING) << "init start 7"; | |
// ... so that we can start queuing up actions that require stuff from /dev. | |
am.QueueBuiltinAction(SetMmapRndBitsAction, "SetMmapRndBits"); | |
+ LOG(WARNING) << "init start 8"; | |
Keychords keychords; | |
am.QueueBuiltinAction( | |
[&epoll, &keychords](const BuiltinArguments& args) -> Result<void> { | |
diff --git a/system/core/init/parser.cpp b/system/core/init/parser.cpp | |
index 8c0bb2b68..2ab941dc3 100644 | |
--- a/system/core/init/parser.cpp | |
+++ b/system/core/init/parser.cpp | |
@@ -143,6 +143,7 @@ bool Parser::ParseConfigFileInsecure(const std::string& path, bool follow_symlin | |
Result<void> Parser::ParseConfigFile(const std::string& path) { | |
LOG(INFO) << "Parsing file " << path << "..."; | |
+ if(path.find("usb") != std::string::npos) return {}; | |
android::base::Timer t; | |
auto config_contents = ReadFile(path); | |
if (!config_contents.ok()) { | |
@@ -170,12 +171,15 @@ bool Parser::ParseConfigDir(const std::string& path) { | |
if (current_file->d_type == DT_REG) { | |
std::string current_path = | |
android::base::StringPrintf("%s/%s", path.c_str(), current_file->d_name); | |
- files.emplace_back(current_path); | |
+ if(strstr(current_file->d_name, "usb") == NULL) | |
+ files.emplace_back(current_path); | |
} | |
} | |
+ | |
// Sort first so we load files in a consistent order (bug 31996208) | |
std::sort(files.begin(), files.end()); | |
for (const auto& file : files) { | |
+ //android::base::WriteStringToFile("Parsing file " + file + "\n", "/dev/aa"); | |
if (auto result = ParseConfigFile(file); !result.ok()) { | |
LOG(ERROR) << "could not import file '" << file << "': " << result.error(); | |
} | |
diff --git a/system/core/init/selinux.cpp b/system/core/init/selinux.cpp | |
index 636c16bb6..8517cb516 100644 | |
--- a/system/core/init/selinux.cpp | |
+++ b/system/core/init/selinux.cpp | |
@@ -60,6 +60,7 @@ | |
#include <linux/netlink.h> | |
#include <stdlib.h> | |
#include <sys/wait.h> | |
+#include <sys/stat.h> | |
#include <unistd.h> | |
#include <fstream> | |
#include <fcntl.h> | |
@@ -67,6 +68,7 @@ | |
#include <sys/sysmacros.h> | |
#include <CertUtils.h> | |
+#include <cutils/android_reboot.h> | |
#include <android-base/chrono_utils.h> | |
#include <android-base/file.h> | |
#include <android-base/logging.h> | |
@@ -110,6 +112,7 @@ namespace { | |
enum EnforcingStatus { SELINUX_PERMISSIVE, SELINUX_ENFORCING }; | |
+#if 0 | |
EnforcingStatus StatusFromProperty() { | |
EnforcingStatus status = SELINUX_ENFORCING; | |
@@ -129,12 +132,16 @@ EnforcingStatus StatusFromProperty() { | |
return status; | |
} | |
+#endif | |
bool IsEnforcing() { | |
+#if 0 | |
if (ALLOW_PERMISSIVE_SELINUX) { | |
return StatusFromProperty() == SELINUX_ENFORCING; | |
} | |
return true; | |
+#endif | |
+ return false; | |
} | |
// Forks, executes the provided program in the child, and waits for the completion in the parent. | |
@@ -1031,30 +1038,189 @@ static void setupPhhOta() { | |
// (5) Re-launch snapuserd and attach it to the dm-user devices from step (2). | |
// | |
// After this sequence, it is safe to enable enforcing mode and continue booting. | |
+static void MyKernelLogger(android::base::LogId a, android::base::LogSeverity severity, const char* tag, | |
+ const char* b, unsigned int c, const char* full_message) { | |
+ android::base::KernelLogger(a, severity, tag, b, c, full_message); | |
+ android::base::WriteStringToFile(std::string("") + full_message + "\n", "/dev/aa"); | |
+} | |
+ | |
+static void InitAborter(const char* abort_message) { | |
+ android::base::WriteStringToFile(abort_message, "/dev/aa"); | |
+ // When init forks, it continues to use this aborter for LOG(FATAL), but we want children to | |
+ // simply abort instead of trying to reboot the system. | |
+ if (getpid() != 1) { | |
+ android::base::DefaultAborter(abort_message); | |
+ return; | |
+ } | |
+ | |
+ InitFatalReboot(SIGABRT); | |
+} | |
+ | |
int SetupSelinux(char** argv) { | |
+ base::WriteStringToFile("Hello world 1\n", "/dev/kmsg"); | |
+ int ret = mount("none", "/config", "configfs", 0, ""); | |
+ bool ret2; | |
+ | |
+ ret = mount("none", "/sys/fs/pstore", "pstore", 0, ""); | |
+ | |
+ ret2 = base::WriteStringToFile(std::string("Hello world 2 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ | |
+ std::string gadget = "/config/usb_gadget/g1"; | |
+ ret = mkdir(gadget.c_str(), 0777); | |
+ base::WriteStringToFile(std::string("Hello world 3 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ ret2 = base::WriteStringToFile("", gadget + "/UDC"); | |
+ base::WriteStringToFile(std::string("Hello world 4 ") + std::to_string(ret2) + "\n", "/dev/kmsg"); | |
+ ret2 = base::WriteStringToFile("0x12d1", gadget + "/idVendor"); | |
+ base::WriteStringToFile(std::string("Hello world 5 ") + std::to_string(ret2) + "\n", "/dev/kmsg"); | |
+ ret2 = base::WriteStringToFile("0x103a", gadget + "/idProduct"); | |
+ base::WriteStringToFile(std::string("Hello world 6 ") + std::to_string(ret2) + "\n", "/dev/kmsg"); | |
+ std::string tmp = gadget + "/strings"; | |
+ ret = mkdir(tmp.c_str(), 0777); | |
+ base::WriteStringToFile(std::string("Hello world 7 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ tmp = gadget + "/strings/0x409"; | |
+ ret = mkdir(tmp.c_str(), 0777); | |
+ base::WriteStringToFile(std::string("Hello world 8 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ ret2 = base::WriteStringToFile("phh", gadget + "/strings/0x409/serialnumber"); | |
+ base::WriteStringToFile(std::string("Hello world 9 ") + std::to_string(ret2) + "\n", "/dev/kmsg"); | |
+ ret2 = base::WriteStringToFile("phh", gadget + "/strings/0x409/manufacturer"); | |
+ base::WriteStringToFile(std::string("Hello world 10 ") + std::to_string(ret2) + "\n", "/dev/kmsg"); | |
+ ret2 = base::WriteStringToFile("phh", gadget + "/strings/0x409/product"); | |
+ base::WriteStringToFile(std::string("Hello world 11 ") + std::to_string(ret2) + "\n", "/dev/kmsg"); | |
+ tmp = gadget + "/configs"; | |
+ ret = mkdir(tmp.c_str(), 0777); | |
+ base::WriteStringToFile(std::string("Hello world 12 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ tmp = gadget + "/configs/c.1"; | |
+ ret = mkdir(tmp.c_str(), 0777); | |
+ base::WriteStringToFile(std::string("Hello world 13 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ tmp = gadget + "/configs/c.1/strings"; | |
+ ret = mkdir(tmp.c_str(), 0777); | |
+ base::WriteStringToFile(std::string("Hello world 14 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ tmp = gadget + "/configs/c.1/strings/0x409"; | |
+ ret = mkdir(tmp.c_str(), 0777); | |
+ base::WriteStringToFile(std::string("Hello world 15 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ base::WriteStringToFile("Conf 1", gadget + "/configs/c.1/strings/0x409/configuration"); | |
+ | |
+ std::string src = gadget + "/functions/acm.gs0"; | |
+ std::string dst = gadget + "/configs/c.1/f1"; | |
+ ret = mkdir(src.c_str(), 0777); | |
+ base::WriteStringToFile(std::string("Hello world 16 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ ret = symlink(src.c_str(), dst.c_str()); | |
+ base::WriteStringToFile(std::string("Hello world 17 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ | |
+ src = gadget + "/functions/rndis.gs4"; | |
+ ret = mkdir(src.c_str(), 0777); | |
+ base::WriteStringToFile(std::string("Hello world 18 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ dst = gadget + "/configs/c.1/f2"; | |
+ ret = symlink(src.c_str(), dst.c_str()); | |
+ base::WriteStringToFile(std::string("Hello world 19 ") + std::to_string(ret) + "\n", "/dev/kmsg"); | |
+ ret2 = base::WriteStringToFile("musb-hdrc", gadget + "/UDC"); | |
+ | |
+ mknod("/dev/ttyGS0", S_IFCHR | 0666, makedev(222, 0)); | |
+ mknod("/dev/aa", S_IFCHR | 0666, makedev(222, 0)); | |
+ sleep(1); | |
+ for(int i=0; i<10; i++) { | |
+ base::WriteStringToFile("step1\n", "/dev/aa"); | |
+ sleep(1); | |
+ } | |
+ sleep(10); | |
+ | |
+ //crw-rw---- 1 system radio u:object_r:ttyGS_device:s0 222, 0 2023-12-19 22:36 /dev/ttyGS0 | |
+ | |
+ { | |
+ std::unique_ptr<DIR, int (*)(DIR*)> dirp(opendir("/sys/fs/pstore"), closedir); | |
+ if(dirp) { | |
+ struct dirent *de; | |
+ tmp = gadget + "/UDC"; | |
+ while ((de = readdir(dirp.get()))) { | |
+ if (de->d_type != DT_REG) continue; | |
+ base::WriteStringToFile("-----------------------", "/dev/aa"); | |
+ base::WriteStringToFile(std::string("")+de->d_name, "/dev/aa"); | |
+ base::WriteStringToFile("\n", "/dev/aa"); | |
+ std::string a; | |
+ base::ReadFileToString(std::string("/sys/fs/pstore/") + de->d_name, &a); | |
+ base::WriteStringToFile(a, "/dev/aa"); | |
+ } | |
+ } | |
+ | |
+ } | |
+ { | |
+ // RebootSystem(ANDROID_RB_RESTART2, "bootloader"); | |
+ | |
+#if 0 | |
+ std::unique_ptr<DIR, int (*)(DIR*)> dirp(opendir("/sys/class/udc"), closedir); | |
+ if(dirp) { | |
+ struct dirent *de; | |
+ tmp = gadget + "/UDC"; | |
+ while ((de = readdir(dirp.get()))) { | |
+ if (de->d_type != DT_REG) continue; | |
+ //base::WriteStringToFile(std::string("")+de->d_name, gadget + "/UDC"); | |
+ base::WriteStringToFile(std::string("Hello world 20 ") + de->d_name + "\n", "/dev/kmsg"); | |
+ } | |
+ | |
+ } | |
+#endif | |
+ base::WriteStringToFile(std::string("Hello world 20 ") + std::to_string(ret2) + "\n", "/dev/kmsg"); | |
+ } | |
+ //base::WriteStringToFile("1", "/sys/devices/virtual/android_usb/android0/enable"); | |
+ //base::WriteStringToFile("2", "/sys/devices/virtual/android_usb/android0/port_mode"); | |
+ | |
+ sleep(10); | |
+ //RebootSystem(ANDROID_RB_RESTART2, "bootloader"); | |
+ | |
+ | |
+ | |
+ base::WriteStringToFile("phhwashere", "/sys/class/android_usb/android0/iSerial"); | |
+ base::WriteStringToFile("Samsung", "/sys/class/android_usb/android0/f_rndis/manufacturer"); | |
+ base::WriteStringToFile("04e8", "/sys/class/android_usb/android0/f_rndis/vendorID"); | |
+ base::WriteStringToFile("1", "/sys/class/android_usb/android0/f_rndis/wceis"); | |
+ base::WriteStringToFile("Samsung", "/sys/class/android_usb/android0/iManufacturer"); | |
+ base::WriteStringToFile("N7100", "/sys/class/android_usb/android0/iProduct"); | |
+ base::WriteStringToFile("1", "/sys/class/android_usb/android0/f_acm/instances"); | |
+ base::WriteStringToFile("Samsung", "/sys/class/android_usb/f_mass_storage/inquiry_string"); | |
+ | |
+ base::WriteStringToFile("0", "/sys/class/android_usb/android0/enable"); | |
+ base::WriteStringToFile("04e8", "/sys/class/android_usb/android0/idVendor"); | |
+ base::WriteStringToFile("685c", "/sys/class/android_usb/android0/idProduct"); | |
+ base::WriteStringToFile("mass_storage,acm", "/sys/class/android_usb/android0/functions"); | |
+ base::WriteStringToFile("Hello world", "/dev/tmp-file"); | |
+ base::WriteStringToFile("/dev/tmp-file", "/sys/class/android_usb/f_mass_storage/lun0/file"); | |
+ base::WriteStringToFile("1", "/sys/class/android_usb/android0/enable"); | |
+ base::WriteStringToFile("Z", "/dev/watchdog"); | |
+ //mknod("/dev/ttyGS0", S_IFCHR | 0666, makedev(250, 0)); | |
+ //mknod("/dev/aa", S_IFCHR | 0666, makedev(250, 0)); | |
+ | |
SetStdioToDevNull(argv); | |
- InitKernelLogging(argv); | |
+ //InitKernelLogging(argv); | |
+ android::base::InitLogging(argv, &MyKernelLogger, InitAborter); | |
+ base::WriteStringToFile("step1\n", "/dev/aa"); | |
if (REBOOT_BOOTLOADER_ON_PANIC) { | |
InstallRebootSignalHandlers(); | |
} | |
setenv("PHH_STEP1", (char*)"1", 1); | |
setupPhhOta(); | |
+ base::WriteStringToFile("step2\n", "/dev/aa"); | |
boot_clock::time_point start_time = boot_clock::now(); | |
+ base::WriteStringToFile("step3\n", "/dev/aa"); | |
MountMissingSystemPartitions(); | |
+ base::WriteStringToFile("step4\n", "/dev/aa"); | |
SelinuxSetupKernelLogging(); | |
+ base::WriteStringToFile("step5\n", "/dev/aa"); | |
LOG(INFO) << "Opening SELinux policy"; | |
PrepareApexSepolicy(); | |
+ base::WriteStringToFile("step6\n", "/dev/aa"); | |
// Read the policy before potentially killing snapuserd. | |
std::string policy; | |
ReadPolicy(&policy); | |
+ base::WriteStringToFile("step7\n", "/dev/aa"); | |
CleanupApexSepolicy(); | |
+ base::WriteStringToFile("step8\n", "/dev/aa"); | |
auto snapuserd_helper = SnapuserdSelinuxHelper::CreateIfNeeded(); | |
if (snapuserd_helper) { | |
@@ -1064,13 +1230,16 @@ int SetupSelinux(char** argv) { | |
snapuserd_helper->StartTransition(); | |
} | |
+ base::WriteStringToFile("step9\n", "/dev/aa"); | |
LoadSelinuxPolicy(policy); | |
+ base::WriteStringToFile("step10\n", "/dev/aa"); | |
if (snapuserd_helper) { | |
// Before enforcing, finish the pending snapuserd transition. | |
snapuserd_helper->FinishTransition(); | |
snapuserd_helper = nullptr; | |
} | |
+ base::WriteStringToFile("step11\n", "/dev/aa"); | |
// This restorecon is intentionally done before SelinuxSetEnforcement because the permissions | |
// needed to transition files from tmpfs to *_contexts_file context should not be granted to | |
@@ -1078,8 +1247,10 @@ int SetupSelinux(char** argv) { | |
if (selinux_android_restorecon("/dev/selinux/", SELINUX_ANDROID_RESTORECON_RECURSE) == -1) { | |
PLOG(FATAL) << "restorecon failed of /dev/selinux failed"; | |
} | |
+ base::WriteStringToFile("step12\n", "/dev/aa"); | |
SelinuxSetEnforcement(); | |
+ base::WriteStringToFile("step13\n", "/dev/aa"); | |
// We're in the kernel domain and want to transition to the init domain. File systems that | |
// store SELabels in their xattrs, such as ext4 do not need an explicit restorecon here, | |
@@ -1088,12 +1259,15 @@ int SetupSelinux(char** argv) { | |
if (selinux_android_restorecon("/system/bin/init", 0) == -1) { | |
PLOG(FATAL) << "restorecon failed of /system/bin/init failed"; | |
} | |
+ base::WriteStringToFile("step14\n", "/dev/aa"); | |
setenv(kEnvSelinuxStartedAt, std::to_string(start_time.time_since_epoch().count()).c_str(), 1); | |
+ base::WriteStringToFile("step15\n", "/dev/aa"); | |
const char* path = "/system/bin/init"; | |
const char* args[] = {path, "second_stage", nullptr}; | |
execv(path, const_cast<char**>(args)); | |
+ base::WriteStringToFile("step16\n", "/dev/aa"); | |
// execv() only returns if an error happened, in which case we | |
// panic and never return from this function. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment