-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
63 lines (47 loc) · 1.95 KB
/
Copy pathtest.sh
File metadata and controls
63 lines (47 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -e
# Create a new virtual disk (1 MB for demonstration)
echo "Creating virtual disk 'disk.vd' (1 MB)..."
./vfs dmake disk.vd 1048576
echo -e "\nListing files on new disk (should be empty):"
./vfs dls disk.vd
# Prepare some host files
echo -e "\nCreating host files file1.txt and file2.bin..."
echo "Hello, TTvfs!" > file1.txt
dd if=/dev/urandom of=file2.bin bs=512 count=2 2>/dev/null
# Copy files into virtual disk
echo -e "\nCopying file1.txt and file2.bin into virtual disk..."
./vfs dput disk.vd file1.txt
./vfs dput disk.vd file2.bin
echo -e "\nListing files after copy:"
./vfs dls disk.vd
echo -e "\nBlock map after initial copy (no fragmentation yet):"
./vfs dmap disk.vd
# Delete one file to create a free block between data regions
echo -e "\nDeleting file1.txt from virtual disk..."
./vfs ddel disk.vd file1.txt
echo -e "\nBlock map after deleting file1.txt (fragmentation created):"
./vfs dmap disk.vd
# Copy another file to fill the gap (may become fragmented)
echo -e "\nCreating and copying file3.txt..."
echo "Another file to the VFS." > file3.txt
./vfs dput disk.vd file3.txt
echo -e "\nFinal directory listing:"
./vfs dls disk.vd
echo -e "\nFinal block map (showing how new file filled gaps):"
./vfs dmap disk.vd
# Copy file2.bin back out of virtual disk
echo -e "\nCopying file2.bin from virtual disk to host as output2.bin..."
./vfs dget disk.vd file2.bin output2.bin
echo "Size of output2.bin: $(stat --printf="%s" output2.bin) bytes"
# Clean up: delete virtual disk
echo -e "\nRemoving virtual disk 'disk.vd'..."
./vfs dremove disk.vd
# Creating very small disk
echo -e "\nCreating very small disk 'small.vd' (1024 bytes)..."
./vfs dmake small.vd 8096 # 8 KB, which is smaller than the file we will try to write
# Write a file bigger than the disk size
echo -e "\nAttempting to write a file larger than the disk size (should fail)..."
./vfs dput small.vd borat.mp4
# Clean up: delete small disk
echo -e "\nRemoving small disk 'small.vd'..."