From 7209b23fb01fd35f6aab2f9e1323efa37eddb823 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 10 Apr 2018 15:10:37 +0200 Subject: [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) --- .../run-virt-includes/vmchooser_runvirt_functions.inc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc') 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 +} -- cgit v1.2.3-55-g7522