add script to create block with random data and script to write file into block and keep track of offset and files

This commit is contained in:
Johanna Dorothea Reichmann 2019-07-06 16:30:08 +02:00
commit b1f7d55be3
Signed by untrusted user who does not match committer: transcaffeine
GPG Key ID: 03624C433676E465
3 changed files with 21 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/files/
/fs/

18
insert.sh Executable file
View File

@ -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;

1
mk_block.sh Executable file
View File

@ -0,0 +1 @@
dd if=/dev/urandom of=fs/0.block bs=1024k count=64