tape-admin: rework ltfs format/wipe

- can't reformat or wipe an active mounted ltfs media
- check that the the media is free

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2019-09-10 13:08:23 +02:00
parent 9c804b8370
commit a706511423

View File

@@ -496,7 +496,7 @@ get_poolmember () {
i=0
for i in $poolmember ; do
if [ "${volume_name}" = "any" ]; then
if [ "$volume_name" = "any" ]; then
volume_name=$i
if [ $verbose -ge 2 ]; then
printf "${MAGENTA}selecting first volume_name ${GREEN}'%s'${MAGENTA} from media-pool ${GREEN}'%s'${NO_COLOR}\n" \
@@ -736,10 +736,13 @@ ltfs_format () {
fi
make_err_file
ltfs_umount
if [ $? -eq 0 ]; then
${MKLTFS} --device=$ltfs_devname --volume-name=${volume_name} --tape-serial=${volume_serial} --force 2>${ERRFILE}
RET=$?
rm -f ${ERRFILE}
return $RET
fi
}
ltfs_is_mounted () {
@@ -879,14 +882,11 @@ ltfs_reformat () {
if [ ${#need_format} -ge 1 ]; then
ltfs_format ${volume_name_active} ${volume_serial}
else
ltfs_umount
if [ $? -eq 0 ]; then
ltfs_wipe
if [ $? -eq 0 ]; then
ltfs_format ${volume_name_active} ${volume_serial}
fi
fi
fi
if [ $? -eq 0 ]; then
ltfs_mount
fi
@@ -934,6 +934,8 @@ ltfs_wipe () {
printf "${BLUE}ltfs_wipe...${NO_COLOR}\n"
fi
ltfs_umount
if [ $? -eq 0 ]; then
#rm -rf $ltfs_mountpoint/*
make_err_file
if [ $verbose -ge 2 ]; then
@@ -968,7 +970,7 @@ ltfs_wipe () {
return 0
;;
8)
printf "${MAGENTA}%s: Get device error while processing, the cartridge may be modified ${GREEN}%s${NO_COLOR}\n" \
printf "${MAGENTA}%s: Get device error while processing, the cartridge may be modified; Return-Code: ${GREEN}%s${NO_COLOR}\n" \
${MKLTFS} $RET
return $RET
;;
@@ -976,6 +978,7 @@ ltfs_wipe () {
return $RET
;;
esac
fi
}
make_err_file() {
@@ -1038,7 +1041,7 @@ media_change () {
fi
get_poolmember_next "${mediapool_name}"
if test $? -eq 0; then
if [ $verbose -ge 2 ]; then
if [ $verbose -ge 1 ]; then
printf "${MAGENTA}MediaPool: ${GREEN}%s${NO_COLOR} (next tape: ${GREEN}%s${NO_COLOR})\n" \
"${mediapool_name}" "${volume_name_next}"
fi
@@ -1164,7 +1167,7 @@ mount_tape () {
"${volume_name}"
fi
ltfs_wipe
ltfs_format ${volume_name} ${volume_serial}
#ltfs_format ${volume_name} ${volume_serial}
if [ $? -eq 0 ]; then
return 0
fi
@@ -1301,15 +1304,12 @@ mount_tape () {
compare_date $date_now $volume_retensiondate
if [ $? -eq 2 ]; then
# retensiondate has exposed: wipe given tape
ltfs_mount
if [ $? -eq 0 ]; then
ltfs_wipe
ltfs_format ${volume_name} ${volume_serial}
#ltfs_format ${volume_name} ${volume_serial}
if [ $? -eq 0 ]; then
return 0
fi
fi
fi
if [ $? -eq 1 ]; then
# respect active retensiondate: unload given tape
mtx_unload