+ else
+ DEST="${SNAP_OUTPUT}"
+ fi
+}
+
+Validate_input ()
+{
+ case "${SNAP_TYPE}" in
+ cpio|squashfs|jffs2|ext2|ext3)
+ ;;
+
+ *)
+ Error "invalid filesystem type \"${SNAP_TYPE}\""
+ ;;
+ esac
+
+ if [ ! -d "${SNAP_COW}" ]
+ then
+ Error "${SNAP_COW} is not a directory"
+ fi
+
+ if [ "$(id -u)" -ne 0 ]
+ then
+ Error "you are not root"
+ fi
+}
+
+Mount_device ()
+{
+ case "${SNAP_DEV}" in
+ "")
+ # create a temp
+ mount -t tmpfs -o rw tmpfs "${MOUNTP}"
+ ;;
+
+ *)
+ if [ -b "${SNAP_DEV}" ]
+ then
+ try_mount "${SNAP_DEV}" "${MOUNTP}" rw
+ fi
+ ;;
+ esac
+}
+
+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