Question: The star hash ( Subsets 1 , 2 , 3 ) It should also check the star magic number ( first byte ) of each

The star hash (Subsets 1,2,3)It should also check the star magic number (first byte) of each star, and emit an error if it is incorrect.
HINT:
space_main.c calls the function check_galaxy in space.c when the -C option is specified on the
command line.
Add code to check_galaxy in space.c.
Call galaxy_hash to calculate hash values.
Think carefully about the functions you can construct to avoid repeated code.
For example, for every byte you read with fgetc you need to call galaxy_hash to calculate a new hash
value, so write a function that does both. Hint: have the function take a pointer to a hash value which it can
update.
Each star ends with a hash (sometimes referred to as a digest) which calculated from the other values of the star.
This allows us to detect if any bytes of the galaxy have changed, for example by disk or network errors.
The galaxy_hash() function makes one step of computation of the hash of a sequence of bytes:
Given the hash value of the sequence up to this byte, and the value of this byte it calculates the new halue
If we create a galaxy of a single one-byte file, like this:
We can then inspect the galaxy, and see its hash is 015.
Here's the sequence of calls that calculated that value:
void check_galaxy(char *galaxy_pathname){
}
The star hash ( Subsets 1 , 2 , 3 ) It should

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!