+}
+
+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
+}
+
+Do_filelist ()
+{
+ # BUGS: supports only cpio.gz types right now
+ TMP_FILELIST=$1
+ if [ -f "${SNAP_LIST}" ]
+ then
+ # Generate include list
+ for entry in $(cat "${SNAP_LIST}" | grep -v '^#.*$' | grep -v '^ *$')
+ do
+ if [ -f "${entry}" ]
+ then
+ printf "%s\000" "${entry}" >> "${TMP_FILELIST}"
+ elif [ -d "${entry}" ]
+ then
+ cd /
+ find "${entry}" -print0 >> "${TMP_FILELIST}"
+ cd "${OLDPWD}"
+ fi
+ done