Commit graph

211 commits

Author SHA1 Message Date
Treehugger Robot
e9741b25e5 Merge changes I9830baf7,I01da0a68,I05d0a6c7 into main
* changes:
  Added liblp_apis_fuzzer
  Added TestPartitionOpener_group
  Added liblp_builder_fuzzer and liblp_super_layout_builder_fuzzer
2023-10-18 04:58:25 +00:00
Kelvin Zhang
78d5352289 Make partition metadata write atomic
We have seen multiple OTA failures with invalid geometry magic
signature. Make partition metadata write atomic by writing to a tmpfile
first and then do a rename.

Test: th
Bug: 303770065
Bug: 298149189
Change-Id: Id1d565de73439b95b665144c2f02fc97273d341c
2023-10-13 15:46:28 -07:00
Harsh Abichandani
4ac5b76d96 Added liblp_apis_fuzzer
exec/s: 9393
Test: ./liblp_apis_fuzzer
Bug: 285829660

Change-Id: I9830baf7ffbcffa7571aea75e69d1ced64fe613a
2023-10-05 05:03:32 +00:00
Harsh Abichandani
072af6eec1 Added TestPartitionOpener_group
Added TestPartitionOpener_group for test_partition_opener.cpp, as this
file shall be used by liblp_apis_fuzzer and liblp_test_defaults

Test: make TestPartitionOpener_group
Bug: 285829660

Change-Id: I01da0a6896409af99af9e89092f6e1e3760cf4c2
2023-09-19 13:01:07 +05:30
Harsh Abichandani
4080e34426 Added liblp_builder_fuzzer and liblp_super_layout_builder_fuzzer
exec/s: 17002
Test: ./liblp_builder_fuzzer
exec/s: 31273
Test: ./liblp_super_layout_builder_fuzzer
Bug: 285829660

Change-Id: I05d0a6c72069e500b2c838f9c6d900ca1ce2c8cc
2023-09-19 12:57:26 +05:30
Mitchell Wills
908056efeb Add logs in SuperLayoutBuilder::Open when the metadata isn't supported
Change-Id: Ic9733775616b642f669ceb7459cccd33631ae12b
2023-07-20 06:07:18 +00:00
David Anderson
8fc623eb63 liblp: Fix a crash when adding an image to a partition with no extents.
Bug: N/A
Test: lpmake --partition=system:readonly:0 --image=system=system.img
Change-Id: I4de616cc1b9ca2838d38518ec24a382f4bc1b1be
2023-02-08 22:09:58 -08:00
David Anderson
7cf627bac9 Merge changes Ib744d763,I74278bb5,I3d240d6e,I1b41d233
* changes:
  fastboot: Move some helpers into util.h/.cpp.
  fastboot: Allow using LOG().
  fastboot: Use RAII for sparse_file objects.
  liblp: Add a helper class for building sparse-compatible super image layouts.
2023-02-01 21:27:03 +00:00
David Anderson
e6cef616f1 liblp: Add a helper class for building sparse-compatible super image layouts.
This class helps export a list of regions comprising a super partition,
and what the contents of those regions should be. It is very similar to
ImageBuilder, except that it does not require actual partition image
files, nor does it actually write an image file to disk.

The goal is to support building an in-memory super image that uses as
little memory and backing storage as possible. For example, fastboot can
use this to upload a super image without having to read and write
gigabytes of unnecessary data.

Since the goal is to optimize fastboot, we've taken some shortcuts here.
Retrofit devices and other edge-casey behavior are safely rejected. We
also don't rely on libsparse behavior here, and attempt to make the
translation to sparse records as trivial as possible, by explicitly
declaring where fill/dontcare gaps are, and only exporting 4KB aligned
regions. Hopefully this will allow the code to be portable to
non-fastboot consumers.

Bug: 266982466
Test: liblp_test
Change-Id: I1b41d233bc4512c4b62e19603e8e77bc5867cfab
2023-01-31 18:46:35 -08:00
Yi-Yo Chiang
bc851b6dbf fs_mgr: Add one space between [libfs_mgr] tag and log msg
This is but a cosmetic change. Before:

> [libfs_mgr]__mount(...

After:

> [libfs_mgr] __mount(...

Also change liblp, libfs_avb and libvbmeta.

Bug: 241688845
Test: Presubmit
Change-Id: I7d408a94a7fe279d9b65d699e22159b167f34526
2023-01-31 09:41:43 +00:00
Florian Mayer
1e7af8d975 Promote HWASan tests to presubmit.
They have been passing and do not show significant slowdown.

Change-Id: If3aea998fcf33559824cf02e9963e8a71ac80163
2022-05-06 19:14:15 +00:00
Automerger Merge Worker
92c83b3d47 Merge "Merge "Merge "resolve merge conflicts of 21ef3ae3fd to android11-tests-dev" into android11-tests-dev am: bdf02cc54d" into android12-tests-dev am: fdca6ffb38" into android12L-tests-dev am: c1a6b27d21
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1726290

Change-Id: I5988f66d41af54127829baa6edb3a3217a99e583
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-21 01:12:53 +00:00
Florian Mayer
92c1ef9e97 Add liblp to hwasan-postsubmit
Test: Run tests under HWASan.
Bug: 193568145
Change-Id: I6514e9f170d03ee2d2673d115a9c8337ac6941b0
2022-03-18 21:23:51 +00:00
Treehugger Robot
dfcd654a7d Merge "resolve merge conflicts of 21ef3ae3fd to android11-tests-dev" into android11-tests-dev am: bdf02cc54d
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1726290

Change-Id: If1f75842c028f8511bfa0d50b76bc3fef29a2f2b
2021-10-20 22:10:42 +00:00
Justin Yun
43678b17a5 Replace test_min_api_level with test_options.min_shipping_api_level
Test options for the api levels are moved to test_options.
test_min_api_level property will be removed with this change.

Bug: 187258404
Test: build
Change-Id: Id943566de2ac693b5955bd84a8463e5013a8bb0f
2021-09-28 20:35:09 +09:00
Yiming Pan
15a97fc951 Merge "Add OWNERS for VTS module vts_core_liblp_test" 2021-09-09 19:19:32 +00:00
Yiming Pan
7bd12ad1a9 Add OWNERS for VTS module vts_core_liblp_test
Each VTS module is required to have OWNERS file. The ownership is based on
go/vts-owners. For more information about ownership policy, please visit
go/xts-owners-policy.

Test: Tree Hugger
Bug: 143903671
Change-Id: I685d6fda211c9bce445d9fea351442b29541e639
2021-08-11 16:36:21 -07:00
David Anderson
a07503afc1 Make libfs_mgr and its dependencies vendor_ramdisk_available.
This is needed to link libfs_mgr with snapuserd.

Bug: 193833730
Test: builds
Change-Id: I5abd706fe134fecebb80ecb790b5be0495e2b925
2021-07-23 16:50:06 -07:00
Inseob Kim
2e20058069 Completely migrate init first stage to Soong
adb_debug.prop is migrated too. And ramdisk_available is added to all
dependencies.

Bug: 187196593
Test: boot
Change-Id: I59cd149e0021211b8fd59c44b93bbf18dc8637bf
2021-06-18 14:26:55 +09:00
David Anderson
560d098e0f resolve merge conflicts of 21ef3ae3fd to android11-tests-dev
Change-Id: I50ad8773a8e6182a48b8edb065bf1490616ebe0a
2021-06-02 23:36:48 +00:00
huan qin
2c25e261fa Skip test for Automotive in Android Q
Two tests in VtsKernelLiblpTest
require dynamci partion which is not
mandatory for Automotive in Android Q:
VtsKernelLiblpTest#BuilderTest.block_device_info
VtsKernelLiblpTest#liblp.ReadSuperPartition

Test:run vts -m VtsKernelLiblpTest -t
VtsKernelLiblpTest#BuilderTest.block_device_info
Test:run vts -m VtsKernelLiblpTest -t
VtsKernelLiblpTest#liblp.ReadSuperPartition

Bug: 156287966
Change-Id: I353b854dd37f1ae3aeb7212c97e376dc9719ba91
2021-03-08 14:02:06 -05:00
David Anderson
5aa0527499 liblp: Remove uses of alignment_offset.
alignment_offset restrictions were removed in R and are no longer
needed.

Bug: 180571070
Test: liblp_test
Change-Id: I43fa4a929c20cc8c6ec2fece71d5400351c13dbe
2021-03-02 18:35:05 -08:00
Bob Badour
d69ad69a93 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Id740a7d2884556081fdb68876584b25eb95e1bef
2021-02-19 12:59:05 -08:00
Elliott Hughes
c3a206ccda Revert "[LSC] Add LOCAL_LICENSE_KINDS to system/core"
This reverts commit 187b7d1950.

Reason for revert: system/core is multiple projects, not one.

Change-Id: I790ea41741f8cd9b8b6db2f59a49e71fb0958fd6
2021-02-16 20:01:20 +00:00
Bob Badour
187b7d1950 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  Android.bp
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I5bd81adb5cdcf2b4dd4141b204eb430ff526af8f
2021-02-16 04:10:03 -08:00
Dan Shi
67b7dd570f Remove vts10 related configs
Bug: 169582597
Test: build
Change-Id: I38e1e0f8e32b86ab14b905d040c1c62245a1a9e3
2020-10-06 13:52:44 -07:00
David Anderson
29e7b2af30 Merge "liblp: fix host lpdump cannot work issue" 2020-09-02 17:36:00 +00:00
Hongguang Chen
f248cc5a98 Use more inclusive language for #inclusivefixit
Updating language to comply with Android’s inclusive language guidance.

See https://source.android.com/setup/contribute/respectful-code for reference.

Bug: 161896447
Test: make
Change-Id: I3e43a9a0f09b0587ec95de886705f03c1a430ef6
2020-07-23 11:13:37 -07:00
Tianjie Xu
d7b4fe95c7 Merge "Add function to compare the partitions' extents in metadata" 2020-07-09 02:46:47 +00:00
Tianjie
07c951fcf3 Add function to compare the partitions' extents in metadata
For partial updates, the metadata for untouched dynamic partitions
are just copied over to the target slot. So, verifying the extents
of these partitions in the target metadata should be sufficient for
correctness. And we don't need to read & hash the bytes on these
partitions.

Bug: 151088567
Test: unit tests pass
Change-Id: I95836ee6f76d884c7a1f5537154ac7230563493a
2020-07-06 17:40:01 -07:00
Yifan Hong
a819a3cad2 liblp: Force 10.0 metadata on downgrade to Q.
Q liblp only supports 10.0 super partition metadata, so
forcefully downgrade the current metadata version too.

On retrofit Virtual A/B devices, the metadata version is
at most 10.1, because the new VIRTUAL_AB flag is not set
on retrofit devices.

In version 10.1, two per-partition flags: UPDATED and DISABLED
are introduced.
- The updated flag is set when the device undergoes a Virtual A/B
update before. Clear it.
- The disabled flag should only be set on metadata files used by
libfiemap ImageManager. It shouldn't be used on super partition metadata.

Hence, this CL should only clear UPDATED flag.

Test: R->R->Q OTA
Bug: 159590481
Change-Id: I8b548c8ce36a75197e7172a77f9207fd44fe4670
(cherry picked from commit ba5dfd76de)
Merged-In: I8b548c8ce36a75197e7172a77f9207fd44fe4670
2020-07-06 13:36:20 -07:00
Yifan Hong
ba5dfd76de liblp: Force 10.0 metadata on downgrade to Q.
Q liblp only supports 10.0 super partition metadata, so
forcefully downgrade the current metadata version too.

On retrofit Virtual A/B devices, the metadata version is
at most 10.1, because the new VIRTUAL_AB flag is not set
on retrofit devices.

In version 10.1, two per-partition flags: UPDATED and DISABLED
are introduced.
- The updated flag is set when the device undergoes a Virtual A/B
update before. Clear it.
- The disabled flag should only be set on metadata files used by
libfiemap ImageManager. It shouldn't be used on super partition metadata.

Hence, this CL should only clear UPDATED flag.

Test: R->R->Q OTA
Bug: 159590481
Change-Id: I8b548c8ce36a75197e7172a77f9207fd44fe4670
2020-07-06 10:06:36 -07:00
lijiazi
ecd9b0d8db liblp: fix host lpdump cannot work issue
If a relative path is provided on linux host, lpdump will not
work because GetPartitionAbsolutePath return an incorrect pathname.

Test: lpdump super.img

Change-Id: I7d0f10110eb72745edba810bdf288e2506bfedd6
Signed-off-by: lijiazi <lijiazi@xiaomi.com>
2020-06-12 09:39:23 +08:00
David Anderson
a5f8e50fbb liblp: Remove tests for alignment_offset being 0.
This test doesn't exist on AOSP anymore, and the bugs around
alignment_offset have been fixed in R. There is no need for the test
anymore.

Bug: 157398966
Test: liblp_test gtest
Change-Id: I00ac7486faf8db8b18f764e61db1d545feb0312c
Merged-In: I563122282e940e07a7ece97ed1a9846ad1f3253c
2020-06-11 03:25:28 +00:00
Yifan Hong
bcf3cc8cce liblp: delete unused function and fields
Test: builds
Change-Id: Ib7c93cfadacedc4f8d983c490e55fb4672cc9c1d
2020-05-26 23:02:31 +00:00
David Anderson
42c2733d6c liblp: Add integer overflow checks when aligning.
This will prevent ubsan crashes on invalid inputs.

Bug: 155510366
Test: liblp_test gtest
Change-Id: Id6dd8badd0025d6cac3113c3f9076ea3f4d9c175
2020-05-05 11:37:53 -07:00
TreeHugger Robot
19685064b9 Merge "Convert vts configs to Android.bp" into rvc-dev 2020-04-27 17:05:10 +00:00
Automerger Merge Worker
cb02c1f825 Convert vts configs to Android.bp
Bug: 154727600
Test: treehugger
Change-Id: Ibe8ed03555ac78ee38be6511eb4169cddfcd3555
Merged-In: Ibe8ed03555ac78ee38be6511eb4169cddfcd3555
2020-04-27 16:36:53 +00:00
David Anderson
171681caf9 liblp: Remove alignment_offset handling.
This code is complex and alignment_offset is not useful for
optimization. Remove it, and add another test that misaligned extents do
not cause overlapping partitions.

Bug: 154646936
Test: liblp_test gtests
Change-Id: I563122282e940e07a7ece97ed1a9846ad1f3253c
2020-04-22 23:44:03 -07:00
David Anderson
f81ec0e43a liblp: Fix tests for linear extent overlap.
The "OwnsSector" tests did not work if one range fit completely inside
another range. The new OverlapsWith() methods address this case.

Bug: 154277287
Bug: 154646936
Test: liblp_test gtests
Change-Id: I1a59069db4ffe4f13c45963c4847cff7b3dd3dfc
2020-04-22 14:39:04 -07:00
David Anderson
9c66e53a82 liblp: Fix tests for linear extent overlap.
The "OwnsSector" tests did not work if one range fit completely inside
another range. The new OverlapsWith() methods address this case.

Bug: 154277287
Bug: 154646936
Test: liblp_test gtests
Change-Id: I1a59069db4ffe4f13c45963c4847cff7b3dd3dfc
2020-04-21 15:43:59 -07:00
Dan Shi
ab8acaedae Rename vts-core to vts
Bug: 151896491
Test: local build
Exempt-From-Owner-Approval: This CL moves all tests in vts-core to vts.
It won't change test logic or behavior.

Change-Id: I24779951257ce37fc18929f214d3cf5f76c23a19
Merged-In: I24779951257ce37fc18929f214d3cf5f76c23a19
2020-04-07 02:48:48 +00:00
Dan Shi
a7b9a2bfd2 Rename vts-core to vts
Bug: 151896491
Test: presubmit check
Exempt-From-Owner-Approval: This CL renames suite name vts-core to vts.
It won't change test logic or behavior.

Change-Id: I24779951257ce37fc18929f214d3cf5f76c23a19
2020-04-06 16:11:29 -07:00
Dan Willemsen
a8f188f011 Convert vts configs to Android.bp
Test: treehugger
Change-Id: Ibe8ed03555ac78ee38be6511eb4169cddfcd3555
2020-03-07 21:21:33 -08:00
Haoran.Wang
f7d1a07952 fix some liblp file access for win32
The file accessing API in liblp don't work on win32. Add the O_BINARY
to correct the file stream access.
This patch follow the AOSP change 829979.

Change-Id: I97180e2f07cacf109a86593b6a12975597552053
Signed-off-by: Haoran.Wang <elven.wang@nxp.com>
2020-03-05 08:34:52 +08:00
David Anderson
8edafa2393 Merge "libfiemap: Add helpers to remove images from recovery." 2019-12-27 20:28:48 +00:00
David Anderson
f41c7bbb96 libfiemap: Add helpers to remove images from recovery.
ImageManager can map images in recovery, but not delete them, because
/data is not mounted. libsnapshot handles this by storing extra state
files, but this is complex to manage and inconvenient for
fs_mgr_overlayfs.

Instead, this patch introduces two new calls:

 - DisableImage(), which indicates the image should not be used. This is
   implemented by adding a new DISABLED attribute to
   LpPartitionMetadata. CreateLogicalPartitions ignores this flag, and
   thus recovery/fastbootd can disable the scratch partition and
   communicate that it can be deleted. This cannot be called from binder
   since it is intended for recovery/first-stage init only.

 - RemoveDisabledImages(), which walks the images for a given folder on
   /metadata and deletes any that are disabled. This can be called from
   binder.

Note that there is no metadata version bump for this flag. It's
considered to be included in the flag list for minor version 1, and
currently is not used for the actual super partition.

Bug: 134949511
Test: adb remount, fastboot flash system
Test: fiemap_image_test
Change-Id: Iaeca2d1eddb5637dd9a20202cafd11ae60b4d0e3
2019-12-20 16:41:35 -08:00
David Anderson
4ba68b6451 liblp: Add a VIRTUAL_AB_DEVICE flag for LpMetadataHeader.
Bug: 134949511
Test: liblp_test gtests
Change-Id: I8b376d0980e1372086ed15b980209f3726ef651a
2019-12-16 22:20:40 +00:00
David Anderson
9f75098c60 liblp: Expand the metadata header for future use.
A few times we have wanted to stash small bits of information in the
super header, but we haven't had any bits to do so. This patch addresses
future needs in two ways:

  1. A "flags" field has been added for miscellanious bits that do not
     need a version bump.
  2. The header struct has been padded to 256 bytes to allow for future
     expansion without complicating the struct-parsing code.

This is the first time we've materially changed the format, so this
patch needs some extra explanation.

In all the places we rely on sizeof(LpMetadataHeader), we now need to
use the |header_size| field instead. To make newer versions of liblp
compatible with older headers, we read the minimum required header size
and fill in the extra bytes as needed. To make the validation and
reading logic more clear, it is now combined into a single function,
ReadMetdataHeader.

MetadataBuilder will still emit 1.0-compatible headers, to avoid
changing the on-disk format of existing devices. The new header will
only be emitted as-needed.

Bug: 134949511
Test: liblp_test gtest
      retrofit DAP device boots
      launch DAP device boots

Change-Id: I6221123768ff0057a73967ecb2ff9b006c17af88
2019-12-14 00:35:58 +00:00
David Anderson
2780d0abb2 liblp: Allow "flashing" files on the host.
UpdatePartitionTable expects to be run on a device, which is a
reasonable assumption. However to implement lpadd (offline modification
of super images), it's useful to be able to run these methods, and
IPartitionOpener allows us to masquerade a flie as a block device.

The only catch is that we can't query partition information on the host.
Since this logic is a protection mechanism, just surround it with
an ifdef for __ANDROID__.

Bug: 144468779
Test: lpadd
Change-Id: I3c50e5677fa1dd59f2d4216038d3d4fbfb6edcc0
2019-11-19 17:39:55 -08:00