+Entry_is_modified ()
+{
+ # Returns true if file exists and it is also present in "cow" directory
+ # This means it is modified in respect to read-only media, so it deserve
+ # to be saved
+
+ entry="${1}"
+
+ if [ -e "${entry}" ] || [ -L "${entry}" ]
+ then
+ if [ -e "${DEF_SNAP_COW}/${entry}" ] || [ -L "${DEF_SNAP_COW}/${entry}" ]
+ then
+ return 0
+ fi
+ fi
+ return 1
+}
+
+Do_filelist ()
+{
+ # BUGS: supports only cpio.gz types, and does not handle deleted files yet
+
+ TMP_FILELIST=$1
+ if [ -f "${SNAP_LIST}" ]
+ then
+ # Generate include list removing empty and commented lines
+ for entry in $(sed -e '/^ *$/d' -e '/^#.*$/d' "${SNAP_LIST}")
+ do
+ if [ -d "${entry}" ]
+ then
+ cd /
+ find "${entry}" | while read line
+ do
+ if Entry_is_modified "${line}"
+ then
+ printf "%s\000" "${line}" >> "${TMP_FILELIST}"
+ fi
+ done
+ cd "${OLDPWD}"
+ elif Entry_is_modified "${entry}"
+ then
+ # if file exists and it is modified
+ printf "%s\000" "${entry}" >> "${TMP_FILELIST}"
+ fi
+ done
+
+ if [ "${SNAP_COW}" = "${DEF_SNAP_COW}" ]
+ then
+ # Relative to rootfs
+ echo "/"
+ else
+ # Mostly "/home"
+ echo "${SNAP_COW}"
+ fi
+ else
+ cd "${SNAP_COW}"
+ find . -path '*.wh.*' -prune -o -print0 >> "${TMP_FILELIST}"
+ cd "${OLDPWD}"
+ echo "${SNAP_COW}"
+ fi
+}
+