Making an Initial File Tree | 32 Bit OS Dev (in C)
Setting up an initial file tree for the OS, instead of only having a root directory.
make_disk will copy all files and folders under a host filepath, and use that as the initial file tree for first boot.
Other than a couple hardcoded paths for the bootloader, kernel, and a font, this should end up being a lot more flexible and allow an easy way to add files and folders to the OS at build time; adding text files, images, programs, etc. from a host system to the OS can be done by simply copying them into the "build" file tree.
Notes:
- Naming could've been better, e.g. get_file_info() doesn't really explain that it gets the total amounts for the superblock and overall file system.
- Found out later that vim includes a man utility already, via
":runtime! ftplugin/man.vim" (can add this to .vimrc) and ":Man" commands. Also 'K' when the cursor is on the word to search man for.
I will definitely be trying this out for the future!
- Seeking to the inode block position for an inode id could've been simplified with
fseek(IMAGE_PTR, (superblock.first_inode_block * FS_BLOCK_SIZE) + (inode.id * sizeof(inode_t)), SEEK_SET);
- The makefile or build process could change to use this new host file tree to build everything, so that the src/obj/bin/whatever folders are the single source of truth, and are the same or in "sync" inside and outside the OS, at least for the first boot after building.
The project structure would then exactly mirror the files and folders inside the OS. Not sure if that's cool or meta or anything, but it'd be pretty neat.
OS Dev Playlist:
https://www.youtube.com/playlist?list=PLT7NbkyNWaqZYHNLtOZ1MNxOt8myP5K0p
Git Repos:
https://git.sr.ht/~queso_fuego/quesos
https://github.com/queso-fuego/amateuros
Repo state at the start of this video:
git clone https://github.com/queso-fuego/amateuros
cd amateuros
git checkout 59774ed484c8d2347b44f400c9c3745c97c38a8a
Repo state at the end of this video (after other unrelated fixes/changes):
git checkout a266d6240c12b51a70e697cf82d5f47a95f960ce
Next video:
- Delete file/dir, rename, move, and delete commands, "help" or docs command, alias command, disk block or filesystem info command... or something else in the ToDos.txt file.
Join the Community Discord: https://discord.gg/yKm4T89QFn
Contact:
https://queso_fuego.srht.site/contact.html
- Let me know if there's anything specific you'd like to see!
Questions about setup/software/etc.?
Check the FAQ: https://queso_fuego.srht.site/about.html
Outline:
0:00:00 Intro, fix chdir for nested dirs and 1st free bit in superblock
0:07:06 Plan for today, create example file tree under /bin
0:10:43 Get kernel & font inodes from direct path in 3rdstage bootloader
0:21:42 Start make_disk.c changes
0:37:04 Get total # of files and disk blocks in file tree
1:16:20 Add inodes and data for files
2:19:03 Show end result, fix booting again and test
2:31:09 Show fixes for superblock and adding new files to the right spots
2:37:51 Up next & outro
Music credits:
HoliznaCC0 - In The End.mp3
Creative Commons CC0
https://freemusicarchive.org/genre/Chiptune
#osdev #filesystem #programming