Page 2 of 2

Posted: Sat May 12, 2007 3:05 pm
by madeofstaples
A few more questions I realized about partition tables as I started:

I tried a search on partition tables.... doesn't the CHS format of the partition tables limit to 8.4 GB partitions? There are LBA values, and they are 32-bits... which allows for drives up to 2 TB's, so I don't think I need to worry about this (until I start worrying about RAID, etc), HOWEVER, if LBA48 isn't supported, then LBA28 limits us down to 137 GB's. How is it that I can have a 500 GB hard drive, with a partition starting at 250 GB's? This is larger than any CHS value or LBA value in the partition table can describe!


I thought I came across a partition table document that talked about using 48-bit fields for partitions (or something like that) but I can't seem to find it

Posted: Sat May 12, 2007 3:56 pm
by mathematician
It's just my opinion, but I think you could save yourself a lot of trouble if, MS-DOS style, you had your second stage loader at a fixed location in the root directory and on the disk. If you are worried about somebody accidentally deleting it, then make sure they can't. Have a flag in the directory for files which absolutely must not be deleted, and make sure that there is no system call which would allow the user to clear that flag. Or simply have the system recognise the files which mustn't be deleted either by name, or with an appropriately sophisticated checksum.

Just my opinion.

Posted: Sat May 12, 2007 4:12 pm
by madeofstaples
mathematician wrote:It's just my opinion, but I think you could save yourself a lot of trouble if, MS-DOS style, you had your second stage loader at a fixed location in the root directory and on the disk. If you are worried about somebody accidentally deleting it, then make sure they can't. Have a flag in the directory for files which absolutely must not be deleted, and make sure that there is no system call which would allow the user to clear that flag. Or simply have the system recognise the files which mustn't be deleted either by name, or with an appropriately sophisticated checksum.

Just my opinion.
Suppose they delete it from another OS with the standard ext2 driver (since, there really isn't such a flag). They should be able to fix it by simply placing it back on the drive in the correct location.

However, you did give me a good idea:
The partition bootloader should look for the second stage in head 0, track 0 of the drive. If it's not there, it should have an offset of the file on the drive stored, and simply load it from the drive. If it doesn't find the signature there either, it should scan the partition. Still no second stage, then the user must've done something and not fixed it, so display an error.

Of course, when I get into the user-space programs of my OS, I'd make it display warnings upon warnings (or just flat out refuse) if you try to delete important files.

Posted: Sat May 12, 2007 4:34 pm
by mathematician
madeofstaples wrote:There are LBA values, and they are 32-bits... which allows for drives up to 2 TB's, so I don't think I need to worry about this (until I start worrying about RAID, etc), HOWEVER, if LBA48 isn't supported, then LBA28 limits us down to 137 GB's.
The answer must be that, on drives large enough to require it, LBA48 must be supported, mustn't it? Unless you mean literally that you own a 500gb drive which only supports LBA28.

Once drives get beyond 2Tb I suppose they will have to redesign partition tables; with something to indicate that this is a "new style" parttion table with CHS values no longer present, but with potentially huge LBA values.

Posted: Sat May 12, 2007 4:47 pm
by madeofstaples
mathematician wrote:
madeofstaples wrote:There are LBA values, and they are 32-bits... which allows for drives up to 2 TB's, so I don't think I need to worry about this (until I start worrying about RAID, etc), HOWEVER, if LBA48 isn't supported, then LBA28 limits us down to 137 GB's.
The answer must be that, on drives large enough to require it, LBA48 must be supported, mustn't it? Unless you mean literally that you own a 500gb drive which only supports LBA28.

Once drives get beyond 2Tb I suppose they will have to redesign partition tables; with something to indicate that this is a "new style" parttion table with CHS values no longer present, but with potentially huge LBA values.
Err, my 500 GB drive probably supports LBA48... I guess I was just confused about how, if you only have LBA28, then you can only use 28 of the 32 bits, but if you have LBA48, the bottlekneck becomes the 32 bits, but I get it now... so should I just ignore the CHS values, then?

Also, should I display an error if the partition I need to access has more than 28 bits set in the LBA offset or length fields when there's no LBA48 support? Or can I trust that this never happens?

what happens to the CHS values when a partition starts and/or ends after the 8.4 GB barrier?

Posted: Sat May 12, 2007 4:49 pm
by mathematician
Although we write operating systems with the hypothesis that people other than ourselves will be using it once it is finished, but also with the knowledge that, in 99% of cases, that won't be the case. As much as it pains me to say it.

Unless you have a really new idea, and that really new idea has a potential market large enough to at least keep you fed and watered.

Posted: Sat May 12, 2007 4:52 pm
by mathematician
You can ignore the CHS values if you want to. They will be on their way out anyway when more space is needed for LBA values, but the size of partition table entries can't be changed

Posted: Sat May 12, 2007 4:53 pm
by Brynet-Inc
mathematician wrote:Although we write operating systems with the hypothesis that people other than ourselves will be using it once it is finished, but also with the knowledge that, in 99% of cases, that won't be the case. As much as it pains me to say it.

Unless you have a really new idea, and that really new idea has a potential market large enough to at least keep you fed and watered.
Don't be so negative... You can always leave.. nobody is begging you to stay ;)

Posted: Sat May 12, 2007 5:10 pm
by Aali
madeofstaples wrote: Suppose they delete it from another OS with the standard ext2 driver (since, there really isn't such a flag).
immutable would accomplish that, no?

Posted: Sat May 12, 2007 5:57 pm
by madeofstaples
Aali wrote:
madeofstaples wrote: Suppose they delete it from another OS with the standard ext2 driver (since, there really isn't such a flag).
immutable would accomplish that, no?
Err, well the other OS would still let you unset that flag

Posted: Sun May 13, 2007 4:03 am
by Aali
yeah, and similarly, any OS would let you "dd if=/dev/zero of=/dev/hda" or equivalent

i would still say its 'good enough' to make it immutable
you could always write a tool that will recreate the files from another OS, just in case

Posted: Sun May 13, 2007 4:26 am
by mathematician
You seem to want your security to be tighter than that on any commercially available operating system. but there is only so much you can do to protect people from themselves. If I really wanted to I could go to the Windows system folder, and delete the file system, or something stupid like that, but I have no intention of doing so. It is hard to see why anybody else would arbitrarily delete a file whose purpose thay perhaps have no idea of (except that it resides in a system folder). If they do..... well like I say, there is only so much you can do to protect them from themselves.

Won't the ext2 file system let you hide files/folders? If it won't maybe you could put most of the really critical stuff on a hidden partition.

Posted: Sun May 13, 2007 7:47 am
by earlz
I don't have much time, but just want to tell you of a small project I started called SecOS, which was an OS in a bootsector...it might give you a bit of some hints or something as to how to code for small sizes...

it's website link is at http://jouleos.galekus.com/secos.php

it unfortunately only does floppy booting..(or at least floppy reading)

Posted: Sun May 13, 2007 1:30 pm
by madeofstaples
mathematician wrote:Although we write operating systems with the hypothesis that people other than ourselves will be using it once it is finished, but also with the knowledge that, in 99% of cases, that won't be the case. As much as it pains me to say it.

Unless you have a really new idea, and that really new idea has a potential market large enough to at least keep you fed and watered.
Although it's probably true, thinking like that when writing anything will just cement the fact.
mathematician wrote:You seem to want your security to be tighter than that on any commercially available operating system. but there is only so much you can do to protect people from themselves.
Point taken, maybe I'll just write a bootloader that loads from a static position on the hard drive, and perhaps later I can go back and add security policies to keep it from being tampered with.

Because I think an OS should definitely be designed to protect it's own bootcode, but it shouldn't be designed to limit the user (so if the user really wants to destroy things, he/she can).
hckr83 wrote:I don't have much time, but just want to tell you of a small project I started called SecOS, which was an OS in a bootsector...it might give you a bit of some hints or something as to how to code for small sizes...

it's website link is at http://jouleos.galekus.com/secos.php

it unfortunately only does floppy booting..(or at least floppy reading)
I've seen your project while browsing through these forums, it looks very interesting, but I haven't taken a look at your code. Will do, thanks.