cryptblockfs/insert.sh

19 lines
395 B
Bash
Raw Permalink Normal View History

#!/bin/bash
FILE=$1
# Get size of file and current offset
SIZE=$(stat --printf="%s" $FILE)
OFFSET=$(cat ./fs/offset)
# Write file into block
dd if=$1 of="./fs/0.block" seek=$OFFSET oflag=seek_bytes
RESULT=$?
if [[ "$RESULT" == "0" ]]; then
# Append index and update offset
echo "$FILE;$OFFSET;$SIZE" >> ./fs/fileIndex
echo $((( $OFFSET + $SIZE ))) > ./fs/offset
echo "file inserted"
fi;