Commit graph

55179 commits

Author SHA1 Message Date
Tom Cherry
e17b4f62df Cleanup package_string() and its users
package_string() isn't readable in its current form and a loop is
unnecessary, so let's replace that with the direct calculations.  The
new and old functions are identical in results except an edge case
where the old function incorrectly believes it needs to round up to
'10' for the size prefix, when '9' would be ok, specifically:
10\naaaaa\n\f vs 9\naaaaa\n\f.  This is true for all powers of 10.

Clean up the calling side in logcat as well.

Test: printing log statistics and prune list works
Change-Id: Ib62ab2badab59040215b130ec9e3efbc7c95af3f
2019-12-06 13:55:08 -08:00
Josh Gao
efc9a63bde base: steal Chromium's NoDestructor.
Pillage from Chromium a wrapper type that skips destruction of its
wrapped type, to avoid problems with premature destruction of
variables with static lifetime.

Test: libbase_test on host
Change-Id: I7d4541f7b59f467b232d5c4f8250dc1ea45e28fa
2019-12-06 13:23:05 -08:00
Tom Cherry
238eae1738 Merge "logcat: more error printing clean-up" 2019-12-06 19:56:55 +00:00
Tom Cherry
ed860ff4bf Make android_logger_set_prune_list() sane
The current version requires callers to supply a string with 32 extra
bytes for liblog to internally prepend "setPruneList ", and to have
enough space to parse logd's return string.  That is an unacceptable
requirement on callers.

This change removes that requirement by having liblog allocate the
needed std::string in any case.

It also stops writing back the 'success' or 'Invalid' string to the
caller's buffer, since that is redundant as well.

Test: changing prune settings works.
Change-Id: Ic0f03a229f0b9a77d03adcb91288370c3bd42903
2019-12-06 11:23:58 -08:00
Tom Cherry
97437a7aae init: fsync() persistent properties directory after rename()
See the inline comment on why this is necessary.

Test: persistent properties work without errors
Change-Id: I820a193fb032a1845791a55a76390d396678f151
2019-12-06 11:16:50 -08:00
Tom Cherry
72a4e08864 logcat: more error printing clean-up
* The --help text is way too long to print after each error, so simply
  print the errors and exit.
* Report errno in a few cases where it was previously not reported
* Fix more punctuation
* Fix '?' and ':' getopt_long() return cases for long options.

Test: errors look better
Change-Id: I57058a2250e9f3c3431f104e43f0eb5ec60d8c8a
2019-12-06 10:27:07 -08:00
Tom Cherry
1dd1056f5d Merge "logcat: clean up handling of logd control commands with -f and -L" 2019-12-06 16:16:13 +00:00
Anton Hansson
38ad736944 Merge "Run the derive_sdk service" 2019-12-06 13:28:21 +00:00
Treehugger Robot
6e0a0dad52 Merge "unwindstack: fix dangling pointer in LocalUpdatableMaps." 2019-12-06 03:16:07 +00:00
Nikita Ioffe
abd504611b Merge "Remove service defined in an APEX during userspace reboot" 2019-12-06 02:35:41 +00:00
Nikita Ioffe
dde59c32ac Merge "libdm: add an overload of DeleteDevice accepting a timeout_ms" 2019-12-06 02:35:23 +00:00
Jaegeuk Kim
fe9e8a3fa5 rootdir: init.rc to limit discard size to 128MB
In any case, UFS storage suffers from long discard latency.

Change-Id: Iaa8ef6eb862934af43254bd10873a12c3d34e926
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2019-12-05 15:58:18 -08:00
Tom Cherry
c30a3eede5 logcat: clean up handling of logd control commands with -f and -L
* Print an error if -c is provided with -f and -L since it is ambiguous
* Move the clear operation when -f is provided to a stand alone
  location, since there is no need to loop
* Prevent -g/-G, -S, and -p/-P with -f, since that combination doesn't
  make sense

Test: logpersist works
Change-Id: I6d8709bd61c898c47835470e99b0acff8c2692e4
2019-12-05 13:39:34 -08:00
Yifan Hong
ab0b17c081 Merge changes from topic "libsnapshot_write_atomic"
* changes:
  libsnapshot: write files atomically
  libsnapshot: lock on /metadata/ota
2019-12-05 20:13:21 +00:00
Tom Cherry
d596ed66aa Merge "liblog: accept log messages with hdr_size greater than known headers" 2019-12-05 17:54:54 +00:00
Nikita Ioffe
091c4d1439 Remove service defined in an APEX during userspace reboot
Such services will be re-parsed and added back to the service list
during post-fs-data stage.

Test: adb reboot userspace
Test: atest CtsInitTestCases
Bug: 145669993
Bug: 135984674
Change-Id: Ibb393dfe0f101c4ebe37bc763733fd5d981d3691
2019-12-05 17:51:43 +00:00
Tom Cherry
759240289b Merge "init: Replace property_set() with android::base::SetProperty()" 2019-12-05 17:26:30 +00:00
Tom Cherry
bb4754bef9 Merge "logcat: improve --help and error messages" 2019-12-05 17:09:23 +00:00
Anton Hansson
572350911a Merge "Point to exec_start from start in init documentation" 2019-12-05 17:04:25 +00:00
Christopher Ferris
25cd25168a Merge "Use elf offset in signal step check." 2019-12-05 16:31:34 +00:00
Anton Hansson
3c5cc31824 Run the derive_sdk service
Run this process as early as possible in the boot -- right
after its config has been parsed from the apex. This ensures
the sdk prop is set as early as it can be, should some other
early process need to look at it.

Note: this is unlikely to be the permanent way this gets run,
as it's only needed when apexes update.

Bug: 137191822
Test: boot && adb shell getprop | grep sdk_info
Change-Id: Ia48ef89435ca165333b52d653e3131f71a522747
2019-12-05 15:38:37 +00:00
Anton Hansson
8c4d930805 Point to exec_start from start in init documentation
Since it mentions a caveat, it's nice to know how to avoid
that caveat.

Test: N/A
Change-Id: I487f1080058bf83a76a725735c6f283f88b0739e
2019-12-05 15:37:09 +00:00
Nikita Ioffe
2c28919d48 libdm: add an overload of DeleteDevice accepting a timeout_ms
In some scenarios (e.g. apexd or userspace reboot), dm-devices are
getting deleted and re-created. Since this operation can be racy (newly
created device can get the same path as the previously deleted one,
resulting in the unexpected ENOENT errors on a system call to the path),
it will be nice to have an API that blocks until ueventd processes
corresponding udev events.

Test: libdm_test
Bug: 143970043
Bug: 122059364
Change-Id: I31a19afd9e245bf5e3554011bdde1c3cc4878f1c
2019-12-05 10:37:47 +00:00
Jooyung Han
028e1d4434 Merge "Bind-mount individual flattened APEXes" 2019-12-05 08:55:31 +00:00
Tom Cherry
c88d8f93cf init: Replace property_set() with android::base::SetProperty()
Init is no longer a special case and talks to property service just
like every other client, therefore move it away from property_set()
and to android::base::SetProperty().

In doing so, this change moves the initial property set up from the
kernel command line and property files directly into PropertyInit().
This makes the responsibilities between init and property services
more clear.

Test: boot, unit test cases
Change-Id: I36b8c83e845d887f1b203355c2391ec123c3d05f
2019-12-04 15:43:21 -08:00
Tom Cherry
8d2225353c liblog: accept log messages with hdr_size greater than known headers
We don't need to be so strict about this comparison.  It's possible
that logd will extend the message that it passes to readers in the
future, and since we have a hdr_size parameter it can do so in a
backwards compatible way, as long as we loosen this restriction.

This keeps a sane upper bound that the hdr_size cannot be larger than
the log message itself.

Test: logcat, liblog-unit-tests
Change-Id: I8a6bea2a2d6e3315d998c51c1029e466ff06b45f
2019-12-04 15:28:03 -08:00
Yifan Hong
55974f1425 libsnapshot: write files atomically
... by writing to a temporary file then rename()'ing it
back.

Test: libsnapshot_test
Bug: 144549076
Change-Id: Ide400aff8d67d56d422d0adea3a4f1673ebc9994
2019-12-04 14:49:47 -08:00
Yifan Hong
b6663cfb5a libsnapshot: lock on /metadata/ota
We used to flock() on /metadata/ota/state to ensure
atomic access. However, writing the file itself is
not necessary atomic and may lead to inconsistent
states.

This change redirects flock() to the outer directory, /metadata/ota,
which is very likely to exist (see exception below).
flock() is called on this directory instead of /state. This allows
a follow-up change to turn all writes to the /metadata partition
atomic.

Note: /metadata/ota may not exist during first boot after a flash
with wipe. However, first_stage_init always checks existence of
boot indicator before even trying to flock() (via
IsSnapshotManagerNeeded() and NeedSnapshotsInFirstStageMount()). If
the boot indicator exists, /metadata/ota must exist as well.

Also add tests to ensure LockExclusive() and LockShared() works as
expected.

Test: libsnapshot_test
Test: apply OTA from older build to this, then reboot

Bug: 144549076

Change-Id: Ib4dd9e9be1a43013c328e181b9398ac0b514dbce
2019-12-04 14:49:47 -08:00
Christopher Ferris
f0c82e7bad Use elf offset in signal step check.
The function StepIfSignalHandler assumed that the rel_pc passed
to it was actually an elf offset. A new version of clang created a libc.so
that has a load bias, so tests unwinding through a signal handler
would fail on arm. On other ABIs, there is unwind information that could
be used instead, so the unwind still worked.

The fix is to subtract the load bias from the rel_pc to get an elf
offset to pass to the Register StepIfSignalHandler functions. Change all
of the Register funtions to make it clear what the first parameter means.

Add a unit test for this new code. Also, add an offline test for
this case.

Bug: 145683525

Test: Ran unit tests using the new clang and the old clang.
Change-Id: I3e249653b79bcad6d3a56411a7911fde4888e9d6
2019-12-04 22:29:59 +00:00
Tom Cherry
416973276e logcat: improve --help and error messages
Makes slight improvements to the --help text:
- Fix whitespace formatting and punctuation.
- Divide options into categories
- Clarify how the logd control functions work.
- Clarify --print.

Add additional text to the EOF error message that is returned when
logd disconnects the logcat instance, to clarify that this is intended
behavior if the logcat instance is reading too slowly.

Bug: 144311420
Test: view these messages
Change-Id: Icc12d278a8e8cb483918c0637b6fb529949cc33f
2019-12-04 14:00:50 -08:00
Thomas Joseph Avila
f7a6c4587f Merge "Remove projects being moved into from system/core into system/memory" 2019-12-04 19:50:06 +00:00
Nikita Ioffe
cafa75ca22 Merge "FscryptInstallKeyring: don't re-create keyring if it's already created" 2019-12-04 19:27:52 +00:00
Nikita Ioffe
9f71d6193a Merge "Add basic support for remounting ext4 userdata into checkpoint" 2019-12-04 19:22:50 +00:00
Tom Cherry
8fa4d6c382 Merge "init: always kill oneshot services' process groups." 2019-12-04 18:16:19 +00:00
Tom Cherry
ab96d9dec1 Merge "Remove warning from VNDK's <cutils/log.h>" 2019-12-04 18:16:05 +00:00
Nikita Ioffe
1f40c94a1f FscryptInstallKeyring: don't re-create keyring if it's already created
During userspace reboot FscryptInstallKeyring will be called again, this
CL will make it second call a no-op, which IMHO is better than having a
special logic in init to conditionally call FscryptInstallKeyring
depending on whenever it's normal boot, or userspace reboot.

Test: adb reboot userspace
Test: checked in kernel logs that new keyring is not created
Bug: 135984674
Change-Id: I4ad5aee6887b7318fb1cd02bf1c7be8da6ece599
2019-12-04 17:47:37 +00:00
Suren Baghdasaryan
c19f63004d Remove projects being moved into from system/core into system/memory
The following directories are being moved into separate projects under
system/memory:
  platform/system/memory/libion
  platform/system/memory/libmeminfo
  platform/system/memory/libmemtrack
  platform/system/memory/libmemunreachable
  platform/system/memory/lmkd

Remove them from system/core.

Bug: 141634854
Test: build and boot
Change-Id: I0ecc0668a281ec360133c8472bbf12ece92116d2
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Merged-In: Ica64900cd8af273fdffd321591acf3a566f04355
Merged-In: I98793edd10954058448727635f101219f71d3ccf
2019-12-04 17:30:45 +00:00
Erwin Jansen
10fdfeb7b8 Merge "Dup the correct fd for qemu pipe." 2019-12-04 17:15:20 +00:00
Christopher Ferris
2da8e3c2ee Merge "Fix support finding global variables." 2019-12-04 17:03:44 +00:00
Tom Cherry
2d5cfa9fa6 Remove warning from VNDK's <cutils/log.h>
We're never going to fix this warning and it's not causing any active
issues that vendors are using this header.  It is however causing
active issues that we have extraneous warning messages in the log.

Bug: 123758136
Test: no build warnings from <cutils/log.h>
Change-Id: Iccf702bf2536ba106a00ac04467d54401cbe2a50
2019-12-04 08:33:49 -08:00
Treehugger Robot
fea51309dc Merge "libsnapshot: Call EnsureImageManager before RemoveAllImages" 2019-12-04 13:53:36 +00:00
Yifan Hong
e62591ec3b libsnapshot: Call EnsureImageManager before RemoveAllImages
Calls to RemoveAllImages may be on uninitialized
image manager.

Test: apply OTA to self

Change-Id: Id57c01ddfdb6985fb2c3c142ee19fd65eef6c131
2019-12-04 00:24:55 -08:00
Christopher Ferris
df683b7439 Fix support finding global variables.
The code was not properly getting the variable addresses and using
the offset and address fields of the .data section.

Fix all of that, and update the tests.

Bug: 145162678

Test: Unit tests pass.
Test: ./art/test/run-test --dex2oat-jobs 4 --host --prebuild --compact-dex-level fast --jit --no-relocate --runtime-option -Xcheck:jni  137-cfi
Test: ./art/test/testrunner/testrunner.py -t 137 --host
Change-Id: Ic61c4487334fd2273cda9c56eb1a3b525a03edb7
2019-12-03 17:35:00 -08:00
Jason Jeremy Iman
8bde191202 Enable "localfilesystem" UNIX domain socket for ADB.
This patch introduce "service.adb.listen_addrs", a new
string type property, while keeping the old properties.
The new property added in this patch is used to listen
on UNIX domain socket "localfilesystem".

"service.adb.listen_addrs" can be used to listen on
multiple addresses, such as tcp:5555 and tcp:5556.
It is separated by ',' (comma) character.

In the process of introducing the new socket type, the
method tcp_connect is removed and combined into
socket_spec_connect.

Without specifying using the new property, adb will
try to listen on both tcp and vsock (following the
previous implementation).

Some examples of the new property value are:
  - "tcp:5555"
  - "vsock:5555"
  - "localfilesystem:/tmp/test"
  - "tcp:5555,vsock:5555"

Bug: 133378083
Test: On master-arc-dev:
        adb root;
        setprop service.adb.listen_addrs localfilesystem:
	    <path_to_socket>;
        adb connect localfilesystem:<path_to_socket>;
        adb -s localfilesystem:<path_to_socket> shell;
	    inside Chrome OS.
Test: On aosp_bluefin:
        setprop service.adb.listen_addr tcp:5555;
        adb connect <IP>:5555; adb shell;
Test: On aosp_bluefin:
        setprop service.adb.tcp.port 5555;
        adb connect <IP>:5555; adb shell;
Test: On aosp_bluefin:
        setprop service.adb.listen_addrs tcp:5555,tcp:6666;
        adb connect <IP>:5555; adb shell;
        adb connect <IP>:6666; adb shell;
Test: On aosp_bluefin:
        ./adb_test;
Test: On cuttlefish:
        launch_cvd;
        adb -s 127.0.0.1:6520 shell;
Test: Ran host tests:
        ./adb_test;
        ./adb_integration_test_adb;
        ./adb_integration_test_device;

Change-Id: I8289bf0ab3305cf23ce5695ffba46845d58ef6bb
2019-12-04 10:05:05 +09:00
Yifan Hong
51fb2a0855 Merge "libsnapshot: start in background" 2019-12-04 00:04:54 +00:00
Wei Wang
6db520807d libsnapshot: start in background
so that it won't block init starting other services on boot_completed.

Test: build
Bug: 145612906
Change-Id: I1ca325b9ef191c4689e925da2e797271ec9c7979
2019-12-03 13:27:05 -08:00
Yifan Hong
3a8001476d Merge changes I8c5ab552,If8546dea
* changes:
  libsnapshot: tests uses common MapUpdateSnapshot/WriteSnapshotAndHash
  libsnapshot: Add test for accounting for hash tree
2019-12-03 19:44:51 +00:00
Yifan Hong
8b8ffbb2df Merge "SOURCE_COPY operation: implement src == dst" 2019-12-03 19:44:35 +00:00
David Anderson
332360fece Merge "libsnapshot: Remove all image data and metadata when cancelling an update."
am: 710d6cc419

Change-Id: If47a068143c7416f1b6aa5e479996f26403a6dd6
2019-12-02 16:46:49 -08:00
David Anderson
710d6cc419 Merge "libsnapshot: Remove all image data and metadata when cancelling an update." 2019-12-03 00:36:56 +00:00