tape-admin: ltfs_refomat()

* Adervtise, if loader needds to exchange tapes
  that takes some time ....
* volume handling update
* improve verbose message output
* correct media detection in drive slot

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2019-12-13 15:32:03 +01:00
parent b4ac93d8d6
commit 4047a6f3e1

View File

@@ -821,37 +821,54 @@ ltfs_reformat () {
ltfs_is_mounted
if [ $? -eq 0 ]; then
if [ $verbose -ge 2 ]; then
printf "${MAGENTA}LTFS tape ${GREEN}'%s'${MAGENTA} is mounted to ${GREEN}'%s'${NO_COLOR}\n" \
"$ltfs_devname" "$ltfs_mountpoint"
printf "${MAGENTA}Unmount ${GREEN}'%s'${NO_COLOR} to reformat LTFS tape.\n" \
"$ltfs_mountpoint"
fi
ltfs_umount
fi
# Take care that we have the correct media in drive slot
slot_source="0"
mtx_getlabel $slot_source
if [ ${#volume_name} -gt 0 ] && [ $volume_name_active != $volume_name ]; then
get_mediapool_name $volume_name
if [ $? -eq 0 ]; then
ltfs_umount
if [ ${#volume_name_active} -gt 0 ]; then
if [ $volume_name_active != $volume_name ]; then
if [ $verbose -ge 1 ]; then
printf "${MAGENTA}Loader needs to exchange loaded tape ${GREEN}'%s'${MAGENTA} with tape ${GREEN}'%s'${NO_COLOR}\n" \
"$volume_name_active" "$volume_name"
fi
if [ $? -eq 0 ]; then
mtx_unload
if [ $? -eq 0 ]; then
mount_tape "${mediapool_name}" "${volume_name}"
if [ $verbose -ge 2 ]; then
printf "${MAGENTA}MTX finished unload tape ${GREEN}'%s'${NO_COLOR}\n" \
"$volume_name_active"
fi
volume_name_active=""
fi
fi
fi
fi
else
if [ ! -d $ltfs_mountpoint ]; then
mkdir -p $ltfs_mountpoint
fi
if [ ${#volume_name_active} -eq 0 ]; then
# no tape in drive slot, load selected volume_name
get_mediapool_name "${volume_name}"
if [ $? -eq 0 ]; then
if [ ${#mediapool_name} -gt 0 ]; then
get_slot "${mediapool_name}" "${volume_name}"
if [ $? -eq 0 ]; then
slot_source=0
mtx_getlabel ${slot_source}
mtx_load ${volume_slot}
if [ $? -eq 0 ]; then
if [ ${volume_name_active} != ${volume_name} ]; then
mtx_unload ${slot_source}
mtx load ${volume_slot}
if [ $verbose -ge 2 ]; then
printf "${MAGENTA}MTX finished loading tape ${GREEN}'%s'${NO_COLOR}\n" \
"$volume_name"
fi
fi
fi
fi
fi
# check LTFS
if [ ! -d $ltfs_mountpoint ]; then
mkdir -p $ltfs_mountpoint
fi
make_err_file
if [ $verbose -ge 2 ]; then
@@ -869,10 +886,6 @@ ltfs_reformat () {
need_format=$(grep "medium is not partitioned" ${ERRFILE})
rm -f ${ERRFILE}
fi
fi
fi
fi
fi
if [ ${#volume_name} -eq 0 ] || [ $volume_name_active = $volume_name ]; then
tape_id=$(echo $volume_name_active | sed -e 's/\([[:alpha:]]*-\)//g')
@@ -880,17 +893,23 @@ ltfs_reformat () {
volume_serial=$(printf "%0.s0" $(seq 1 $((6 - ${#tape_id}))))
volume_serial="${volume_serial}${tape_id}"
if [ ${#need_format} -ge 1 ]; then
ltfs_format ${volume_name_active} ${volume_serial}
ltfs_format $volume_name_active $volume_serial
else
if [ $verbose -ge 2 ]; then
printf "${MAGENTA}Wipe tape ${GREEN}'%s'${MAGENTA} (Volume-Name: ${GREEN}'%s'${NO_COLOR})\n" \
"$volume_name_active" "$volume_serial"
fi
# wiping: put tape in an unformatted state
ltfs_wipe
# RET = 8 -> error?
if [ $? -eq 0 ]; then
ltfs_format ${volume_name_active} ${volume_serial}
fi
fi
ltfs_format $volume_name_active $volume_serial
if [ $? -eq 0 ]; then
ltfs_mount
fi
fi
fi
fi
return $?
}