diff options
author | Jonathan Bauer | 2018-04-10 15:10:37 +0200 |
---|---|---|
committer | Jonathan Bauer | 2018-04-10 15:10:37 +0200 |
commit | 7209b23fb01fd35f6aab2f9e1323efa37eddb823 (patch) | |
tree | 78c47e55dc549ac11c22b6962813e327dc29ad0b /core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc | |
parent | [slx-issue] support for SLX_PXE_NETIF (diff) | |
download | mltk-7209b23fb01fd35f6aab2f9e1323efa37eddb823.tar.gz mltk-7209b23fb01fd35f6aab2f9e1323efa37eddb823.tar.xz mltk-7209b23fb01fd35f6aab2f9e1323efa37eddb823.zip |
[run-virt] check for /tmp/virt not in RAM
to cater for usecases where /tmp is in RAM but /tmp/virt is backed by,
e.g., an NFS (Ramboz)
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc')
-rw-r--r-- | core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc index 30676152..2336718a 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc @@ -468,3 +468,21 @@ clean_string() { tr '[A-Z]' '[a-z]' | tr -d -c '[a-z0-9\-]' fi } + +# Helper to check whether given directory resides in RAM, either +# by being mounted as tmpfs or not mounted at all in which case +# we assume the same. Returns 0 if so, 1 otherwise. +dir_on_tmpfs() { + local current_dir="$1" + while [ -n "$current_dir" ]; do + local mount_line="$(awk -v dir="$current_dir" '$2 == dir' /proc/mounts)" + if [ -z "$mount_line" ]; then + # check its parent directory + current_dir="${current_dir%/*}" + continue + fi + [ "x$(cut -d' ' -f3 <<< ${mount_line})" == "xtmpfs" ] + return $? + done + return 0 +} |