Commit Graph

401 Commits

Author SHA1 Message Date
Bowgo Tsai c131341a03 Merge "fs_mgr: removing fs_mgr_read_fstab_with_dt()" am: 53108b269e am: 5a5017c07c
am: da5a7a585b

Change-Id: I384384973a92385108dfa797127452f3df0f122e
2017-04-01 03:14:58 +00:00
Treehugger Robot 53108b269e Merge "fs_mgr: removing fs_mgr_read_fstab_with_dt()" 2017-04-01 03:05:25 +00:00
Bowgo Tsai a739e16825 Merge "fs_mgr_avb_ops: stores the by-name prefix of /misc instead of fstab struct" am: 5c4af9698c am: 474897035d
am: cecfaff6cd

Change-Id: I6fb0fd462385bef975515740ed1ebb948fbba35d
2017-03-31 04:40:07 +00:00
Bowgo Tsai 2437532331 Merge "fs_mgr_avb: allow top-level vbmeta struct to be in 'boot' partition" am: 2e0f8a3b13 am: ec10a51d7d
am: 1c7f528f4e

Change-Id: Idd0ebe9ad12c622732e29dc2b4747bd2b5c78602
2017-03-31 03:54:56 +00:00
Bowgo Tsai f5bbfd64a9 fs_mgr_avb_ops: stores the by-name prefix of /misc instead of fstab struct
fs_mgr_avb_ops->read_from_partition() relies on the by-name prefix to
get the device file when reading a partition. Previously we store the
fstab struct and use fs_mgr_get_entry_for_mount_point() for every read.

It's better to do that once and store the by-name prefix for later use.

Bug: 33254008
Test: test AVB on bullhead
Change-Id: Ie999851b529f984e29ccbf39fb52a8220056fe0c
2017-03-31 10:25:04 +08:00
Bowgo Tsai 37a0b318ef fs_mgr_avb: allow top-level vbmeta struct to be in 'boot' partition
get_hashtree_descriptor() currently restricts HASHTREE descriptor to be
either in /vbmeta or in the same partition for dm-verity setup.

Also allows it to be from /boot partition because the top-level vbmeta
might be appended at /boot in legacy devices without /vbmeta.

Bug: 35880930
Test: test AVB on bullhead with top-level vbmeta being at /boot
Change-Id: I1ebd16a3c9f17bced6055146e8843b5918a737eb
2017-03-30 20:37:12 +08:00
Bowgo Tsai acc1c3c792 fs_mgr: removing fs_mgr_read_fstab_with_dt()
Currently there is no client requires fs_mgr_read_fstab_with_dt() so
remove this API. Devices with fstab entries in device tree should use
fs_mgr_read_fstab_default() to get default fstab, or just use
fs_mgr_read_fstab_dt() to get those in device tree.

Bug: 35811655
Test: normal boot sailfish
Test: run factory data reset in sailfish
Test: recovery boot sailfish
Test: adb sideload in sailfish

Change-Id: I1579d81cea7366cf3867cfe5ad56feb36cbb7246
2017-03-29 16:25:03 +08:00
Bowgo Tsai 207a9fcec9 Merge "fs_mgr: change the log level in fs_mgr_get_boot_config()" am: c8c3e61eeb am: c30261f266
am: 73d9e8e938

Change-Id: I3b0caeda0d9b9ecf2aeb1592463c55e8480adf69
2017-03-28 15:59:49 +00:00
Bowgo Tsai 0f34094a17 fs_mgr: change the log level in fs_mgr_get_boot_config()
fs_mgr might try to get a non-existing config through fs_mgr_get_boot_config()
on a device (e.g., for backward compatibility). Lower the log level to INFO
so it won't appear on the recovery screen.

Bug: 35811655
Test: recovery boot sailfish
Change-Id: I81497259aff3691740170abeef932d363b52be35
2017-03-28 18:52:04 +08:00
Bowgo Tsai 9b83226871 Merge "fs_mgr_avb: allow top-level vbmeta struct to be in 'boot' partition" am: ea057b46e0 am: 75ada5fce3
am: f6b7adb464

Change-Id: I375d5a1129253d9c08e6b57039487f094bf3dd42
2017-03-28 00:43:24 +00:00
Treehugger Robot ea057b46e0 Merge "fs_mgr_avb: allow top-level vbmeta struct to be in 'boot' partition" 2017-03-28 00:28:33 +00:00
Tao Bao 9d3760e3b3 Merge "fs_mgr: use different fstab paths for normal/recovery boot" am: 9c59029add am: 07052c0509
am: 4ba8d8b5bf

Change-Id: Id3b713b7d132bc1e500a24aa79598350868470d3
2017-03-27 19:37:12 +00:00
Tao Bao 9c59029add Merge "fs_mgr: use different fstab paths for normal/recovery boot" 2017-03-27 19:23:12 +00:00
Bowgo Tsai d05a2f7dcb fs_mgr: use different fstab paths for normal/recovery boot
recovery boot: /etc/recovery.fstab
  normal boot: use the first one found by the order:
               /odm/etc/fstab.{hardware} ->
               /vendor/etc/fstab.{hardware} ->
               /fstab.{hardware}

Bug: 35811655
Bug: 36637553

Test: Sideload OTA installation in sailfish
Change-Id: I3e260e077afa5a37fb65246246c824e9379e68c8
2017-03-28 01:34:28 +08:00
Bowgo Tsai 3286a6fe73 Merge "fs_mgr_avb: fix return value check of fs_mgr_get_boot_config()" am: 51da2aaa36 am: eb0a5e7e26
am: 07fb5bf7f0

Change-Id: I6d4888f2c376f9d7f24f592bb1c4898a3ea04fb8
2017-03-27 17:19:56 +00:00
Bowgo Tsai 97db0809f4 fs_mgr_avb: fix return value check of fs_mgr_get_boot_config()
fs_mgr_get_boot_config() returns true/false but the return value check
in current fs_mgr_avb is for 0/1. This was introduced during a refactoring.

Check true/false for the return value.

Bug: 33254008
Test: manual test AVB on bullhead
Change-Id: I72c366627214df4a99c4d9cf1eb577e94f7afb31
2017-03-27 22:33:21 +08:00
Bowgo Tsai b016896c98 fs_mgr_avb: allow top-level vbmeta struct to be in 'boot' partition
avb_ops->read_from_partition() should return
AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION if the requested partition does
not exist. Then libavb will try to load top-level vbmeta from /boot partition.

Two related changes in external/avb:

  https://android-review.googlesource.com/#/c/344907/
  https://android-review.googlesource.com/#/c/348731/

Bug: 35880930
Test: test AVB on bullhead with top-level vbmeta being at /boot
Change-Id: I80355ba5ae4d29a6f102714cd2f7c2550b238f27
2017-03-27 21:35:06 +08:00
Fernando Lugo 189bbbfe36 Merge "fs_mgr: update to new androidboot.slot param" am: 0fc8a4b363 am: 64bf462eb9
am: cefc9134f8

Change-Id: I64bc926c5f12221ddd3b9ccc39e5d4d612c57dd1
2017-03-24 23:37:42 +00:00
Fernando Lugo 9c7ae587c2 fs_mgr: update to new androidboot.slot param
androidboot.slot_suffix is being deprecated for a androidboot.slot.
Bootloader must pass slot used to boot into the androidboot.slot which
does not include the '_' character

Test: boot android
Bug: 36533366
Change-Id: I6137bd08418f67a88120c8609eda10b2ada4607d
Signed-off-by: Fernando Lugo <flugo@google.com>
2017-03-24 23:28:55 +00:00
Fernando Lugo 9e0c682e61 Merge changes I0ad349f2,I0f528cf1 am: 27a091d4a1 am: 69482cc127
am: 89573b397d

Change-Id: Id087881d88f87e2b31a77aab6f818118c04c25c6
2017-03-23 17:01:12 +00:00
Fernando Lugo ce9d7db979 fs_mgr: allow using legacy A/B suffix
Right now all platforms supporting A/B have not fixed
androidboot.slot_suffix kernel command line parameter. To avoid breaking
all those platform allow using legacy support bootloaders get fixed.

Bug: 36533366
Test: boot
Change-Id: I0ad349f262d0b7f4897f3e184cb053b1440b2d5b
Signed-off-by: Fernando Lugo <flugo@google.com>
2017-03-22 19:22:25 -07:00
Fernando Lugo d1dcedd3fb fs_mgr: adapt to new A/B support
In the new A/B partition support suffixes don't have "_". So, fix fs_mgr
code that assumes it has "_"

Bug: 36533366
Test: boot
Change-Id: I0f528cf1e8fecacb1b4ae34f6dc42e18ebe777bb
Signed-off-by: Fernando Lugo <flugo@google.com>
2017-03-22 19:21:56 -07:00
Mark Salyzyn cfcc1dfa93 Merge "fs_mgr: remove private/android_filesystem_config.h" am: f5ee213a5c am: ba9d88ebab
am: 8f9a187785

Change-Id: Ib9cbcd36021cc80202f04162a4aa555142a46ea6
2017-03-21 15:28:57 +00:00
Mark Salyzyn e989a22553 fs_mgr: remove private/android_filesystem_config.h
Test: compile
Bug: 33241851
Change-Id: I3807871dcdfe5c751b1eea6e57c1ff5aac15806e
2017-03-20 14:30:48 -07:00
bowgotsai 5353833a21 Merge "fs_mgr: change the log level in fs_mgr_read_fstab_dt()" am: b280bb210b am: d141190210
am: 82bcc7b0ea

Change-Id: I39a1c5757596071b1d4f10cc9ca6c91c265139d9
2017-03-17 02:21:58 +00:00
bowgotsai 172c1d8b6e fs_mgr: change the log level in fs_mgr_read_fstab_dt()
Devices having no early mount enabled won't have fstab in device tree.
Lower the log level to INFO when fstab is absent there.

Bug: 35811655
Test: boot into recovery mode in a device without fstab in dt
Change-Id: I4b1e0e6554f50b8118770d00aa8f54be86aca858
2017-03-16 10:25:39 +09:00
NIEJuhu cc9d94ce04 Merge "fs_mgr: fix errno setted by mount_with_alternatives" am: 488525b47b am: 21a33342af
am: 56c920aed9

Change-Id: I12fea4ae42c6c7071355911d968432ce5d4e07ee
2017-03-12 03:38:37 +00:00
Treehugger Robot 488525b47b Merge "fs_mgr: fix errno setted by mount_with_alternatives" 2017-03-12 03:27:14 +00:00
NIEJuhu 5c31ffe9cd fs_mgr: fix errno setted by mount_with_alternatives
mount_with_alternatives should set errno to match the 1st mount failure.

Bug: N/A
Test: run `fs_mgr -a <fake_fstab>` and check dmesg log
Change-Id: If4148d327f75c659b843e95f85568ea49c5d0180
Signed-off-by: NIEJuhu <niejuhu@xiaomi.com>
2017-03-10 08:36:11 +00:00
Bowgo Tsai eeea724900 Merge changes from topic 'fstab_relocation' am: ac13718d0a am: 8f7125fbee
am: 9fc983315a

Change-Id: Ic62c46c160e9995ff11067300ec5c831301bceb9
2017-03-10 03:17:50 +00:00
Bowgo Tsai 46c6dc1a6f fs_mgr: support reading fstab file from /odm or /vendor partition
fstab contains device- and soc- specific content that should reside in
/odm or /vendor partition. This change searches the fstab.${ro.hardware}
file from /odm/etc, /vendor/etc and /, then use the first one found.

Bug: 35811655
Test: boot sailfish
Change-Id: I82f89b41a849faedb64072a7cfc52d7424e1aaa1
2017-03-09 22:35:54 +08:00
Bowgo Tsai 47d342739a fs_mgr: add fs_mgr_read_fstab_with_dt() API
With the early mount support in init, fstab entries of verified partitions
(e.g., /system, /vendor) will be moved into device tree in kernel image.

Those early mount fstab entries will be removed from the fstab file to
prevent duplicated and/or inconsistent settings.

This change adds a new function: fs_mgr_read_fstab_with_dt(), to return
the combined results from both places. It also removes
fs_mgr_read_fstab_file() from the public APIs and makes it as an
internal function.

Bug: 35811655
Test: early mount /vendor with dm-verity on sailfish

Change-Id: I2fba3614685bf9f852a789cda6f53013e2164e60
2017-03-09 21:15:08 +08:00
Keun-young Park 19761b8ea7 Merge "collect fs stat for ext4" am: 5811a434fc am: f3fcb883b2
am: 820d28b3e2

Change-Id: I90f95321b133305a16e3abe0fc3885992e99d890
2017-03-07 19:37:40 +00:00
Keun-young Park 3fbf94e19a collect fs stat for ext4
- This is to collect data to understand if e2fsck -f option
  can be dropped wholly based on information from fs.
- Ideally e2fsck should not fix fs if it was clean shutdown
  or if it is not enabling quota.
- The log is added to /dev/fscklogs/log and other system components
  can collect it later.

TODO: add mechanism to distinguish old vs new fs generation tool.

bug: 32246772
Test: reboot and check saved logs under different shutdown conditions (clean, non-clean)

Change-Id: Id00fad4c5f8ebbb9f9908164a1026e415df06721
2017-03-06 19:39:58 -08:00
Bowgo Tsai 8789cd5292 Merge "fs_mgr: allow disable dm-verity when the device is unlocked without metadata" am: 17c84b2cca am: 63b22a3eb1
am: 944c9f667c

Change-Id: I905f5d7be07fa77f8846edec56eef9a1fb298296
2017-03-06 19:13:18 +00:00
Bowgo Tsai 7ad3159db9 fs_mgr: allow disable dm-verity when the device is unlocked without metadata
To start Treble VTS test, a single AOSP system.img will be flashed onto
the device. The size of AOSP system.img might be different than the
system partition size on device, making locating verity metadata fail
(at the last fixed size of the partition).

This change allows disabling dm-verity on system partition when the
device is unlocked (orange device state) with invalid metadata.

BUG: 35603549

Test: Boot bullhead with a different-sized system.img, checks verity is
      not enabled via:

          "adb shell getprop | grep partition.system.verified"

Change-Id: Id89d023e82c78ff1902ab7a528431cf7f65e49ad
2017-03-06 16:04:03 +08:00
Sandeep Patil 23e7f86d36 Merge "fs_mgr: make is_device_secure() work even in the absence of properties." am: 0026f1e693 am: 5cdbcbbcbf
am: 8207bd8486

Change-Id: Idb8fb584b38914d1c510737716e1eff6e70b0f65
2017-02-27 22:49:11 +00:00
Sandeep Patil e7a1b3757f fs_mgr: make is_device_secure() work even in the absence of properties.
During early mount property area is not initialized, and as a result an
'eng' build will always incorrectly be detected as a 'secure' build by
early mount code path resulting into verity error and consequent boot
loop.

The change here makes sure the is_device_secure() check works with /
without properties based on the 'eng' build based build flag so the
early mount code works fine both ways.

Bug: 35791581
Bug: 27805372

Test: Boot sailfish-{eng,userdebug} builds successfully w/ early
mount enabled

Change-Id: Icd101ccad56b669f49b60bbb3005d5be9f53b02b
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-27 12:46:18 -08:00
Wei Wang eebe07c539 Merge "fs_mgr: fix const parameter in fs_mgr_do_tmpfs_mount" am: 7a5d535cd2 am: be838ae027
am: 771f642d89

Change-Id: Ie8cd01116a1f0437eee80168dc5f6aa57b08fa55
2017-02-25 05:23:40 +00:00
Wei Wang 4d71bc5350 fs_mgr: fix const parameter in fs_mgr_do_tmpfs_mount
Bug: 35425974
Test: mma, marlin/angler boot
Change-Id: Ibadd04ad3a7c4ea184a6344d566302d577d8fee3
2017-02-24 19:33:53 -08:00
Sandeep Patil ddfe01281a Merge changes from topic 'fs_mgr_dt' am: dbb40b64e9 am: ad384fc992
am: 50eb15a0d0

Change-Id: I4c8784610d0d41c3807851c516e3ef59388ca70f
2017-02-24 23:10:30 +00:00
Sandeep Patil 4cd9a46916 fs_mgr: refactor: consolidate device tree file reading in one place
If Device tree values are read for comparison, they produce false
negatives with std::strings due to trailing '\0'. This change
consolidates the triming of trailing null into a single helper function
to be used everywhere fs_mgr reads DT values for comparison or other
reasons where it wishes to have the trailing null trimmed.

b/27805372

Test: Boot sailfish w/ early mount /vendor

Change-Id: If71efc830dc440323df764c7461867e71ed6515b
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-24 13:29:33 -08:00
Sandeep Patil e396c607ff fs_mgr: consolidate DT compatible check
Fixes the compatible check in fs_mgr_boot_config by consolidating the
check in a single privately exported function within fs_mgr (i.e.
is_dt_compatible()).

b/27805372

Test: Boot sailfish w/ early mount

Change-Id: Ie2d1646b81cf9eba8d16828ca8cf2c75156c294c
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-24 13:29:26 -08:00
Sandeep Patil 72b689bf34 Merge changes from topic 'early-mount-verity' am: 93072f2ce3 am: 2eb715d866
am: d93e05052a

Change-Id: I014d926e0bf7f560b7fbfa32f11b078dc7b6edc4
2017-02-24 02:23:54 +00:00
Sandeep Patil c20c0c2cdd early_mount: fs_mgr: move all fstab logic into fs_mgr
With init parsing fstab fragments from kernel separately, the fs_mgr
would completely miss the device tree entries. That leads to things like
'adb remount' to go through without warning for verity even if /system
is verified. This happens because 'verity_update_state' completely
misses the partitions passed to android through the device tree.

solution is to teach fs_mgr about device tree fstab entries and add 2
new public APIs.

1. fs_mgr_read_fstab_dt() - reads device tree and returns fstab
generated from it.

2. fs_mgr_read_fstab_default() - reads both device tree fstab and
/fstab.{ro.hardware} and returns the combined table.

This also reduces the hardcoded /fstab.{ro.hardware} occurence only to
fs_mgr and for eveyone who wants to read the "default" fstab must be
changed to call fs_mgr_read_fstab_default() instead. e.g. adb.

b/27805372

Test: Angler was used since it has 2 early mounted partitions instead of
one. 1 verified and 1 unverified.
- Boot angler successfully without early mount
- Boot angler successfully with /vendor early mount and test if 'adb
remount' warns us about verity
- Boot angler successfully with both /system and /vendor early mounted
and ensure 'adb remount' warns us about verity.
- check partitions.system.verified status after /system early mount ot
ensure it is set to VERITY_MODE_DEFAULT.
- 'adb disable-verity' with early mounted /system doesn't work due to
missing changes in adb

TODO:
change adb to use the new fs_mgr_read_fstab_default() API

Change-Id: I82038d87c7a44488e938acce2cc1082c08f6f73a
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-23 16:48:43 -08:00
Sandeep Patil bb5a8380b0 Merge changes from topic 'early-mount-support' am: 4bd3facbb1 am: e0d7b830f0
am: 5f08cb2aea

Change-Id: I40a70549a545d9d1dd4f007f5fd259102785412c
2017-02-23 07:23:37 +00:00
Sandeep Patil 9de748f745 fs_mgr: add a generic fs_mgr_get_boot_config internal API
depending on when fs_mgr is trying to read the configuration passed into
the kernel commandline, it may be able to read it successfully.
Specially in the case when init has not initialized properties.

This change adds a new fs_mgr_get_boot_config() API to be used by all
fs_mgr code in order to get filesystem parameters specified in kernel
command line or device tree. This way the fs_mgr code doesn't have to
handle the "early" cases separately anywhere.

Test:
Tested angler boot with both /system and /vendor mounted in init
first stage.
Tested sailfish to make sure /vendor can be continued to be
mounted early without verity

Change-Id: I9a44cdfc32681f714c5d73ae55c3deda95c02545
2017-02-22 12:58:15 -08:00
Sandeep Patil 05ff38ba43 init: early_mount: disallow partitions to be verified at boot
While technically possible, the verification at boot basically will
block init for as long as the entire partition is read while nothing
else is running. Disallow that as this is not going to be used anywhere.

Bug: 27805372
Test: boot angler with verifyatboot fs_mgr option for early mounted
vendor partition. That resulted in a panic() as expected.

Change-Id: I9da5caa163cae8bce6dbfb630f0ed5605ea044a0
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-22 11:22:53 -08:00
Sandeep Patil 4129f20aaf fs_mgr: make fs_mgr_setup_verity public API
Consequently this removes the 'early' version of the exact same API.
This is to be used by early mount code where we need to do
1. setup verity
2. create verity device
3. mount partition
as separate steps since that happens during init first stage.

b/27805372

Test: Boot sailfish successfully

Change-Id: I01abecfdfa210d3e240a291ddcb3d2e9ed39ede6
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-22 11:22:53 -08:00
Sandeep Patil d2462570b8 fs_mgr: fix the fs_mgr_setup_verity param name
The 'verify_dev' parameter for fs_mgr_setup_verity is confusing, since
it doesn't necessarily control the "verification" part of the function.
Instead, it merely allows the caller to skip the
wait_for_dm_verity_device part of the function. So, rename that
parameter for what it is.

b/27805372

Test: Boot sailfish

Change-Id: I024e02fd728f5cd5bb333d9c3b512861731fa215
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-22 11:22:53 -08:00