Skip to content

Commit 4d12979

Browse files
committed
custom-persist: prefer objets pre-creation in /rw
This commit changes the files and dirs pre-creation path. Instead of pre-create files and dirs directly on the RO file system and let bind_dirs() function populate /rw/bind-dirs, custom-persist creates objects in /rw/bind-dirs like a regular user would do.
1 parent c778254 commit 4d12979

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

vm-systemd/bind-dirs.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,21 +159,24 @@ if is_custom_persist_enabled; then
159159
continue
160160
fi
161161

162+
rw_path="/rw/bind-dirs${path}"
162163
# create resource if it does not exist
163-
if ! [ -e "${path}" ] && ! [ -e "/rw/bind-dirs${path}" ]; then
164+
if ! [ -e "${path}" ] && ! [ -e "$rw_path" ]; then
164165
if [ "$resource_type" = "file" ]; then
165166
# for files, we need to create parent directories
166-
parent_directory="$(dirname "$path")"
167+
parent_directory="$(dirname "$rw_path")"
168+
echo "custom-persist: pre-creating file ${rw_path} with rights ${owner}:${group} ${mode}"
167169
[ -d "$parent_directory" ] || mkdir -p "${parent_directory}"
168-
touch "${path}"
170+
touch "${rw_path}"
169171
elif [ "$resource_type" = "dir" ]; then
170-
mkdir -p "${path}"
172+
echo "custom-persist: pre-creating directory ${rw_path} with rights ${owner}:${group} ${mode}"
173+
mkdir -p "${rw_path}"
171174
else
172175
echo "Invalid entry ${target}, skipping"
173176
continue
174177
fi
175-
chown "$owner":"$group" "${path}"
176-
chmod "$mode" "${path}"
178+
chown "$owner":"$group" "${rw_path}"
179+
chmod "$mode" "${rw_path}"
177180
fi
178181
target="$path"
179182
fi

0 commit comments

Comments
 (0)