---
# System prepended metadata

title: Self-evaluation Practice 3
tags: [SOA]

---

###### tags: `SOA`
# Self-evaluation Practice 3

Using the `fatsoa` program's `volume` and `stat` commands, obtain the following parameters of the file system FAT32 in the `fatsoa.fs` image:
- Number of sectors per cluster (allocation unit) and number of sectors reserved.
- Size and starting cluster of `/LEEME.txt` and `/UD4/FAT32.h` files.
- Startup cluster of the `/` and `/UD4` directories.


Using the offset from the beginning of the FAT32 image, as indicated by the `fatsoa` tool for each of the previously mentioned files, use `hexdump` to reveal all the parameters and data structures for them. Find also the matching entry in the FAT for each cluster, and discuss if the number of FAT entries are consistent with the file size of the file.

Example of an image start dump using hexdump: 

```
adasilva@Leon:~/SOA/LAB/P3/$ hexdump -C -n 512 -s 0 fatsoa.fs
00000000 eb 58 90 6d 6b 66 73 2e 66 61 74 00 02 08 20 00 |.X.mkfs.fat... .|
00000010 02 00 00 00 00 f8 00 00 20 00 40 00 00 00 00 00 |........ .@.....|
00000020 00 20 03 00 c8 00 00 00 00 00 00 00 02 00 00 00 |. ..............|
00000030 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000040 80 00 29 0f 70 45 60 53 4f 41 2d 46 53 20 20 20 |..).pE`SOA-FS |
00000050 20 20 46 41 54 33 32 20 20 20 0e 1f be 77 7c ac | FAT32 ...w|.|
00000060 22 c0 74 0b 56 b4 0e bb 07 00 cd 10 5e eb f0 32 |".t.V.......^..2|
00000070 e4 cd 16 cd 19 eb fe 54 68 69 73 20 69 73 20 6e |.......This is n|
00000080 6f 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 64 69 |ot a bootable di|
00000090 73 6b 2e 20 20 50 6c 65 61 73 65 20 69 6e 73 65 |sk. Please inse|
000000a0 72 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 66 6c |rt a bootable fl|
000000b0 6f 70 70 79 20 61 6e 64 0d 0a 70 72 65 73 73 20 |oppy and..press |
000000c0 61 6e 79 20 6b 65 79 20 74 6f 20 74 72 79 20 61 |any key to try a|
000000d0 67 61 69 6e 20 2e 2e 2e 20 0d 0a 00 00 00 00 00 |gain ... .......|
000000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
```

## Short questions

1. What type is a variable containing a file descriptor?

2. Where is the file access pointer after executing `lseek(fd, 0, SEEK_END)`?
3. How many characters would be read from the file with the following code?
```
char buffer [100];
read(fd, buffer, sizeof(buffer));
```
4. What operation does this call perform, given that fd contains the descriptor of a file? what does `NULL` mean in the first parameter?
```
char *pmap = (char *)mmap( NULL, TAM, PROT_READ, MAP_PRIVATE, fd, 0 );
```
5. On a FAT32 file system, what does it mean that the first byte of the name of a directory entry has the value `0xE5`?
6. In which cluster number is the root directory "/"?
7. If the number of sectors per cluster is 8, what is the size in bytes of a cluster?
8. If the number of reserved sectors specified in BPB is 32, calculate the scrolling from the beginning of the image where the FAT?
9. Calculate the offset from the beginning of the image where the clusters area?
10. What does it mean that a FAT entry has a value of `0x0FFFFFF7`?