[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Patch] Allow specific ordering of images in /casper directory



This patch causes casper to mount images in the /casper directory in
alpha-numeric order, rather than in the previously undefined,
psuedo-arbitrary order.  It also adds support for an optional config
file, /casper/order.lst, to define a specific order to load images (and
to omit any images not listed in this file).

The later an image appears in the alpha-numeric list, or in order,lst,
the "higher" it will be unionfs order.

I created this patch to allow for the use of an incrimental snapshot
scenario. In our setup, our base filesystem will remain unchanged, and
config changes will be written to incrimental squashfs images.  Using
this patch, it is now possible to use image names such as 00_base.dir,
01_update.squashfs 02_update.squashfs, etc, and the config changes will
be applied in the unionfs in the proper order.  And by using the
order.lst file, it is possible to specify a non-alpha-numeric order, and
it is also becomes possible to exclude ceritan images from the unionfs
without explicitly removing them from the /casper directory.


diff -ru casper-1.79+debian/debian/manpage/casper.7 casper-1.79
+debian3/debian/manpage/casper.7
--- casper-1.79+debian/debian/manpage/casper.7  2007-02-06
14:45:32.000000000 -0600
+++ casper-1.79+debian3/debian/manpage/casper.7 2007-02-06
16:47:52.000000000 -0600
@@ -66,6 +66,9 @@
 .SH FILES
 .B /etc/casper.conf
 some variables can be configured via this config file.
+.TP
+.B /casper/order.lst
+This optional file contains a list of white-space- or
carriage-return-separated file names corresponding to disk images in
the /casper directory. If this file exists, only image
s listed here will be merged into the root unionfs, and they will be
loaded in the order listed here. The first entry in this file will be
the "lowest" point in the unionfs, and
the last file in this list will be on the "top" of the unionfs, directly
below /cow.  Without this file, any images in the /casper directory are
loaded in alphanumeric order.

 .SH BUGS
 .B casper
diff -ru casper-1.79+debian/scripts/casper casper-1.79
+debian3/scripts/casper
--- casper-1.79+debian/scripts/casper   2007-02-06 14:45:32.000000000
-0600
+++ casper-1.79+debian3/scripts/casper  2007-02-06 16:44:01.000000000
-0600
@@ -403,10 +403,27 @@
     else
         roopt="ro"
     fi
+
+    # Read image names from order.lst if it exists
+    if [ -e "${image_directory}/order.lst" ]; then
+        for image in $(cat "${image_directory}/order.lst"); do
+            image_string="${image_string} ${image_directory}/${image}";
+        done
+    else
+    # If order.lst does not exist, create a list of images
+        for image_type in "ext2" "squashfs" "dir"; do
+            for image in "${image_directory}"/*."${image_type}"; do
+                image_string="${image_string} ${image}";
+            done
+        done
+        # Now sort the list
+        image_string=$(ls ${image_string} | sort)
+    fi

     mkdir -p "${croot}"
-    for image_type in "ext2" "squashfs" "dir" ; do
-        for image in "${image_directory}"/*."${image_type}"; do
+#    for image_type in "ext2" "squashfs" "dir" ; do
+#        for image in "${image_directory}"/*."${image_type}"; do
+         for image in ${image_string}; do
             imagename=$(basename "${image}")
             if [ -d "${image}" ]; then
                 # it is a plain directory: do nothing
@@ -422,7 +439,7 @@
                 mount -t "${fstype}" -o ro "${backdev}"
"${croot}/${imagename}" || panic "Can not mount $backdev ($image) on
${croot}/${imagename}" && rofsstring="${croot}/${ima
gename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename}
${rofslist}"
             fi
         done
-    done
+#    done
     rofsstring=${rofsstring%:}

     mkdir -p /cow




Reply to: