Commit graph

16 commits

Author SHA1 Message Date
Sandeep Patil
2d04ce3b5a dmctl: Add verbose 'dmctl list devices'
This adds an option to list device mapper devices including their
current target table. Useful to be included in bugreport to
map the logical partitions metadata with actual device mapper setup.

Bug: 120916687
Test: dmctl list devices -v

Change-Id: I091666506d24372d1e111ffa1c0256c8bbff0c5e
Signed-off-by: Sandeep Patil <sspatil@google.com>
2018-12-19 08:51:59 -08:00
Paul Lawrence
8a9c294f37 Adding bow dm-target
Test: Can load with dm-ctl
Change-Id: I0c6a750340fa6babcfa0f72b66c18a0b3eacd9d8
2018-10-02 10:12:30 -07:00
Yifan Hong
d449e2e59f libdm: remove libbase dependency in header.
libbase logging macros conflicts with libchrome's logging macros.
Test: compiles

Change-Id: I02697baa87c1466caf2e4ef58b0c8b2635982527
2018-08-16 11:12:36 -07:00
Sandeep Patil
efc5479085 fs_mgr: libdm: add support android-verity target.
The support for android-verity makes it possible for us to test
raw verified filesystem images to be attached to android-verity
target and have it verified by the kernel.

This makes the testing of android-verity device mapper target
much easier as it doesn't _have_ to be used for root mount.

Bug: 72722987
Test:
 $ losetup /dev/block/loop0 /data/local/tmp/verity_fs.img
 $ dmctl create verity-fs android-verity 0 4200 \
   Android:7e4333f9bba00adfe0ede979e28ed1920492b40f 7:0

Change-Id: Ica6bf5c6e1fd758fdb4005fc8a09755f369a8a0f
Signed-off-by: Sandeep Patil <sspatil@google.com>
2018-07-23 15:24:55 -07:00
Sandeep Patil
0d469de9a0 dmctl: Do not skip argument if not matched with '-ro'.
'dmctl create' command would fail if '-ro' flag is not
used. This happend because the argument in place of '-ro'
is skipped unconditionally.

Bug: 72722987
Test:
 $ losetup /dev/block/loop0 fs.img
 $ dmctl create FOO linear 0 25600 /dev/block/loop0 0

Change-Id: I3f6264336b9c9a1b5de76f3a1d29e6045453f9cb
Signed-off-by: Sandeep Patil <sspatil@google.com>
2018-07-23 14:50:26 -07:00
David Anderson
40b594827f fs_mgr: replace DM_TABLE_STATUS use with libdm.
This change introduces a new GetTableStatus method on DeviceMapper,
which returns a vector of information about each target in a device's
table. Some target types (such as verity) can also return additional
information as a string.

Support for this call has also been added to the "dmctl" tool via a
"table" command. Examples:

    $ dmctl create blah zero 0 8000 linear 8000 1000 /dev/block/sdd1 0
    $ dmctl table blah
    Targets in the device-mapper table for blah:
    0-8000: zero
    8000-9000: linear

    For verity:
    sailfish:/ # dmctl table system
    Targets in the device-mapper table for system:
    0-4128792: android-verity, V

Bug: 110035986
Test: libdm_test gtest; AVB1 device still boots
Change-Id: Iaf13450d3b32e2264c7c399a8af8d6bade260592
2018-06-27 12:48:28 -07:00
David Anderson
5e9e74be61 libdm: Implement GetDmDevicePathByName().
This change implements the ability to get the path of a block device
given a device-mapper device name. In addition, dmctl now has a
"getpath" command to perform this query, as a shortcut for searching
through /sys/block/*/dm/name.

Bug: 110035986
Test: N/A
Change-Id: I9ebd824fa800004f591fc02fc1b1950e0c7fba65
2018-06-22 14:23:31 -07:00
David Anderson
bac58aeecf libdm: Implement zero and linear targets.
This change implements DmTargetZero and DmTargetLinear, and integrates
them into dmctl. It also implements DmTarget and DmTable serialization.

Example dmctl invocation:

  dmctl create my-device -ro \
        linear 0 800 /dev/block/by-name/system 0 \
        zero   800 1200                          \
        linear 1200 1500 /dev/block/by-name/system 1200

Bug: 110035986
Test: libdm_test gtest
Change-Id: I7f945c1d9e23cfb78239c23a1aad88e8aef4972b
2018-06-21 12:48:34 -07:00
David Anderson
c7def6849a libdm: Add DmTargetTypeInfo and a unit test.
This change refactors DmTarget. It was satisfying two separate use cases
that have no overlap: (1) as a container for informational queries, and
(2) for specifying table targets.

The kernel's nomenclature for the former is a "target type," so the new
class is named DmTargetTypeInfo.

In addition, this change adds a unit test for
DeviceMapper::GetAvailableTargets that ensures the device has at least a
linear target type (with more TBD).

Bug: 110035986
Test: libdm_test gtest
Change-Id: Icb87976801e8a1e6ec79e48b1d58c308d36279e5
2018-06-21 12:48:34 -07: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
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
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
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