Low-Level IO - I love it!

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Low-Level IO - I love it!

Post by pcmattman »

OK, I just finished the low-level ATA driver for my OS (read, write, lseek)...

Now I have to change all the ReadSector calls in my FAT32 driver to lseek/read pairs, and I've noticed how clean my code is now! It's incredible!
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

Good job, I think I speak for everyone when I say, we're all very proud of you..lol
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Seriously, read/write/ioctl/lseek/open/close - all reasonably simple to implement but really quite helpful. My device management system means I can do:

Code: Select all

int d = open( "dr0", READWRITE );
char buff[512];
lseek( d, 1024, SEEK_SET );
read( d, buff, 1 );
close( d );
To open the first hard drive for read/write access, and read in the data at sector 1024. I'm really happy it works now :D
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

umm..why is an int used?
and how do you keep track with just a simple int?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Look at your documentation:

Code: Select all

int _open( const char *filename, int oflag [, int pmode] );
(That's MSDN)

The int is nothing more than an index in a linked list of descriptors stored elsewhere.

Edit: this is it in action, when inside my fread() function:

Code: Select all

Welcome to Mattise!
Version 1.1, ALPHA
Hello world, this is a test of the fread function, which is based on the read fu
nction, which is shiny and new and hopefully works well in my OS.
Post Reply