summaryrefslogtreecommitdiff
path: root/init/mount_namespace.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'init/mount_namespace.cpp')
-rw-r--r--init/mount_namespace.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/init/mount_namespace.cpp b/init/mount_namespace.cpp
index ec48cde02..15252a622 100644
--- a/init/mount_namespace.cpp
+++ b/init/mount_namespace.cpp
@@ -301,5 +301,20 @@ Result<void> SwitchToMountNamespaceIfNeeded(MountNamespace target_mount_namespac
return {};
}
+base::Result<MountNamespace> GetCurrentMountNamespace() {
+ std::string current_namespace_id = GetMountNamespaceId();
+ if (current_namespace_id == "") {
+ return Error() << "Failed to get current mount namespace ID";
+ }
+
+ if (current_namespace_id == bootstrap_ns_id) {
+ return NS_BOOTSTRAP;
+ } else if (current_namespace_id == default_ns_id) {
+ return NS_DEFAULT;
+ }
+
+ return Error() << "Failed to find current mount namespace";
+}
+
} // namespace init
} // namespace android