Corrección ticket:71 (fallo en detectar partición extendida).

git-svn-id: https://opengnsys.es/svn/trunk@411 a21b9725-9963-47de-94b9-378ad31fedc9
remotes/github/debian-pkg
ramon 2009-10-26 09:58:01 +00:00
parent e834b669e6
commit 3543b3e360
4 changed files with 44 additions and 31 deletions

View File

@ -329,8 +329,16 @@ fi
[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
#/// Obtener el tamaño de la partición.
DISK="$(ogDiskToDev $1)" || return $?
PART="$(ogDiskToDev $1 $2)" || return $?
sfdisk -s $PART
case "$(ogGetPartitionId $1 $2)" in
5|f) # Procesar detección de tamaño de partición Extendida.
sfdisk -l $DISK | \
awk -v p=$PART '{if ($1==p) {sub (/\*/,""); print $5} }'
;;
*) sfdisk -s $PART
;;
esac
}
@ -351,7 +359,7 @@ sfdisk -s $PART
function ogListPartitions () {
# Variables locales.
local DISK PART NPARTS
local DISK PART NPARTS TYPE
#/// Si se solicita, mostrar ayuda.
if [ "$*" == "help" ]; then
@ -364,9 +372,15 @@ fi
#/// Procesar la salida de \c parted .
DISK="$(ogDiskToDev $1)" || return $?
NPARTS=$(parted -s $DISK print | awk '$1~/^[1-9]/ {print $1}')
for PART in $NPARTS; do
echo -n "$(ogGetFsType $1 $PART):$(ogGetPartitionSize $1 $PART) "
#NPARTS=$(parted -s $DISK print | awk '$1~/^[1-9]/ {print $1}')
NPARTS=$(ogGetPartitionsNumber $1)
for (( PART = 1; PART <= NPARTS; PART++ )); do
TYPE=$(ogGetFsType $1 $PART) 2>/dev/null
if [ $? -eq 0 ]; then
echo -n "$TYPE:$(ogGetPartitionSize $1 $PART) "
else
echo -n "EMPTY:0 "
fi
done
echo
}

View File

@ -15,7 +15,7 @@ function ogCopyFile () {
local ARGS SOURCE TARGET
ARGS="$@"
case "$1" in
/*) # Camino completo.
/*) # Camino completo. */ (necesario Doxygen)
SOURCE=$(ogGetPath "$1")
shift ;;
[1-9]*) # ndisco npartición.
@ -34,6 +34,23 @@ cp "$SOURCE" "$TARGET" # (definir posible error)
}
#/**
# ogDeleteTree [ str_repo | int_ndisk int_npartition ] path_dirpath
#@brief Metafunción que borra todo un subárbol de directorios de un dispositivo.
#@see ogGetPath
#@version 0.9 - Pruebas con OpenGNSys.
#@author Ramon Gomez, ETSII Universidad de Sevilla
#@date 2009-09-29
#*/
# Borrar subárbol de directorio.
function ogDeleteTree () {
local DIR
DIR=$(ogGetPath "$@") || return $?
[ -z "$DIR" ] && ogRaiseError $OG_ERR_NOTFOUND "$*" && reutrn $?
rm -fr "$DIR" || ogRaiseError $OG_ERR_NOTFOUND "$*" || reutrn $?
}
#/**
# ogGetPath [ str_repo | int_ndisk int_npartition ] path_filepath
#@brief Inicia el proceso de arranque de un sistema de archivos.
@ -76,7 +93,7 @@ case $# in
CACHE|cache)
FILE="$OGCAC/$OGIMG/$2" ;;
CDROM|cdrom)
FILE="$(ogMount cdrom)/$2" ;;
FILE="$(ogMountCdrom)/$2" ;;
*) ogRaiseError $OG_ERR_FORMAT
return $? ;;
esac ;;
@ -97,7 +114,7 @@ while [ "$FILE" != "$PREVFILE" ]; do
PREVFILE="$FILE"
FILE="${FILE#*/}"
done
# */ (necesario Doxygen)
#/// Muestra el camino Linux, quitando el "/" inicial duplicado.
[ "$FILEPATH" != "/" ] && echo ${FILEPATH#/}
cd $CURRENTDIR
@ -121,7 +138,6 @@ case $# in
*) ogRaiseError $OG_ERR_FORMAT
return $? ;;
esac
echo $PARENT
ogGetPath $PARENT
}
@ -142,23 +158,6 @@ rm -f "$FILE" || ogRaiseError $OG_ERR_NOTFOUND "$*" || reutrn $?
}
#/**
# ogDeleteTree [ str_repo | int_ndisk int_npartition ] path_dirpath
#@brief Metafunción que borra todo un subárbol de directorios de un dispositivo.
#@see ogGetPath
#@version 0.9 - Pruebas con OpenGNSys.
#@author Ramon Gomez, ETSII Universidad de Sevilla
#@date 2009-09-29
#*/
# Borrar subárbol de directorio.
function ogDeleteTree () {
local DIR
DIR=$(ogGetPath "$@") || return $?
[ -z "$DIR" ] && ogRaiseError $OG_ERR_NOTFOUND "$*" && reutrn $?
rm -fr "$DIR" || ogRaiseError $OG_ERR_NOTFOUND "$*" || reutrn $?
}
#/**
# ogMakeDir [ str_repo | int_ndisk int_npartition ] path_dirpath
#@brief Metafunción que crea un subdirectorio vacío en un dispositivo.

View File

@ -37,7 +37,7 @@ local PART IMGDIR IMGFILE ERRCODE
#/// Si se solicita, mostrar ayuda.
if [ "$*" == "help" ]; then
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npart path_dir str_image" \
"$FUNCNAME 1 1 aula1 winxp"
"$FUNCNAME 1 1 REPO /aula1/winxp"
return
fi
#/// Error si no se reciben menos de 2 parámetros.
@ -105,7 +105,7 @@ local IMGFILE
#/// Si se solicita, mostrar ayuda.
if [ "$*" == "help" ]; then
ogHelp "$FUNCNAME" "$FUNCNAME path_dir str_image int_ndisk int_npart" \
"$FUNCNAME aula1 winxp ==> 5642158"
"$FUNCNAME 1 1 REPO /aula1/winxp ==> 5642158"
return
fi
#/// Error si no se reciben menos de 2 parámetros.
@ -157,7 +157,7 @@ local PART PARTSIZE IMGFILE IMGSIZE
#/// Si se solicita, mostrar ayuda.
if [ "$*" == "help" ]; then
ogHelp "$FUNCNAME" "$FUNCNAME path_dir str_image int_ndisk int_npart" \
"$FUNCNAME aula1 winxp 1 1"
"$FUNCNAME REPO /aula1/winxp 1 1"
return
fi
#/// Error si no se reciben 4 parámetros.

View File

@ -42,11 +42,11 @@ MSG_HELP_ogGetImageSize="Devuelve el tamaño de una imagen de sistema."
MSG_HELP_ogGetMountPoint="Devuelve el directorio donde está montado un sistema de archivos local."
MSG_HELP_ogGetOsType="Devuelve el tipo de un sistema operativo instalado."
MSG_HELP_ogGetOsVersion="Devuelve el tipo y la versión de un sistema operativo instalado."
MSG_HELP_ogGetParentPath=""
MSG_HELP_ogGetParentPath=$"Devuelve el camino completo del directorio padre de un fichero de sistema OpenGNsys."
MSG_HELP_ogGetPartitionActive="Indica cual es la partición marcada como activa en un disco."
MSG_HELP_ogGetPartitionId="Devuelve el identificador de tipo de una partición."
MSG_HELP_ogGetPartitionSize="Devuelve el tamaño de una partición."
MSG_HELP_ogGetPath=""
MSG_HELP_ogGetPath="Devuelve el camino completo de un fichero de sistema OpenGNsys."
MSG_HELP_ogGetRegistryValue="Devuelve el dato de un valor del registro de Windows."
MSG_HELP_ogGetWindowsName="Devuelve el nombre del cliente guardado en el registro de Windows."
MSG_HELP_ogHelp="Muestra mensajes de ayudas para las funciones."