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:
commit
b1f7d55be3
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/files/
|
||||
/fs/
|
18
insert.sh
Executable file
18
insert.sh
Executable 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
1
mk_block.sh
Executable file
@ -0,0 +1 @@
|
||||
dd if=/dev/urandom of=fs/0.block bs=1024k count=64
|
Loading…
Reference in New Issue
Block a user