简体   繁体   English

当缺少/ system / bin / sh时,如何在android上获得有效的adb shell?

[英]How can I get a working adb shell on android when /system/bin/sh is missing?

I'm trying to build Android Jellybean from source for the Measy U2C HDMI stick. 我正在尝试从Measy U2C HDMI棒的源头构建Android Jellybean。 I've managed to build and install all the partitions (boot, kernel, misc, recovery, system...). 我已经设法构建并安装所有分区(启动,内核,misc,恢复,系统......)。 The problem I'm having is that the system partition doesn't seem to be mounting. 我遇到的问题是系统分区似乎没有安装。 When I run 我跑的时候

adb ls /system

I get the following output: 我得到以下输出:

000041ed 00000400 51301410 .
000041c0 00000800 00000003 lost+found
000041ed 00000000 00000001 ..

I'd like to adb shell into the device and try to debug why the system partition is not mounting but adb wants there to be a working shell in /system/bin/sh. 我想将shell添加到设备中并尝试调试系统分区未安装的原因,但adb希望在/ system / bin / sh中有一个可用的shell。

$ adb shell
- exec '/system/bin/sh' failed: No such file or directory (2) -

My question is, how can I get adb to look elsewhere for the shell command so i can get this working? 我的问题是,如何让adb在别处查找shell命令,这样我才能使用它? Or is there an alternate way to remote into the device and debug this? 或者是否有另一种远程进入设备并进行调试的方法? There is a busybox install at /sbin/busybox so if I can just invoke that somehow, I can figure this out. 在/ sbin / busybox上安装了busybox,所以如果我能以某种方式调用它,我可以解决这个问题。

"SHELL_COMMAND" appears to be hardcoded in adb/services.c an unofficial copy of which is browsable at “SHELL_COMMAND”似乎是在adb / services.c中硬编码的,其中非正式的副本可以浏览

https://github.com/android/platform_system_core/blob/master/adb/services.c https://github.com/android/platform_system_core/blob/master/adb/services.c

Given that you are building from source you should be able to change this. 鉴于您正在从源代码构建,您应该能够更改它。 But since you want to point it to a shorter path, you could also probably edit the binary and move up the terminating null. 但是,由于您希望将其指向较短的路径,因此您也可以编辑二进制文件并向上移动终止空值。

Another approach to investigating your problem could be to see if you can get a working adb shell after booting to the recovery partition, and try manually mounting the problematic system partition there to see what errors result. 调查问题的另一种方法可能是在启动到恢复分区后查看是否可以获得有效的adb shell,并尝试在那里手动安装有问题的系统分区以查看导致的错误。

Still another idea would be to put something in the startup scripts which launches an alternate shell listening on something which you could forward a socket to using adb - I'm not thinking of an obvious reason why setting up adb forwards would depend on the device side shell, but I haven't verified that by experiment or examining the code. 另一个想法是在启动脚本中添加一些东西,启动一个备用shell,监听你可以使用adb转发套接字的东西 - 我没有想到为什么设置adb转发依赖于设备端的明显原因shell,但我还没有通过实验或检查代码验证。

If you wanted to get really clever , I believe that you could create a /system/bin containing a copy of sh on the root filesystem. 如果你想变得非常聪明 ,我相信你可以在文件系统上创建一个包含sh副本的/ system / bin。 My recollection is that you can mount a filesystem over a non-empty directory - not sure if there would be an issue with open file descriptors to that directory, such as for the running sh itself, but your mount is failing anyway, and you could try doing a manual mount elsewhere in order to debug that issue. 我的回忆是,您可以在非空目录上挂载文件系统 - 不确定是否存在打开该目录的文件描述符的问题,例如运行sh本身,但是您的挂载无论如何都会失败,并且您可以尝试在别处手动安装以调试该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM