author | Baocheng Sun <baocheng.sun@amlogic.com> | 2017-11-30 08:23:57 (GMT) |
---|---|---|
committer | Baocheng Sun <baocheng.sun@amlogic.com> | 2017-12-01 02:23:27 (GMT) |
commit | 436733a11bf19a6c64b1fa36aa02d6db51653ed5 (patch) | |
tree | cfed0ef33f5780868c2d417b11eb5519baba2e01 | |
parent | 56c6c8a49dfa6cbb99e90caf7acc38839771cbe3 (diff) | |
download | droidvold-436733a11bf19a6c64b1fa36aa02d6db51653ed5.zip droidvold-436733a11bf19a6c64b1fa36aa02d6db51653ed5.tar.gz droidvold-436733a11bf19a6c64b1fa36aa02d6db51653ed5.tar.bz2 |
droidvold: add virtual cdrom support [3/3]
PD#155365
add virtual cdrom support
Change-Id: I3865c5823b368bc7b5c984640bfe1d86c3ad61aa
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | DroidVold.cpp | 23 | ||||
-rw-r--r-- | VolumeManager.cpp | 2 |
3 files changed, 26 insertions, 0 deletions
@@ -61,6 +61,7 @@ LOCAL_INIT_RC := droidvold.rc LOCAL_C_INCLUDES := $(common_c_includes) LOCAL_CFLAGS := $(vold_cflags) LOCAL_CFLAGS += -DHAS_NTFS_3G +LOCAL_CFLAGS += -DHAS_VIRTUAL_CDROM LOCAL_CONLYFLAGS := $(vold_conlyflags) LOCAL_SHARED_LIBRARIES := $(common_shared_libraries) diff --git a/DroidVold.cpp b/DroidVold.cpp index e64ff0c..3d6086a 100644 --- a/DroidVold.cpp +++ b/DroidVold.cpp @@ -80,6 +80,18 @@ Return<Result> DroidVold::mount(const hidl_string& id, uint32_t flag, uint32_t u VolumeManager *vm = VolumeManager::Instance(); std::string vid = id; + +#ifdef HAS_VIRTUAL_CDROM + // is loop volume + if (flag == 0xF) { + if (vm->mountloop(vid.c_str())) { + LOG(ERROR) << " mount loop error!"; + return Result::FAIL; + } + return Result::OK; + } +#endif + auto vol = vm->findVolume(vid); if (vol == nullptr) { LOG(ERROR) << "mount ,count not find volume id=" << vid; @@ -102,6 +114,17 @@ Return<Result> DroidVold::unmount(const hidl_string& id) { // unmount [volId] VolumeManager *vm = VolumeManager::Instance(); std::string vid = id; + +#ifdef HAS_VIRTUAL_CDROM + if (vid.find("/mnt/loop") != std::string::npos) { + if (vm->unmountloop(true)) { + LOG(ERROR) << "unmount loop error!"; + return Result::FAIL; + } + return Result::OK; + } +#endif + auto vol = vm->findVolume(vid); if (vol == nullptr) { LOG(ERROR) << "unmount, count not find volume id=" << vid; diff --git a/VolumeManager.cpp b/VolumeManager.cpp index bc1c80f..ac9e1b5 100644 --- a/VolumeManager.cpp +++ b/VolumeManager.cpp @@ -30,6 +30,7 @@ #include <unistd.h> #include <linux/kdev_t.h> +#include <linux/loop.h> #define LOG_TAG "droidVold" @@ -41,6 +42,7 @@ #include <selinux/android.h> #include <sysutils/NetlinkEvent.h> +#include <private/android_filesystem_config.h> #include "VolumeManager.h" #include "NetlinkManager.h" |