Commit Graph

39108 Commits

Author SHA1 Message Date
David Anderson 23de22d54b fs_mgr: Add a method for creating one-off partition instances.
fastbootd needs to temporarily map and unmap logical partitions in order
to flash them. To make this easier, this change introduces fs_mgr
methods to create and destroy a single logical partition by name.

Bug: 79173901
Test: N/A
Change-Id: Ic085f2175c26a5edf5f18544012dcfe6d8088f09
2018-07-23 11:43:27 -07:00
Treehugger Robot 1d2b29a902 Merge "init: rename init_first_stage" 2018-07-21 02:47:36 +00:00
Tom Cherry 258109ce4a Merge "init: clean up logging initialization" 2018-07-21 02:01:14 +00:00
Tom Cherry 21d03d83fa Merge "init: removed unused includes" 2018-07-21 01:06:45 +00:00
Treehugger Robot d4abb70a98 Merge "Revert "Revert "base: add support for tagged fd closure to unique_fd.""" 2018-07-20 23:09:27 +00:00
Tom Cherry f02506938e init: removed unused includes
Test: build
Change-Id: Ie3020491f67f6930acebe6397be6997b59477b96
2018-07-20 22:48:51 +00:00
Tom Cherry 38a11ccdd1 init: rename init_first_stage
In preparation for splitting first stage init from the rest of the
init executable, rename these files which are specifically involved in
first stage mount operations to a more appropriate name.

Test: builds
Change-Id: I8a2d4e8c7e1deea1bab45cc8e738727bc2ceb3e5
2018-07-20 15:31:36 -07:00
Tom Cherry 74069d1734 init: clean up logging initialization
Clean up a few mistakes in logging initialization

1) Only init needs to clear stdout/stderr/stdin, so remove this from
   ueventd, watchdogd, and subcontext init
2) Only init should reboot due to FATAL errors. This was true even
   before this change due to getpid() checks, but there's no reason to
   not just use the DefaultAborter for other processes.
3) It's probably a mistake for FATAL logs in init to try to gracefully
   shutdown the system, so simply call RebootSystem() here.
4) Lastly, remove log.cpp since it's not actually shared code anymore

Test: build
Change-Id: Ic8c323393dc7ee98ed6bb9691361b51d0d915267
2018-07-20 15:30:14 -07:00
Treehugger Robot b13c49b1b0 Merge "fastboot: add tomcherry to OWNERS." 2018-07-20 22:16:42 +00:00
Treehugger Robot 3ba85c4d17 Merge "ParseInt/ParseUint: allow validation only." 2018-07-20 21:53:27 +00:00
Chris Fries 767506fc5a Merge "Refactor libfastboot" 2018-07-20 20:52:58 +00:00
Josh Gao 22666feacc Revert "Revert "base: add support for tagged fd closure to unique_fd.""
Use __attribute__((weak)) to check for fdsan availability at runtime,
to support being used when built with the NDK while targeting older
platform versions.

This reverts commit af798acaea49b8d9150b94eb9f5f11450a6b8893.

Bug: http://b/110100358
Test: m libjnitest
Change-Id: Ie59d041d69cc3d4b6c59412d706f702dd1d2dab2
2018-07-20 13:50:15 -07:00
Elliott Hughes 4239aa7b75 fastboot: add tomcherry to OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie2a367b7fbf1dd5319a3506d09951d571512f438
2018-07-20 13:20:09 -07:00
Treehugger Robot a570644b7d Merge "fastboot: fix USB_TRACE, make it better." 2018-07-20 20:01:05 +00:00
Treehugger Robot c23280a1e3 Merge changes Iccfe3bd4,I6380245b,I20d9f2fe
* changes:
  adb: Remove most C-style allocations
  adb: Modernize the service creation
  adb: Preserve the original mount flags when remounting
2018-07-20 18:35:25 +00:00
Steven Moreland a96e43d3d6 ParseInt/ParseUint: allow validation only.
Removes segfault if T* out != nullptr and just
returns validation result.

Bug: 110758329
Test: libbase_test
Change-Id: I0f304533a7076bba977fbd1a715b9cc0d9e58e75
2018-07-20 11:02:47 -07:00
Treehugger Robot 74be24d696 Merge "Adb and fastboot completion supports zsh users." 2018-07-20 10:27:27 +00:00
Treehugger Robot ea674a38f3 Merge "Revert "base: add support for tagged fd closure to unique_fd."" 2018-07-20 05:11:33 +00:00
Josh Gao 30dd7d4dff Revert "base: add support for tagged fd closure to unique_fd."
This reverts commit fcf2c01b55.

Commit broke full-eng, because libbase is being compiled against the NDK.

Test: treehugger
Change-Id: I8447b6a7fc33e6aa34cec0f037727322fa824446
2018-07-20 01:42:02 +00:00
Treehugger Robot 65e4751633 Merge changes from topic "bionic_fdsan"
* changes:
  crasher: add close(fileno(FILE*)) and close(dirfd(DIR*)).
  debuggerd_handler: use syscall(__NR_close) instead of close.
  base: add support for tagged fd closure to unique_fd.
2018-07-19 23:43:37 +00:00
Treehugger Robot 881be58f41 Merge "fs_mgr: Remove early prototype code." 2018-07-19 23:32:33 +00:00
Christopher Ferris b8a2fa7fba Merge "Remove PenaltyExcessCharacter from clang-formats." 2018-07-19 23:25:45 +00:00
Treehugger Robot 8ab1fd076d Merge "init: Don't look for logical partitions via uevents." 2018-07-19 21:42:55 +00:00
David Anderson e0384bbc69 fs_mgr: Remove early prototype code.
This early code is no longer needed now that logical partitions can be
created and flashed normally.

Bug: 79173901
Test: N/A
Change-Id: I393ef23b3d3ce1cd9c80833358051838d0e9f333
2018-07-19 14:38:33 -07:00
David Anderson ab8414dd6c init: Don't look for logical partitions via uevents.
When using AVB, init's first stage regenerates uevent to find the paths
of block devices for verified partitions. If it can't find them all, it
will panic, causing the device to boot to recovery.

This does not work with logical partitions, since devices for those
partitions are created later in the first stage. In fact, they cannot be
created until uevent regeneration completes, since logical partitions are
are created by finding the "super" partition.

To address this we exclude logical partitions (as marked in fstab) from
the device finding process. Note that partitions moved from GPT to liblp
will no longer appear in by_name_symlink_map_.

Bug: 79173901
Test: AVB 2.0 device boots after deleting the vendor partition,
      creating a super partition, and flashing it with a dynamic
      vendor partition.

Change-Id: I19371b05912240480dc50864a2c04131258a7103
2018-07-19 14:38:27 -07:00
Christopher Ferris 6c481b9a06 Remove PenaltyExcessCharacter from clang-formats.
This option can cause the number of columns to exceed 100.

Bug: 111310533

Test: NA
Change-Id: Icbda1ba9afbf68a29f2a13082df6ca65af3c0f37
2018-07-19 13:50:41 -07:00
Aaron Wisner db511207ed Refactor libfastboot
This change creates a nice and clean API for issuing
fastboot commands without using the fastboot tool itself.

Test: fastboot tool itself (now using libfastboot2)
on sailfish, walleye, and other devices.
Test: flash bootloader bootloader.img
Test: flash radio radio.img
Test: -w update img.zip
Test: Manually getvar and reboot commands.

Bug: 111126621
Change-Id: I0022536b204ce0c5ad8329367fd522fa3c57877d
2018-07-19 15:16:47 -05:00
Chih-hung Hsieh f07dbdd022 Merge "Use __VA_ARGS__ when in clang static analyzer." 2018-07-19 19:05:32 +00:00
Treehugger Robot 17fde657bc Merge "liblp: Allow packing partition data into super images." 2018-07-19 19:04:09 +00:00
Luis Hector Chavez 6150a37dbe adb: Remove most C-style allocations
This change gets rid of most malloc/calloc/free calls. The future is
now!

Bug: None
Test: test_device.py
Change-Id: Iccfe3bd4fe45a0319bd9f23b8cbff4c7070c9f4d
2018-07-19 09:41:40 -07:00
Tom Cherry 1fefb9f129 Merge "Fix loading ueventd.${ro.hardware}.rc." 2018-07-19 15:00:08 +00:00
Luis Hector Chavez 095792c300 adb: Modernize the service creation
This change removes the void* argument passing and instead uses C++11
features to avoid having to handle memory manually.

Bug: None
Test: python ./system/core/adb/test_device.py

Change-Id: I6380245b2ca583591810e3e363c67c993a107621
2018-07-18 20:38:10 -07:00
Luis Hector Chavez c20c85008d adb: Preserve the original mount flags when remounting
This change preserves any additional flags mount flags (e.g. MS_NODEV)
that any of the mounts would have. This avoids unnecessarily opening up
permissions, and also allows kernels that have additional restrictions
about what mount flags can be used to be happy with the remounts.

Bug: 111618714
Test: `adb remount` works in Chrome OS
Test: `adb remount` works in sailfish_aosp

Change-Id: I20d9f2feaf3a47b93bfcdfb4164ee61546ec0b68
2018-07-18 19:48:08 -07:00
Josh Gao 3fa9637e81 crasher: add close(fileno(FILE*)) and close(dirfd(DIR*)).
Add some cases to trigger fdsan aborts.

Test: crasher fdsan_file; crasher fdsan_dir
Change-Id: I48152d333dc25900f1c8d8e0f2e8728154643508
2018-07-18 18:11:46 -07:00
Josh Gao c954ec09c5 debuggerd_handler: use syscall(__NR_close) instead of close.
Avoid bionic's file descriptor ownership checks by calling the close
syscall manually.

Test: debuggerd_test
Change-Id: I10af6aca0e66fe030fd7a53506ae61c87695641d
2018-07-18 18:11:46 -07:00
Josh Gao fcf2c01b55 base: add support for tagged fd closure to unique_fd.
Test: libbase_test
Change-Id: Ibba5e60d7007265a566eb8f76021d5dbeb734532
2018-07-18 18:11:46 -07:00
Sen Jiang d76f174a78 Fix loading ueventd.${ro.hardware}.rc.
Regression introduced in aosp/717324.

Bug: 111543389
Test: device boots further
Change-Id: I4cf57381104aa1a801cf82a42b1c5ae1a2273e89
2018-07-18 18:10:36 -07:00
Chih-Hung Hsieh fdd3f5ec74 Use __VA_ARGS__ when in clang static analyzer.
Clang static analyzer can optimize out if (false) ...
and report unused variables in __VA_ARGS__.

Bug: 111614304
Test: make with WITH_TIDY=1
Change-Id: I214ced736230fda847031fd4eee23015fd988ffc
2018-07-18 17:07:45 -07:00
David Anderson 9555f3dcf6 liblp: Allow packing partition data into super images.
This change allows partition data to be included in the sparse image for
the super partition. The data is specified as a map from partition name
to partition image file. The image file can either be a normal file or a
sparse image. If it is sparse, it is unpacked into a temporary file and
then re-packed into the super image.

Bug: 79173901
Test: (1) lpmake -S with a partition image flashes to walleye.
      (2) The image can be mounted if it contains a filesystem.
      (3) simg2img will successfully unpack the image.

Change-Id: I98e9af3bfec9863143c1b95a1712b1d435942542
2018-07-18 16:53:42 -07:00
Treehugger Robot 54f40303d5 Merge "liblp: Allow specifying a custom block size when building sparse images." 2018-07-18 21:08:16 +00:00
Tom Cherry bd130567f8 Merge "ueventd: add a test for ueventd_parser.cpp" 2018-07-18 16:56:04 +00:00
Joel Fernandes 5fd5be33e6 Merge "libcutils: ashmem: Avoid doing fd checks for ashmem calls" 2018-07-18 02:14:54 +00:00
David Anderson ce483b6f06 liblp: Allow specifying a custom block size when building sparse images.
liblp currently creates sparse files with a block size of 512 bytes.
Unfortunately devices can reject sparse files that don't have a specific
block size. To accomodate this, SparseBuilder now requires that
partition metadata be built with an explicit block size, and the device
alignment must be a multiple of that block size.

This change also modifies SerializeGeometry to automatically include
0-padding to 4096 bytes.

Bug: 79173901
Test: lpmake -S can be flashed with fastboot to walleye
Change-Id: Iab04f6f55bb373e21767963335c85ad1119a65a7
2018-07-17 18:37:46 -07:00
Joel Fernandes 56cd651e7a libcutils: ashmem: Avoid doing fd checks for ashmem calls
Callers already verify that they are calling ashmem API on a valid fd by
calling ashmem_valid first. Lets make the fstat syscall only if the
ioctl returns -ENOTTY. This means in the regular case, only 1 syscall is
needed (ioctl) vs the current 2 (fstat+ioctl).

Some data to show improvements in reduction of vfs_getattr calls in the
kernel by 10x when doing a camera.

Test: Boot and camera CTS
Bug: 111418894
Change-Id: I992620bbe44355e54ba19eeac81da586c5e5a6e0
Signed-off-by: Joel Fernandes <joelaf@google.com>
2018-07-17 17:02:44 -07:00
Jerry Zhang cb140c04c9 Merge changes I31e444f3,If07ff05f,If3ba190d
* changes:
  adb: Add io size and zero packet to usb_handle
  adb: Have device usb_handle return io size
  adb: Expose device usb_handle through libadbd
2018-07-17 22:35:36 +00:00
Tom Cherry 5f0198bfbb ueventd: add a test for ueventd_parser.cpp
Test: this unit test
Change-Id: Ib23f23ea5b362bb458adf8208573e5dc80ad6cf0
2018-07-17 15:28:51 -07:00
Jerry Zhang cda7c3b27c adb: Add io size and zero packet to usb_handle
Fastboot protocol doesn't include zero packets,
so make it possible to configure that.

Allow fastbootd to see how many bytes the handle
can read/write at once.

Test: adb works
Bug: 78793464
Change-Id: I31e444f384d9d0cdf1ea936439b2028f8151c3b8
2018-07-17 11:54:38 -07:00
Jerry Zhang 16b78db945 adb: Have device usb_handle return io size
Previously, read and write would return 0
on success. Now it will return the number
of bytes read/write. This is more consistent
with other usb handles and is needed in order
to handle partial packets (for fastbootd).

Update usb_write in other usb handles
to return amount written.

Change transport_usb accordingly.

Test: adb works
Bug: 78793464
Change-Id: If07ff05fbc8120343f20661475d34f4e5ff805de
2018-07-17 11:53:30 -07:00
Jerry Zhang b156c60ad4 adb: Expose device usb_handle through libadbd
Fastbootd will reuses adb's functionfs transport
implementation.

Move it to daemon/include as well so it can be accessed
with "adbd/usb.h". Otherwise usb.h will conflict with
other imports.

Test: adb builds and works
Bug: 78793464
Change-Id: If3ba190d5c74b5f3633411f0484195e5a2a34d44
2018-07-17 11:53:06 -07:00
Yi Kong a63b3309ff Merge "[adb] Modernize codebase by replacing NULL with nullptr" 2018-07-17 17:45:30 +00:00