summaryrefslogtreecommitdiffstats
path: root/client/engine/Disk.lib
diff options
context:
space:
mode:
Diffstat (limited to 'client/engine/Disk.lib')
-rwxr-xr-xclient/engine/Disk.lib15
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