diff options
| author | Mike Lockwood <lockwood@android.com> | 2009-08-04 20:37:51 -0400 |
|---|---|---|
| committer | Mike Lockwood <lockwood@android.com> | 2009-08-05 17:57:20 -0400 |
| commit | ee15662140632672a6878787a1ff26f5ebdc1e68 (patch) | |
| tree | fb2d49a2abe6e380ac38ac86cf3ce2a04fc3fa62 /adb/services.c | |
| parent | c98c2b89706aeadb170472c3af9b381c58346d92 (diff) | |
| download | system_core-ee15662140632672a6878787a1ff26f5ebdc1e68.tar.gz system_core-ee15662140632672a6878787a1ff26f5ebdc1e68.tar.bz2 system_core-ee15662140632672a6878787a1ff26f5ebdc1e68.zip | |
adb: add "adb reboot" command.
This will allow rebooting the device via adb on any build, including user builds.
An optional argument can be provided
(for example, "adb reboot bootloader" or adb reboot recovery")
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'adb/services.c')
| -rw-r--r-- | adb/services.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/adb/services.c b/adb/services.c index 78d092b8..517da55f 100644 --- a/adb/services.c +++ b/adb/services.c @@ -33,6 +33,7 @@ # endif #else #include <sys/poll.h> +#include <sys/reboot.h> #endif typedef struct stinfo stinfo; @@ -133,6 +134,20 @@ void restart_root_service(int fd, void *cookie) } } +void reboot_service(int fd, char *arg) +{ + char buf[100]; + int ret; + + sync(); + ret = __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, arg); + if (ret < 0) { + snprintf(buf, sizeof(buf), "reboot failed: %s\n", strerror(errno)); + writex(fd, buf, strlen(buf)); + } + adb_close(fd); +} + #endif #if 0 @@ -399,6 +414,11 @@ int service_to_fd(const char *name) ret = create_service_thread(file_sync_service, NULL); } else if(!strncmp(name, "remount:", 8)) { ret = create_service_thread(remount_service, NULL); + } else if(!strncmp(name, "reboot:", 7)) { + char* arg = name + 7; + if (*name == 0) + arg = NULL; + ret = create_service_thread(reboot_service, arg); } else if(!strncmp(name, "root:", 5)) { ret = create_service_thread(restart_root_service, NULL); #endif |
