From 16bfe4de7ebc651854fd66939a84c6af8ee81af2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 13 Dec 2022 15:42:45 +0100 Subject: global-functions: $MkDir: create a tmpfs (RAM disk)... ... if the path starts with "tmpfs/". This helps to mitigate flash wear. --- global-functions | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/global-functions b/global-functions index 9ff6bd5..a9c1c93 100644 --- a/global-functions +++ b/global-functions @@ -525,6 +525,7 @@ :global CleanFilePath; :global GetRandom20CharAlNum; :global LogPrintExit2; + :global RequiredRouterOS; :global WaitForFile; :set Path [ $CleanFilePath $Path ]; @@ -547,6 +548,15 @@ :set Continue true; } + :if ($Continue = false && $PathNext = "tmpfs" && [ $RequiredRouterOS $0 "7.7rc1" false ] = true) 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" ]; + [ :parse "/disk/add slot=tmpfs type=tmpfs;" ]; + } + :set Continue true; + } + :if ($Continue = false && [ :len [ /file/find where name=$PathNext ] ] = 1) do={ $LogPrintExit2 warning $0 ("The path '" . $PathNext . "' exists, but is not a directory.") false; :return false; -- cgit v1.2.3-54-g00ecf