Commit graph

645 commits

Author SHA1 Message Date
David Anderson
e9619eb6d1 liblp: Add unit tests.
Bug: 79173901
Test: liblp_test gtest
Change-Id: Iba77f0a0886741e459ab65122c28e8bd52ec93e8
2018-06-21 12:58:34 -07:00
Treehugger Robot
2e98fd23c3 Merge "libdm: Implement LoadTableAndActivate." 2018-06-21 19:01:49 +00:00
Treehugger Robot
bdc56b046e Merge "libdm: Move includes to a libdm folder." 2018-06-21 19:01:20 +00:00
David Anderson
e1c0744c26 libdm: Implement LoadTableAndActivate.
This change implements DeviceMapper::LoadTableAndActivate by serializing
the given DmTable and issuing DM_TABLE_LOAD and DM_DEV_SUSPEND ioctls.
In addition, this makes the CreateDevice() method private, and
introduces a separate method for creating a device and loading a table
as a single operation. This will obviate the need for separate inactive
device cleanup logic later.

Note that this change does not yet implement DmTable::Serialize().

Bug: 110035986
Test: N/A
Change-Id: Ic8affe591db4930ce672b00db989978b57ca8cbf
2018-06-20 15:16:05 -07:00
David Anderson
b1a834ec31 libdm: Move includes to a libdm folder.
This places libdm includes into a libdm folder, to match how many other
library includes are organized.

Bug: 110035986
Test: N/A
Change-Id: I430b0cf749c8d16265481864f1f33927fd740a53
2018-06-20 15:16:04 -07:00
Treehugger Robot
9a2891c84b Merge "libdm: Clean up error messages and dm_ioctl use." 2018-06-20 21:48:13 +00:00
David Anderson
b6181e3e46 libdm: Clean up error messages and dm_ioctl use.
This change removes unnecessary malloc() calls for dm_ioctls. It also
simplifies and fixes line endings on some error messages.

Bug: 110035986
Test: N/A
Change-Id: I2f56e5dab7f25cd9b2f80896f80101db56228981
2018-06-19 18:15:14 -07:00
David Anderson
6590df2763 init: Create logical partitions via liblp.
Currently, init can create logical partitions by hardcoding them in
fs_mgr or by specifying them in device-tree. This change allows init to
also create logical partitions by using liblp, which stores partition
tables in a physical partition. The current name for this partition is
"android".

Two aspects of this code will change long-term. One, the prototype code
using device-tree will be deleted once fastboot supports logical
partitions. Two, libdm will obsolete most of the code in
fs_mgr_dm_linear.cpp. For now however we preserve how the prototype code
functions and we layer liblp on top of the existing dm_linear logic.

Bug: 79173901
Test: N/A
Change-Id: If014a109da78fa12269bf0df0dda39028ac2d1aa
2018-06-19 14:03:58 -07:00
David Anderson
ea3b8ac9ff fs_mgr: Add a library for managing logical partitions.
This library has methods to build, read, and modify logical partition tables
based on device-mapper targets. Targets currently supported are
dm-linear and dm-zero.

Note: this is a revert of a revert, with changes to fix Mac build
bustage.

Bug: 79173901
Test: N/A
Change-Id: If89a788d1919ce8ddc6eedaecc9687a92f111dfa
2018-06-19 14:03:57 -07:00
David Anderson
89a1dca721 Revert "fs_mgr: Add a library for managing logical partitions."
This reverts commit e238358b76.

Reason for revert: Broke mac build.

Change-Id: I93390aa839d4471f328529fe5b86a498b3583d8a
2018-06-18 21:13:24 +00:00
David Anderson
e238358b76 fs_mgr: Add a library for managing logical partitions.
This library has methods to build, read, and modify logical partition tables
based on device-mapper targets. Targets currently supported are
dm-linear and dm-zero.

Bug: 79173901
Test: N/A
Change-Id: I194c6832cb53f781c396016d961386d3ca833f87
2018-06-14 17:17:23 -07:00
Sandeep Patil
d34d0ef50e fs_mgr: dmctl: fix 'dmctl help' output
Test: adb shell dmctl help
Bug: 110035986

Change-Id: I5764b0b5f707dff03e715f975e54cdc2fd8fd437
Signed-off-by: Sandeep Patil <sspatil@google.com>
2018-06-13 18:38:59 -07:00
Treehugger Robot
b066bbebd1 Merge changes from topic "libdm"
* changes:
  fs_mgr: libdm: Add support to list existing device mapper devices
  fs_mgr: libdm: add support to create and delete device mapper devices.
  fs_mgr: device mapper: Add libdm and 'dmctl' tool to use it.
2018-06-13 22:45:30 +00:00
Sandeep Patil
f603cfdd70 fs_mgr: libdm: Add support to list existing device mapper devices
Test: dmctl create system; dmctl list devices; dmctl delete system;
      dmctl list devices
Bug: 110035986

Change-Id: I4ae5d40041458421068976fa2a99c662c542a9a1
Signed-off-by: Sandeep Patil <sspatil@google.com>
2018-06-13 13:50:21 -07:00
Sandeep Patil
45d94ab683 fs_mgr: libdm: add support to create and delete device mapper devices.
Test: dmctl create system; dmctl delete system
Test: verify that ueventd creates /dev/block/dm-X and verify the dm
device name from /sys/block/dm-X/dm/name
Bug: 110035986

Change-Id: I2a08e2ea7007c0c13fe64d444f0d6618784edae7
Signed-off-by: Sandeep Patil <sspatil@google.com>
2018-06-13 13:35:48 -07:00
Sandeep Patil
59f04ee74c fs_mgr: device mapper: Add libdm and 'dmctl' tool to use it.
libdm is small static library that is intended to be the one source to
control device mapper. It is intended to have APIs to create, control
and destroy device mapper targets. Eventually, all fs_mgr implementation
that talks to device mapper will be moved to using libdm APIs.

Added 'dmctl', a command line tool that lists the registered device
mapper targets and their corresponding version. The tool will continue
to get new features to exemplify new APIs implemented in libdm.

The library is intentionally static and folds into libfs_mgr. All
clients must link to libfs_mgr as a result.

Test: dmctl list
Bug: 110035986

Change-Id: I71e7146073a74e7523524bf3b20d0be6d06f9fad
Signed-off-by: Sandeep Patil <sspatil@google.com>
2018-06-13 13:35:44 -07:00
Bowgo Tsai
7481e6cceb fs_mgr: reorder getting boot config
The params in kernel cmdline is expected to be consumed by kernel.
For bootloader <--> userland communication, we're moving it to
device-tree or system property.

Bug: 78615592
Test: boot a device
Change-Id: I26bc2ea4cda91241242eb9fd0210b5b10659a297
2018-06-12 00:16:14 +08:00
Treehugger Robot
ec9b6b73ff Merge "fs_mg: allow getting VBMeta Digest from device-tree" 2018-06-11 16:10:21 +00:00
Bowgo Tsai
3474297379 fs_mg: allow getting VBMeta Digest from device-tree
fs_mgr gets androidboot.vbmeta.{size, hash_alg, digest} from kernel
cmdline to assure the integrity of all vbmeta structs. This CL Allows
fs_mgr to get those parameters from device tree because they're only
consumed by userland instead of kernel.

  https://android.googlesource.com/platform/external/avb/+/master#The-VBMeta-Digest

Bootloader could construct a device tree overlay at run time then merge
it into main device tree. e.g.,

    firmware {
        android {
            vbmeta.size = "5245";
            vbmeta.hash_alg = "sha256";
            vbmeta.digest = "0c51233ca3ecaa...63c6d912e79b709";
        };
    };

Bug: 80168311
Test: boot a device using AVB

Change-Id: I6cf151713af04e6cf554d593e9f0b43e9e214d8c
2018-06-11 22:08:45 +08:00
Mark Salyzyn
596fac3c6d fs_mgr: fs_mgr_get_boot_config_from_kernel_cmdline deal with quote
Spans quoted with " are dealt with atomically, and are stripped from
the key/value results when parsing the kernel cmdline.

Test: compile, device boot, fs_mgr_unit_test
Bug: 109821005
Change-Id: I45f3d7395f34295edefdeaafa4c15c6ee25cc4da
2018-06-08 16:04:17 -07:00
Tom Cherry
158dd05b8a Merge "fs_mgr: remove some unused functions" 2018-06-08 02:27:03 +00:00
Tom Cherry
e6eabf42f2 fs_mgr: remove some unused functions
Test: build
Change-Id: I8a44f2f777fff369df06c73f06d53e448826f7b5
2018-06-07 16:49:01 -07:00
Mark Salyzyn
346c52e972 fs_mgr: avb should use built-in kernel command line parser
Switch from open-coded parsing of /proc/cmdline to built-in
fs_mgr_get_boot_config_from_kernel_cmdline function.

Test: compile and smoke boot test
Bug: 109821005
Change-Id: I935d2e76c76ad417cbcee398e2afbf9b061d1719
2018-06-07 14:45:08 -07:00
Jiyong Park
a0e75045e6 Build adbd for recovery
adbd (and its dependencies) are marked as recovery_available:true so
that recovery version of the binary is built separately from the one for
system partition. This allows us to stop copying the system version to
the recovery partition and also opens up the way to enable shared
libraries in the recovery partition. Then we can also build adbd as a
dynamic executable.

Bug: 79146551
Test: m -j adbd.recovery
Change-Id: Ib95614c7435f9d0afc02a0c7d5ae1a94e439e32a
2018-05-24 14:11:11 +09:00
Bowgo Tsai
8eec38f4e4 Adds /dev/block/by-name/<partition> symlinks
During uevent processing, some "by-name" symlinks will be created.
    /dev/block/<type>/<device>/by-name/<partition>

<type> can be: platform, pci or vbd.
<device> might be: soc.0/f9824900.sdhci, soc.0/f9824900.sdhci, etc.
<partition> might be: system, vendor, system_a, system_b, etc.

e.g., on a non-A/B device:
    /dev/block/platform/soc.0/f9824900.sdhci/by-name/system
    /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor

On a A/B device:
    /dev/block/platform/soc/1da4000.ufshc/by-name/system_a
    /dev/block/platform/soc/1da4000.ufshc/by-name/system_b
    /dev/block/platform/soc/1da4000.ufshc/by-name/vendor_a
    /dev/block/platform/soc/1da4000.ufshc/by-name/vendor_b

However, those symlinks are "device-specific".

This change adds the "generic" symlinks in ueventd, in addition to
the existing symlinks, when the possible "boot devices" are specified
in device tree. e.g.,

    &firmware_android {
	compatible = "android,firmware";
	boot_devices ="soc/1da4000.ufshc,soc.0/f9824900.sdhci";
    }

The following symlinks will then be created on the aforementioned non-A/B
and A/B devices, respectively.

    /dev/block/by-name/system
    /dev/block/by-name/vendor

    /dev/block/by-name/system_a
    /dev/block/by-name/system_b
    /dev/block/by-name/vendor_a
    /dev/block/by-name/vendor_b

Note that both <type> and <device> are skipped in the newly create symlinks.
It assumes there is no more than one devices with the same <partition>,
which is the assumption of current first stage mount flow.

Finally, when 'boot_devices' in DT is absent, it fallbacks to extract
'boot_devices' from fstab settings. e.g., using 'soc/1da4000.ufshc',
'soc.0/f9824900.sdhci' for a fstab with the following content:

   /dev/block/platform/soc/1da4000.ufshc/by-name/system
   /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor

Bug: 78613232
Test: adb shell ls /dev/block/by-name
Change-Id: Iec920b5a72409b6a2bdbeeb290f0a3acd2046b5d
2018-05-19 07:57:35 +08:00
David Anderson
62e5b20b50 init/fs_mgr: prototype first-stage dm-linear support
This adds an API to fs_mgr for reading dm-linear tables out of device trees
and issuing device-mapper ioctls. The device tree code will be
implemented separately. The dm-linear structures in fs_mgr are organized
assuming we may want to pull them from sources other than DT (for
example, text files, binary blobs, or something hardcoded for testing).

File systems which are mounted from these logical partitions have
specific fstab requirements. The block device must be a partition name,
and if Verified Boot is used, that name must match the vbmeta partition name.
Second, the entry must have the "logical" fs_mgr flag. Example fstab
entry:

    vendor  /vendor  ext4  ro  wait,logical

Example fstab entry in device tree:

    vendor {
        compatible = "android,fstab";
        dev = "vendor";
        type = "ext4";
        mnt_flags = "ro";
        fs_mgr_flags = "wait,slotselect,avb,logical";
    };

Bug: 78914864
Test: N/A
Change-Id: I4d8878ea8858f26310119616cadc3ee0dd08566c
2018-05-14 12:43:42 -07:00
David Anderson
0b8e22eb5f fs_mgr: target-agnostic device-mapper helpers
Remove "verity" from device-mapper helper functions so it's clear they can be
re-used for non-verity targets.

Bug: 78914864
Test: AVB device still boots

Change-Id: Id8474b2c6e23e828eff563263ebb409031cde17e
2018-05-03 16:35:09 -07:00
David Anderson
5a4db628ee fs_mgr: clean up dm ioctl flags
DM_READONLY_FLAG should only be used when loading tables, and
DM_STATUS_TABLE_FLAG should only be used when querying a table's status. This
patch cleans up how we set flags to reflect when the kernel actually cares
about them.

Bug: 78914864
Test: AVB device still boots

Change-Id: I809d8c2ef2105849ebdd095bbe7f08f15ae63465
2018-05-02 18:46:20 -07:00
Jaegeuk Kim
e2596bfed5 make_f2fs: specify sector size for target image size and missing options
The total sectors that we want to format is used in different meanings from
various users. This notifies its size based on 4096 bytes explicitly.

Bug: 76407663
Change-Id: I4e00f2e2289c1381f0238d2a4acb606a0ab551a9
Merged-In: I4e00f2e2289c1381f0238d2a4acb606a0ab551a9
Reported-by: katao@xiaomi.com
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-04-04 09:24:24 -07:00
Paul Crowley
e640bc1b88 Support Speck encryption.
Test: Modified Pixel to support and use Speck encryption, booted.
Bug: 77227248
Change-Id: I6ec272db5e4f16e9dd4f759203c14ad2a8772cd1
Merged-In: I6ec272db5e4f16e9dd4f759203c14ad2a8772cd1
2018-03-30 10:18:46 -07:00
Tom Marshall
66f6a6dc67 fs_mgr: Ignore invalid DT device nodes
With treble, the vendor kernel and ramdisk are supposed to be used.
But vendors always find new and interesting ways to break things:

$ cat /proc/device-tree/firmware/android/fstab/system/dev; echo
/by-name/system_a
$

Change-Id: I826a96ebd625b52563d3cc970bf99d9b26dc093e
2018-03-07 17:59:57 +01:00
Jaegeuk Kim
efd3b9c28f fs_mgr: add sysfs_path=%s to indicate a location of sysfs entry
This patch adds sysfs_path=%s in fstab to get the sysfs entry path.
One example is that vold is able to conduct UFS-specific operations given the
below fstab entry.

/dev/block/bootdevice/by-name/userdata  /data f2fs  noatime,nosuid,nodev,discard
  latemount,wait,check,fileencryption=ice,quota,formattable,sysfs_path=/sys/devices/platform/soc/1d84000.ufshc

Bug: 63264275
Bug: 68721792
Change-Id: I5097873893948f12296ac5eaa0c2a59a6e6dd9e1
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-02-26 15:47:09 -08:00
Paul Crowley
c684696a96 Use vold's mount with metadata encryption service.
Don't use the FDE flow to support metadata encryption; just use the
vold service which directly mounts the volume.

Bug: 63927601
Test: Boot Taimen to SUW with and without metadata encryption.
Change-Id: Idf9c27a69872cd7a9e2fb76df09a91d8e5ef4896
2018-02-01 14:54:04 -08:00
Christopher Morin
ace69b2f7b Merge "fs_mgr: don't log error messages when missing fstab" 2018-01-08 19:52:32 +00:00
Jeff Sharkey
a7004e5fed Merge changes from topic "resgidz"
* changes:
  Add reserved disk GID to critical component.
  Set reserved GID when setting reserved blocks.
  Allocate GID to use reserved disk space.
2018-01-08 18:17:50 +00:00
Jeff Sharkey
47dc236d2f Set reserved GID when setting reserved blocks.
If we're setting up the number of reserved blocks, we also want to
set our new AID_DISK_RESERVED as the GID that's allowed to use those
blocks.

Test: builds, boots
Bug: 62024591
Change-Id: Iaabfa7d63ad9ff0b9732e2b9996937607d622fe2
2018-01-07 19:24:55 -07:00
Chris Morin
b183e05c3c fs_mgr: don't log error messages when missing fstab
Some devices, such as android on chromebooks, don't need an fstab.

Test: Ensure no error messages are seen from fs_mgr when fstab is
missing.

Change-Id: Ifadb2193743a61d03f1becefd6bc81a61eb45081
2018-01-05 13:37:26 -08:00
Chris Morin
517ed633c2 fs_mgr: fix memory leak
The fstab struct wasn't properly being freed.

Test: Ensure a user of fs_mgr (vold) runs without errors.
Change-Id: I4dcb8ae2ab3e831fbdb13372eb31a67a5d9fb735
2018-01-04 18:48:21 -08:00
Treehugger Robot
edaa28771f Merge "first stage mount: support mount points like /vendor/abc" 2017-12-14 06:45:37 +00:00
Bowgo Tsai
8028189499 first stage mount: support mount points like /vendor/abc
Current syntax of the fstab in device tree (fstab_dt) assumes the
node name is the mount point, which doesn't allow subdir:

    vendor {   <== using "vendor/abc" leads to syntax error in device tree
        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";
    };

This CL adds a new field "mnt_point" in the fstab_dt configuration:

    vendor_abc {
        compatible = "android,vendor_abc";
        dev = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/abc";
        type = "ext4";
        mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
        mnt_point = "/vendor/abc";                          <== new field
        fsmgr_flags = "wait";
    };

The new field is optional and will fallback to using node name as mount
point if it is absent.

Note that this CL also sorts fstab_dt by mount point, because
/vendor needs to be mounted first, which contains a directory
/vendor/abc, before /vendor/abc can be mounted.

Bug: 69955336
Test: first stage mount /vendor/abc on a device
Change-Id: Ie2e519f9801f211a7a221622f32c82bedd00353f
2017-12-14 09:48:26 +08:00
Jaegeuk Kim
ec87074542 Merge changes from topic "sload_f2fs"
* changes:
  fastboot/fs_mgr/init: add sload_f2fs
  fs_mgr: format f2fs with length=xx fstab
2017-12-08 00:57:42 +00:00
Elliott Hughes
3289b9c928 Merge "Add OWNERS." 2017-12-07 23:21:26 +00:00
Elliott Hughes
693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
Jaegeuk Kim
6a3967a64b fs_mgr: format f2fs with length=xx fstab
Merged-In: Icce29ad918f20b16c9908e7fa3ae19eb8c96760b
Change-Id: Icce29ad918f20b16c9908e7fa3ae19eb8c96760b
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
(cherry picked from commit a367430734)
2017-12-06 22:37:57 -08:00
Elliott Hughes
a78c686799 Merge "Remove dead code." 2017-12-07 00:44:56 +00:00
Elliott Hughes
231f1e664d Remove dead code.
Bug: N/A
Test: boots
Change-Id: Id901d95aa05d26767aa5d956ac6e167db1cc3036
2017-12-06 12:38:41 -08:00
Xin Li
23e27db576 Merge commit 'a63ccea6abc7ea02e2d98e41c80793ca97237bd3' from
oc-mr1-dev-plus-aosp into stage-aosp-master

Change-Id: Ia33311cd1fd26dfaea59a69317b306fb91203c40
Merged-In: I03d06b10807e8a313c9654c2e1db36bfb59e3f99
2017-11-14 13:19:45 -08:00
Treehugger Robot
6b07ee9fb5 Merge "DO NOT MERGE ANYWHERE Add comments and code about ro.boot.slot back" 2017-11-13 16:36:34 +00:00
Sandeep Patil
25f1631aa7 DO NOT MERGE ANYWHERE Add comments and code about ro.boot.slot back
Taimen bootloader passes androidboot.slot for now.
This reverts commit 211a4a5d5a.

Bug: 68710251
Test: taimen successfully mounts partition in first stage
Change-Id: I046afc99120e7ec9ef4b8ea7a852eb70e7231ea9
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-11-10 16:20:27 -08:00
Bowgo Tsai
ec19cf6306 first stage mount: abort when failed to parse fstab in device-tree
The client of FirstStageMount class should check the existence of fstab
in device-tree prior to using it. So raising a FATAL error inside
FirstStageMount when failed to parsing the fstab, in order to expose
more accurate error messages.

Also fixing a comment in fs_mgr, where it might happen in either
non-A/B or A/B.

Bug: 69102431
Test: boot sailfish
Change-Id: Ifb525beaa3423b118644778bfe0f84bff9465303
2017-11-10 12:53:46 +08:00