Commit Graph

494 Commits

Author SHA1 Message Date
Bowgo Tsai 81af8c7362 first stage mount: removing the restriction of mount points
Current first stage mount only allows three mount points: system, vendor
and/or odm. This was introduced by project Treble to mount those
verified partitions early. However, there might be some other custom
partitions needs to be mounted early as well. This CL removes the
restriction and does first stage mount for whatever specified in
fstab-dt.

Bug: 62423887
Test: first stage mount /vendor with vboot 1.0
Test: first stage mount /vendor with vboot 2.0 (AVB)

Change-Id: I6c146c64e673c35c2823523ccbde193590430c48
Merged-In: I6c146c64e673c35c2823523ccbde193590430c48
(cherry picked from commit 06ed613e73)
2017-06-09 12:47:17 +08:00
Jaegeuk Kim 0331c2cf77 fs_mgr: call format_f2fs correctly with -f
This patch formats f2fs with -f option.

Change-Id: I3fc415f35d81f22cbf1eadebc619465d36205927
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-06-05 13:57:15 -07:00
Jinguang Dong efa3c047e2 Merge "fs_mgr: Fix ZRAM error when ZRAM disk size beyond (2^31-1) bytes" am: 28c11dcff4 am: 6a75b73c36 am: 40d4ad9cdf
am: 1123da7a42

Change-Id: If57135eb48c0f9376eb6a4c658d60b99573930e3
2017-06-01 17:57:58 +00:00
Jinguang Dong 1123da7a42 Merge "fs_mgr: Fix ZRAM error when ZRAM disk size beyond (2^31-1) bytes" am: 28c11dcff4 am: 6a75b73c36
am: 40d4ad9cdf

Change-Id: Ia93c8fd9fd4b799ec253241e0571077006ded21b
2017-06-01 17:43:38 +00:00
Treehugger Robot 28c11dcff4 Merge "fs_mgr: Fix ZRAM error when ZRAM disk size beyond (2^31-1) bytes" 2017-06-01 17:21:30 +00:00
Jinguang Dong f7d1014795 fs_mgr: Fix ZRAM error when ZRAM disk size beyond (2^31-1) bytes
Because the zram_size type is unsigned int.so if ZRAM size great
than 2^31 -1, zram_fp will receive a negtive integer, while the
ZRAM driver only accept natural number.We need to use printf
formatting %u instand of %d.

Test: 1. Config the zramdisk size 2348810240 and build a ramdisk
      2. Reflash device and check below command:
         $adb shell dumpsys meminfo
         $ adb shell cat /sys/block/zram0/disksize
         ZRAM info display will be abnormal
      3. Config the zramdisk size 2348810240 and apply with this
         patch.
      4. Retest to step 2 and the ZRAM info will be ok.

Change-Id: I473de33fbd0b66cf13eac3172684e9fef11b6ef0
2017-06-01 19:42:22 +08:00
Sandeep Patil 02a5108308 Respect that status property when parsing fstab from device tree
For an fstab entry in device tree, fs_mgr now honors the status property
as done by linux. i.e. the node (in this case, the fstab entry) is
enabled if status is not set, "ok" or "okay". For every other value, the
node is considered as disabled.

Merged-In: I5ff8f710de2c54afc76b4af28108ca9075357ad1
Bug: 62127741
Test: Test sailfish w/ no status property, result: boots
Test: Test with status = "disabled", result: skips mounting /vendor
Test: Test with status = "ok", result: boots

Change-Id: I5ff8f710de2c54afc76b4af28108ca9075357ad1
Signed-off-by: Sandeep Patil <sspatil@google.com>
(cherry picked from commit be4302bf58)
2017-05-30 10:25:58 -07:00
Sandeep Patil 5c7ec5af16 Respect that status property when parsing fstab from device tree am: be4302bf58
am: b472ef10c0

Change-Id: I90eccf22b2d5f52f36e5c8ee136c82d5ca0ec552
2017-05-27 03:40:05 +00:00
Sandeep Patil b472ef10c0 Respect that status property when parsing fstab from device tree
am: be4302bf58

Change-Id: Id7fa225c8e77154e6f37e40c5f1e15a7f16c2741
2017-05-27 03:31:28 +00:00
Sandeep Patil be4302bf58 Respect that status property when parsing fstab from device tree
For an fstab entry in device tree, fs_mgr now honors the status property
as done by linux. i.e. the node (in this case, the fstab entry) is
enabled if status is not set, "ok" or "okay". For every other value, the
node is considered as disabled.

Bug: 62127741
Test: Test sailfish w/ no status property, result: boots
Test: Test with status = "disabled", result: skips mounting /vendor
Test: Test with status = "ok", result: boots

Change-Id: I5ff8f710de2c54afc76b4af28108ca9075357ad1
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-05-26 18:09:06 -07:00
Bowgo Tsai 25b83186cc Merge "fs_mgr: fix SIGSEGV when ostream << nullptr" am: 225f0d98c8 am: 9af4b13b8f am: 942b4efa2e
am: 63d224a2bc

Change-Id: I2798cd3e57b89a5a8b48d72d62f00b749cc690d9
2017-05-24 16:48:27 +00:00
Bowgo Tsai 63d224a2bc Merge "fs_mgr: fix SIGSEGV when ostream << nullptr" am: 225f0d98c8 am: 9af4b13b8f
am: 942b4efa2e

Change-Id: Ibcac8ee1c680401a9311da0429cc482fb46a7344
2017-05-24 16:32:27 +00:00
Bowgo Tsai 98af6b320a fs_mgr: fix SIGSEGV when ostream << nullptr
fstab_rec.fs_options might be nullptr when printing error message.
Use android::base::StringPrintf() to '(null)' when needed.

Bug: 37759782
Test: Boot device and manaully trigger the output
Change-Id: I1bdf4ba57331aaea9dd5e790f6bf9d9b8bdc8b53
Merged-In: I1bdf4ba57331aaea9dd5e790f6bf9d9b8bdc8b53
(cherry picked from commit 59af33c9ed)
2017-05-25 00:25:24 +08:00
Bowgo Tsai 59af33c9ed fs_mgr: fix SIGSEGV when ostream << nullptr
fstab_rec.fs_options might be nullptr when printing error message.
Use android::base::StringPrintf() to '(null)' when needed.

Bug: 37759782
Test: Boot device and manaully trigger the output
Change-Id: I1bdf4ba57331aaea9dd5e790f6bf9d9b8bdc8b53
2017-05-24 18:57:16 +08:00
Tom Cherry fe1631735a Merge "fs_mgr: convert libfs_mgr to Android.bp" am: 3d33dae74d am: 4c4f1f99be am: a4c0591513
am: 9405cd416f

Change-Id: I9370e06c15f9a8004f8bd8f5b63a8ad98d279583
2017-05-18 20:43:01 +00:00
Tom Cherry 9405cd416f Merge "fs_mgr: convert libfs_mgr to Android.bp" am: 3d33dae74d am: 4c4f1f99be
am: a4c0591513

Change-Id: I635d90f15ae8bc84d60e52c9e25f263075d6fb57
2017-05-18 20:35:00 +00:00
Tom Cherry 3d33dae74d Merge "fs_mgr: convert libfs_mgr to Android.bp" 2017-05-18 20:18:00 +00:00
TreeHugger Robot 9b41af310c Merge "fs_mgr: Update for new libavb API." 2017-05-16 15:05:52 +00:00
Bowgo Tsai 7e318e0d3e Merge "fs_mgr: support different dm-verity error modes" am: b9b95ee3a9 am: d1a2aac294 am: c7690e0abe
am: d236ea6e79

Change-Id: Ia3451e596e2411ee8434b1e21fc97255feafddb7
2017-05-16 02:18:26 +00:00
Bowgo Tsai d236ea6e79 Merge "fs_mgr: support different dm-verity error modes" am: b9b95ee3a9 am: d1a2aac294
am: c7690e0abe

Change-Id: I78bab02e15cc6ffe7f693377217c325e40894e67
2017-05-16 01:15:36 +00:00
David Zeuthen e2e1b67c88 fs_mgr: Update for new libavb API.
In https://android-review.googlesource.com/#/c/392873/ we slightly
changed the libavb API. This CL updates fs_mgr to use the new API.

Bug: 38157502
Test: Manually tested.
Change-Id: I90484a3d045c9d51946c14e8136258d2f940da81
2017-05-15 12:04:18 -04:00
Bowgo Tsai d7846a2c53 first stage mount: removing the requirement of by-name prefix for AVB
Current first stage mount for AVB requires specifying a common prefix of
by-name symlink for all AVB partitions. It limits all AVB partitions to be on
the same block device.

firmware {
    android {
        compatible = "android,firmware";
        vbmeta {
            compatible = "android,vbmeta";
            parts = "vbmeta,boot,system,vendor";
            by_name_prefix="/dev/block/platform/soc.0/f9824900.sdhci/by-name"  <-- *removing this*
        };
        fstab {
            compatible = "android,fstab";
            vendor {
                compatible = "android,vendor";
                dev = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor";
                type = "ext4";
                mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
                fsmgr_flags = "wait,avb";
            };
        };
    };
};

For normal mount with AVB, it extracts the by-name prefix of /misc
partition and use it as the prefix for all other partitions:
    - /dev/block/platform/soc.0/f9824900.sdhci/by-name/misc ->
    - /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor_a

Fix this by adding an internal map in FsManagerAvbOps to record the mapping
from partition name to its by-name symlink:

    ByNameSymlinkMap["vendor_a"] = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor_a"

Two overloaded factory methods are then provided for FsManagerAvbUniquePtr:
    - FsManagerAvbUniquePtr Open(ByNameSymlinkMap&& by_name_symlink_map):
      for first stage mount, where the by-name symlink map will be
      constructed externally, from the uevents processed by init, before
      invoking this factory method.

    - FsManagerAvbUniquePtr Open(const fstab& fstab): for normal mount,
      where the by-name symlink map will be constructed from the input fstab
      internally.

Bug: 37552224
Test: first stage mount /vendor with vboot 1.0
Test: first stage mount /vendor with vboot 2.0 (AVB)
Test: normal mount /vendor with vboot 2.0 (AVB)
Change-Id: Id17e8566da87ea22b8923fcd6e47db8d45bc7d6a
Merged-In: Id17e8566da87ea22b8923fcd6e47db8d45bc7d6a
(cherry picked from commit 20651f62d0)
2017-05-15 16:49:37 +08:00
Bowgo Tsai 6879cc1e2e fs_mgr: support different dm-verity error modes
AVB is going to support different modes to handle dm-verity errors.
See the following CL for more details:

  - https://android-review.googlesource.com/#/c/392873/

The verity mode is controlled by bootloader through androidboot.veritymode in
kernel command line. fs_mgr should read the value from there and specify the
corresponding flag when loading dm-verity table into kernel.

Also removes some unused #include libraries.

Bug: 38157502
Test: Manually tested different dm verity modes:
      - "restart_on_corruption" (androidboot.veritymode=enforcing)
      - "ignore_corruption" (androidboot.veritymode=logging)
      - None, default mode is EIO in kernel (androidboot.veritymode=eio)

Change-Id: I80e1e817a148b54fb67ba58112d376dc2cf37c98
2017-05-13 13:24:12 +08:00
Tom Cherry 37b5ada05e fs_mgr: convert libfs_mgr to Android.bp
Test: Build
Change-Id: Ieda384745adbd119020e90c76bcc649ffdffef5f
2017-05-12 17:06:55 -07:00
Vineeta Srivastava 4c01af8129 Revert "fs_mgr: Update for new libavb API."
This reverts commit 7ea2c2814d.
2017-05-12 10:18:14 -07:00
David Zeuthen 8aa239009a Merge "fs_mgr: Update for new libavb API." am: 5ed7d39857 am: fb4d8b0bac am: 91f1bf78b0
am: e4769abd8f

Change-Id: I95a42162c218dcdbaf3b5c4504ca1503b021e758
2017-05-12 07:07:58 +00:00
David Zeuthen e4769abd8f Merge "fs_mgr: Update for new libavb API." am: 5ed7d39857 am: fb4d8b0bac
am: 91f1bf78b0

Change-Id: I9ec32d93fa3484b4dc7eb40344390186435a6786
2017-05-12 01:58:25 +00:00
David Zeuthen 7ea2c2814d fs_mgr: Update for new libavb API.
In https://android-review.googlesource.com/#/c/392873/ we slightly
changed the libavb API. This CL updates fs_mgr to use the new API.

Bug: 38157502
Test: Manually tested.
Change-Id: Ia3371e11fcd81fcc1d147f030cd62af67943aad5
2017-05-10 15:45:12 -04:00
Bowgo Tsai 8301fcfcf5 Merge "first stage mount: removing the requirement of by-name prefix for AVB" am: cdad92fdad am: c82235ebbd am: fec0b13902
am: acef4a9a09

Change-Id: I51e8a7df3db76a7cd626ee2ad2960abc5ec2256d
2017-05-10 03:20:12 +00:00
Bowgo Tsai acef4a9a09 Merge "first stage mount: removing the requirement of by-name prefix for AVB" am: cdad92fdad am: c82235ebbd
am: fec0b13902

Change-Id: I7dec7f517b5b1c601b4372a431789aba1375fbee
2017-05-10 02:11:06 +00:00
Treehugger Robot cdad92fdad Merge "first stage mount: removing the requirement of by-name prefix for AVB" 2017-05-10 01:37:28 +00:00
Bowgo Tsai 20651f62d0 first stage mount: removing the requirement of by-name prefix for AVB
Current first stage mount for AVB requires specifying a common prefix of
by-name symlink for all AVB partitions. It limits all AVB partitions to be on
the same block device.

firmware {
    android {
        compatible = "android,firmware";
        vbmeta {
            compatible = "android,vbmeta";
            parts = "vbmeta,boot,system,vendor";
            by_name_prefix="/dev/block/platform/soc.0/f9824900.sdhci/by-name"  <-- *removing this*
        };
        fstab {
            compatible = "android,fstab";
            vendor {
                compatible = "android,vendor";
                dev = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor";
                type = "ext4";
                mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
                fsmgr_flags = "wait,avb";
            };
        };
    };
};

For normal mount with AVB, it extracts the by-name prefix of /misc
partition and use it as the prefix for all other partitions:
    - /dev/block/platform/soc.0/f9824900.sdhci/by-name/misc ->
    - /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor_a

Fix this by adding an internal map in FsManagerAvbOps to record the mapping
from partition name to its by-name symlink:

    ByNameSymlinkMap["vendor_a"] = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor_a"

Two overloaded factory methods are then provided for FsManagerAvbUniquePtr:
    - FsManagerAvbUniquePtr Open(ByNameSymlinkMap&& by_name_symlink_map):
      for first stage mount, where the by-name symlink map will be
      constructed externally, from the uevents processed by init, before
      invoking this factory method.

    - FsManagerAvbUniquePtr Open(const fstab& fstab): for normal mount,
      where the by-name symlink map will be constructed from the input fstab
      internally.

Bug: 37552224
Test: first stage mount /vendor with vboot 1.0
Test: first stage mount /vendor with vboot 2.0 (AVB)
Test: normal mount /vendor with vboot 2.0 (AVB)
Change-Id: Id17e8566da87ea22b8923fcd6e47db8d45bc7d6a
2017-05-09 11:03:49 +08:00
Bowgo Tsai 87a5b1f992 fs_mgr_verity: fix androidboot.veritymode=enforcing doesn't work
Should set verity mode to VERITY_MODE_DEFAULT when
androidboot.veritymode=enforcing.

Bug: 38103331
Test: `adb shell getprop partition.system.verified` returns 2 when veritymode=enforcing
Test: `adb shell getprop partition.vendor.verified` returns 2 when veritymode=enforcing

(cherry picked from commit 77cbfd6341)

Merged-Id: I2f34eb6509f91989ce726e540cf2c0d353347ede
Change-Id: I2f34eb6509f91989ce726e540cf2c0d353347ede
2017-05-09 09:02:55 +08:00
Bowgo Tsai edba521fed Merge "fs_mgr_verity: fix androidboot.veritymode=enforcing doesn't work" am: 6019991c6e am: 4dd17998ed am: d6576491fe
am: 18e92c342a

Change-Id: I7c81797ad4684b6e23350694b84525c12d5cf958
2017-05-08 15:41:16 +00:00
Bowgo Tsai 18e92c342a Merge "fs_mgr_verity: fix androidboot.veritymode=enforcing doesn't work" am: 6019991c6e am: 4dd17998ed
am: d6576491fe

Change-Id: Id86ee7f84251e4fd4884dae7fab5677bed2c0501
2017-05-08 15:37:45 +00:00
Bowgo Tsai 77cbfd6341 fs_mgr_verity: fix androidboot.veritymode=enforcing doesn't work
Should set verity mode to VERITY_MODE_DEFAULT when
androidboot.veritymode=enforcing.

Bug: 38103331
Test: `adb shell getprop partition.system.verified` returns 2 when veritymode=enforcing
Test: `adb shell getprop partition.vendor.verified` returns 2 when veritymode=enforcing
Change-Id: I2f34eb6509f91989ce726e540cf2c0d353347ede
2017-05-08 17:22:52 +08:00
Bowgo Tsai a0aaf24d62 fs_mgr_avb: allow verification error when the device is unlocked
Current AVB flow in fs_mgr doesn't allow verification error even if the
device is unlocked. This makes first stage mount fail when the device
is flashed with a different-sized boot.img because there is verification
error (HASH_MISMATCH) for the boot partition.

Fix this by allowing verification error only when the device is
unlocked. Whether to enable dm-verity for HASHTREE partitions is still
controlled by the HASHTREE_DISABLED flag in the top-level vbmeta.

Bug: 37985430
Test: First stage mount /vendor with AVB on a device.
      Check dm-verity is enabled on /vendor.
Test: Unlock device, flash a different-sized boot.img. Boot device and check
      dm-verity is still enabled on /vendor.
Test: First stage mount /vendor with AVB on a device with HASHTREE_DISABLED
      is set on the top-level vbmeta, check dm-verity is not enable on /vendor.

Change-Id: I709431bc1c37e4f86133d171cee8e90621cdb857
Merged-In: I709431bc1c37e4f86133d171cee8e90621cdb857
(cherry picked from commit 1140954877)
2017-05-06 09:02:25 +08:00
Thierry Strudel 24e0e03f9c Merge "fs_mgr_avb: allow verification error when the device is unlocked" am: 7245ab6a11 am: 140d1f51a1 am: 5e953b0397
am: cd0ece0752

Change-Id: Ie57e55897a81cefa0dd47668ad91d831ef3d4b5e
2017-05-05 17:12:54 +00:00
Thierry Strudel cd0ece0752 Merge "fs_mgr_avb: allow verification error when the device is unlocked" am: 7245ab6a11 am: 140d1f51a1
am: 5e953b0397

Change-Id: I50144f63c2f1b7c517f5cc7d9ac0d8b437f5848d
2017-05-05 16:51:21 +00:00
Bowgo Tsai 1140954877 fs_mgr_avb: allow verification error when the device is unlocked
Current AVB flow in fs_mgr doesn't allow verification error even if the
device is unlocked. This makes first stage mount fail when the device
is flashed with a different-sized boot.img because there is verification
error (HASH_MISMATCH) for the boot partition.

Fix this by allowing verification error only when the device is
unlocked. Whether to enable dm-verity for HASHTREE partitions is still
controlled by the HASHTREE_DISABLED flag in the top-level vbmeta.

Bug: 37985430
Test: First stage mount /vendor with AVB on a device.
      Check dm-verity is enabled on /vendor.
Test: Unlock device, flash a different-sized boot.img. Boot device and check
      dm-verity is still enabled on /vendor.
Test: First stage mount /vendor with AVB on a device with HASHTREE_DISABLED
      is set on the top-level vbmeta, check dm-verity is not enable on /vendor.

Change-Id: I709431bc1c37e4f86133d171cee8e90621cdb857
2017-05-05 22:36:40 +08:00
Keun-young Park 886b1b45d5 use passed blk dev name for quota / super block check
- It was using blk dev name from fstab and quota / super block check was always
  failing for FDE

bug: 37913441
Test: reboot and confirm quota

(cherry picked from commit 9519688411)

Change-Id: Id5613387924d3a8d9ed4486113654aed89184af9
2017-05-04 21:06:59 -07:00
Keun-young Park eb73fcdcb8 Merge "use passed blk dev name for quota / super block check" am: 7b706c5b9e am: 2f3718c472 am: d31f3a0e9b
am: f7aacf81fa

Change-Id: Ib818fb98b6c01ef041cf6339c590b3f3185553ca
2017-05-05 03:50:20 +00:00
Keun-young Park f7aacf81fa Merge "use passed blk dev name for quota / super block check" am: 7b706c5b9e am: 2f3718c472
am: d31f3a0e9b

Change-Id: I0031690605466dcf7600c162565be5f6d6fd44cf
2017-05-05 03:47:34 +00:00
Keun-young Park 9519688411 use passed blk dev name for quota / super block check
- It was using blk dev name from fstab and quota / super block check was always
  failing for FDE

bug: 37913441
Test: reboot and confirm quota
Change-Id: I8a9e890ef2787f2959e6a0225c6b21d35602f19e
2017-05-04 18:31:06 -07:00
Bowgo Tsai a0c7ee0e76 fs_mgr: set "partition.system.verified" when AVB is used in a A/B device
In a A/B device, system partition is mounted by kernel as root.
In vboot 1.0, the dm device name of system partition is "system" with
the following configuration in kernel command line:
    - dm="system none ro,0 1 android-verity /dev/sda34"

In AVB, the dm device name is switched to vroot as:
    - dm="1 vroot none ro 1,0 5201456 verity 1 ..."

When sending ioctl DM_TABLE_STATUS to query status, we should use "vroot" as the
dm device name for AVB. But still pass "system" for the callback function to set
property [partition.system.verified] instead of [partition.vroot.verified].

Bug: 36900078
Test: Use AVB to mount system in a A/B device, checks the property exists
      [partition.system.verified]
Test: Use vboot 1.0 to mount system in a A/B device, checks the property exists
      [partition.system.verified]
Test: Checks 'adb remount' will output warning message:
        - dm_verity is enabled on the system and vendor partitions.
        - Use "adb disable-verity" to disable verity.

Change-Id: Iaee7eb2b00b03729bc07fa24f1b449488716d2ea
Merged-In: Iaee7eb2b00b03729bc07fa24f1b449488716d2ea
(cherry picked from commit 48fdc292f9)
2017-05-03 12:32:19 +08:00
David Zeuthen 6019363ccf Merge "fs_mgr: Clear AvbOps struct." am: 6ea4f213d8 am: 983d542d49 am: 86da4a42e8
am: 91a0f9e970

Change-Id: Ib243c4ad35eb104370b76f4308c3feee1682353a
2017-05-02 16:06:46 +00:00
David Zeuthen 91a0f9e970 Merge "fs_mgr: Clear AvbOps struct." am: 6ea4f213d8 am: 983d542d49
am: 86da4a42e8

Change-Id: I3ef678bce70cca718fdb9be28f570b58f1da8f40
2017-05-02 13:44:21 +00:00
David Zeuthen 16c6fd1da7 fs_mgr: Clear AvbOps struct.
This ensures that future operations (e.g. function pointers in the
AvbOps struct) added to AvbOps are set to NULL.

Bug: 37709309
Test: Manually tested on UEFI-based bootloader.
Change-Id: If83ea57b7abad94e472768c594efa210e3351a4d
2017-05-01 13:25:20 -04:00
Bowgo Tsai 7fe58ba5b6 Merge "fs_mgr: code clean up" am: 0914d2bdff am: 0bb2ebbe74 am: f7cc23bf3a
am: 1bd2d1c3a5

Change-Id: Id37b33ccb4f5127bd0e5b16bff2c79a1819623ed
2017-04-29 03:37:02 +00:00
Bowgo Tsai 1bd2d1c3a5 Merge "fs_mgr: code clean up" am: 0914d2bdff am: 0bb2ebbe74
am: f7cc23bf3a

Change-Id: I553d18ef489e067eca013d460efc842daa8a50f2
2017-04-29 03:35:31 +00:00