summaryrefslogtreecommitdiffstats
path: root/chroot.function
diff options
context:
space:
mode:
Diffstat (limited to 'chroot.function')
-rw-r--r--chroot.function18
1 files changed, 18 insertions, 0 deletions
diff --git a/chroot.function b/chroot.function
new file mode 100644
index 0000000000..5ebb93ed20
--- /dev/null
+++ b/chroot.function
@@ -0,0 +1,18 @@
+#---------------------------------------------------------------------
+## @Synopsis Set of functions for handling chroots
+##
+## @Copyright Source Mage Team
+#---------------------------------------------------------------------
+
+#---------------------------------------------------------------------
+## Determine whether the current environment is a chroot or not.
+##
+## Limitation; the chroot will not be detected if the chroot is using
+## "/" as a mountpoint or if pid 1 itself is the chroot.
+##
+## @return 0 if the current environment is a chroot
+## @return 1 if the current environment is not a chroot
+#---------------------------------------------------------------------
+function is_chroot() {
+ [[ "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ]]
+}