#!/bin/sh
# VIVER Error Messages
# Copyright (C) 2005-2006 Furuhashi Sadayuki
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

# limit = 122 characters

# display the error message and suggest the repairing method.
# $1 = action which causes the error
# $2 = error code
errormsg()
{
	local code=$2
	case "$1" in
		mount_proc_sys)
		if [ $(expr $code - 2) -ge 0 ];then
			echo "Can't mount sys filesystem."
			code=$(expr $code - 2)
		fi
		if [ $(expr $code - 1) -ge 0 ];then
			echo "Can't mount proc filesystem."
		fi
		;;
		#parse_command_line
		#set_params

		mount_module)
# ⥸塼ǥޥȤǤޤ
# VIVERư˽פʥǡ»ƤޤäΤ⤷ޤ
# PXEǵưƤϡǡžޤäƤޤ󡣺ƵưƤߤƤ
# ʪǥ鵯ưƤϡǥΥ顼ΤƤ
		echo "Can't mount the module disk.
It is probably that essensial data of VIVER is broken.
If it is booting from PXE, transmission of the data went wrong. Try boot again.
If it is booting from physical disk such as CD-ROM, check the error of the disk"
		;;
		
		load_drivers)
		# load_drivers always returns 0
		echo ""
		;;

		mknoah)
# ѤRAMǥޥȤǤޤ
# ۤȤɤξ硢Υ顼ϻѤǤ­Ǥ
# ɬǽƤ뤫ǧƤ
		echo "Can't mount the work space RAM disk.
Mostly this error is caused by shortage of the available size of RAM.
Make sure that required spec is satisfied."
		;;

		do_hwsetup)
		# hwsetupλǤޤ
		# nohwsetup֡ȥѥ᡼ꤷƺƵưƤߤƤ
		echo "Can't complete hwsetup."
		echo "Try to boot again with 'nohwsetup' parameter."

		;;

		wake_network)
# ͥåȥưǤޤ
# ʲȲͤޤ
# * DHCPС¸ߤʤ
#   ʪǥ鵯ưƤϡ꤬ͤޤ
#   DHCPСåȥåפ뤫staticip=֡ȥѥ᡼ꤷƺƵưƤ
# * ɥ饤ФưȽ̤Ǥʤ
#   ɥ饤Ф̾modprobe=֡ȥѥ᡼ǻꤷƺƵưƤ
#   e.g. modprobe=ne2k-pci
#   ưȽ̤ɥ饤Фΰ򸫤ˤϡlsmodȥפƤ
# * ͥåȥ³줿ͥåȥ󥿡եǽΥ󥿡եǤϤʤ
#   ʣΥͥåȥ󥿡եԥ塼ܤƤ硢³ߤΤϰֺǽΥ󥿡եǤ
#   ʣΥͥåȥ󥿡եܤƤϡnetdev=eth1֡ȥѥ᡼ꤷƺƵưƤߤƤ
#   e.g.  netdev=eth1
		echo "Can't wake up the network.
Following problems and solutions are conceivable.
 * There is no a DHCP server in the network
   If it is booting from physical disk such as CD-ROM, this probrem is conceivable.
   Set up DHCP server correctly or specify 'staticip=' boot parameter and then reboot.
   e.g. staticip=192.168.10.3
 * Can't detect the driver of the network interface automatically
   Specify the name of the driver of the network interface with 'modprobe=' boot parameter.
   e.g. modprobe=ne2k-pci
   To see the list of the drivers that are detected automatically, type 'lsmod'.
 * The network interface that is connected to the network is not the first interface
   The computer has more than one network interfaces, the first one is tried to connect.
   If the computer has more than one network interfaces, specify 'netdev=' boot parameter and reboot.
   e.g. netdev=eth1 (second interface)  or  netdev=eth2 (third interface)  ..."
		;;


		mount_cow)
		# Copy-on-WriteǥХޥȤǤޤ
		echo "Can't mount the Copy-on-Write device."
		case $code in
			1)
# $cowkeyޤCopy-on-WriteǥХĤޤ
# cowkey=֡ȥѥ᡼ǧƤ
# ޤϡ$cowkeyޤCopy-on-WriteǥХ$cowfsΤ줫Υե륷ƥǥեޥåȤƤʤǽޤ
# cowfs=֡ȥѥ᡼ꤷƺƵưƤߤƤ
# e.g cowfs=ntfs
			echo "Can't find the Copy-on-Write device that contains $cowkey.
Make sure the 'cowkey=' boot parameter is correct.
Otherwise possibly the Copy-on-Write device that contains $cowkey is formatted by none of $cowfs
filesystems.
Try to specify 'cowfs=' boot parameter and reboot.
e.g. cowfs=ntfs"
			;;
			2|3)
# Copy-on-WriteǥХɤ߽񤭥⡼ɤǥޥȤǤޤ
# Copy-on-WriteǥХϻѤ뤳ȤǤޤ
			echo "Can't mount the detected Copy-on-Write device as Read-Write mode.
This Copy-on-Write device can't be used."
			;;
			4)
# $cowkeyޥȤǤޤ
# ¿ξ硢֤$cowkey$cowkeyfsե륷ƥǥեޥåȤƤʤȤǤ
# $cowkey$cowkeyfsǥեޥåȤ뤫$cowkeyΥե륷ƥcokeyfs=֡ȥѥ᡼ǻꤷƤ
# e.g. cowkeyfs=xfs
# $cowkey롼ץХåޥȤCopy-on-WriteǥХľCopy-on-WriteڡȤƻѤϡ'directcow'֡ȥѥ᡼ꤷƤ
			echo "Can't mount $cowkey.
Mostly this error is caused by that $cowkey is not formatted by $cokeyfs.
Format $cowkey by $cowkeyfs or specify the file system of the $cowkey with 'cowkeyfs=' boot parameter
and reboot.
e.g. cowkeyfs=xfs
If you want to use the Copy-on-Write device as the Copy-on-Write space directly without loopback mounting $cowkey,
specify 'directcow' boot parameter."
			;;
		esac
		;;

		mount_tmp)
		# tmpfsCopy-on-WriteڡȤƥޥȤǤޤ
		echo "Can't mount the tmpfs as Copy-on-Write space."
		;;


		mount_disk)
# 롼ȥǥޥȤǤޤ
# ͥåȥ֡Ȥϡrootserver=֡ȥѥ᡼ꤷƤ
# 롼ȥǥ³ˤäƤϡusbieee1394pcmciasatascsi֡ȥѥ᡼ꤹɬפޤ
# 뤤ϡ롼ȥǥ$diskfsΤ줫Υե륷ƥǥեޥåȤƤʤǽޤ
# diskfs=֡ȥѥ᡼ꤷƤߤƤ
# e.g. diskfs=vfat
# ⤷嵭Τ褦ʥ֡ȥѥ᡼ꤷƤ⥨顼ȯϡVIVERΥԥ塼Υϡɥ򥵥ݡȤƤޤ
		echo "Can't mount the root disk.
Specify 'rootserver=' boot parameter if you want to boot from network.
Depending on the connection of the root disk, you may hove to specify 'usb', 'ieee1394', 'pcmcia', 'sata' or 'scsi' boot
parameter.
Otherwise, possibly the root disk is formatted by none of $diskfs filesystems. Try to specify 'diskfs=' boot
parameter.
e.g. diskfs=vfat
If you get an error even if you specify these boot parameters, VIVER does not support your hardware."
		;;

		connect_rootserver)
		# NBD³ΩǤޤ
		# 'rootserver='֡ȥѥ᡼ְäƤ뤫ꤵ줿СưƤޤ
		echo "Can't establish the NBD connection."
		echo "'rootserver=' is wrong or the specified server isn't working correctly."
		;;

		map_crypt)
# 롼ȥե륷ƥΰŹ沽뤳ȤǤޤ
# ۤȤɤξ硢ѥɤְäƤ뤳ȤǤ
# password=֡ȥѥ᡼ꤷľƺƵưƤ
# 롼ȥե륷ƥबŹ沽Ƥʤϡpassword=֡ȥѥ᡼ꤷƤ
		echo "Can't unlock crypted root filesystem.
Mostly this error is caused by the error of the password.
Try to reboot with the correct 'password=' boot parameter.
If the root filesystem is not crypted, specify the empty 'password=' bootparameter."
		;;

		toram)
		# 롼ȥե륷ƥRAM˥ԡǤޤ
		# ۤȤɤξ硢Copy-on-Writeڡ­Ǥ
		echo "Can't copy root filesystem to RAM."
		echo "Mostly this error was caused by the insufficiency of the size of Copy-on-Write space."
		if [ -n "$cowkey" -a -n "$directcow" ];then
			# ̤礭Copy-on-WriteǥХѤƤ
			echo "Use a larger Copy-on-Write device."
		elif [ -n "$cowkey" -a -z "$directcow" ];then
			# ̤礭cowkey֤Ƥ
			# ޤϡdirectcow֡ȥѥ᡼ꤷľCopy-on-WriteǥХCopy-on-WriteڡȤƻѤƤ
			echo "Set a larger cowkey."
			echo "Othersise specify 'directcow' boot parameter to use the Copy-on-Write device as a Copy-on-Write space directly without"
			echo "loopback mounting $cowkey."
		else
			# 礭ʿͤramsize=֡ȥѥ᡼˻ꤷƤ
			# e.g. ramsize=1024
			# ⤷'Specified ramsize is too large'ȤåɽƤ顢̤ʪŪ­Ƥޤ
			# toram֡ȥѥ᡼ꤻ˺ƵưƤ
			echo "Set larger figure for 'ramsize=' boot paramter."
			echo "e.g. ramsize=1024"
			echo "If you has got 'Specified ramsize is too large' message, the size of the memory is physically insufficient."
			echo "Reboot without 'toram' boot paramter."
		fi
		;;

		mount_squash)
# ̤줿롼ȥե륷ƥޥȤǤޤ
# 롼ȥե륷ƥκ˥顼ȯƤǽ⤤Ǥ
# 롼ȥե륷ƥľƤ
		echo "Can't mount the compressed root filesystem.
Some errors are probably caused during making the root filesystem.
Remake the root filesystem."
		;;

		linearize_root)
# ʬ롼ȥե륷ƥǤޤ
# 롼ȥե륷ƥκ˥顼ȯƤǽ⤤Ǥ
# 롼ȥե륷ƥľƤ
		echo "Can't linearize the splited root filesystem.
Some errors are probably caused during making the root filesystem.
Remake the root filesystem."
		;;

		map_cow)
		# Copy-on-Writeե롼ȥե륷ƥ˽Ťͤޤ
		echo "Can't put the Copy-on-Write file on the top of the root filesystem."
		if [ -n "$cowkey" ];then
			# $cowkeyƤ뤫롼ȥե륷ƥľ˻ѤǤʤʤäƤޤ
			# $cowkeyľƤ
			echo "$cowkey is broken or the root filesystem is remade."
			echo "Remake $cowkey."
		fi
		;;

		mount_root)
# 롼ȥե륷ƥޥȤǤޤ
# 롼ȥե륷ƥκ˥顼ȯƤǽ⤤Ǥ
# 롼ȥե륷ƥľƤ
		echo "Can't mount the root filesystem.
Some errors are probably caused during making the root filesystem.
Remake the root filesystem."
		;;

		find_swap)
		# find_swap always returns 0
		echo ""
		;;

		edit_fs)
		# edit_fs always returns 0
		echo ""
		;;

		move_mtpoint)
		echo "Can't move the mountpoint."
		echo "Please reboot."
		;;

		umount_module)
		echo "Can't unmount the module disk."
		;;

		do_pivot_root)
		echo "Can't move root filesystem."
		;;

		bootrc)
		# bootrc always returns 0
		echo ""
		;;

	esac
}
