diff options
author | ramon <ramongomez@us.es> | 2018-02-27 13:19:11 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2018-02-27 13:19:11 +0000 |
commit | e38039ed04670a92d4f3c7ddaef5b993eefc29f0 (patch) | |
tree | ef6417ac19419a1bb836c3a1ff28a2c95955b230 /client/engine/Disk.lib | |
parent | 55fcaa615c6b43eacdcf91b503cdc4b2d14d32b9 (diff) |
#830: Ayuda y control de errores en función {{{ogGetDiskType}}}.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5621 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'client/engine/Disk.lib')
-rwxr-xr-x | client/engine/Disk.lib | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/client/engine/Disk.lib b/client/engine/Disk.lib index 076e3bda..95c80f2e 100755 --- a/client/engine/Disk.lib +++ b/client/engine/Disk.lib @@ -618,26 +618,49 @@ SIZE=$(awk -v D=${DISK#/dev/} '{if ($4==D) {print $3}}' /proc/partitions) #/** # ogGetDiskType path_device -#@brief Muestra el tipo de disco (real, RAID, meta-disco, etc.). -#@warning Función en pruebas +#@brief Muestra el tipo de disco (real, RAID, meta-disco, USB, etc.). +#@param path_device Dispositivo +#@exception OG_ERR_FORMAT formato incorrecto. +#@exception OG_ERR_NOTFOUND disco no detectado o no es un dispositivo de bloques. +#@note Requisitos: udevadm +#@version 1.1.1 - Primera version para OpenGnsys +#@author Ramon Gomez, ETSII Universidad de Sevilla +#@date 2018-02-27 #*/ ## function ogGetDiskType () { +# Variables locales local DEV MAJOR TYPE +# Si se solicita, mostrar ayuda. +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME path_device" \ + "$FUNCNAME /dev/sdb => USB" + return +fi +# Error si no se recibe 1 parámetro. +[ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? + # Obtener el driver del dispositivo de bloques. -[ -b "$1" ] || ogRaiseError $OG_ERR_FORMAT || return $? +[ -b "$1" ] || ogRaiseError $OG_ERR_NOTFOUND "$1" || return $? DEV=${1#/dev/} MAJOR=$(awk -v D="$DEV" '{if ($4==D) print $1;}' /proc/partitions) TYPE=$(awk -v D=$MAJOR '/Block/ {bl=1} {if ($1==D&&bl) print toupper($2)}' /proc/devices) # Devolver mnemónico del driver de dispositivo. case "$TYPE" in - SD) TYPE="DISK" - udevadm info -q property $1 2>/dev/null | grep -q "^ID_BUS=usb" && TYPE="USB" - ;; - SR|IDE*) TYPE="CDROM" ;; # FIXME Comprobar discos IDE. - MD|CCISS*) TYPE="RAID" ;; - DEVICE-MAPPER) TYPE="MAPPER" ;; # FIXME Comprobar LVM y RAID. + SD) + TYPE="DISK" + udevadm info -q property $1 2>/dev/null | grep -q "^ID_BUS=usb" && TYPE="USB" + ;; + SR|IDE*) + TYPE="CDROM" # FIXME Comprobar discos IDE. + ;; + MD|CCISS*) + TYPE="RAID" + ;; + DEVICE-MAPPER) + TYPE="MAPPER" # FIXME Comprobar LVM y RAID. + ;; esac echo $TYPE } @@ -654,15 +677,16 @@ echo $TYPE #@note Requisitos: sfdisk, sgdisk #@version 1.0.4 - Primera versión compatible con OpenGnSys. #@author Universidad de Huelva -#@date 2012/06/03 +#@date 2012-06-03 #@version 1.0.6b - uso de sgdisk para todo tipo de particiones. Incidencia #762 #@author Universidad de Málaga -#@date 2016/11/10 +#@date 2016-11-10 #*/ ## function ogGetLastSector () { # Variables locales local DISK PART LASTSECTOR + # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk [int_npart]" \ |