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.
OFS uses blocks of 2048 bytes to segment and organize data within files.
It allocates files with a default size of a single block (2 kbs) on sectors determined by the offset of the most recently created file.
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.
During initialization, or as files are created/deleted, an OFS memory cache will be built for faster and easier access of file information.
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, tag info, and the magic numbers used to by OFS to recognize data as files.
There's only really 3 file formats, 1 for general text files, 1 for images, and 1 for binary executables.
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.
Fragmentation, encryption, and compression are also implemented but they don't really work the best as of v2.1 so... sorry.
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 text-mode 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 2048 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.
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 2048 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 the 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 2048*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.
Most of the time you'll be creating and editing files in the graphical environment though, for this you can use Journal
.
Journal is the name of osakaOS' built in GUI text editor, to launch it you can just type journal
as a command in the terminal.
For any graphical program, you can use the F4 and F5 keys to save or read in files respectively. Just type in the file name and hit enter.
Different programs will have their own unique behaviour for handling files, but Journal will just read the file text into the buffer for editing.
I'll cover the different program file handling behaviour in another section, for now I'll go over some other filesystem related commands and concepts.
Tags are used for basic file organization in OFS, in a way similar to a venn diagram. Files can have tags in common, tags unique to them, and be treated as elements of different sets.
There is a maximum of 8 tags that can be assigned to a file with 32 characters for each tag string. (I've been thinking about changing this to 16 tags with 16 characters per string but idk lol).
You can use the tag (tag1, tag2, tag3....) (file)
command to assign tags to files. tag txt new
will assign a tag of txt
to the file new
.
When using the files
command, you can see any tags associated with the listed files. You can also list files that only match specific tags by passing the tags as an argument.
Likely, you can use the detag (tag1, tag2, tag3....) (file)
command to remove tags from a file.
One last thing is the ofs
command that will print out the data in the OFS memory cache currently.