fbpx

How are filesystem organized with multiple drives?

Now that you know why you should learn how to use a filesystem in your programming, what do you need to know?

Programming with a filesystem is different than just using your computer to open and close files. You need to understand how a filesystem works in even more details in order to include this ability in your programs. Depending on what you’re programming, you might need to know quite a bit. Even a simple program will expose you to error handling and exceptions, security, favorite locations, common dialogs, and much more.

Listen to the full episode or read the full transcript below to learn more about some of the reasons that helped define how filesystems worked.

Transcript

Now that you know why you should learn how to use a filesystem in your programming, what do you need to know?

Programming with a filesystem is different than just using your computer to open and close files. You might think you already know how to use a filesystem. It’s kinda hard to use a computer without knowing this. But you need to understand how a filesystem works in even more details in order to include this ability in your programs.

Depending on what you’re programming, you might need to know quite a bit. Even a simple program will expose you to error handling and exceptions, security, favorite locations, common dialogs, and much more.

I’ll be explaining how to use a filesystem in this series in your code. The operating systems will be Windows, Linux, and Mac. This is based a lot on my experience through the years which has mostly been on Windows with a bit of Linux. I first started using a Mac about 9 years ago so don’t have much experience with early Apple operating systems. My explanation might be a bit tilted in favor of what I know about most.

In many ways, a Linux filesystem and a Mac filesystem are similar. They might look different to you as you use the computer but this gets back to the differences between using a computer vs. programming a computer.

Windows filesystems are very different while Linux and Mac are more closely aligned.

Before Windows came along, IBM and Microsoft worked together to create an operating system for personal computers. Back then, using disk drives of any kind was still new. Personal hard drives were very rare. I didn’t get my first hard drive until probably a year after I got my first computer. Even then, it was unreliable and would overheat. I had to keep it outside of my computer with the cables running through the back of the computer. And I pointed a small fan at the hard drive to help keep it cool. The whole setup looked like a mess but it mostly worked.

It was possible back then to use a computer without inserting any floppy disk or running any operating system. When the computer started, it would look for a disk and if none was found, then it would start running a BASIC interpreter. BASIC is a programming language where you give each line a number and then you can refer to other places in your code by using the line numbers. It was possible to turn on a computer, type in a few lines of code, and print your name over and over on the screen. Maybe you could even use some colors assuming the monitor was a color monitor. Many monitors back then used a black screen with green text. That’s all.

When color monitors came out, they were still limited to about 16 colors. But at least the normal text was then white on a black screen. The computer could display 25 lines and 40 columns of text on the monitor.

I remember when I was even younger and my family got an Apple II computer. I don’t really consider this part of my computer experience because all I really did on the computer was practice some typing. Yes, I taught myself how to type which is probably why to this day, I still have to look at the keyboard in order to type properly. It always amazes me when I talk to another programmer and they turn their head to look at me and keep on typing at the same time.

Anyway, along with this Apple II computer, my family bought a special extension card that plugged into the inside of the computer and gave it enough memory and the code needed to display up to 80 columns of text. The difference was amazing.

If you want to learn more about the history of IBM and Microsoft and Apple, there are some good documentaries available. From what I remember, there were only two choices available for a personal computer. You were either using IBM PC-DOS or Microsoft MS-DOS. This was the operating system. And the entire operating system would fit on a single floppy disk.

In both cases, DOS stood for disk operating system. Like I said, using floppy disks was still new and both companies made this fact very clear in the name of the operating system. This was an operating system that let you use disks. And that meant it had a filesystem.

It worked like this. You had to insert your disk with the operating system into the computer and then either turn it on or hit the reset button if it was already on. There were computer viruses back then too. And it was easy to insert your operating system disk into an infected computer which would detect the disk and immediately write the virus code onto your disk. The only way to protect against this was to make sure to hit the reset button first or make sure that the computer was turned off before inserting your operating system disk.

If you were using an infected computer, then it would infect every disk that you inserted into the drive.

Once the operating system loaded, this would allow you to skip the BASIC language interpreter and the screen would show a command prompt. It was waiting for you to start typing commands now. If you had a program that you wanted to run, maybe you needed to write a letter, then you would take out the floppy disk with your operating system and insert another disk with the program code. This would allow the computer to find the application code so it could be loaded into memory. Remember that the operating system code was already loaded into memory and would stay there. Applications could be started, stopped, and other applications started and stopped. You could only run one application at a time.

At least normal applications could only be run one at a time. There were some programming tricks available that could allow control to pass back to the operating system but keep the previous application in memory. There were called terminate and stay resident applications. The short name was a TSR. Writing a TSR was a dark journey through undocumented operating system internals.

IBM and Microsoft did not make this easy for programmers and the reason they made it so challenging to write TSR applications is that writing a TRS was actually very similar to writing a virus. The only real difference is that a good TSR didn’t have to worry about trying to hide itself or its activities.

When I was in college, a friend of mine wrote a TSR called Line26. It was a clever program that would squeeze an extra line of text onto the screen at the bottom of the actual 25 lines of text. The program would then display information about what the computer was doing in this extra line. Any normal applications were completely unaware of this extra line.

Okay, back to normal applications. They would be loaded from their own disk and once in memory, then you could remove the application disk from the drive and insert another disk containing the files or documents that you wanted to work with.

It was usually a bad idea to save your documents directly to the disk containing the application itself. I remember carrying around a plastic box that held all my floppy disks. I would place a sticky label on each disk and write a note to remember what the disk was used for. At least that was better than writing the note on the protective sleeve that came with each disk like an envelope. It was too easy to forget which disks came from which sleeves. Sometimes, they would still get mixed up and I would have to insert a disk into the computer just to see what was on the filesystem.

You see, each disk had it’s own filesystem. They were completely separate from each other.

Now, if you think about this for a moment, this causes some problems for the operating system. It’s trying to manage a filesystem on a floppy disk. And along comes a person who, without any warning at all, flips the tab to unlock the disk from the drive, removes the disk, and puts in a new disk containing a new filesystem.

The operating system is supposed to deal with this abrupt change. Because most of us, actually, all of us, will, at some point forget, and simply remove the disk. This is still relevant today even though we don’t use floppy drives anymore. How many times have you pulled a USB thumb drive out of a computer without ejecting it first? At least CDs and DVDs cannot be removed like this anymore. They need a button to be pressed that will allow the operating system to handle the removal. Then it’s aware that the filesystem on the disk is going away.

But back when CD drives were new, even they had physical eject buttons that allowed humans to yank the disk away from the computer without any notice at all.

This episode is getting a bit long so I’ll continue explaining about drive letters, mounting, and paths next week. Knowing this background information is important because this lets you understand the reasons behind why our filesystems are designed the way they are. A lot of those decisions were made to deal with people swapping disks.