History log of /system/vold/Disk.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
fa1c677c1ac6fae00653d41cf85ff9951d57f7b1 26-Mar-2017 Jeff Sharkey <jsharkey@android.com> Add a new "virtual disk" feature.

It's extremely difficult to test storage related logic on devices
that don't have physical SD card slots. So to support better
debugging and testing, add a new "virtual disk" feature which mounts
a 512MB file through loop device.

It relies on the kernel having the "loop.max_part" value set to
something other than 0 via the boot command line, since that allows
all the existing partition logic to fall into place.

Bug: 34903607
Test: builds, boots, virtual disk works
Change-Id: I04c5b33e37319d867542985a56b7999a9b7cf35d
/system/vold/Disk.cpp
157175110948b3cf604e40420059aa5265039847 23-Aug-2016 Jeff Sharkey <jsharkey@android.com> Block adoptable storage when using FBE.

For adoptable storage and FBE to coexist we need a new dm-biocrypt
kernel feature which isn't ready yet. So for now, prevent devices
from being adopted on FBE devices.

Bug: 30770036
Change-Id: I47639209161ee403ce13ea9a60da235e97c3fc30
/system/vold/Disk.cpp
aa668f3d132f773dc0c11734d10c8f74d7f8c46d 28-Jul-2016 Chih-Hung Hsieh <chh@google.com> Merge \"Fix clang-tidy performance warnings in system/vold.\"
am: e24d4eef9b

Change-Id: I8e882391fb343a5dd8b5cd32b2e7c087219334dc
11a2ce8da33e0ec4be250fd85c47f706d6c91a10 27-Jul-2016 Chih-Hung Hsieh <chh@google.com> Fix clang-tidy performance warnings in system/vold.

* Use const reference type for for-loop index variables
to avoid unnecessary copy.

Bug: 30413223
Change-Id: Id4d980ae8afec1374fc3be0b23f1c6a39bff86e0
Test: build with WITH_TIDY=1
/system/vold/Disk.cpp
f84fe907141bcdb76425d5ba42913576f018a11c 11-Mar-2016 Jeff Sharkey <jsharkey@google.com> Merge "Print size as unsigned when sending to framework." into nyc-dev
d087bbc66f885ba23876ed7324d2e671dc94a8be 10-Mar-2016 Jeff Sharkey <jsharkey@android.com> Print size as unsigned when sending to framework.

Otherwise we might output negative numbers that confuse the rest
of the recovery stack.

Bug: 26007445
Change-Id: Ic99b49360732e5389c6330be065e1222e25b60ca
/system/vold/Disk.cpp
942d4e830b2057177fd2d47c51b788edd6e94398 08-Jan-2016 Yu Ning <yu.ning@intel.com> Support emulator's virtio-blk based SD card

Currently, vold only supports MMC (for SD cards) and SCSI (for USB
drives) devices. It does not recognize any device whose major number is
not one of those used by MMC and SCSI. Unfortunately, virtio-blk is one
such device. It is used by the new Android emulator (a.k.a. qemu2,
featuring the "ranchu" virtual board) for SD card emulation.

In order to make this virtio-blk based SD card device appear in Android
and appear as an SD card (rather than a USB drive), changes have to be
made to both vold (wherever the device major number is checked) and
ranchu's storage configuration. This CL implements former.

This is a stop-gap solution for emulator in nyc.
A longer term solution in-tune with upstream kernel is in the pipes.

Updated from aosp/master version.

BUG:27431753

Change-Id: I5014edec73be7c5b565d91542464c82cbe58992c
Signed-off-by: Yu Ning <yu.ning@intel.com>
(cherry picked from commit 5b1d1c7dfa13b4dca75213581dc8351b841b76c8)
/system/vold/Disk.cpp
a9d5080109623884c8f8e7c3515eaa9ed3f85c58 05-Dec-2015 Elliott Hughes <enh@google.com> Merge "Track rename from base/ to android-base/."
am: 20a8fa98f6

* commit '20a8fa98f6b858999b623272a182843259e1044c':
Track rename from base/ to android-base/.
7e128fbe212c64492afa98bfd6d7fab6f1956831 05-Dec-2015 Elliott Hughes <enh@google.com> Track rename from base/ to android-base/.

Change-Id: I3096cfa50afa395d8e9a8043ab69c1e390f86ccb
/system/vold/Disk.cpp
dadcceea7a8e931eaf970d95a297d8c89a0ebe9d 23-Sep-2015 Jeff Sharkey <jsharkey@android.com> Clean up any/all stale partition tables.

When formatting media as a public volume, we write an MBR, but we
might leave a stale GPT floating around. Some devices are configured
to aggressively prefer GPT when detected, even if the checksums
between primary/secondary don't match.

To work around this, nuke both MBR and GPT tables from the media
before we lay down our new MBR.

Bug: 24112219
Change-Id: Ibf1be466a6877cbab925a24db5e5dbab0613bea7
/system/vold/Disk.cpp
c86ab6f538bec63638c168d6c843fe7cf73add3b 26-Jun-2015 Jeff Sharkey <jsharkey@android.com> 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
/system/vold/Disk.cpp
63123c067a4e709198d9b8d3279c98561f8c990e 26-Jun-2015 Jeff Sharkey <jsharkey@android.com> Last ditch check for partition on raw disk.

Some storage devices can be formatted as bare partitions, without an
MBR or GPT header. If we found no partitions, try poking at the raw
disk, and treat it as a public volume if we found a valid filesystem.

Bug: 20503551
Change-Id: I80304e1ad865435321c341b667c0daf2daf4d56c
/system/vold/Disk.cpp
bc40cc8f07f69e0e26fc41516e2a83f0a8becbe0 18-Jun-2015 Jeff Sharkey <jsharkey@android.com> Add method to forget private partition keys.

Report both the disk and the partition GUID for private volumes to
userspace, and offer to forget the encryption key for a given
partition GUID.

Bug: 21782268
Change-Id: Ie77a3a58e47bf3563cdb3e4b0edfab1de4d0e6b4
/system/vold/Disk.cpp
d0640f6358041f7e2657167560b357078db73526 22-May-2015 Jeff Sharkey <jsharkey@android.com> 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
/system/vold/Disk.cpp
ba6747f119811032b258cf3c6334a4d0f9b675bf 29-Apr-2015 Jeff Sharkey <jsharkey@android.com> Scan failure still means we finished scan.

Bug: 19993667
Change-Id: If6a79391e34b652b2ba4e6df40a8e712f7a2e172
/system/vold/Disk.cpp
c8e04c5a8285de07d2c84bfbda8eda2c14a9457d 21-Apr-2015 Jeff Sharkey <jsharkey@android.com> 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
/system/vold/Disk.cpp
f3ee200303f632d940588926f9d31d1e1d51a5c6 20-Apr-2015 Jeff Sharkey <jsharkey@android.com> Handle *ALL* the SCSI disks!

Bug: 19993667
Change-Id: I47099c262686127f82dd376570d49cf0ad119842
/system/vold/Disk.cpp
613b26f8e3f71429945924837e3713dc73ce45d6 19-Apr-2015 Jeff Sharkey <jsharkey@android.com> Notify when disk scan finished.

Bug: 19993667
Change-Id: I20dc183a35c11b5b4ba6139e690929b9c279b830
/system/vold/Disk.cpp
f1b996df6f8283aac6953b22bd9e2496d8c30c86 18-Apr-2015 Jeff Sharkey <jsharkey@android.com> Volumes know parent disks; unsupported disks.

This is cleaner and more direct than the reverse of having the disk
publish child volume membership. Rename state constants to match
public API. Add state representing bad removal. Make it clear that
volume flags are related to mounting.

Send new unsupported disk event when we finish scanning an entire
disk and have no meaningful volumes.

Bug: 19993667
Change-Id: I08a91452ff561171a484d1da5745293ec893aec0
/system/vold/Disk.cpp
7d9d0118658648d85c6ce649a9f8d2893a7b5a78 15-Apr-2015 Jeff Sharkey <jsharkey@android.com> Lock while partitioning.

Otherwise we get really excited and trip over ourselves while
partitions are still being created.

Bug: 19993667
Change-Id: I034e56b3063a71d73f9311a945c05ea2ae255f7d
/system/vold/Disk.cpp
ffeb0079782896121785692157804b4cc12daddb 15-Apr-2015 Jeff Sharkey <jsharkey@android.com> Don't be picky about zap status.

Bug: 19993667
Change-Id: Id125d9252bf7130516c0ec619d5f067fea24d560
/system/vold/Disk.cpp
502164deaae6d4bd6d6e36cc10fa666ceae92e3c 15-Apr-2015 Jeff Sharkey <jsharkey@android.com> Fix destroy ordering bug; add debug flag.

Bug: 19993667
Change-Id: Ib15e79a94a185843dace35fea7daaea866120f87
/system/vold/Disk.cpp
3161fb3702830b586b2e36fa9ca4519f59f951b4 13-Apr-2015 Jeff Sharkey <jsharkey@android.com> Emulated volumes above private volumes.

When a private volume is mounted, create an emulated volume above it
hosted at the /media path on that device. That emulated volume is
automatically torn down when unmounting the private volume.

Add "removed" state for volume, which signals to framework that
media has left the building, send when the volume is destroyed.

Bug: 19993667
Change-Id: I1f82b51de578ac5cfcc5d7b9a6fb44f6f25c775c
/system/vold/Disk.cpp
ce6a913aeac7db94a41362c63bab74092767bb3e 09-Apr-2015 Jeff Sharkey <jsharkey@android.com> Exclusive exec() path, format after partition.

Sadly setexeccon() is process global, so we need to carefully ensure
that all exec() are mutually exclusive to avoid transitioning into
unwanted domains. Also, because we have several threads floating
around, we need to guard all our FDs with O_CLOEXEC.

Format all newly created volumes immediately after partitioning,
but silence all events emitted from those volumes to prevent the
framework from getting all excited. Unify all notify events under a
single codepath to make them easy to silence.

Sent SIGINT before escalating to SIGTERM when unmounting.

Bug: 19993667
Change-Id: Idc6c806afc7919a004a93e2240b42884f6b52d6b
/system/vold/Disk.cpp
9c48498f4529f623650c56d03e63324c8d813032 31-Mar-2015 Jeff Sharkey <jsharkey@android.com> Support for private (adopted) volumes.

This adds support for private volumes which is just a filesystem
wrapped in a dm-crypt layer. For now we're using the exact same
configuration as internal encryption (aes-cbc-essiv:sha256), but we
don't store any key material on the removable media. Instead, we
store the key on internal storage, and use the GPT partition GUID
to identify which key should be used.

This means that private external storage is effectively as secure as
the internal storage of the device. That is, if the internal storage
is encrypted, then our external storage key is also encrypted.

When partitioning disks, we now support a "private" mode which has
a PrivateVolume partition, and a currently unused 16MB metadata
partition reserved for future use. It also supports a "mixed" mode
which creates both a PublicVolume and PrivateVolume on the same
disk. Mixed mode is currently experimental.

For now, just add ext4 support to PrivateVolume; we'll look at f2fs
in a future change. Add VolumeBase lifecycle for setting up crypto
mappings, and extract blkid logic into shared method. Sprinkle some
more "static" around the cryptfs code to improve invariants.

Bug: 19993667
Change-Id: Ibd1df6250735b706959a1eb9d9f7219ea85912a0
/system/vold/Disk.cpp
38cfc028607a6756ac7d37200182724f033375d8 31-Mar-2015 Jeff Sharkey <jsharkey@android.com> Fix 64 bit builds.

Change-Id: I4e30ecff3c29d0f8351c6f43de1c979c8c792fab
/system/vold/Disk.cpp
36801cccf27152c9eca5aab6ba3527221525110f 14-Mar-2015 Jeff Sharkey <jsharkey@android.com> Progress towards dynamic storage support.

Wire up new Disk and VolumeBase objects and events to start replacing
older DirectVolume code. Use filesystem UUID as visible PublicVolume
name to be more deterministic.

When starting, create DiskSource instances based on fstab, and watch
for kernel devices to appear. Turn matching devices into Disk
objects, scan for partitions, and create any relevant VolumeBase
objects. Broadcast all of these events towards userspace so the
framework can decide what to mount.

Keep track of the primary VolumeBase, and update the new per-user
/storage/self/primary symlink for all started users.

Provide a reset command that framework uses to start from a known
state when runtime is restarted. When vold is unexpectedly killed,
try recovering by unmounting everything under /mnt and /storage
before moving forward.

Remove UMS sharing support for now, since no current devices support
it; MTP is the recommended solution going forward because it offers
better multi-user support.

Switch killProcessesWithOpenFiles() to directly take signal. Fix
one SOCK_CLOEXEC bug, but SELinux says there are more lurking.

Bug: 19993667
Change-Id: I2dad1303aa4667ec14c52f774e2a28b3c1c1ff6d
/system/vold/Disk.cpp
ae9e8903375e13028b140e86fcc68c6e152b6f43 16-Mar-2015 Dan Albert <danalbert@google.com> Update for libbase.

Change-Id: I23b1281a63031a7481ea7b33c9ddbdbe7d3d6174
/system/vold/Disk.cpp
deb240573754daf36fa8ea10a05240f9f31e7b2c 03-Mar-2015 Jeff Sharkey <jsharkey@android.com> Checkpoint of better dynamic device support.

This is the first in a series of changes that are designed to
introduce better support for dynamic block devices.

It starts by defining a new Volume object which represents a storage
endpoint that knows how to mount, unmount, and format itself. This
could be a filesystem directly on a partition, or it could be an
emulated FUSE filesystem, an ASEC, or an OBB.

These new volumes can be "stacked" so that unmounting a volume will
also unmount any volumes stacked above it. Volumes that provide
shared storage can also be asked to present themselves (through bind
mounts) into user-specific mount areas.

This change also adds a Disk class which is created based on block
kernel netlink events. Instead of waiting for partition events from
the kernel, it uses gptfdisk to read partition details and creates
the relevant Volume objects.

Change-Id: I0e8bc1f8f9dcb24405f5e795c0658998e22ae2f7
/system/vold/Disk.cpp