‫Hello and welcome in this lecture, we are going to start implementing the Fat 16 filesystem, the first
‫thing we're going to do is change our bootloader so that it has the fat 16 head to.
‫This will then mean that we can mount our operating system to a kernel that supports fat.
‫16, such as Linux will then be able to copy files across unmount the file system and our operating
‫system will then have files.
‫We won't be able to read these files yet because we haven't implemented a fat file system in our kernel.
‫However, the files will exist there.
‫Let's begin.
‫So the very first thing you need to do is go to Firefox or whatever browser you have and just search
‫for Fat 16 file system.
‫And this one is Wikipedia design of the fat file system.
‫And we can see.
‫How the head of all is laid out on desk now, this one's for five, 30 to bear in mind, by the looks
‫of it, however, the concept is mostly the same.
‫OK, let's begin writing our fatheads.
‫You'll notice that at the very beginning of the course, we did times 33 DB zero, this was to make
‫space for this head.
‫Now we're obviously going to start implementing that had.
‫So you can get rid of times 33, DB zero and you'll notice this jump shot start no operation.
‫Now, this is the start of the head as shown in the presentation.
‫So watch the presentation again to see how that should be laid out and we're now going to start implementing
‫it.
‫So just get rid of this start label here and we're going to keep the jump in the no operation.
‫And just into here, we're going to have we're going to make a common fat sixteen head, OK?
‫And the very first thing we need is the OEM identifier.
‫Are these labels don't matter so much, just as long as they are present, so you can name them whatever
‫you like, but I suggest naming them what I name them here, so it makes sense to you.
‫OK, so the OEM identifier is eight bytes.
‫If we go back to Firefox, we can see that this is confirmed by here in the boot sector section of the
‫design of the fat file system.
‫We can see that from offset zero.
‫We have three bytes.
‫This is our short jump Bonnano operation.
‫Then comes the OEM name padded with spaces, OK, and this is eight bytes in size.
‫So you do need to count this as you're doing it because it has to be right.
‫So process that is.
‫One, two, three, four, five, six, seven, seven bites, so then we should have one space after
‫this, OK, and then there's our OEM identifier for pictures.
‫So we look back on the file allocation table reference here.
‫We can see that there's more data to come, but it depends on the version of the file allocation table
‫and so on.
‫And but not to worry, because I know what we need to be writing, so just copy what I'm doing.
‫The next thing to do is the bytes per sector, because we're implementing Fat 16 here, guys.
‫So if you do get stuck or want to understand it a little more, find a fat 16 reference and it'll explain
‫each of these fields.
‫However, I will briefly go over them as we go through this Savides project, DWC 200.
‫So this is a word we're making here, right.
‫And this just says 512 bytes per cent.
‫However, you know, this number, just because we change it doesn't mean the bytes per sector changes.
‫Do you understand the way the disk works is fixed?
‫We can't change that.
‫Now, this field is generally ignored by its sector, is generally ignored by most Col's.
‫They won't really listen to that field.
‫So we're going to have sectors per cluster now and this will be GWC 680.
‫OK, so that's how many sectors we want per cluster.
‫And now we're going to have reserved sectors.
‫This will be decimal two hundred.
‫And this will be a word, by the way, guys.
‫Two hundred reserved sectors for our colonel is plenty of space.
‫Absolutely plenty.
‫And you'll notice in the file allocation table presentation, I mentioned that we wouldn't be loading
‫the colonel from the desk.
‫What I actually meant to say was, is we wouldn't be loading the colonel from a file, which is why
‫we store the whole colonel in the reserved sectors.
‫So this is what I was trying to say, but I just misspoke.
‫So, yeah, the reserved sectors is where our colonel will be.
‫It won't be stored in a file as such because that would mean we would have to load the colonel from
‫a file, which will be much more difficult to do because our colonel contains the code for loading in
‫the first place.
‫So then you need you.
‫It just makes things a little more complicated.
‫So our entire colonel, we stored in the reserved sectors.
‫So next comes off fat copies.
‫We are going to have to fax copies of the original and the backup.
‫So here we have the total root directory entries.
‫This can be zero x forty and it's a word.
‫OK, guys, be careful.
‫You're reading W in and DB correctly and we used on some of these as well.
‫Make sure it's written exactly right, because if the head is wrong then Linux won't be able to recognize
‫it as a as a valid file system and then we'll have problems copying files to it from Linux.
‫So yeah, we're going to have some sectors.
‫This can just be zero.
‫We're not using this media type comes next.
‫Xerox effort, guys sectors purrfect.
‫So sectors per fact is D.W. Xerox one hundred.
‫So now we're going to go sectors per track.
‫And this will be a W again, guys, 06 20, now we're going to have a number of heads, DWC exploding
‫hidden sectors, Deedes zero zero zero sectors, big DDC seven seven three five nine four.
‫So now we're going to make our extended BPP.
‫And don't worry too much about what that is.
‫Just copy what I'm doing because we just need to get this header done and then we can actually get to
‫what's important.
‫So now we're going to go drive no DB zero exacty win and Tibbits DB zero zero zero signature DB zero
‫x twenty nine Vol. I d d d zero x d 105 volume I'd string.
‫And this one's a little more complicated because I need to see how big this is.
‫So we're going to go back to Firefox's here.
‫We're going to search for volume I.D. and we can see it's 11 bytes, OK, 11 bytes.
‫So we need to count these correctly because if we count them wrong, that the bootloader will be invalid
‫and it won't be seen as a real file system.
‫So DB one, two, three, four, five, six, seven, eight, nine, ten, eleven.
‫OK, so that looks like eleven bytes and we just double check.
‫One, two, three, four, five, six, seven, eight, nine, ten, eleven ah one by too many guys.
‫One, two, three, four, five, six, seven, eight, nine, ten, eleven.
‫Yeah.
‫So we're just going to get rid of the T by the sumptuous space boot rather than boot, because if you
‫get this wrong, it's not going to work, by the way.
‫So if you run into problems, you need to check you've done this right.
‫So now we're going to have the system ID string, which is a bytes in size.
‫OK, so this is the filesystem TypePad Blancs.
‫So we're using five sixteen.
‫So we're going to go fat sixteen.
‫So that's one, two, three, four, five, six, seven, eight.
‫There you go.
‫And that should be it for the actual header itself.
‫OK, so now go to our makefile.
‫We need to change some things here so you can see we currently put a hundred sectors of nulls into the
‫OS stop in.
‫This needs to be changed completely.
‫So both needs to become one megabyte, which is one two four eight five, seven, six.
‫I think that's one megabyte.
‫And we're going to put sixteen by here.
‫So we're just going to we're just going to put basically sixteen megabytes of nulls straight to the
‫the file here.
‫OK, and this will be used by Lennix to store our file data because then will see our header file.
‫It will think this is a file system.
‫So these no bytes here will be used by Linux to store our file data.
‫We give it plenty of room so that it can store our files.
‫OK, so we now just go into the terminal.
‫We're going to make clean and we're going to build that S.H..
‫When I was Cribben, I want to go to to make directory Mount D. And for me, it already exists, but
‫for you guys, maybe not.
‫And I was going to go pseudo mounty Dashty, I mean, Refat top forward slash a stop in Mount D..
‫So should look like that.
‫Just presenta.
‫Excellent.
‫If we now open a new terminal and we go KDDI Mount D and we just go touch hello dot text, you can see
‫it says Prestons and I just use pseudo touch.
‫Hello dot t.
‫And I was going to do a pseudo G, I did hello, dad texte hello world, and just save that close up
‫and we can see we now have hello to extend our operating system here when we was controlled to close
‫the terminal.
‫When it goes to the unmount, to the the mounted directory, I want to go out there and there we are.
‫S unmounted now.
‫We now go bless.
‫So I stopped them uh and we go control f and we go to text and we search for hello.
‫You can see our hello world stored on the desk here.
‫Right.
‫Which is really useful.
‫Right.
‫And OK, you know, close that and we now go and remount the OS again with this command and we go to
‫CD Mount D and then we go Hello, the text.
‫What you see.
‫Hello World.
‫So our operating system now stores files.
‫We just can't access those files yet.
‫OK, so the stuff we've done here, we're going to put it in the header in the Makefile, I mean and
‫basically just copy a little dummy file across and then we're going to implement the file functionality
‫to be able to read that file.
‫OK, so copy and paste this command.
‫Into the makefile and make sure you tabit out, guys, because to make Foleo and here, then we're just
‫going to have hashtag copy a file over and we're going to go see the Mount Mounty here.
‫Now, this assumes you've you've created the Mount Directory, OK, if that directory doesn't exist
‫and this Comando fails.
‫So just bear that in mind.
‫You're welcome to make the directory and delete it later on.
‫But we're not going to bother.
‫We're just going to keep it like this is pretty straightforward if the file doesn't exist.
‫Just going to tell you.
‫Right.
‫So you're going to be able to solve that yourself.
‫But yeah, just make sure Mandi's created now in our main directory here where the makefile is, we're
‫going to create a new file and we're just going to call it hello.
‫Dubcek's t would just literally going to type Hello World.
‫Simple as that.
‫And I would not makefile.
‫We're going to copy the file over pseudo sepi top forward slash.
‫Hello, Dubcek's t mount the OK press control asked to save and now we're going to go make clean Bill
‫Dot S.H. and you can see it complains that this file doesn't exist.
‫But that's OK because we just need to do bean in here instead because we were in the bin directory when
‫we originally wrote this.
‫Come on.
‫Right this time we are not.
‫We're in the Makefile, which is not in the bin directory.
‫So just stood up for its spin forward slash showstopping.
‫And after you now build we can see that works absolutely fine.
‫We go seed bin, we're going to run kumu.
‫We can see the operating system works perfectly fine and now we're going to go bless dot os stop bin.
‫We're going to do control left to search, we're going to change the text and now we're going to do
‫capital h e l l and then we go we see hello world.
‫So our operating system now actually holds files.
‫Linux knows how to read them.
‫We do not.
‫So we now need to implement that.