Commit graph

89 commits

Author SHA1 Message Date
Andreas Gampe
eb69e85768 Fs_mgr: Fix format code
Suggested printing for off_t is to cast to intmax_t and print that.

Follow-up to https://android-review.googlesource.com/133111.

Change-Id: Icff6844044c3d0fa6372c3f399453a526fd89954
2015-03-04 13:29:12 -08:00
Sami Tolvanen
a88fb24ab4 Merge "Add fs_mgr support for dm-verity modes" 2015-03-04 20:41:49 +00:00
Sami Tolvanen
51bf11ad95 Add fs_mgr support for dm-verity modes
Add support for dm-verity modes and storing persistent state in
a location specified by the following properties:

  ro.verity.state.location
  ro.verity.state.offset

If these properties do not exist, dm-verity is always loaded in
EIO mode. If the properties do exist, but the location does not
have valid state data, dm-verity is loaded in RESTART mode. The
mode is updated to LOGGING if a dm-verity triggered restart has
occurred.

Change-Id: Ibb82953594d234f81ad21c40f524190b88e4ac8f
2015-03-04 03:07:35 +00:00
Sami Tolvanen
214f33b8c0 Set underlying block device RO when enabling verity
Currently, when verity is set up on a block device, the underlying
device is still accessible directly. Change the existing function
fs_set_blk_ro visible to other fs_mgr modules, change the behavior
to match the comment above the function definition, and call it to
disable write access to the block device when setting up verity.

Bug: 18609347
Change-Id: I7884175df15f9161174788d74d20a08e4cd472ca
2015-02-27 11:28:34 +00:00
Yabin Cui
e2d63af002 Move sprintf to snprintf.
Bug: 19340053
Change-Id: Id0d866e6195ed4752b4be6081eeb2aab8b1dbe9a
2015-02-17 19:27:51 -08:00
Nick Kralevich
7294eb6cae fs_mgr: error check umount calls / add retry logic
Don't silently ignore umount errors. At a minimum, log them.

Add strerror(errno) to another umount call, to make sure we get
some actionable data.

check_fs: try 5 times umounting the filesystem. It appears that
the umount is failing, perhaps because some service is opening
the file on the device or other error. Try unmounting it multiple
times in case it's a transient problem and we can recover.

Bug: 19199624
Bug: 19156134
Change-Id: I7213eb52d55116fb2419a36494d26d5e159981a7
2015-02-05 20:50:22 -08:00
Paul Lawrence
36d0eaecd7 Make encryption configurable
Delay mounting encryptable but unencrypted volumes until we can
check the ro.vold.forceencrypt flag, then optionally encrypt.

Requires matching vold change from
    https://googleplex-android-review.git.corp.google.com/#/c/615309/

Bug: 18764230
Change-Id: If22008be8de6a4f3216b349f81ace49be1730314
2015-01-28 11:41:53 -08:00
Paul Lawrence
2f7ee6b7dd Provide a way to select force encryption from vendor partition
This allows a vendor to force encryption on devices via a vendor
partition flag:

ro.vold.forceencryption 1

Bug: 18764230
Change-Id: Id0049ce64e34e4f6f96e593aadd70c277ac131c8
2015-01-28 11:41:35 -08:00
Christoffer Dall
8298234847 fs_mgr: Support filesystem labels in fstab
When mounting fstab entries it is practical to be able to specify
for example LABEL=data instead of a specific block device.

This is particularly important for the new Android Emulator code base,
which uses virtio block devices for the various partitions
(system,data,cache), because there is no defined ordering between the
way the filesystems are specified to the emulator and how they are
enumerated by the android kernel as /dev/vdX.

Change-Id: I7aef95f12e8f7b02ac2e33804ba7897fdcb9ad7f
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
2015-01-23 17:47:39 +00:00
Elliott Hughes
4083ed7dff Merge "Revert "fs_mgr: Support filesystem labels in fstab"" 2015-01-23 00:34:08 +00:00
Elliott Hughes
572226c25c Revert "fs_mgr: Support filesystem labels in fstab"
This reverts commit 69407ccb02.

Change-Id: I537a3b4257b7bc2a69f1f4d62b4e18e91f2dc713
2015-01-23 00:33:43 +00:00
JP Abgrall
f9e2339553 Merge "fs_mgr: Support filesystem labels in fstab" 2015-01-22 23:59:05 +00:00
Christoffer Dall
69407ccb02 fs_mgr: Support filesystem labels in fstab
When mounting fstab entries it is practical to be able to specify
for example LABEL=data instead of a specific block device.

This is particularly important for the new Android Emulator code base,
which uses virtio block devices for the various partitions
(system,data,cache), because there is no defined ordering between the
way the filesystems are specified to the emulator and how they are
enumerated by the android kernel as /dev/vdX.

Change-Id: I12c3db0ba6a515dc8e917e0349afd257888d3aef
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
2015-01-17 21:05:39 +01:00
Paul Lawrence
88a12fb381 Fix Nick's nits
(cherry-pick of 97e487311b1cb780dfd3b0994917c72047d6188f.)

Change-Id: Ide7925e7ad328f0343d444d63ff72f1a26206d4c
2014-12-09 19:38:23 -08:00
Sami Tolvanen
02c698d93f Fix verity on system partitions larger than 2G
If the system partition is larger than 2G, the device fails to read
verity metadata, because fseek accepts only a 32-bit signed offset.
Switch from fseek to lseek64 to allow seeking using a 64-bit offset,
which solves the problem. At the same time, move away from stdio in
the function.

(cherry-pick of 4cafe2ff89b49329e0e880900195d8e061bd3750.)

Bug: 17705619
Change-Id: I226320498dcb750ec6cde84411c7fe0774c9cab7
2014-12-09 19:34:08 -08:00
Paul Lawrence
ec900bba20 Revert "Revert "Enable verity on userdebug, and add disable-verity to adb""
This reverts commit 152d2d4234.

Fixed build error, and also fixed memory leak spotted from warning.

(cherry-pick of bbb36319119edde9377fb80015235893c30d2bc9.)

Bug: 17691572
Change-Id: I23b5ba537f7b557432041d4338b38b9be434e981
2014-12-09 17:02:17 -08:00
Mark Salyzyn
ee80cf8755 am af191cd1: am 6b66025f: Merge "fs_mgr: fix build breakage"
* commit 'af191cd157f076ee5d99890711e2881a60d7770a':
  fs_mgr: fix build breakage
2014-10-09 14:25:31 +00:00
Mark Salyzyn
89fa114e2a fs_mgr: fix build breakage
Some compilers are not as smart as other compilers

Change-Id: I9d93c73bdbd2dca37373d8a42a2ed510d0559274
2014-10-08 16:43:47 -07:00
Paul Lawrence
fdf93c0631 am cf234dc7: Preserve errno from fsmgr_do_mount
* commit 'cf234dc7e081ac4063c3c5ddcdd4da40c82d51cb':
  Preserve errno from fsmgr_do_mount
2014-09-12 19:58:47 +00:00
Paul Lawrence
cf234dc7e0 Preserve errno from fsmgr_do_mount
Bug: 17358530
Change-Id: I4cd7403c0b7c4f878d6afa5199f998e6f614adb9
2014-09-11 17:31:49 -07:00
Chih-Hung Hsieh
aed0769eef am 04929638: am da3510b2: Merge "Avoid partial initialization warning."
* commit '049296382d3604868378c957e999ae63cf3a1f5f':
  Avoid partial initialization warning.
2014-09-10 17:21:11 +00:00
Chih-Hung Hsieh
e32b8952a6 Avoid partial initialization warning.
Clang compiler is picky about partial initialization and
here we only need to initialize the 'len' field.

BUG: 17410010
Change-Id: I718582cef96d5f4076b5ff1c7b8162327e7809b6
2014-09-08 14:41:28 +00:00
JP Abgrall
cee206880e [HACK]fs_mgr+init: Format via recovery if encryptable /data is wiped
If the encryptable partition is wiped (4KB worth of 0 or 0xff),
then reboot into recovery to format /data+/cache

This is while waiting for the Mac OS support to format f2fs.
The flashstation running on Mac OS will currently just erase userdata
and not format it with f2fs.

Bug: 15720406
Bug: 15747366
Change-Id: Ib7cca3e1701483a09573457a835750f34da71ee0
2014-07-02 14:28:50 -07:00
JP Abgrall
f22b745294 fs_mrg: clean up multi-type mount_all
Move the code that attempts to mount alternative fstab entries
into its own function.
Clarify return codes.
Suggest wipe via recovery in error messages.

Bug: 15747366
Change-Id: I3634477cd4d1d73f974f3e906c53285f0d9e0eac
Signed-off-by: JP Abgrall <jpa@google.com>
2014-07-02 13:39:44 -07:00
Todd Poynor
4a974df8ad Merge "fs_mgr: fix crash on "noemulatedsd" in fstab" 2014-07-01 19:15:58 +00:00
Todd Poynor
22f63e393f fs_mgr: fix crash on "noemulatedsd" in fstab
MF_FORCECRYPT claimed same flag value as existing MF_NOEMULATEDSD.
MF_FORCECRYPT also crashes if no "=" in the option.

Modify MF_NOEMULATEDSD flag value to unique, and reformat comment to keep
the definition near the other defines.

Change-Id: Iec86f40ff43eea14b791d3d19c0ae11fd4b5f784
2014-07-01 17:57:13 -07:00
JP Abgrall
7553d57298 fs_msg: fix bad tmpfs detection (fix /persist mount errors)
Without this, the wrong mount point is flagged as being mounted.
Which leads to:

<6>[    3.278040] fs_mgr: __mount(source=/dev/block/platform/msm_sdcc.1/by-name/userdata,target=/data,type=ext4)=-1
<7>[    3.278834] SELinux: initialized (dev tmpfs, type tmpfs), uses transition SIDs
<6>[    3.278925] fs_mgr: fs_mgr_mount_all(): skipping fstab dup mountpoint=/persist rec[3].fs_type=ext4 already mounted.


Bug: 15925030
Bug: 15976144
Change-Id: I0bc617f11dfc97c32bb2d0e52b94ec19282568eb
2014-06-30 18:28:09 +00:00
JP Abgrall
e29cbd3372 fs_mgr: increase tmpfs size to accommodate bigger dex2oat data
During encryption and decryption, art is pumping out data via
dex2oat into the /data that is actually a tmpfs.
It currently needs ~195MB.
So we increase the tmpfs from 128MB to 256MB.

Bug: 15909689
Change-Id: I5d518a87d7b4eccf32fcd77f61980646ee8a3d35
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-27 02:24:55 -07:00
Daniel Rosenberg
f67d6bd3c0 Moved symlink back up.
Moving the vendor symlink down was causing issues with some devices.
Moved it back up, and adjusted mount to remove symlinks if necessary.

Change-Id: I77126d77cfbef32250012bea3960c99b55db4cbb
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-06-26 22:07:37 +00:00
JP Abgrall
983411318f fs_mgr: fix double mounting of partition
When looking for partitions to encrypt, it would setup a tmpfs
onto the mount point. But with multi-type mount points it would
repeat the mount.
This would lead to having and extra tmpfs mounted on /data, as
only one would get removed.

Change-Id: I28f2c2c4955906f1172342ea07e0795d6880986b
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-25 20:04:25 +00:00
Daniel Rosenberg
f530c93c4a Added support for vendor partition and image
Modified fastboot to flash vendor.img as well. Moved symlink
for /vendor to occur after mounting partitions. Changed mount
to also create the mount point.

Change-Id: I78e1ba24e6bb8b4af96a67ee0569af579439e682
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-06-24 21:51:31 +00:00
JP Abgrall
4bb7bba118 [HACK]fs_mgr: force recovery+wipe if data looks wiped
We do the recovery+wipe if
 - the mount fails and
 - the partition is forceencrypt
 - the partition seems wiped (== the 1st 4KB are all 0x00 or 0xFF).

This is a hack until we get the flashstation up and running with f2fs.
Bug: 15731906

The alternative would be for the user to manually enter
recovery and wipe his device.

Bug: 15747366
Change-Id: Ic8f3ef59f3d7d01d5d93d8e4c01502080f422157
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-19 22:12:20 -07:00
JP Abgrall
5c01dac6d8 fsmgr: support multiple fs-types/mountpoint
Previous attempt was broken.
It would incorrectly be affected by mount failures.

This changes allows an fstab to contain multiple lines for a given
mount point.
The lines sharing a mount MUST be after each other.

The 1st matching line is the primary when it comes to mounting
and look ups for wiping.

Mounting based on a mount_point will attempt each dup in turn
until one succeeds.
The reported error will be that of the last failed attempt.

This is to allow quick experimentation between different FSes.

Bug: 15702546
Change-Id: I378d68ad13eb0098ec1ccb8dcf108b82acbe9ebb
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-18 22:18:24 +00:00
JP Abgrall
f786fe5438 fsmgr: revert multiple fs-types/mountpoint (fix N5 boot)
This is apparently breaking N5, so reverting for now.

This reverts commit a794f86522.

Bug: 15709256
Change-Id: I37a5160eead17e153e2c83fa94632ffa5d8553c2
2014-06-18 07:28:14 +00:00
JP Abgrall
a794f86522 fsmgr: allow for a multiple fs-types for a mount point.
This changes allows an fstab to contain multiple lines for a given
mount point.
The lines sharing a mount MUST be after each other.

The 1st matching line is the primary when it comes to mounting
and look ups for wiping.

Mounting based on a mount_point will attempt each dup in turn
until one succeeds.

This is to allow quick experimentations between different FSes.
It does not deal with checkfs yet, because the underlying invocation
of fs-type appropriate fsck does not handle the error code.
Only the primary FS (1st in the dups) is checked.

Change-Id: I8329737454b53e2681436fe85cd00a9bc522676b
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-17 17:01:20 -07:00
JP Abgrall
1235158c29 F2FS support for fastboot format and fsmgr
- Enables fsck.f2fs for partitions with type F2FS.
- Adds support for f2fs as format fs-type.
- f2fs is optional and support is dlopen()d when needed.

Needs changes in
  system/extras/f2fs_utils
  external/f2fs-tools

Change-Id: I8d141a0d4d14df9fe84d3b131484e9696fcd8870
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-17 17:01:14 -07:00
Mark Salyzyn
87f1dd5da1 am af0df46d: am e6246ca6: am 01ef52e1: Merge "fs_mgr: turn on -Werror"
* commit 'af0df46d74368bb98edaadb3c09ddbc7252d3110':
  fs_mgr: turn on -Werror
2014-05-08 21:43:06 +00:00
Mark Salyzyn
86e3f22b6a fs_mgr: turn on -Werror
- deal with some -Wunused-variable issues

Change-Id: Ie0140d4777ddf862e4bbed76142a1dbb8320c1b0
2014-05-07 16:56:21 -07:00
Sasha Levitskiy
e2acb82a94 am 43cb7ae6: am 4f362e43: am 835526fd: Merge "Cleanup: warning fixit."
* commit '43cb7ae6c31ced8cd518eab59dfea31ab1ade812':
  Cleanup: warning fixit.
2014-04-12 00:02:33 +00:00
Sasha Levitskiy
cdc1cfb3e5 Cleanup: warning fixit.
bootable/recovery has a dependent commit: I9adb470b04e4301989d128c9c3097b21b4dea431

Change-Id: Icf23e659265d71d5226d527c2b40cfbc132320ee
Signed-off-by: Sasha Levitskiy <sanek@google.com>
2014-04-11 16:15:46 -07:00
Paul Lawrence
2e5ae0a4f9 Add force_encrypt flag to fstab to force encryption on appropriate devices
forceencrypt= will encrypt the drive at boot if it is not encrypted. This change
will not have an impact until we set this flag in appropirate fstabs.

Bug: 11985952

Change-Id: I6c65eda7f109e4936aa160da50f871703aefb351
2014-04-04 11:07:27 -07:00
Geremy Condra
cd642fc0b5 fs_mgr: disable verified partitions on debuggable devices.
This checks ro.debuggable to determine whether a device is in the
debuggable state or not, disabling verification if it is.

Eventually we'd like to narrow this down to only devices which
need to disable it, but we aren't there yet.

Change-Id: I06a329fe5449deab6bae595877dbb1f200850241
2014-04-02 18:07:22 -07:00
Paul Lawrence
166fa3de70 Auto-encrypt drive at startup
Modify fs_mgr to unmount encryptable drives after test mounting them and
then trigger an auto-encrypt via the init script

Needs matching vold changes from
 https://googleplex-android-review.googlesource.com/#/c/414200/

Feature is limited to list of serial numbers with this change

Bug: 11985952
Change-Id: I84f85a258b6a7e9809467c9149249302e203c41b
2014-03-24 15:00:53 -07:00
Geremy Condra
8c40dc90c5 Merge changes Ibea4c13a,I27215a3d
* changes:
  init: Add "partition.*.verified" properties to the property service.
  fs_mgr: Set the 'partition.*.verified' property for verified partitions.
2014-03-19 19:55:07 +00:00
Geremy Condra
05699b3e3e fs_mgr: Set the 'partition.*.verified' property for verified partitions.
This modifies fs_mgr to set the partition.*.verified properties.
Each of these should be used as a weak indicator that a given partition
is verified. For instance, if the 'partition.system.verified' property
is set to '1', this could indicate that the system partition is verified
and therefore should not be modified by, e.g., adb sync.

Note that these properties can be mutated by the system, and so
should not be used as the basis for security decisions.

Change-Id: I27215a3d3628a1b1e184df9eaad90541b9d8b841
2014-03-18 20:35:07 -07:00
Mohamad Ayyash
611f5e960c fs_mgr: fix mount_all when handling already mounted encryptable fs.
Since 38afe5f4ba
  fs_mgr_mount_all() will try to behave more like "mount -a"

So prevent inaccessible or busy (already mounted) encryptable filesystems
from mounting tmpfs in their mount points.


Change-Id: I32e5b3e26f2138d1e4d9ef8ba01c1466f8051d39
2014-03-13 03:45:21 +00:00
Mohamad Ayyash
38afe5f4ba fs_mgr: Ensure mount_all will process all fstab entries despite logging errors.
Change-Id: I0d58dd17d979b749a9ac03567cf2d395f9782f10
2014-03-12 12:44:18 -07:00
David 'Digit' Turner
28483d7ec4 fs_mgr: Don't run e2fsck inside SDK system images.
These images do not have GPL-ed binaries like /system/bin/e2fsck so
avoid running the program when we detect that we're running inside
one of them.

Note that this does not affect other emulator-based build products
(e..g full-eng instead of sdk-eng), which do have the binaries.

BUG=13057123

Change-Id: Ia42f1d02a3845fbf4b2f9d95818f35d760711a12
2014-02-24 23:32:00 +01:00
Colin Cross
5edee2aca9 fs_mgr: split fstab parsing into separate file
Move fstab parsing into fs_mgr_fstab.c so that it compiles into a
separate compilation unit.  uncrypt links against it but doesn't
need to pull in the rest of the dependencies on fs_mgr.c.

Change-Id: I6bffe1cd42720151533e958028259d1931aaa4bf
2014-01-23 14:24:16 -08:00
Colin Cross
a8be627935 fs_mgr: update ext4_parse_sb to match change in ext4_utils
ext4_parse_sb now takes the struct fs_info to fill out to avoid
using the global info from external callers.

Change-Id: I0984ba01c0dbdd5b68b825817faf0c5cf5aa5510
2014-01-23 14:24:16 -08:00