summaryrefslogtreecommitdiffstats
path: root/Utils.cpp
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2015-06-24 11:49:24 -0700
committerJeff Sharkey <jsharkey@android.com>2015-06-25 22:40:08 -0700
commit66270a21df1058434e4d63691221f11ff5387a0f (patch)
tree66f125787af5957b3a8cbaf862c6c1c1b2445b1b /Utils.cpp
parent5d268fdac49bd3174a7f0c6dbb042162ae87a695 (diff)
downloadandroid_system_vold-66270a21df1058434e4d63691221f11ff5387a0f.tar.gz
android_system_vold-66270a21df1058434e4d63691221f11ff5387a0f.tar.bz2
android_system_vold-66270a21df1058434e4d63691221f11ff5387a0f.zip
Let's reinvent storage, yet again!
Now that we're treating storage as a runtime permission, we need to grant read/write access without killing the app. This is really tricky, since we had been using GIDs for access control, and they're set in stone once Zygote drops privileges. The only thing left that can change dynamically is the filesystem itself, so let's do that. This means changing the FUSE daemon to present itself as three different views: /mnt/runtime_default/foo - view for apps with no access /mnt/runtime_read/foo - view for apps with read access /mnt/runtime_write/foo - view for apps with write access There is still a single location for all the backing files, and filesystem permissions are derived the same way for each view, but the file modes are masked off differently for each mountpoint. During Zygote fork, it wires up the appropriate storage access into an isolated mount namespace based on the current app permissions. When the app is granted permissions dynamically at runtime, the system asks vold to jump into the existing mount namespace and bind mount the newly granted access model into place. Bug: 21858077 Change-Id: Iade538e4bc7af979fe20095f74416e8a0f165a4a
Diffstat (limited to 'Utils.cpp')
-rw-r--r--Utils.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Utils.cpp b/Utils.cpp
index 2ccd45f..ec9c906 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -522,5 +522,15 @@ std::string BuildKeyPath(const std::string& partGuid) {
return StringPrintf("%s/expand_%s.key", kKeyPath, partGuid.c_str());
}
+dev_t GetDevice(const std::string& path) {
+ struct stat sb;
+ if (stat(path.c_str(), &sb)) {
+ PLOG(WARNING) << "Failed to stat " << path;
+ return 0;
+ } else {
+ return sb.st_dev;
+ }
+}
+
} // namespace vold
} // namespace android