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