Information Technology Reference
In-Depth Information
Figure 10-2: A mass-storage master performs these actions to write to an
empty file.
marker in the new cluster's FAT entry, convert the cluster number to an
LBA sector number, and store the additional data in the cluster's sector(s).
4. Repeat step 3 as needed until all of the file's data has been written.
5. Update the file's directory entry.
To append data to an existing file, before writing to the file, firmware can
get the file's size from the directory entry and use the value to calculate the
sector and offset to begin writing to the file. To overwrite a file that uses
multiple clusters, firmware can use the FAT to find the clusters already allo-
cated to the file.
Performing a Write Operation
The fwrite function writes a specified number of bytes beginning at a speci-
fied location in a file. The function accepts a FILEOBJ pointer to a FILE
 
Search WWH ::




Custom Search