From e140506af35821857a47c1013bad03b12f31062d Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 6 Dec 2017 14:38:44 +0100 Subject: tests: use flock to modify fstab Note that for btrfs test we need to use low-level ts_fstab_addline, because we add multiple lines there. Signed-off-by: Karel Zak --- tests/functions.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/functions.sh') diff --git a/tests/functions.sh b/tests/functions.sh index 0409b6283..181fe7972 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -628,6 +628,7 @@ function ts_fstab_open { function ts_fstab_close { echo "# -->" >> /etc/fstab + sync /etc/fstab } function ts_fstab_addline { @@ -639,7 +640,12 @@ function ts_fstab_addline { echo "$SPEC $MNT $FS $OPT 0 0" >> /etc/fstab } +function ts_fstab_lock { + ts_lock "fstab" +} + function ts_fstab_add { + ts_fstab_lock ts_fstab_open ts_fstab_addline $* ts_fstab_close @@ -655,6 +661,9 @@ function ts_fstab_clean { } s/# //; /^$/d" /etc/fstab + + sync /etc/fstab + ts_unlock "fstab" } function ts_fdisk_clean { @@ -694,7 +703,7 @@ function ts_lock { # Note that flock(2) lock is released on FD close. function ts_unlock { - 200<&- + 200<&- || : } function ts_scsi_debug_init { -- cgit v1.2.3-55-g7522