commit b1f7d55be3ef590521653a184b2f948aacac6d84 Author: jdreichmann Date: Sat Jul 6 16:30:08 2019 +0200 add script to create block with random data and script to write file into block and keep track of offset and files diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b64e6e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/files/ +/fs/ diff --git a/insert.sh b/insert.sh new file mode 100755 index 0000000..7162a36 --- /dev/null +++ b/insert.sh @@ -0,0 +1,18 @@ +#!/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; diff --git a/mk_block.sh b/mk_block.sh new file mode 100755 index 0000000..3ef403a --- /dev/null +++ b/mk_block.sh @@ -0,0 +1 @@ +dd if=/dev/urandom of=fs/0.block bs=1024k count=64