‫Hello and welcome.
‫And in this lecture, we are going to implement the everyday functionality in the virtual filesystem
‫layout.
‫Let's go to file DOT Hage and we're going to create a new type of function pointer for reading from
‫files.
‫Simply go typedef in it first read function.
‫Struck desk by Privette Unit 30 to te size Unit 32 t NMM char out.
‫So this is our function pointer and essentially what's going to happen is our Alloa file system will
‫implement a function that takes these parameters.
‫So it's going to accept the desk, the private data.
‫It's going to accept the size of the Reed operation, how many bytes you're reading, and it's also
‫going to accept how many of those blocks you want to read.
‫So, for example, if the size is ten and the numbers five, then you want to read 50 bytes, five blocks
‫of ten, five blocks of size.
‫OK, so that's how that's working.
‫So what we're gonna do now is we're going to go first read function, read in the file system.
‫So now we've defined the read function in the file system here.
‫So when I was going to scroll down and just under the F open prototype, we're going to go in it.
‫Elfriede, Void's Pointer, Unit 32 to size Unit 32 T and I'm finally in its F.T. So there's our prototype
‫Senesco to file dot C and we're going to implement the F read function.
‫So start by scrolling down and just under F open, we're going to create the F, right.
‫So we're going to go in it.
‫F reads voie pointer, unit 32 T size unit 32 T and Wempe and it's F.T..
‫Now we're going to go in at equals zero return address.
‫If size is equal to zero or any member equals zero or F.T. below one.
‫Then there's an error and we're going to go rest equals minus invalid arguments.
‫And then we're going to go go to.
‫Now, just down here, we're going to go out.
‫We're going to find out labor.
‫OK, so that ensures that the variables they've passed to us are valid arguments, no negative values,
‫no size of zero.
‫We're reading more than one block and so on.
‫So now we're going to go struct file, descriptor, descriptor equals file, get descriptor, F.T. And
‫we've already implemented that function.
‫If the descriptor is no, then there was an error rest's equals minus invalid argument because that
‫means they've passed us a file.
‫The script.
‫No, that's wrong, because if we look at Etha open, the response for F Open is the descriptor index,
‫the file descriptor index and we can write the script Tohil here using file new descriptor.
‫Right.
‫So the F expects that index pass to it here.
‫OK, and we just take a look and found you descriptor.
‫You can see the descript index is a plus one.
‫OK, that's the idea.
‫The descriptor may make more sense to call that a ID rather than rather than an index, but nevertheless,
‫it's basically an ID.
‫So that's what this Afri function is expecting.
‫It's expecting that ID to be passed to it in the FFT variable here.
‫So the next step is to go rest's equals to script file system, read the script, a desk to script,
‫a private size and mem and finally a pointer cast char and we're going to pass in.
‫Our point here, our viewpoints are provided to us and then we just return.
‫So that's what that's how that's going to work.
‫So basically what's going to happen here?
‫It's going to call the lower filesystem passing in its descript to private data that it gave to us when
‫we did that open.
‫If we look here, just skip the private data when we did open it, pretend that, OK, so we're passing
‫that private data back to back to the lower filesystem, the five 16 filesystem or whatever filesystem
‫it might be.
‫So it can now cost that private data descriptor private data back into what it was supposed to be.
‫And then it will be able to know which file we're talking about, because the private data that have
‫returned to us and F open should have everything it needs to re resolve that file for a redo operation.
‫So that is basically the F read implemented.
‫And let's just make sure that compiles now and then.
‫That is it for the virtual file system, every functionality.
‫And in the next lecture we will implement the fat 16 Afri functionality.
‫So let's just double check this works and see if we are done here.
‫So we're going to open the terminal.
‫We're going to go build that S.H. and we can see a few errors.
‫It's not a big deal.
‫That's just it just can't resolve you in a 32 t, essentially.
‫So just go to file dot Hajj, scroll up and we're just going to include in it the Hajj in the header
‫file at the top there.
‫And now if we recompile that, we can see that works absolutely fine.
‫So that's for that lecture, guys.
‫Like I said, next lecture will implement Fat 16 Elfriede and then we will actually be able to read
‫from our files.