Commit graph

39033 commits

Author SHA1 Message Date
David Anderson
8cf1e38b21 liblp: Force more sizes to be a multiple of the sector size.
This makes offset calculations and library interactions much easier.

Bug: 79173901
Test: liblp_test gtest
Change-Id: I595c5435bd6bc166693a434ecdcd2d098185f963
2018-07-13 18:17:56 -07:00
David Anderson
4813823e73 liblp: Add block device size to LpMetadataGeometry.
This makes it easier to validate the device and make assumptions about
the device layout without having actual access.

Bug: 79173901
Test: liblp_test gtest
Change-Id: I53d24684020ec9210c8a17d155e738b3b2405806
2018-07-13 18:17:55 -07:00
Yi Kong
9154fbc8df Merge "Modernize codebase by replacing NULL with nullptr" 2018-07-14 00:20:38 +00:00
Yi Kong
c1a1562548 Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning for binder.

Test: m
Bug: 68236239
Change-Id: I8184bd6aa4ebff1bd8c88dad16886e98df853b03
2018-07-13 15:28:59 -07:00
Elliott Hughes
dda5fe46ac Merge "cutils: move hashmap to <pthread.h>." 2018-07-13 19:58:45 +00:00
Tom Cherry
a8df2b95cb Merge "init: actually remount /sys when changing network namespaces" 2018-07-13 19:57:52 +00:00
Tom Cherry
9bb0a4de46 init: actually remount /sys when changing network namespaces
Fix a typo from before.

Bug: 73334854
Test: build
Change-Id: I66631a6f251960be0e02d8a119fa0ff7a00fb24c
2018-07-13 11:07:11 -07:00
Elliott Hughes
9d12725cad cutils: move hashmap to <pthread.h>.
Bug: N/A
Test: builds
Change-Id: I16a470265a17ea5bd47ef76ec234907cf7ec3e4f
2018-07-13 10:54:49 -07:00
Elliott Hughes
40ad8e2ade Merge "libbase: return different result depend on the errno" 2018-07-13 15:02:49 +00:00
Treehugger Robot
a73ea65c5a Merge "liblp: Rename the metadata partition name to "super"." 2018-07-13 02:07:35 +00:00
liwugang
c63cb07063 libbase: return different result depend on the errno
In the RemoveFileIfExists it always return true even if error appeared
when using stat function.

It should distinguish different error. Such as ENOENT and ENOTDIR
we exactly know the file does not exist. But EACCES(current user has not
all search permission in the file path) and other errors appeared
we can't know whether file exits. So we should return false indicate
there are some error appeared.

Test: ran unit tests
Change-Id: I75788bf0621040812413d52596b5effb628fd0b1
Signed-off-by: liwugang <liwugang@xiaomi.com>
2018-07-12 17:35:17 -07:00
Treehugger Robot
b399456303 Merge "liblp: Clean up public headers." 2018-07-12 22:55:35 +00:00
Christopher Ferris
5dce8ce747 Merge "Remove Memory::ReadField." 2018-07-12 22:37:18 +00:00
David Anderson
b3fc16c5f3 liblp: Rename the metadata partition name to "super".
Bug: 79173901
Test: N/A
Change-Id: I99ccb095030c82cbc4bb89b40bff333decd35532
2018-07-12 14:08:42 -07:00
David Anderson
9c3c29466a liblp: Clean up public headers.
This changes reader.h and writer.h to be private includes. A new liblp.h
header now contains the public API surface of those two files, as well
as some miscellanious functions previously in metadata_format.h.

Bug: 79173901
Test: N/A
Change-Id: I40c5dda0c8e5765f8bccfd5c17b4c800b41be77b
2018-07-12 14:08:42 -07:00
Treehugger Robot
d73414c5e8 Merge "liblp: Improve reliability of UpdatePartitionTable." 2018-07-12 20:13:43 +00:00
Christopher Ferris
5afddb0637 Remove Memory::ReadField.
In almost all cases, it is faster to read the entire structure rather
than do multiple reads using ReadField. The only case where it would be
slower is if doing a remote unwind and ptrace is the only way to read. In
all other cases, it's a single system call. In the ptrace call, it will be
multiple calls. Given that it is unusual to be forced to use ptrace,
it's better to avoid it.

It also reduces the code complexity to do a single read, and avoids
issues where the code forgets to read the field it needs.

Test: Unit tests pass on host and target.
Change-Id: I7b3875b2c85d0d88115b1776e1be28521dc0b932
2018-07-12 12:45:31 -07:00
Victor Khimenko
097381382b Merge "Separate namespace acquisition from library loading" 2018-07-12 16:53:02 +00:00
Elliott Hughes
df398f2b67 Merge "libcutils: remove unused open_memstream." 2018-07-12 16:07:04 +00:00
Elliott Hughes
fc567a9b95 Merge "libcutils: remove some unused API." 2018-07-12 16:07:00 +00:00
Victor Khimenko
1443ec4972 Separate namespace acquisition from library loading
This way native bridge namespace could be acquired in advance and when
library must be loaded JNIEnv is not needed.

Bug: http://b/79940628

Test: cts-tradefed run commandAndExit cts -m CtsGpuToolsHostTestCases

Change-Id: If8bff272fc5245eb4e418807c3bdd29e82833ab8
2018-07-12 15:44:35 +02:00
David Anderson
a5cb671e94 liblp: Improve reliability of UpdatePartitionTable.
If UpdatePartitionTable is interrupted while writing metadata, the next
update becomes much more risky, as only one valid copy may exist. If
that subsequent update is interrupted, all metadata copies may be
corrupt.

To alleviate this, we now synchronize both metadata copies before each
update. If the backup copy is corrupted, we replace it with the primary
copy, and vice versa. Similarly if the primary and backup metadata do
not match, we sync the backup to contain the same data as the primary.

If for some reason this synchronization process fails, we do not proceed
to write a new partition table.

Bug: 79173901
Test: liblp_test gtest
Change-Id: Ic80cf9a5dc6336ff532e069ca5c8c76371550cb9
2018-07-11 17:14:12 -07:00
Treehugger Robot
c457df7d34 Merge "liblp: Make it easier to test UpdatePartitionTable." 2018-07-12 00:08:52 +00:00
Treehugger Robot
32960e54b4 Merge "liblp: Refactor the partition table update API." 2018-07-11 23:44:13 +00:00
Treehugger Robot
1433f8ab2e Merge "Move libbacktrace off cutils." 2018-07-11 22:56:35 +00:00
Elliott Hughes
c35d4a5213 libcutils: remove unused open_memstream.
Bug: N/A
Test: builds
Change-Id: I3c2d8acd4dfe42fbe883b14501cd47674d84f431
2018-07-11 14:28:21 -07:00
Elliott Hughes
721e3ebf55 libcutils: remove some unused API.
Bug: N/A
Test: builds
Change-Id: Iabe42353a708afde2611b5c642775849e2e45baa
2018-07-11 14:27:32 -07:00
Elliott Hughes
38488907a0 Move libbacktrace off cutils.
There's still <cutils/atomic.h> in a test, but I don't understand why
that isn't just std::atomic.

Also add a shared tgkill wrapper to libbase.

Bug: N/A
Test: ran tests
Change-Id: Idd4baa1e1670a84b3a8f35803cc5ffe5aae008a6
2018-07-11 13:55:07 -07:00
David Anderson
451694e29d liblp: Make it easier to test UpdatePartitionTable.
This change makes the internal UpdatePartitionTable function more
testable by parameterizing its write functions. It also adds two tests,
one of which exposes a flaw in the current implementation.

Bug: 79173901
Test: liblp_test gtest
Change-Id: I3c4112794b97d577a27f035baeac2d42ac75f552
2018-07-11 13:37:52 -07:00
Elliott Hughes
771f2c2a3e Merge "Remove unused #include." 2018-07-11 20:16:21 +00:00
David Anderson
21671eda3e liblp: Refactor the partition table update API.
This change separates the WritePartitionTable function into two separate
functions: FlashPartitionTable and UpdatePartitionTable. This will be
cleaner than having extra unnecessary parameters and makes it clearer
when to call each one.

The motivation for this change is to improve the reliability of
UpdatePartitionTable() and to be able to simulate I/O failures for
testing.

Bug: 79173901
Test: liblp_test gtest
Change-Id: Iee5eb2e99fb76aef0b93a65bf85a89907e7cd9bf
2018-07-11 13:05:09 -07:00
Treehugger Robot
3eb5d77913 Merge "adb: work around adbd push bug." 2018-07-11 18:37:39 +00:00
Elliott Hughes
cd0f5c33fa Remove unused #include.
Bug: N/A
Test: builds
Change-Id: I792bfdb38672f7a51991c19a9838dd12500036c7
2018-07-11 11:21:36 -07:00
Treehugger Robot
19ef02ef42 Merge "init.rc: Remount / with MS_REMOUNT|MS_BIND|MS_NODEV" 2018-07-11 17:38:13 +00:00
Luis Hector Chavez
d07d0942c6 init.rc: Remount / with MS_REMOUNT|MS_BIND|MS_NODEV
/ should not have any character/block devices, so might as well pass in
the nodev flag.

Bug: 73255020
Test: aosp_sailfish still boots
Test: sailfish:/ # find / -xdev -a \( -type b -o -type c -o -type p -o -type s \)
      sailfish:/ #
Test: rootfs on / type rootfs (rw,seclabel)
      /dev/root on / type ext4 (ro,seclabel,nodevrelatime)

Change-Id: Ia73e04b53a47506892d9d3cb61b471b81bb72dc3
2018-07-11 08:36:00 -07:00
Treehugger Robot
bcfc8a2ab0 Merge "adb: fix escape_arg for multiple quotes" 2018-07-11 08:46:11 +00:00
Ryan Prichard
e4fded2c48 adb: fix escape_arg for multiple quotes
escape_arg reuses the same index for the source (s) and the destination
(result), so it breaks on strings containing more than one quote, e.g:

 * a'b'c    ==> 'a'\''b'c'
 * a'bcde'f ==> 'a'\''b'\'cde'f'

Also make the function more efficient by doing fewer string copies. This
code is based on the android::base::Split code.

Use EXPECT_EQ because the tests can keep going if one fails.

Bug: none
Test: adb_test --gtest_filter=adb_utils.escape_arg
Change-Id: I6ca6e905fa53cc61b9a87276cb7116a5df7e8017
2018-07-10 23:32:09 -07:00
Treehugger Robot
348878391a Merge "Fix build breakage on non-linux" 2018-07-11 01:43:24 +00:00
Treehugger Robot
6f5d464fb9 Merge "add event log range for audioserver" 2018-07-11 00:48:59 +00:00
Pawin Vongmasa
2b67f0b85b Fix build breakage on non-linux
Bug: 79173901

Test: liblp_test gtest
Change-Id: I846e99f636ed05f97e44d05a617dc17b5f127d2e
2018-07-10 16:46:44 -07:00
Eric Laurent
ab2ced57f1 add event log range for audioserver
Test: make.
Change-Id: I32a198b075a4c07f000ae311188ea61f71a69dab
2018-07-10 14:21:38 -07:00
Josh Gao
0cee7ccc59 adb: work around adbd push bug.
We shipped (well, are about to ship) an adbd that spuriously fails to
create directories upon push. Work around this in the adb client by
running a mkdir on all of the directories we would have otherwise
created.

On devices where we perform the workaround, this coincidentally fixes
a historic bug where we failed to push empty directories.

Bug: http://b/25566053
Bug: http://b/110953234
Test: python test_device.py
Change-Id: I690ec356c206fed4e5ab2c681c5570c8b231e26b
2018-07-10 13:20:40 -07:00
Yabin Cui
1db3789252 Merge "Add debug system properties to control profiling limits." 2018-07-10 18:03:54 +00:00
Treehugger Robot
6a288d8128 Merge "liblp: Implement support for request queue alignment." 2018-07-10 15:48:17 +00:00
David Anderson
2332afb31f liblp: Implement support for request queue alignment.
Block devices in the Linux kernel have a "minimum I/O request" size. The
minimum size is usually acquired by the block driver and can change
from device to device. When stacking devices (such as with
device-mapper), the kernel goes through great lengths to make sure this
alignment is respected for optimal I/O. In device-mapper's case,
misalignment can lead to kernel warnings and performance issues.

While this is unlikely to matter with a few targets, it could become
problematic on a large number of targets, and so we would prefer to
align all partition extents to the minimum I/O size.

We now support two new properties in the partition table geometry: an
"alignment", which is the minimum I/O size, and an "alignment offset",
which is an offset that when applied to sector 0, causes the sector to
be properly aligned within its parent device (for example, if a
physical partition is misaligned). All partition extents now begin on a
sector that respects this alignment.

One major caveat is that it is difficult for the initial partition table
to have the correct alignment without build system and/or flash tool
support. To accomodate this, all alignment is optional, and the lpmake
tool will support a default alignment of 1MiB as a failsafe.

Bug: 79173901
Test: liblp_test gtest
Change-Id: I5bc41b90aa085f4f30393951af0d2b37c4ac2a72
2018-07-09 18:50:28 -07:00
Treehugger Robot
de1d06ef0c Merge "adbd: fix spurious failure to create dirs when pushing." 2018-07-09 23:47:41 +00:00
Yabin Cui
4f0da7cb82 Add debug system properties to control profiling limits.
When security.perf_harden is disabled through adb, use some debug
system properties to set profiling limits in the kernel, including
cpu percentage, memory, and max sample rate.

Bug: 110706031
Test: boot hikey960 and manually set system properties to make
Test: sure it works.

Change-Id: I44c0adf3a000bb393905233f2a097c97b5fe91ec
2018-07-09 16:03:30 -07:00
Josh Gao
4c0078d67a adbd: fix spurious failure to create dirs when pushing.
When pushing to a path, we first try to ensure the directory path
exists and has the permissions expected by fs_config. Due to a change
that changed the fs_config check from a blacklist to a whitelist, we
started doing this for /data (which doesn't begin with /data/), and the
UID/GID for that path was accidentally being reused for following path
segments that didn't exist, leading to a failed attempt to chown
/data/local/tmp/foo to be owned by system.

Bug: http://b/110953234
Test: python test_device.py
Change-Id: Ie798eec48bcf54aea40f6d90cc03bb2170280ee8
2018-07-09 14:25:51 -07:00
Christopher Ferris
4251739928 Merge "Add support for new defines in v4.17.3 headers." 2018-07-09 19:23:00 +00:00
Treehugger Robot
a04058ea48 Merge "liblp: Fix incorrect get_block_device_size usage." 2018-07-09 17:14:14 +00:00