Projects


osakaOS v1.0 - Files III

This page will go over the OsakaFileSystem (OFS) and how to create/edit/manage files. Once again I'll go over the technical details of OFS first.
Many of the finer details are subject to change in later versions of the OS, but I'll go over OFS how its currently implemented in version 1.0.

OFS uses blocks of 1920 bytes to segment and organize data within files. It would be a lot easier to have blocks in powers of 2, but this makes it more fun.
It allocates files with a default size of a single block (1920 bytes) on sectors determined by the hash value of the given file name.
File names can contain any typable characters with a maximum length of 32 characters. There cannot exist two different files with the same name.
The main reason being that OFS doesn't have directories/folders or any file hierarchies at all. Files can be accessed from anywhere on the system.
OFS doesn't have to format the disk before it can be used for day-to-day usage. The filesystem formats only the parts of the disk necessary for basic operation.

Just like many other aspects of osakaOS, OFS is very simplistic in its functionality, so it only makes sense it is equally simple in its operation and overhead.
As you create files, records will be added to a table beginning at sector 512. This table only records the number of existing files on the system, and their location.
When a file is created, its first sector will be filled with metadata such as the filename, size, and the magic numbers used to by OFS to recognize data as files.

There are currently no file formats supported by the OS, so every file is treated as a general purpose text file.
Currently OFS works best with unformatted PIIX4 drives with at least 1 MB of disk space. They're the only supported storage devices I made drivers for.
As mentioned earlier, OFS is subject to go through dramatic changes in the future, and most of the major bugs within the OS are the fault of OFS, a skill issue on my part.
I hope to flesh out the filesystem more to address things like fragmentation, changing file sizes, automated file I/O, so expect this page to drastically change in the future.

How to Create and Edit Files

With the technical details of OFS out of the way I will go over the process of creating and editing files.

The File Edit mode is used for most file operations. It can be accessed using the keyboard shortcut ctrl-e, and can be exited using ctrl-c.
Upon hitting ctrl-e, you will be greeted with a TUI where you will be asked to enter a filename. A valid name must be entered before you can progress.



The program will then attempt to read the file and display it on screen for you to edit. If the file doesn't exist it will be blank, or filled with whatever data was found.
You can move the cursor around the screen with the arrow keys to change position in the file. Typing will enter all characters behind the cursor's position in the file.
If you want to return to the file search screen, you can press escape and the program will save the place of the last block you were editing, but it won't actually save the data.
Backspace is used to delete characters (overwrite with 0) and tab is used to change the cursor position by 4 characters to the right. Ctrl-w will save any changes to the file block.
When you open a file it will read the first block and any changes written will only apply to that block. Ctrl-Left/RightArrow will go to the previous and next block in the file.

As an example, I will make a file called test that will be written to multiple blocks and then deleted. I will also look at its size and entry on the OFS table.
To delete files and find their size, the following commands can be used.


size (file) ex. size myfile output: 'myfile' is 1920 bytes large.

Reads the metadata sector of given file and returns the size of the file in bytes.


delete (file) ex. delete myfile output: myfile was deleted.

Deletes all data from given file and removes it from OFS table.


After entering the file name, this screen shows up.



The bottom-left text is the name of the file currently being edited and the bottom right is the number of the current block.
Then I'll type the data I want in this file and hit ctrl-w to save it to disk. Since this file didn't exist before, a message lets us know it was created for us.



When I exit to the command line with ctrl-c, I can see that test is listed in the table and has a size of 1920 bytes.



Now I'll go back to edit the file and write data to its second block. I can go to the next block by using ctrl-right_arrow.
You can see that the LBA is now 1 and the program says that the file has been saved, meaning the file we're writing to already exists.
You must hit ctrl-w to save data to each block, if you change blocks without saving, all changed data will be lost.



This time when I ask for the size of test, it is now 1920*2 bytes since it is 2 blocks large.
Using the delete command will overwrite the file with 0's and remove it from the table.



The next page will go over the other software modes.

Previous Page                    Next Page