avoid fs_mkdirs when SD card removed
Must limit vold calls to fs_mkdirs() only when the volume is mounted.
If NOT, it will trigger selinux warning as follows.
audit(1398835637.785:8): avc: denied { write } for pid=137 comm="vold" name="sdcard0" dev="rootfs" ino=3191 scontext=u:r:vold:s0 tcontext=u:object_r:rootfs:s0 tclass=dir
Change-Id: I1113fc961cbdd8bbd2fcbf740c2f504628c8399d
Signed-off-by: Cylen Yao <cylen.yao@mediatek.com>
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 1ffa939..2049706 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -1708,20 +1708,20 @@
}
int VolumeManager::mkdirs(char* path) {
- // Require that path lives under a volume we manage
+ // Require that path lives under a volume we manage and is mounted
const char* emulated_source = getenv("EMULATED_STORAGE_SOURCE");
const char* root = NULL;
if (emulated_source && !strncmp(path, emulated_source, strlen(emulated_source))) {
root = emulated_source;
} else {
Volume* vol = getVolumeForFile(path);
- if (vol) {
+ if (vol && vol->getState() == Volume::State_Mounted) {
root = vol->getMountpoint();
}
}
if (!root) {
- SLOGE("Failed to find volume for %s", path);
+ SLOGE("Failed to find mounted volume for %s", path);
return -EINVAL;
}