Commit graph

67 commits

Author SHA1 Message Date
P.Adarsh Reddy
167c2a658a Acknowledge the 'nofail' fs_mgr flag and skip the expected failure.
fs_mgr supports 'nofail' flag, which is used if we do not want to
error-out incase the mounting/setup fails for a partition tagged with
nofail flag in fstab.

Recently added code in vold misses this handling, i.e. it aborts even
for a nofail partition upon encountering an expected failure.

Test: Add a non-existing logical partition fstab entry with 'nofail'
      flag. Init's first stage mount acks this and doesn't crash.
      Vold aborts (as it doesn't handle it), and device doesn't boot.
      With this change, device boots up.

Change-Id: I2b1904a9c648c31bcc05b2e7e77480db236ff66e
2020-05-06 16:45:23 +00:00
Jaegeuk Kim
4ea573aca7 vold: fix missing has.adoptable
This patch fixes missing entry in the below commit.

Fixes: c52f6724ed ("vold: clean up configuration set")
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: Ia39a427d4747b29a7af42633f34daab63204bbf9
2020-04-23 13:43:12 -07:00
Jaegeuk Kim
c52f6724ed vold: clean up configuration set
This patch introduces a structure to manipulate many configuration flags.

Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: Ib15d2b6e251741160d2febe695132a37f9dde23c
2020-04-13 13:14:14 -07:00
Jaegeuk Kim
f64d30aa82 vold: support F2FS compression
Bug: 134580167
Change-Id: Iadd001dc5ce0f91a4337f5b27ea8cc54f9760b0d
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2020-04-03 14:02:14 -07:00
Paul Crowley
73be12dcd5 Refactor: make cryptfs.h smaller
Move most of it into cryptfs.cpp, and include cryptfs.h in fewer files.

Bug: 147814592
Test: Treehugger
Change-Id: Ia3592d73e7abc1f07a60538e0978a3033bdea7de
2020-02-07 11:16:12 -08:00
Eric Biggers
2fba74c1e1 Merge "Add missing null terminator for getopt_long()" am: 4d05e017f9
am: 4e3300374b

Change-Id: Ic91066f2abfdc191fe4d0b517fd65d9744387e7b
2019-04-04 09:55:49 -07:00
Eric Biggers
f5ef40de83 Add missing null terminator for getopt_long()
getopt_long() assumes an all-zeroes 'struct option' at the end of the
array.  Add it.

Fortunately this isn't causing problems in practice because vold is
always passed valid command line options...

Test: Running 'vold --foo' no longer segfaults.
Change-Id: I2cd3af501cc1aa11327a8062ec492be1d23defdf
2019-04-03 16:32:24 -07:00
David Anderson
42aabc24dc Merge "Enable metadata encryption for userdata_gsi." am: 99046b75c4 am: 8b90acafcd
am: 1f4307e51e

Change-Id: If3e65d967a99e3f757a1ab978067e61a3faeae66
2019-02-14 12:50:52 -08:00
David Anderson
0d71c4b5f7 Enable metadata encryption for userdata_gsi.
When running a live GSI, userdata is a logical partition. If we don't
fix up the fstab we'll derive the underlying block device instead of
the device-mapper node for userdat_gsi, resulting in a corrupt data
partition for both images.

Bug: 123906417
Test: manual test
Change-Id: Ic0101f30504de26e725442da2da3888008c31b63
2019-02-14 08:29:26 -08:00
Tom Cherry
1464410580 Merge "Move over to the C++ Fstab class" am: b6d5cd20d7 am: 4e8e70a949
am: f61f61a6a0

Change-Id: I90f0f0e1161463cef8542a586b53274ec5a2f5ee
2019-01-31 17:23:24 -08:00
Tom Cherry
4c5bde2b92 Move over to the C++ Fstab class
Test: build and boot
Change-Id: Id3850c9c133f6644073a2439368501253a2a94a9
2019-01-31 12:34:39 -08:00
Sudheer Shanka
40ab6742a7 Bind mount pkg specific dirs in the zygote child namespaces.
- Also update vold to create sandboxes for secondary storage devices.
- Since bind mounts are created in the process specific namespaces, we
  don't need /mnt/storage anymore which we were using it to prevent
  some bind mounts from propagating onto /mnt/runtime/write.
- Create bind mounts for {media,obb} dirs similar to data dir in
  per process namespace.
- Also fix a bug where we are not passing correct packages to vold when
  a new user starts.

Bug: 111890351
Test: manual
Change-Id: I7849efc4fbf3c654606fa30de7ab2de0236d766f
2018-09-27 15:50:26 -07:00
Sudheer Shanka
4b6ca4ea65 Update vold to log only debug or higher level messages.
This will allow adding lots of verbose logs which can be enabled
only during local testing/debugging. Update the existing verbose
level logs to debug level since we want those to be logged by
default.

Test: manual
Change-Id: Ib05e2b6efa71308458d49affb6ed81d3975b28ab
2018-09-21 11:16:51 -07:00
Paul Crowley
14c8c0765a clang-format many files.
Test: Format-only changes; treehugger suffices.
Change-Id: I23cde3f0bbcac13bef555d13514e922c79d5ad48
2018-09-18 15:41:22 -07:00
Yifan Hong
024a1241a6 vold uses health filesystem HAL
to runDevGc(). This fixes a Treble violation.
Bug: 111655771
Test: manual

Change-Id: I53d6db6ffa99e43e281f8086442151692c1826ca
2018-09-17 10:06:57 -07:00
Paul Crowley
0fd2626fc3 Add a mount with metadata encryption service
Don't use the FDE flow to support metadata encryption; just provide a
vold service which directly mounts the volume and use that.

Bug: 63927601
Test: Boot Taimen to SUW with and without metadata encryption.
Change-Id: Ifc6a012c02c0ea66893020ed1d0da4cba6914aed
2018-02-01 10:08:17 -08:00
Jeff Sharkey
53d5d7ca8a Wire up reserved blocks presence for tests.
This is how we tell CTS if the device has reserved blocks set aside
for system critical services.

Test: builds, boots
Bug: 62024591
Change-Id: I7c8ec2294b246eed54668b5717df00e72f13887a
2018-01-08 10:43:16 -07:00
Jeff Sharkey
93396c14a8 Use main thread for Binder transactions.
Make the main thread do something useful instead of sitting around
twiddling its thumbs.

Test: builds, boots
Bug: 67041047
Change-Id: I88f7f4fe151ae2b81f80aa575530c12b56ba4d75
2017-10-18 16:54:46 -06:00
Jeff Sharkey
3472e52fc2 Move to modern utility methods from android::base.
Moves away from crufty char* operations to std::string utility
methods, including android::base methods for splitting/parsing.

Rewrite of how Process handles scanning procfs for filesystem
references; now uses fts(3) for more sane traversal.

Replace sscanf() with new FindValue() method, also has unit tests.

Remove some unused methods.  Switch almost everyone over to using
modern logging library.

Test: cts-tradefed run commandAndExit cts-dev -m CtsOsTestCases -t android.os.storage.cts.StorageManagerTest
Test: cts-tradefed run commandAndExit cts-dev --abi armeabi-v7a -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AdoptableHostTest
Bug: 67041047
Change-Id: I70dc512f21459d1e25b187f24289002b2c7bc7af
2017-10-17 12:40:51 -06:00
Paul Crowley
3188805e35 Read the configuration before starting the native service.
Bug: 66739076
Bug: 65737446
Test: reboot-cycle.sh doesn't show a problem.
Change-Id: Ia0699cca7e07475d4df266b482a3b2c96519ed3b
2017-09-27 10:56:54 -07:00
Paul Crowley
e2ee152e46 Refactor of use of fstab in advance of fix.
Test: Ensure device still boots.
Bug: 65737446
Change-Id: Ie466db9f5d8c77656cc525c0d49fe6a3cce154f1
2017-09-26 14:21:10 -07:00
Jeff Sharkey
67b8c49530 Make Loop::destroyAll() smarter.
Instead of blindly looping across 4096 possible devices, use
readdir() to only look at valid devices.  This speeds up destroyAll()
from 40ms to 0.7ms.

Add tracing information in several places.

Test: external/chromium-trace/systrace.py -b 128768 sched freq am pm ss core_services binder_driver -a system_server,installd,vold
Bug: 65634729, 65737446
Change-Id: If581de47fb55850c0fcd6e25bf33ed246e1b079d
2017-09-21 17:11:07 -06:00
Jeff Sharkey
cbe69fc060 Destroy vold socket interface completely.
Long live Binder.

Test: yes
Bug: 13758960
Change-Id: If6be379b5a873f1b0c66dd1522b87413ad10fc46
2017-09-18 16:00:14 -06:00
Jeff Sharkey
11c2d380a7 Move even more vold commands over to Binder.
This moves fstrim, obb and appfuse commands over to the new Binder
interface.  This change also separates creating/destroying and
mounting/unmounting of OBB volumes, which means they finally flow
nicely into the modern VolumeInfo/VolumeBase design.

We now generate unique identifiers for all OBB volumes, instead of
using a shady MD5 hash.

Change all "loop" and "dm" devices to tag the kernel resources with
a vold-specific prefix so that we can clean them up if vold crashes;
there are new destroyAll() methods that handle this cleanup.

Move appfuse mounting/unmounting into VolumeManager so it can be
shared.  Move various model objects into a separate directory to
tidy things up.

Test: cts-tradefed run commandAndExit cts-dev -m CtsOsTestCases -t android.os.storage.cts.StorageManagerTest
Bug: 13758960
Change-Id: I7294e32b3fb6efe07cb3b77bd20166e70b66958f
2017-09-11 18:44:17 -06:00
Jeff Sharkey
068c6be622 Start paving the way for vold calls over Binder.
This change is the bare minimum needed to publish a new vold
Binder service and move the simple "reset" call over to go through
the new interface.

Test: builds, boots
Bug: 13758960
Change-Id: I5b70976653c69f92e1efc8d1f432b2038eb618a4
2017-09-06 14:06:06 -06:00
Jeff Sharkey
95a92f9203 Only enable quotas when supported by device.
Otherwise we might end up creating ext4 partitions that the device
can't mount.

Bug: 63763609
Test: builds, boots
Exempt-From-Owner-Approval: Bug 63673347
Change-Id: I5f6cf73f23a55bc0dea9480523f19049313c3dd1
2017-07-17 13:58:45 -06:00
Jeff Sharkey
fd3dc3c076 Spread around some O_CLOEXEC love.
Also remove some unnecessary SELinux logic when creating image files
for loop devices.

Test: builds, boots, common operations work
Bug: 34903607
Change-Id: I68dfa022ecc39f56c175e786694e0de35b954ca0
2017-03-27 11:13:36 -06:00
Bowgo Tsai
e8fb6c3000 vold: replacing fs_mgr_read_fstab() with fs_mgr_read_fstab_default()
The original default /fstab.{ro.hardware} might be moved to /vendor/etc/.
or /odm/etc/. Use the new API to get the default fstab instead of using
the hard-coded /fstab.{ro.hardware}.

Bug: 35811655
Test: boot marlin with /vendor/etc/fstab.marlin
Change-Id: I92d6aefe6ff3433b7d1a671358d990bb7b1f2150
2017-03-09 23:31:18 +08:00
Wei Wang
2edbe28add vold: add coldboot back and make sure it won't block booting
coldboot is needed when device rebooted with USB device attched
so Vold netlink won't miss the information.
This CL added back coldboot and moved down so that it won't block
vold cl and ccl threads.

Bug: 36007238
Test: reboot marlin with flash drive attached and flash drive is recognized
Change-Id: Ie39f348e97a8500515e394e386541289a91b2425
2017-03-06 17:49:37 -08:00
Wei Wang
6b455c29be Remove coldboot from vold
coldboot is now taken care by ueventd, so removing the duplicate
logic to save boottime.
This CL also fixes a missing lock.


Bug: 33786699
Test: manual
Change-Id: I71270252f3153abc815d142b5da7a9cb85b94dac
2017-01-25 18:15:38 +00:00
Dimitry Ivanov
c976e73bbd Fix deadlock between vold and init
By setting property after listeners are initialized
we avoid deadlock between vold and init where
vold is waiting on property_service while init is blocked
(and therefore is not able to accept connections) on vdc
which is attempting to communicate with vold.

(This also speeds up boot by 250ms)

Test: Boot a device, check locks and make sure there is no timeout
      on property_set(.)
Test: Successfully boot a device with new property service protocol.
Bug: http://b/34278978
Change-Id: I9547d2f19cb35aa452bf01fbff0eb4b32a4824a4
2017-01-19 14:44:03 -08:00
Paul Crowley
38132a1f66 Refactor now that global DE has been reworked
Change-Id: I4d6156332cfc847e25e7c8863fd6a50fa325fb87
2016-02-09 10:11:42 +00:00
Paul Crowley
285956fe11 Rework FBE crypto to match the N way of doing things
Major rework and refactor of FBE code to load the keys at the right
time and in a natural way. The old code was aimed at our goals for M,
with patches on top, and didn't quite work.

Bug: 22358539

Change-Id: I9bf7a0a86ee3f2abf0edbd5966f93efac2474c2c
2016-01-20 13:12:38 +00:00
Lenka Trochtova
9ad4369ce8 Fix a bug in passing parameters to prepare_user_storage.
Add the serial parameter to prepare_user_storage to avoid
confusion when parsing parameters and passing them around.

Change-Id: Id5516c248401ad50585aa8f6e8b1545a6cded549
2015-12-11 13:27:32 +01:00
Lenka Trochtova
395039f007 Introduce support for ephemeral users.
BUG: 24883058

Change-Id: I77d4757f87214166e7c41c7eb0d06b1cd5f06b20
2015-12-08 11:10:59 +01:00
Elliott Hughes
6bf0547ccc resolve merge conflicts of b7d5a47cec to master.
Change-Id: I0c5211a00d92d0ee796bb9c77d2e13675a2a3e8d
2015-12-04 17:55:33 -08:00
Elliott Hughes
7e128fbe21 Track rename from base/ to android-base/.
Change-Id: I3096cfa50afa395d8e9a8043ab69c1e390f86ccb
2015-12-04 15:50:53 -08:00
Jeff Sharkey
c79fb89a10 Switch to new FBE emulation property.
Also prepare CE/DE storage directories for owner user at boot.

Bug: 22358539
Change-Id: I76228952c990ebed83360c69ef36321b99114196
2015-11-19 11:16:22 -07:00
Jeff Sharkey
c86ab6f538 Trim both internal and adopted private storage.
Refactor fstrim code to be encapsulated in unique task object, and
give it option of benchmarking when finished.  Trimming now includes
both storage from fstab and adopted private volumes.  Cleaner timing
stats are logged for each unique volume.

Add wakelock during ongoing async move tasks.  Push disk sysfs path
to framework so it can parse any SD card registers as desired.

Bug: 21831325
Change-Id: I76577685f5cae4929c251ad314ffdaeb5eb1c8bf
2015-07-01 15:53:51 -07:00
Jeff Sharkey
d0640f6358 Add f2fs support for private volumes.
When formatting volumes, pass along fsType string which can be "auto"
to let the volume select the best choice.  For now, private volumes
assume that MMC devices (like SD cards) are best off using f2fs when
both kernel support and tools are present, otherwise fall back to
ext4.  Use blkid when mounting to pick the right set of tools.

Move filesystem utility methods into namespaces and place in separate
directory to be more organized.

Bug: 20275581
Change-Id: Id5f82d8672dda2e9f68c35b075f28232b0b55ed4
2015-06-08 20:21:25 -07:00
Paul Lawrence
d0b4295ccc Move crypt commands to a different listener in vold
In order to prevent this bug from happening, we must allow vold cryptfs
commands to complete while a long running mount is underway.

While waiting for vold to be changed to a binder interface, we will simply
create two listeners, one for cryptfs and one for everything else.

Bug: 19197175
Change-Id: If74142aa81abd58f718a9de6c9e387f6ea442754
2015-06-04 21:29:01 +00:00
Jeff Sharkey
65427f1a80 Offer debug flag to force default primary.
Useful for transforming a secondary SD card slot into a primary SD
card slot without doing a completely different lunch target.

$ adb shell stop
$ adb shell setprop vold.debug.default_primary 1
$ adb shell setprop ro.vold.primary_physical 1
$ adb shell setprop ctl.restart vold
$ adb shell start

Bug: 21017105
Change-Id: I45aac7ab3bb4c5ac3e0140572844883823fc3e4f
2015-05-19 15:54:15 -07:00
Jeff Sharkey
e44a41a17b Communicate if we have adoptable disks.
Bug: 19993667
Change-Id: I3c3dddab157a11038f7160d24d53e728bde2194f
2015-05-13 13:53:07 -07:00
Jeff Sharkey
b0667870ff Property to enable debugging.
Bug: 19993667
Change-Id: Ie226e06edcb426caca2dbc97d2d5d60ae948c85e
2015-04-29 08:59:29 -07:00
Jeff Sharkey
c8e04c5a82 Wider volume mutation lock, move force adoptable.
We eventually should move back to per-disk locks, but use a giant
lock to keep development rolling forward.  Also move force adoptable
flag to framework since, since encrypted devices don't have persisted
properties loaded early during boot.

Bug: 19993667
Change-Id: Ifa3016ef41b038f8f71fc30bc81596cfd21dcd2a
2015-04-21 12:24:57 -07:00
Jeff Sharkey
5bad378015 Switch logging to system log, persistable prop.
Use system log for more durable log history.  Also accept persistable
version of flag to force adoptability.

Bug: 19993667
Change-Id: Icdf36799e26038e9a8e2bdaca276d97b22ba3941
2015-04-18 16:15:12 -07:00
Jeff Sharkey
502164deaa Fix destroy ordering bug; add debug flag.
Bug: 19993667
Change-Id: Ib15e79a94a185843dace35fea7daaea866120f87
2015-04-14 16:45:18 -07:00
Jeff Sharkey
9f18fe7807 Remove unused code.
Bug: 19993667
Change-Id: I1f6519655c5a366eca25e2329e1bf95d81b3bf8c
2015-04-01 23:33:26 -07:00
Jeff Sharkey
f7e86ead9f Some CLOEXEC love.
Bug: 19993667
Change-Id: If8c0b346820f30c6a7dac495f935be17d677ffcc
2015-04-01 23:07:19 -07:00
Jeff Sharkey
95c87cce35 Different blkid and fsck execution domains.
vold works with two broad classes of block devices: untrusted devices
that come in from the wild, and trusted devices like PrivateVolume
which are encrypted.

When running blkid and fsck, we pick which SELinux execution domain
to use based on which class the device belongs to.

Bug: 19993667
Change-Id: I2695f028710a4863f0c3b2ed6da437f466401272
2015-04-01 14:08:40 -07:00