feat: add tapes index view

This commit is contained in:
Samuel N Cui
2023-10-03 16:12:44 +08:00
parent 15079aaa50
commit 999b9bf9b2
27 changed files with 1357 additions and 358 deletions

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -ex;
mt -f ${DEVICE} load
sleep 5
for i in {1..60}; do

24
scripts/get_device Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -e;
DEVICE=`readlink -f ${DEVICE}`
REGEXP='/dev/n?st([0-9]+)[alm]?'
if [[ ! $DEVICE =~ $REGEXP ]]; then
echo "'$DEVICE' doesn't match" >&2
exit 1
fi
NUM="${BASH_REMATCH[1]}"
TRIES=("/dev/nst${NUM}" "/dev/st${NUM}")
for TRY in ${TRIES[@]}; do
SG_DEVICE=`sg_map | grep ${TRY} || echo ''`;
if [[ $SG_DEVICE != "" ]]; then
echo $SG_DEVICE | awk '{print $1}'
exit 0;
fi
done
echo "'$DEVICE' not found" >&2
exit 1

View File

@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -ex;
SG_DEVICE=`sg_map | grep ${DEVICE} | awk '{print $1}'`
CURDIR=$(cd $(dirname $0); pwd);
SG_DEVICE=`${CURDIR}/get_device`
mkltfs -f -d ${SG_DEVICE} -s ${TAPE_BARCODE} -n ${TAPE_NAME}
sleep 3

View File

@@ -1,6 +1,16 @@
#!/usr/bin/env bash
set -ex;
SG_DEVICE=`sg_map | grep ${DEVICE} | awk '{print $1}'`
ltfs -o devname=${SG_DEVICE} -o noatime -o sync_type=unmount -o work_directory=/opt/ltfs -o capture_index -o min_pool_size=256 -o max_pool_size=1024 -o eject -s ${MOUNT_POINT}
CURDIR=$(cd $(dirname $0); pwd);
SG_DEVICE=`${CURDIR}/get_device`
ltfs -o devname=${SG_DEVICE} -o noatime -o sync_type=unmount -o work_directory=/opt/yatm/captured_indices -o capture_index -o min_pool_size=256 -o max_pool_size=1024 -o eject -s ${MOUNT_POINT}
sleep 3
MOUNT_POINT_TARGET=`df ${MOUNT_POINT} --output=target | sed -n '1!p'`
if [[ $MOUNT_POINT != $MOUNT_POINT_TARGET ]]; then
echo "mount '$MOUNT_POINT' fail, current target is '$MOUNT_POINT_TARGET'" >&2
exit 1
fi
echo "mount '$MOUNT_POINT' success" >&2

16
scripts/mount.openltfs Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -ex;
CURDIR=$(cd $(dirname $0); pwd);
SG_DEVICE=`${CURDIR}/get_device`
ltfs -o devname=${SG_DEVICE} -o noatime -o sync_type=unmount -o work_directory=/opt/yatm/captured_indices -o capture_index=/opt/yatm/captured_indices -o min_pool_size=256 -o max_pool_size=1024 -o eject -s ${MOUNT_POINT}
sleep 3
MOUNT_POINT_TARGET=`df ${MOUNT_POINT} --output=target | sed -n '1!p'`
if [[ $MOUNT_POINT != $MOUNT_POINT_TARGET ]]; then
echo "mount '$MOUNT_POINT' fail, current target is '$MOUNT_POINT_TARGET'" >&2
exit 1
fi
echo "mount '$MOUNT_POINT' success" >&2

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -ex;
# SG_DEVICE=`sg_map | grep ${DEVICE} | awk '{print $1}'`
BARCODE=`./yatm-lto-info -f /dev/nst0 | grep 'Barcode' | awk '{print $3}'`
mt -f ${DEVICE} load
BARCODE=`./yatm-lto-info -f ${DEVICE} | grep 'Barcode' | awk '{print $3}'`
echo "{\"barcode\": \"$BARCODE\"}" > $OUT
sleep 3