summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilton D. Miller II <miltonm@us.ibm.com>2016-02-29 21:34:43 -0600
committerMilton D. Miller II <miltonm@us.ibm.com>2016-03-04 10:51:05 -0600
commita987d621d8ddc54cdf32c5f69c8e9873f0c3a199 (patch)
treebed0b702b57f1205f136fe0877f8836b25a20a45
parentc3697de01b798f1ed69652d8463a355e6b9534cd (diff)
downloadtalos-openbmc-a987d621d8ddc54cdf32c5f69c8e9873f0c3a199.tar.gz
talos-openbmc-a987d621d8ddc54cdf32c5f69c8e9873f0c3a199.zip
update: Save whitelist files from RAM or mounted read-write filesystem
Skip mounting and unmounting the read-write file system when saving files if the upper directory exists. Instead interpret this as a sign the system either is or was running from RAM (or from some future alternative and maybe temporary mounted file system) and save the files from that upper directory. It is possible some other filesystem is mounted on the read-write mountpoint that is not a mtd device, either a tmpfs or some other future media, so only try to unmount the file system if this update script mounted it. Each boot an empty /run filesytem is created and populated by init with selected directories and mount points for the read-only and read-write file systems and mounts them on these points. The upper directory is under the read-write mount point, so if it exists then either a file system is mounted there or the system was prepared to run from RAM using the run tmpfs file system and updates may have been made there. In either case the files to be saved exist in that directory. Background on overlayfs: The upper directory contains files and directory entries that were either opened for write or had meta data changed. Before this happens the overlayfs copies each file or directory by name into the work directory then atomically moves it into the corresponding upper directory. To form a read-write overlayfs mount, the upper directory must be, by definition, in a read-write file system along with the work directory, and both are required to be in the same filesystem. Signed-off-by: Milton Miller <miltonm@us.ibm.com>
-rwxr-xr-xmeta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
index e58056109..6f265502a 100755
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
@@ -59,6 +59,7 @@ rwdir=/run/initramfs/rw
upper=$rwdir/cow
save=/run/save/${upper##*/}
+mounted=
doclean=
dosave=y
dorestore=y
@@ -93,10 +94,14 @@ do
esac
done
-if test "x$dosave" = xy -a -n "$rwfs"
+if test "x$dosave" = xy
then
- mkdir -p $rwdir
- mount $rwdev $rwdir -t $(probe_fs_type $rwdev) -o $rorwopts
+ if test ! -d $upper -a -n "$rwfs"
+ then
+ mkdir -p $rwdir
+ mount $rwdev $rwdir -t $(probe_fs_type $rwdev) -o $rorwopts
+ mounted=$rwdir
+ fi
while read f
do
@@ -109,7 +114,10 @@ then
cp -rp $upper/$f "${d%/*}/"
done < $whitelist
- umount $rwdir
+ if test -n "$mounted"
+ then
+ umount $mounted
+ fi
fi
for f in $image*
OpenPOWER on IntegriCloud