summaryrefslogtreecommitdiffstats
path: root/chroot.function
blob: 5ebb93ed20ad25c8429981ed2e79d580c8bb846c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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/.)" ]]
}