flat assembler
Message board for the users of flat assembler.

Index > OS Construction > any idea of file system support in a boot loader?

Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 04 Aug 2011, 11:43
i seek a way to load a binary file using path.

but path means... file system, and i still don't have my own file system.

fat32?
fat12?
ntfs?
ext?
etc???

when i see that file systems are all different, and maybe more or less independant from the bootcode... maybe it is a good idea to make a dual load in the bootloader.

first load the file system lib that starts in the second sector, or elsewhere...
second, load the file using the file system lib freshly loaded.

then, when you will modify the boot sector, you will not need to modify the file system routine.

you will be able to install the same bootloader, on any drive, with any file system, assuming they all have the corresponding driver installed on them.
Post 04 Aug 2011, 11:43
View user's profile Send private message Visit poster's website Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 04 Aug 2011, 16:30
All OSs I know of support booting off of only one or at most two FS(s). Bootloaders are usually FS-dependent. If you want to support more than one FS, simply write two (or more) different bootloaders and give the user the option of installing either one of them when they install the OS.
A 1 sector bootloader is more than enough to load files. It's done in virtually every existing OS. It doesn't really take that much code to read and traverse the entire FS hierarchy. You only need a very basic read-only support at that stage, i.e. sector reading routines and a lot of loops and checks depending on the FS structures you're reading and parsing (BPB, superblock, FAT, MFT, inode table, root directory).

On the other hand, the entire first track (minus the bootloader) is often kept free of data and boot managers (for example) usually fill that space with their own code so you could very well use it too.

It's your OS, write it as you wish...
Post 04 Aug 2011, 16:30
View user's profile Send private message Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 04 Aug 2011, 16:54
In my opinion the best option is to create one read-only plain partition for kernel, drivers and all the stuff that works in priviligies level 0, and modules that work as regular applications(GUI, etc) should go to any other partition.
This should provide security for kernel, driver, etc and free you from writing FS driver in bootloader Cool

_________________
_______________________________
NSOS
Post 04 Aug 2011, 16:54
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 04 Aug 2011, 17:17
My boot images construct their own FS but calculate absolute LBAs for the boot sector/loader to use to load the core, system and basic drivers. Higher up, the proper FS handling will be used and can access the full FS not just those particular files I've selected. I find this a nice lazy shortcut Laughing (it also means I only have to implement my FS once which is designed towards 64bit rather 16/32bit)
Post 04 Aug 2011, 17:17
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 05 Aug 2011, 09:03
A stage 1 boot loader is boot device and file system specific. You could use call back technique for access to stage 1 boot loader's API. But this technique has two essential lacks such as RM (maybe only for me) and small size of boot loader in some cases that is reason to have no support for paths (only reading from root dir is supported).

Other way is to load two files instead one from root dir by stage 1 boot loader. The first one could be a stage 2 boot loader and the second one could be a driver for specific boot device and file system. I use this technique in two variants:
1) to load basic system modules from root dir I just load kernel and PM boot device and file system driver by stage 1 boot loader;
2) to load basic system modules from other than root dir I load stage 2 boot loader and RM boot device and file system driver by stage 1 boot loader and then I load kernel and PM boot device and file system driver by stage 2 boot loader (which use a specific RM driver).
Or the first file could be a stage 2 boot loader for specific boot device and file system and the second one could be a configuration file for this boot loader.


Last edited by egos on 05 Aug 2011, 10:31; edited 1 time in total
Post 05 Aug 2011, 09:03
View user's profile Send private message Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 05 Aug 2011, 10:28
cod3b453 wrote:
I find this a nice lazy shortcut

All long journies start from words "I know a shortcut" Laughing

_________________
_______________________________
NSOS
Post 05 Aug 2011, 10:28
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 05 Aug 2011, 16:36
BOTOKILLER wrote:
cod3b453 wrote:
I find this a nice lazy shortcut

All long journies start from words "I know a shortcut" Laughing
The keyword here is nice Razz In this case, the additional code for proper implementation would violate the lowest common multiple of 512 byte sector devices.

(Nasty shortcuts are my page mapping code Shocked Embarassed )
Post 05 Aug 2011, 16:36
View user's profile Send private message Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 11 Aug 2011, 11:51
Also, How do file systems map 'free space'???

_________________
_______________________________
NSOS
Post 11 Aug 2011, 11:51
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 11 Aug 2011, 15:01
Different FSs use different methods. One easy and efficient one is to use bitmaps. Check the See also section at the end of the article for other methods.
Post 11 Aug 2011, 15:01
View user's profile Send private message Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 11 Aug 2011, 15:25
ManOfSteel wrote:
Different FSs use different methods. One easy and efficient one is to use bitmaps. Check the See also section at the end of the article for other methods.

Thanks!!!
I'll to mix B-tree and bitmap cuz b-tree is complex and bitmap is large

_________________
_______________________________
NSOS
Post 11 Aug 2011, 15:25
View user's profile Send private message Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 08 Sep 2011, 09:28
One more question:
How do I edit files that located in my FS ???
Post 08 Sep 2011, 09:28
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 08 Sep 2011, 10:42
Using an editor of some kind (text, hex, etc.) that calls FS-independent file operation functions (e.g. open, seek, write, etc.) that call FS-dependent APIs that call low-level disk routines (e.g. write block).
In case you were wondering how big that is, the code used in everything except the editor is probably 1/3 (or more) of the entire OS.
Post 08 Sep 2011, 10:42
View user's profile Send private message Reply with quote
xleelz



Joined: 12 Mar 2011
Posts: 86
Location: In Google Code Server... waiting for someone to download me
xleelz 11 Sep 2011, 01:19
BOTOKILLER wrote:
One more question:
How do I edit files that located in my FS ???


if you're wanting to learn how to design a FS in entirety I'd suggest reading Practical File System Design with the Be File System

_________________
The person you don't know is the person that could help you the most... or rape you, whichever they prefer.
Post 11 Sep 2011, 01:19
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.