drogon wrote:
There are even filesystems that are not even filesystems.
That's why we don't call them filesystems.
Quote:
The first forth I used simply used disk block numbers - each block corresponded to (very exactly) a page that the Apple II display could show. From what I recall, you had to put a link instruction at the bottom of one page to continue your program to the next page. The directory was literally a block which you hand-edited to show what blocks were used by what files. (It may well have been an early/original Fig Forth - this looks familiar:
https://github.com/ForthHub/FIG-Forth/b ... er/fig.fth ) Even some early mainframe computers had nothing much better than that for a while...
The P-System filesystem is basically just a minor step above the Forth Block system.
It's a block system with a directory.
I've schemed about an idea for what I was calling "block sets" to make managing multiple "chunks" of block storage easier. In the end, it's a simple directory structure pointing to continuous "sets" of blocks. The importance of the block set was that they were a first class concept within the Forth system and, specifically, things like the editor and other utilities worked with them.
The essential use case was "how do I insert a screen of code in to a block of routines" and it goes from there. For this simple use case, you need to know where to start and how long your block set was, so you would know what range of blocks need to move to make space for the new screen. Add on the additional factor of some Forth systems that use "shadow screens" for documentation means that when you insert a new screen, you actually insert TWO screens -- one for the code, one for the shadow. A shadow screen is a screen that's allocated at some fixed offset from the code block. So, if you had a set of 200 screens, the shadow screens would start at block 100. The basic idea is that you could easily swap back and forth between the normal screen and the shadow screen, using the shadow screen for documentation. It actually works pretty well, but it's one more thing you have to keep track of.
Going back to the P-System, it has a simple directory, and contiguous files. Most file systems have some kind of "table of contents" to track which sectors are in use. P-System does not. Since all of the files are contiguous, it "knows" what sectors are free or not simply looking at the directory. If it sees two entries, one starting at sector 100 and 50 long, and the next starting at 200 and 25 long, it knows that sectors 150-199 are not in use. It was a routine process to "K)runch" your drive, which simply means it compacts all of the files and removes free space in order to give you the best chance to have the most contiguous space available when creating a new file.
However, it also limits the system to only allowing a single file to be opened for write at one time. And in the previous scenario, before the compaction, if you tried to write a file that was 51+ sectors long, you'd get a "disk full", since it would start writing the file at the first free sector it found at 150, even though there may well be free sectors later on in the disk.
As I hope you can see, this is just a step up from what Forth offers. It's usable, it's trivial to implement, but does have some limitations. The implementation of a table of contents allows you to create more than one file for write at a time. At the same time, it allows disk fragmentation, which is a different problem.
Another interesting tid bit about the P-System is that beyond creating, reading, and writing files, the runtime didn't offer any routines for file manipulation. It has a "Filer" which does all of the file maintenance. There's no "rename" file system primitive you can call, rather, when you renamed a file, the Filer utility went peeking and poking in to the directory structure itself. The Filer was intimate with the file system details, but these were not published to the system at large. (This may have changed later on in later versions of the P-System.)