In Android 8.0, the MountService class was renamed to StorageManagerService.
2017-11-21 10:55
537 查看
Device Configuration
External storage is managed by a combination of the voldinit service and
StorageManagerServicesystem
service. Mounting of physical external storage volumes is handled by
vold, which
performs staging operations to prepare the media before exposing it to apps.
Note: In Android 8.0, the
MountServiceclass was renamed to
StorageManagerService.
File mappings
For Android 4.2.2 and earlier, the device-specific vold.fstabconfiguration file
defines mappings from sysfs devices to filesystem mount points, and each line follows this format:
dev_mount <label> <mount_point> <partition> <sysfs_path> [flags]
label: Label for the volume.
mount_point: Filesystem path where the
volume should be mounted.
partition: Partition number (1 based),
or 'auto' for first usable partition.
sysfs_path: One or more sysfs paths to
devices that can provide this mount point. Separated by spaces, and each must start with
/.
flags: Optional comma separated list
of flags, must not contain
/. Possible values include
nonremovableand
encryptable.
For Android releases 4.3 and later, the various fstab files used by init, vold and recovery were unified in the
/fstab.<device>file.
For external storage volumes that are managed by
vold, the entries should have
the following format:
<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
src: A path under sysfs (usually mounted
at /sys) to the device that can provide the mount point. The path must start with
/.
mount_point: Filesystem path where the
volume should be mounted.
type: The type of the filesystem on the
volume. For external cards, this is usually
vfat.
mnt_flags:
Voldignores
this field and it should be set to
defaults
fs_mgr_flags:
Voldignores
any lines in the unified fstab that do not include the
voldmanaged=flag in
this field. This flag must be followed by a label describing the card, and a partition number or the word
auto.
Here is an example:
voldmanaged=sdcard:auto. Other possible flags are
nonremovable,
encryptable=sdcard,
noemulatedsd,
and
encryptable=userdata.
Configuration details
External storage interactions at and above the framework level are handled through StorageManagerService.
Due to configuration changes in Android 6.0 (like the removal of the storage_list.xml resource overlay), the configuration details are split into two categories.
Android 5.x and earlier
The device-specific storage_list.xmlconfiguration file, typically provided through
a
frameworks/baseoverlay, defines the attributes and constraints of storage
devices. The
<StorageList>element contains one or more
<storage>elements,
exactly one of which should be marked primary.
<storage>attributes include:
mountPoint: filesystem path of this mount.
storageDescription: string resource that
describes this mount.
primary: true if this mount is the primary
external storage.
removable: true if this mount has removable
media, such as a physical SD card.
emulated: true if this mount is emulated
and is backed by internal storage, possibly using a FUSE daemon.
mtp-reserve: number of MB of storage
that MTP should reserve for free storage. Only used when mount is marked as emulated.
allowMassStorage: true if this mount
can be shared via USB mass storage.
maxFileSize: maximum file size in MB.
Devices may provide external storage by emulating a case-insensitive, permissionless filesystem backed by internal storage. One possible implementation is provided by the FUSE daemon in
system/core/sdcard,
which can be added as a device-specific
init.rcservice:
# virtual sdcard daemon running as media_rw (1023)
service sdcard /system/bin/sdcard <source_path> <dest_path> 1023 1023
class late_start
Where
source_pathis the backing internal storage and
dest_pathis
the target mount point.
When configuring a device-specific
init.rcscript, the
EXTERNAL_STORAGEenvironment
variable must be defined as the path to the primary external storage. The
/sdcardpath
must also resolve to the same location, possibly through a symlink. If a device adjusts the location of external storage between platform updates, symlinks should be created so that old paths continue working.
Android 6.0
Configuration of the storage subsystem is now concentrated in the device-specific fstabfile,
and several historical static configuration files/variables have been removed to support more dynamic behavior:
The
storage_list.xmlresource overlay
has been removed and is no longer used by the framework. Storage devices are now configured dynamically when detected by
vold.
The
EMULATED_STORAGE_SOURCE/TARGETenvironment
variables have been removed and are no longer used by Zygote to configure user-specific mount points. Instead, user separation is now enforced with user-specific GIDs, and primary shared storage is mounted into place by
voldat
runtime.
Developers may continue to build paths dynamically or statically depending on their use case. Including the UUID in the path identifies each card to make location clearer for developers. (For example,
/storage/ABCD-1234/report.txtis
clearly a different file than
/storage/DCBA-4321/report.txt.)
The hard-coded FUSE services have been removed from device-specific
init.rcfiles
and are instead forked dynamically from
voldwhen needed.
In addition to these configuration changes, Android 6.0 includes the notion of adoptable storage. For Android 6.0 devices, any physical media that is not adopted is viewed as portable.
Adoptable storage
To indicate an adoptable storage device in the fstab, use the
encryptable=userdataattribute
in the
fs_mgr_flagsfield. Here’s a typical definition:
/devices/platform/mtk-msdc.1/mmc_host* auto auto defaults
voldmanaged=sdcard1:auto,encryptable=userdata
When a storage device is adopted, the platform erases the contents and writes a GUID partition table that defines two partitions:
a small empty
android_metapartition
that is reserved for future use. The partition type GUID is 19A710A2-B3CA-11E4-B026-10604B889DCF.
a large
android_extpartition that is
encrypted using dm-crypt and formatted using either
ext4or
f2fsdepending
on the kernel capabilities. The partition type GUID is 193D1EA4-B3CA-11E4-B075-10604B889DCF.
Portable storage
In the fstab, storage devices with the
voldmanagedattribute
are considered to be portable by default unless another attribute like
encryptable=userdatais
defined. For example, here’s a typical definition for USB OTG devices:
/devices/*/xhci-hcd.0.auto/usb* auto auto defaults
voldmanaged=usb:auto
The platform uses
blkidto detect filesystem types before mounting, and users
can choose to format the media when the filesystem is unsupported.
相关文章推荐
- android ;linux ;Plug-in org.eclipse.ajdt.ui was unable to load class
- Eclipse:Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.
- android 8.0 MountService -->StorageManagerService
- Eclipse:Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.j
- Apache 安装出现 Failed to open the Windows service manager, perhaps you forgot to log in as Adminstrator
- Eclipse:Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart. 解决方法
- Eclipse:Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.j
- the connection to the VMware USB Arbitration Service was unsuccessful.Please check the status of this service in the Microsogt M
- Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart
- [Windows Azure] How to use the Windows Azure Blob Storage Service in .NET
- Eclipse:Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.
- Eclipse:Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.j
- Apache 安装出现 Failed to open the Windows service manager, perhaps you forgot to log in as Adminstrator
- Eclipse:Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.jdt.internal.ui.packageview.P
- Eclipse:Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.
- Eclipse:Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class
- Eclipse:Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.j
- eclipse 第三方jar包 关联源码,提示 The Jar of this class file belongs to container 'Android Dependencies'
- 启动hive报错:("com.mysql.jdbc.Driver") was not found in the CLASSPATH
- eclipse中无法新建Android工程 出现问题:Plug-in org.eclipse.ajdt.ui was unable to load