aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-03-25 21:27:24 +0100
committerGravatar Christian Hesse <mail@eworm.de>2023-03-28 12:05:47 +0200
commitd3ca5063947f4350721cfe1828faae2cd771f133 (patch)
treee4a0c1caab59634b8d91193cb1d958881bf3286c
parent7293306f76b638f8ca94e9916e92389aed34b770 (diff)
global-functions: $MkDir: create tmpfs in local function
-rw-r--r--global-functions.rsc32
1 files changed, 22 insertions, 10 deletions
diff --git a/global-functions.rsc b/global-functions.rsc
index ffe9a4b..2eb0416 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -560,6 +560,26 @@
:global LogPrintExit2;
:global WaitForFile;
+ :local MkTmpfs do={
+ :global LogPrintExit2;
+ :global WaitForFile;
+
+ :if ([ :len [ /disk/find where slot=tmpfs type=tmpfs ] ] = 1) do={
+ :return true;
+ }
+
+ $LogPrintExit2 info $0 ("Creating disk of type tmpfs.") false;
+ /file/remove [ find where name="tmpfs" type="directory" ];
+ :do {
+ /disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource/get total-memory ] / 3);
+ $WaitForFile "tmpfs";
+ } on-error={
+ $LogPrintExit2 warning $0 ("Creating disk of type tmpfs failed!") false;
+ :return false;
+ }
+ :return true;
+ }
+
:set Path [ $CleanFilePath $Path ];
:if ($Path = "") do={
@@ -581,16 +601,8 @@
}
:if ($Continue = false && $PathNext = "tmpfs") do={
- :if ([ :len [ /disk/find where slot=tmpfs type=tmpfs ] ] = 0) do={
- $LogPrintExit2 info $0 ("Creating disk of type tmpfs.") false;
- /file/remove [ find where name="tmpfs" type="directory" ];
- :do {
- /disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource/get total-memory ] / 3);
- $WaitForFile "tmpfs";
- } on-error={
- $LogPrintExit2 warning $0 ("Creating disk of type tmpfs failed!") false;
- :return false;
- }
+ :if ([ $MkTmpfs ] = false) do={
+ :return false;
}
:set Continue true;
}