diff options
author | ramon <ramongomez@us.es> | 2017-06-29 11:32:30 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2017-06-29 11:32:30 +0000 |
commit | 472a4fb3313133ad2884d7532e4d0517cf5c6d24 (patch) | |
tree | 205c0e150191536feb3daeaca25e268195c53799 /client/engine/Disk.lib | |
parent | d5cbfa8dadf2bdb582b4782cb51b9cd869f7080d (diff) |
#748: Función {{{ogDevToDisk}}} usa fichero de configuración de discos detectados.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5396 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'client/engine/Disk.lib')
-rwxr-xr-x | client/engine/Disk.lib | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/client/engine/Disk.lib b/client/engine/Disk.lib index 90e13151..bf0039c7 100755 --- a/client/engine/Disk.lib +++ b/client/engine/Disk.lib @@ -391,7 +391,7 @@ esac function ogDevToDisk () { # Variables locales. -local DEV d n +local CACHEFILE DEV PART d n # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then ogHelp "$FUNCNAME" "$FUNCNAME path_device | LABEL=str_label | UUID=str_uuid" \ @@ -411,10 +411,17 @@ case "$DEV" in UUID=*) DEV=$(blkid -U "${1#*=}") ;; esac -# Error si no es fichero de bloques. -[ -b "$DEV" ] || ogRaiseError $OG_ERR_NOTFOUND "$1" || return $? +# Error si no es fichero de bloques o directorio (para LVM). +[ -b "$DEV" -o -d "$DEV" ] || ogRaiseError $OG_ERR_NOTFOUND "$1" || return $? -# Procesa todos los discos para devolver su nº de orden y de partición. +# Buscar en fichero de caché de discos. +CACHEFILE=/var/cache/disks.cfg +PART=$(awk -F: -v d="$DEV" '{if ($2==d) {print $1}}' $CACHEFILE 2>/dev/null) +if [ -n "$PART" ]; then + echo "$PART" + return +fi +# Si no se encuentra, procesa todos los discos para devolver su nº de orden y de partición. n=1 for d in $(ogDiskToDev); do [ -n "$(echo $DEV | grep $d)" ] && echo "$n ${DEV#$d}" && return |