Darryl L. Pierce
2010-Mar-23 15:48 UTC
[Ovirt-devel] Resend of one patch, new to follow on...
The first patch in this set was submitted in January but never ACK'd. The following three are follow on patches to fix other issues that have come up.
Darryl L. Pierce
2010-Mar-23 15:48 UTC
[Ovirt-devel] [PATCH 1/4] Fixed unpersisting directories and persisting directories that contain persisted files.
Resolves: rhbz#556616 Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-functions | 107 ++++++++++++++++++++++++++++++---------------- 1 files changed, 70 insertions(+), 37 deletions(-) diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions index f760b69..ad3f511 100644 --- a/scripts/ovirt-functions +++ b/scripts/ovirt-functions @@ -1,4 +1,4 @@ -# -*-Shell-script-*- +\# -*-Shell-script-*- OVIRT_LOGFILE=/var/log/ovirt.log OVIRT_TMP_LOGFILE=/tmp/ovirt.log @@ -465,28 +465,41 @@ ovirt_store_config() { if grep -q " /config ext3" /proc/mounts; then printf "storing to /config :\n" for p in "$@"; do - f=$(readlink -f $p) - printf "$f" - # skip if file does not exist or is empty - if [ ! -s "$f" ]; then - printf " Skipping, file '%s' does not exist or is empty\n" $p - continue - fi - # skip if already bind-mounted - if ! grep -q " $f ext3" /proc/mounts ; then - mkdir -p /config$(dirname $f) - cp -a $f /config$f \ - && mount -n --bind /config$f $f - if [ $? -ne 0 ]; then - printf " Failed to persist\n" - rc=1 - else - printf " File persisted\n" + local persist_it=true + + # ensure that, if this is a directory + if [ -d $p ]; then + if [ -d /config$p ]; then + persist_it=false fi fi - # register in /config/files used by rc.sysinit - if ! grep -q "^$f$" /config/files 2> /dev/null ; then - printf "$f\n" >> /config/files + + if $persist_it; then + f=$(readlink -f $p) + printf "$f" + # skip if file does not exist or is empty + if [ ! -s "$f" ]; then + printf " Skipping, file '%s' does not exist or is empty\n" $p + continue + fi + # skip if already bind-mounted + if ! grep -q " $f ext3" /proc/mounts ; then + mkdir -p /config$(dirname $f) + cp -a $f /config$f \ + && mount -n --bind /config$f $f + if [ $? -ne 0 ]; then + printf " Failed to persist\n" + rc=1 + else + printf " File persisted\n" + fi + fi + # register in /config/files used by rc.sysinit + if ! grep -q "^$f$" /config/files 2> /dev/null ; then + printf "$f\n" >> /config/files + fi + else + printf "Could not persist $p: it contains an already persisted file.\n" fi done echo @@ -529,13 +542,24 @@ remove_config() { f=$(readlink -f $p) if grep -q " $f ext3" /proc/mounts ; then if umount -n $f; then - if [ -f /config$f ]; then - # refresh the file in rootfs if it was mounted over - cp -a /config$f $f + if [ -d $f ]; then + cp -ar /config/$f/* $f if [ $? -ne 0 ]; then - printf " Failed to unpersist %s\n" $f + printf " Failed to unpersist ${f}\n" + exit 1 else - printf " %s successully unpersisted\n" $f + printf " $f successfully unpersisted\n" + fi + else + if [ -f /config$f ]; then + # refresh the file in rootfs if it was mounted over + cp -a /config$f $f + if [ $? -ne 0 ]; then + printf " Failed to unpersist %s\n" $f + exit 1 + else + printf " %s successully unpersisted\n" $f + fi fi fi fi @@ -557,17 +581,26 @@ remove_config() { # WARNING: file is shredded and removed # ovirt_safe_delete_config() { - if grep -q " /config ext3" /proc/mounts; then - for f in "$@"; do - if grep -q " $f ext3" /proc/mounts ; then - umount -n $f - fi - # unregister in /config/files used by rc.sysinit - sed --copy -i "\|^$f$|d" /config/files - shred -u /config$f - done - fi - shred -u $f + local target + + for target in "$@"; do + if grep -q " $target ext3" /proc/mounts; then + umount -n $target + fi + + sed --copy -i "\|$target$|d" /config/files + + if [ -d $target ]; then + for child in $(ls -d $target/*); do + ovirt_safe_delete_config $child + done + rm -rf /config$target + rm -rf $target + else + shred -u /config$target + shred -u $target + fi + done } -- 1.6.6.1
Possibly Parallel Threads
- [PATCH] Ensures that persist and unpersist work with relative paths.
- [PATCH] Fixed unpersisting directories and persisting directories that contain persisted files.
- [PATCH node] updated unpersist prompts bz512539
- [PATCH node] REPOST Joey's and Darryl's ovirt-config-* patches
- [PATCH node] o-c-config will only run when local storage is configured. rhbz#505560