ref: 52c766d0264b281bac522604c5ab419b3303ed63
parent: 19535ffd6a03602cf0fcb4d78a2a89c4f494d859
author: Tevo <estevan.cps@gmail.com>
date: Thu Sep 3 22:16:56 EDT 2020
Create RAM-backed mountpoint when directory doesn't exist
--- a/overlay
+++ b/overlay
@@ -1,4 +1,5 @@
-#!/bin/rc
+#!/bin/rc -e
+# Overlays a directory tree over another
fn usage {
echo usage: $0 [-u] source target >[1=2]
@@ -24,14 +25,19 @@
usage
files=`{walk -f $source}
-mtpts=`{for(file in $files) basename -d $file | sed s@$source@$target@g}
+mtpts=`{{for(file in $files) basename -d $file} | sort | uniq | sed 's@^'$source@$target@g}
for(mtpt in $mtpts)
switch($mode) {
case bind
- bind -cq $mtpt $mtpt || status=''
+ if(test -d $mtpt)
+ bind -cq $mtpt $mtpt || status=''
+ if not { # This might not be desirable
+ aux/stub -d $mtpt
+ ramfs -m $mtpt
+ }
case unbind
- unmount $mtpt >/dev/null >[2=1] || status=''
+ unmount $mtpt >/dev/null >[2=1] || status=''
}
if(~ $mode bind)
@@ -42,4 +48,3 @@
}
if not
status=''
-