Commit Graph

34402 Commits

Author SHA1 Message Date
Tom Cherry 130e3d7204 init: pass errors from one Result<T> to another better
Result<T> currently has two problems,
1) A failing Result<T> cannot be easily constructed from a Result<U>'s
error.
2) errno is lost when passing .error() through multiple Result<T>'s

This change fixes both problems having Result<T>::error() return a
ResultError class that contains the std::string error message and int
errno.

It additionally has ostream operators to continue to allow printing
the error string directly to an ostream and also to pass the errno
through to another Result<T> class via Error() creation.

Lastly, it provides a new constructor for Result<T> for ResultError,
such that a Result<T> can be constructed from Result<U>::error().

Test: boot bullhead, init unit tests
Change-Id: Id9614b727cdabd2f5498b0da0e598e9aff7d9ae0
2017-08-23 11:04:32 -07:00
Tom Cherry 6de21f1112 init: cleanup environment handling
Init keep its own copy of the environment that it uses for execve when
starting services.  This is unnecessary however as libc already has
functions that mutate the environment and the environment that init
uses is clean for starting services.  This change removes init's copy
of the environment and uses the libc functions instead.

This also makes small clean-up to the way the Service class stores
service specific environment variables.

Test: boot bullhead
Change-Id: I7c98a0b7aac9fa8f195ae33bd6a7515bb56faf78
2017-08-23 10:09:21 -07:00
Treehugger Robot 7f16cad877 Merge "init: add log to time spent in waiting for file" 2017-08-22 23:23:25 +00:00
Treehugger Robot 8570d1db70 Merge "Don't preserve file attributes when pulling bugreport file..." 2017-08-22 22:41:26 +00:00
Wei Wang 4cea121872 init: add log to time spent in waiting for file
Bug: 64925999
Test: boot and take log
Change-Id: I7d37906708b5a4a195fb1ba1113641656d419e62
2017-08-22 14:09:11 -07:00
Josh Gao 46244a6497 Merge changes I2270cc0a,I55e5dc5a
am: 2066e0585e

Change-Id: I72f3a3272bcce4f0e4f24050e5035810be040ec9
2017-08-21 23:41:53 +00:00
Treehugger Robot 2066e0585e Merge changes I2270cc0a,I55e5dc5a
* changes:
  adb: add track-devices-l service.
  adb: allow selection of a specific transport.
2017-08-21 23:34:30 +00:00
Josh Gao b0c1802615 adb: add track-devices-l service.
Add a way to get the full `devices -l` output on a continuous basis.

Test: manual
Change-Id: I2270cc0a0d7e1384ce19631724ddf2462d963ade
2017-08-21 14:15:07 -07:00
Josh Gao b122b17555 adb: allow selection of a specific transport.
Extend device selection to allow selecting a specific transport via
monotonically increasing identifier (visible in devices -l).

This is useful when using multiple devices (like hikey960...) that
have identical bogus serial numbers like 0123456789ABCDEF.

Bug: http://b/37043226
Test: adb -t {1, 2, 9999999} {get-serialno, shell, features}
Change-Id: I55e5dc5a406a4eeee0012e39b52e8cd232e608a6
2017-08-21 14:15:06 -07:00
Josh Gao 9a1e060dc6 Merge "fastboot: gracefully handle failure to open a USB device on OS X."
am: 11be3e54bd

Change-Id: I366df52af24947a746fee515a8d16ff728a01deb
2017-08-21 18:42:01 +00:00
Treehugger Robot 11be3e54bd Merge "fastboot: gracefully handle failure to open a USB device on OS X." 2017-08-21 18:29:22 +00:00
Andreas Huber 7ec963f00b Merge "Fix use-after-free of stack-allocated temporary string."
am: 4bcccdf998  -s ours

Change-Id: I719a6b2af7dae5d5a2dffffc7309f6adfb687456
2017-08-21 17:39:58 +00:00
Andreas Huber 4bcccdf998 Merge "Fix use-after-free of stack-allocated temporary string." 2017-08-21 17:31:02 +00:00
Andreas Huber c41b838baa Fix use-after-free of stack-allocated temporary string.
Bug: 64848081
Test: built and successfully booted again
Merged-In: I93c899249bf2cc5ab8d880c0eaff471518e73121

Change-Id: I93c899249bf2cc5ab8d880c0eaff471518e73121
2017-08-21 09:44:56 -07:00
Andreas Huber f5e0464683 Fix use-after-free of stack-allocated temporary string.
Bug: 64848081
Test: built and successfully booted again
Merged-In: I93c899249bf2cc5ab8d880c0eaff471518e73121

Change-Id: I93c899249bf2cc5ab8d880c0eaff471518e73121
2017-08-21 09:05:13 -07:00
Josh Gao f806a3c303 fastboot: gracefully handle failure to open a USB device on OS X.
High Sierra restricts opening some USB devices (e.g. the touchbar)
to processes that have specific entitlements. Ignore devices that we
can't open.

Bug: http://b/64292422
Test: manual
Change-Id: I6074b53a365b8d936610bafea60244f8bba1a33f
2017-08-18 18:25:44 -07:00
Josh Gao 68f92308ec Merge "crash_dump: print the identity of tracers."
am: e67c7b94c2

Change-Id: Ic926e668cee9163a3caadcd6313ff4bc76c2768f
2017-08-19 01:25:21 +00:00
Treehugger Robot e67c7b94c2 Merge "crash_dump: print the identity of tracers." 2017-08-19 01:20:24 +00:00
Josh Gao fd13bf0dcd crash_dump: print the identity of tracers.
Instead of printing a useless "ptrace attach failed: strerror(EPERM)"
message, print the name and pid of a competing tracer when we fail to
attach because a process is already being ptraced.

Bug: http://b/31531918
Test: debuggerd_test32, debuggerd_test64 on aosp_angler
Test: strace -p `pidof surfaceflinger`; debuggerd -b surfaceflinger
Change-Id: Ifd3f80fe03de30ff38c0e0068560a7b12875f29d
2017-08-18 16:16:58 -07:00
Tom Cherry a1a6826c59 Merge "init: only set ro.boottime.<service> properties once."
am: fe0607575d

Change-Id: I1ef16e0a09803a4b3681227135ce2f1ec17b6401
2017-08-18 20:05:45 +00:00
Josh Gao b43479c764 Merge "adb: fix deadlock in kick_all_transports."
am: c2449e871e

Change-Id: I2dd6e22a8ad1d819ed47b54071a394f5b64e1ce7
2017-08-18 20:00:19 +00:00
Tom Cherry fe0607575d Merge "init: only set ro.boottime.<service> properties once." 2017-08-18 19:59:29 +00:00
Tom Cherry 6698195d64 Merge "ueventd: fix subsystem list logic issues"
am: edf03e23bb

Change-Id: I4ce43385af2376bc7246f25057dd3d7d76ec5dc8
2017-08-18 19:53:48 +00:00
Treehugger Robot c2449e871e Merge "adb: fix deadlock in kick_all_transports." 2017-08-18 19:50:32 +00:00
Tom Cherry edf03e23bb Merge "ueventd: fix subsystem list logic issues" 2017-08-18 19:47:28 +00:00
Tom Cherry fed3373b5b init: only set ro.boottime.<service> properties once.
Currently, init attempts to set ro.boottime.<service> properties
whenever a service starts, however since these properties are ro. this
means that an error is printed whenever a service is restarted.

Since these properties are intended for reporting boottime, these
subsequent writes during restarts are erroneous and therefore this
change stops attempting to write them, thus silencing the error.

Test: boot bullhead, restart processes, observe no error print
Change-Id: I372f8d5c26590fc0661b92f632410e23e6418841
2017-08-18 10:47:46 -07:00
Tom Cherry 9c8d6dd7de ueventd: fix subsystem list logic issues
1) Check subsystems list before doing usb subsystem logic.  This allows
   developers to handle usb* subsystems in ueventd.rc files.
2) Fix a bug where each subsystem_ instance is not reinitialized, but
   rather only the name_ member was set.

Test: boot bullhead
Test: check that multiple uevent_devname subsystems work when
      specified in ueventd.rc
Change-Id: Ifcac04763afcaf72a3b14ef5f3a6cb89981b51a1
2017-08-18 10:39:48 -07:00
Tom Cherry ce2325895f Merge "init: replace panic() with LOG(FATAL)"
am: 57a89f3ba0

Change-Id: Ib00187f9296ea8afd2bd323a87e290e7424a864e
2017-08-18 15:58:26 +00:00
Tom Cherry 57a89f3ba0 Merge "init: replace panic() with LOG(FATAL)" 2017-08-18 15:49:46 +00:00
Huihong Luo 4be54a4622 Merge "Fix bug #37284906, adb shell crashes on windows with invalid options. For example, "adb.exe shell -list" crashes without this fix. Test: adb.exe shell -list-packages"
am: e275043d38

Change-Id: Idd5574dc504eaa2b740847c8baed795507b9d180
2017-08-18 14:42:21 +00:00
Huihong Luo e275043d38 Merge "Fix bug #37284906, adb shell crashes on windows with invalid options. For example, "adb.exe shell -list" crashes without this fix. Test: adb.exe shell -list-packages" 2017-08-18 14:35:52 +00:00
Huihong Luo af39885c9f Fix bug #37284906, adb shell crashes on windows with invalid options.
For example, "adb.exe shell -list" crashes without this fix.
Test: adb.exe shell -list-packages

Change-Id: I96be44128ff3ecab7804b70074cbde630b3fc3d1
2017-08-17 22:26:46 -07:00
Tom Cherry ad42b33eaa Merge "init: fix copy/paste mistake"
am: f85404521e

Change-Id: Id7382a959f5a22e4f4897ad593ea7202aae95c19
2017-08-18 01:55:43 +00:00
Treehugger Robot f85404521e Merge "init: fix copy/paste mistake" 2017-08-18 01:49:40 +00:00
Tom Cherry d8db7ab80d init: replace panic() with LOG(FATAL)
Test: boot bullhead
Test: Introduce LOG(FATAL) at various points of init and ensure that
      it reboots to the bootloader successfully
Test: Introduce LOG(FATAL) during DoReboot() and ensure that it reboots
      instead of recursing infinitely
Test: Ensure that fatal signals reboot to bootloader

Change-Id: I409005b6fab379df2d635e3e33d2df48a1a97df3
2017-08-17 18:16:51 -07:00
Tom Cherry 94f3bcdbc1 init: fix copy/paste mistake
Test: boot bullhead
Change-Id: I0fedb48a9684e21a27a1d260b84cb49a1038ce3f
2017-08-17 16:52:10 -07:00
Josh Gao 1db71afe97 adb: fix deadlock in kick_all_transports.
Previously, kick_all_transports would deadlock if there were any
inaccessible transports, because the transport kick function would call
unregister_usb_transport, which attempts to take the already-held
transport lock.

Fix this by switching the transport lock over to a recursive mutex.

Test: manual
Change-Id: If61296ff4745e1699f3e216811c1383582627604
2017-08-17 13:50:51 -07:00
Wei Wang 57f94aa4bc Merge "Skip unnecessary sleep during shutdown"
am: e3e4ec7c97

Change-Id: Iaa8af758ebcb2c7a300dde32902d14a11b6c53d6
2017-08-17 01:54:18 +00:00
Wei Wang e3e4ec7c97 Merge "Skip unnecessary sleep during shutdown" 2017-08-17 01:46:17 +00:00
Wei Wang 8c00e42f20 Skip unnecessary sleep during shutdown
Skip sleep if timeout is zero
Skip sleep if first pass umount succeed

Bug: 64768138
Test: reboot
Change-Id: I5ef731611320ade51974b414f7e47520ce36b287
2017-08-16 15:41:12 -07:00
Ting-Yuan Huang 6677429bff Merge "Fix a potential memory leak"
am: f583ff660e

Change-Id: Ib6c7f4b328d91c59248a20486f49fb1f3d8051a0
2017-08-16 17:06:44 +00:00
Treehugger Robot f583ff660e Merge "Fix a potential memory leak" 2017-08-16 16:55:54 +00:00
Felipe Leme 4bfddbd20e Don't preserve file attributes when pulling bugreport file...
...otherwise it could have weird dates when the device clock is wrong.

Test: m -j32 adb && ./out/host/linux-x86/bin/adb bugreport test.zip && ls -l test.zip
Test: m -j32 adb_test && ./out/host/linux-x86/nativetest64/adb_test/adb_test

Fixes: 63927360

Change-Id: I3f87277f1acb97212a87b89639e42b6d7d300faa
2017-08-15 18:11:38 -07:00
Jocelyn Bohr 4e8bbb968c Merge "Pass in message_version_ received from the secure side."
am: 1a955faab2

Change-Id: I39906a476272c781b37c20707bea0fbe1244305e
2017-08-15 23:53:32 +00:00
Ting-Yuan Huang f26cf6d520 Fix a potential memory leak
Test: Built without seeing the warnings
Change-Id: I934509c78482af9ef7dc447c807f6450484b4b38
2017-08-15 16:48:24 -07:00
Treehugger Robot 1a955faab2 Merge "Pass in message_version_ received from the secure side." 2017-08-15 23:35:48 +00:00
Christopher Ferris e23b30a6da Merge "Decrease size of LogBufferElements to 32 bytes."
am: 44ad937411

Change-Id: Ibfcc70ed00e8d76a3ff77e0e00cdf922bc65b55f
2017-08-15 17:00:02 +00:00
Christopher Ferris 44ad937411 Merge "Decrease size of LogBufferElements to 32 bytes." 2017-08-15 16:53:56 +00:00
Tom Cherry db640d87cd Merge changes I7f00c5f0,Idc18f331,I1e7d3a88
am: 334929b525

Change-Id: If6526adf256c1e5958d5aa6135d9e7efd11cf1cf
2017-08-14 22:52:34 +00:00
Tom Cherry 334929b525 Merge changes I7f00c5f0,Idc18f331,I1e7d3a88
* changes:
  init: use Result<T> for the parsing functions
  init: use Result<T> for builtin functions
  init: introduce Result<T> for return values and error handling
2017-08-14 22:43:23 +00:00