Versión 1.0.2: función {{{ogCheckFs}}} solo devuelve errores de ejecución e ignora los códigos de salida de comprobación de sistema de archivos; función {{{ogFormatFs}}} inicia partición de swap.

git-svn-id: https://opengnsys.es/svn/branches/version1.0@2314 a21b9725-9963-47de-94b9-378ad31fedc9
remotes/github/debian-pkg
ramon 2011-09-23 08:25:11 +00:00
parent 0084b423a4
commit 1616b6ece0
1 changed files with 28 additions and 23 deletions

View File

@ -21,34 +21,38 @@
#@note Requisitos: *fsck*
#@warning No se comprueban sistemas de archivos montados o bloqueados.
#@todo Definir salidas.
#@version 0.9 - Primera adaptación para OpenGNSys.
#@version 0.9 - Primera adaptación para OpenGnSys.
#@author Ramon Gomez, ETSII Universidad de Sevilla
#@date 2009-10-07
#@version 1.0.2 - Ignorar códigos de salida de comprobación (no erróneos).
#@author Ramon Gomez, ETSII Universidad de Sevilla
#@date 2011-09-23
#*/
function ogCheckFs ()
{
# Variables locales.
local PART TYPE PROG PARAMS
local PART TYPE PROG PARAMS CODES
#/// Error si no se reciben 2 parámetros.
# Error si no se reciben 2 parámetros.
[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
#/// Obtener partición.
# Obtener partición.
PART="$(ogDiskToDev $1 $2)" || return $?
TYPE=$(ogGetFsType $1 $2)
case "$TYPE" in
EXT[234]) PROG="e2fsck" ;;
REISERFS) PROG="reiserfsck"; PARAMS="<<<\"Yes\"" ;;
JFS) PROG="fsck.jfs" ;;
EXT[234]) PROG="e2fsck"; CODES="1|2" ;;
REISERFS) PROG="fsck.reiserfs"; PARAMS="<<<\"Yes\""; CODES="1|2" ;;
REISER4) PROG="fsck.reiser4"; PARAMS="-ay" ;;
JFS) PROG="fsck.jfs"; CODES="1|2" ;;
XFS) PROG="fsck.xfs" ;;
NTFS|HNTFS) PROG="ntfsfix" ;;
FAT32|HFAT32) PROG="dosfsck"; PARAMS="-a" ;;
FAT16|HFAT16) PROG="dosfsck"; PARAMS="-a" ;;
FAT12|HFAT12) PROG="dosfsck"; PARAMS="-a" ;;
FAT32|HFAT32) PROG="dosfsck"; PARAMS="-a"; CODES="1" ;;
FAT16|HFAT16) PROG="dosfsck"; PARAMS="-a"; CODES="1" ;;
FAT12|HFAT12) PROG="dosfsck"; PARAMS="-a"; CODES="1" ;;
*) ogRaiseError $OG_ERR_PARTITION "$1, $2, $TYPE"
return $? ;;
return $? ;;
esac
#/// Error si el sistema de archivos esta montado o bloqueado.
# Error si el sistema de archivos esta montado o bloqueado.
if ogIsMounted $1 $2; then
ogRaiseError $OG_ERR_PARTITION "$1 $2" # Indicar nuevo error
return $?
@ -57,14 +61,14 @@ if ogIsLocked $1 $2; then
ogRaiseError $OG_ERR_LOCKED "$1 $2"
return $?
fi
#/// Comprobar en modo uso exclusivo.
# Comprobar en modo uso exclusivo.
ogLock $1 $2
eval $PROG $PARAMS $PART
ERRCODE=$?
case $ERRCODE in
0) ;;
127) ogRaiseError $OG_ERR_NOTEXEC "$PROG" ;;
*) ogRaiseError $OG_ERR_PARTITION "$1 $2" ;;
0|$CODES) ;;
127) ogRaiseError $OG_ERR_NOTEXEC "$PROG" ;;
*) ogRaiseError $OG_ERR_PARTITION "$1 $2" ;;
esac
ogUnlock $1 $2
return $ERRCODE
@ -93,20 +97,20 @@ function ogExtendFs ()
# Variables locales.
local PART PROG PARAMS
#/// Si se solicita, mostrar ayuda.
# Si se solicita, mostrar ayuda.
if [ "$*" == "help" ]; then
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
"$FUNCNAME 1 1"
return
fi
#/// Error si no se reciben 2 parámetros.
# Error si no se reciben 2 parámetros.
[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
#/// Obtener partición.
# Obtener partición.
PART="$(ogDiskToDev $1 $2)" || return $?
ogUnmount $1 $2 2>/dev/null
#/// Redimensionar al tamano máximo según el tipo de partición.
# Redimensionar al tamano máximo según el tipo de partición.
TYPE=$(ogGetFsType $1 $2)
case "$TYPE" in
EXT[234]) PROG="resize2fs"; PARAMS="-f" ;;
@ -115,7 +119,7 @@ case "$TYPE" in
*) ogRaiseError $OG_ERR_PARTITION "$1 $2 $TYPE"
return $? ;;
esac
#/// Error si el sistema de archivos está montado o bloqueado.
# Error si el sistema de archivos está montado o bloqueado.
if ogIsMounted $1 $2; then
ogRaiseError $OG_ERR_PARTITION "$1 $2" # Indicar nuevo error
return $?
@ -124,7 +128,7 @@ if ogIsLocked $1 $2; then
ogRaiseError $OG_ERR_LOCKED "$1 $2"
return $?
fi
#/// Redimensionar en modo uso exclusivo.
# Redimensionar en modo uso exclusivo.
ogLock $1 $2
eval $PROG $PARAMS $PART &>/dev/null
ERRCODE=$?
@ -217,7 +221,8 @@ if [ -z "$PROG" ]; then
REISERFS) PROG="mkfs.reiserfs"; PARAMS="-f" ;;
REISER4) PROG="mkfs.reiser4";;
XFS) PROG="mkfs.xfs"; PARAMS="-f" ;;
JFS) PROG="mkfs.jfs"; PARAMS="<<<\"y\"";;
JFS) PROG="mkfs.jfs"; PARAMS="<<<\"y\"" ;;
LINUX-SWAP) PROG="mkswap" ;;
NTFS|HNTFS) PROG="mkntfs"; PARAMS="-f" ;;
FAT32|HFAT32) PROG="mkdosfs"; PARAMS="-F 32" ;;
FAT16|HFAT16) PROG="mkdosfs"; PARAMS="-F 16" ;;