tape-admin: update ltfs_reformat()

- only reformat the tape, if the given volume_name is a
  member of the requested pool
- only call mtx to exchange tapes, if the requested
  volume_name is not the loaded and active tape in given drive (slot 0)

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2019-01-02 01:08:53 +01:00
parent 238c950c06
commit a94ae31a51

View File

@@ -803,21 +803,35 @@ ltfs_reformat () {
if [ ! -d $ltfs_mountpoint ]; then if [ ! -d $ltfs_mountpoint ]; then
mkdir -p $ltfs_mountpoint mkdir -p $ltfs_mountpoint
fi fi
make_err_file get_mediapool_name "${volume_name}"
if [ $verbose -ge 2 ]; then if [ $? -eq 0 ]; then
printf "${MAGENTA}LTFS mounting tape ${GREEN}'%s'${MAGENTA} to ${GREEN}'%s'${NO_COLOR}\n" \ get_slot "${mediapool_name}" "${volume_name}"
"$ltfs_devname" "$ltfs_mountpoint" if [ $? -eq 0 ]; then
${LTFS} -o devname=$ltfs_devname -o verbose=$verbose $ltfs_mountpoint 1>/dev/null 2>${ERRFILE} slot_source=0
else mtx_getlabel ${slot_source}
${LTFS} -o devname=$ltfs_devname -o verbose=0 $ltfs_mountpoint 1>/dev/null 2>${ERRFILE} if [ $? -eq 0 ]; then
fi if [ ${volume_name_active} != ${volume_name} ]; then
if [ $? -ge 0 ]; then mtx_unload ${slot_source}
if [ -z $volume_name_active ]; then mtx load ${volume_slot}
slot_source="0" fi
mtx_getlabel $slot_source make_err_file
fi if [ $verbose -ge 2 ]; then
need_format=$(grep "medium is not partitioned" ${ERRFILE}) printf "${MAGENTA}LTFS mounting tape ${GREEN}'%s'${MAGENTA} to ${GREEN}'%s'${NO_COLOR}\n" \
rm -f ${ERRFILE} "$ltfs_devname" "$ltfs_mountpoint"
${LTFS} -o devname=$ltfs_devname -o verbose=$verbose $ltfs_mountpoint 1>/dev/null 2>${ERRFILE}
else
${LTFS} -o devname=$ltfs_devname -o verbose=0 $ltfs_mountpoint 1>/dev/null 2>${ERRFILE}
fi
if [ $? -ge 0 ]; then
if [ -z $volume_name_active ]; then
slot_source="0"
mtx_getlabel $slot_source
fi
need_format=$(grep "medium is not partitioned" ${ERRFILE})
rm -f ${ERRFILE}
fi
fi
fi
fi fi
fi fi