Seek 4 Help!!!
- voonwah
Seek 4 Help!!!
Post by voonwah »
i'm currently develop my own OS, and now i'm facing some problem, i wish to write a ''Dir" function just like in the MS-DOS, what i have to do is to call out the function like this??
my OS already support the FAT12 file system.My OS just currenty support the floppy drive file system.
Can any i can provide me some sample code like this?
Thanks....
<edit by="pype"> made a whole sentence </edit>
- proxy
Re:Seek 4 Help!!!
Post by proxy »
getdirentry, open, close, read, write, seek
proxy
- Pype.Clicker
- Member
Member - Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Seek 4 Help!!!
Post by Pype.Clicker »
Code: Select all
new_number read_dir_entry(dir_handle, old_number [,search_pattern]);
Code: Select all
new_number read_dir_entries(dir_handle, old_number, how_many_entries, &buffer);
- kataklinger
- Member
Member - Posts: 381
- Joined: Fri Nov 04, 2005 12:00 am
- Location: Serbia
Re:Seek 4 Help!!!
Post by kataklinger »
- Dex4u
Re:Seek 4 Help!!!
Post by Dex4u »
From there you can add, more functionality.
If you need some example code there some here:
http://alexfru.chat.ru/epm.html#los4d
Called "OS Development for Dummies"
- GLneo
Re:Seek 4 Help!!!
Post by GLneo »
Code: Select all
void put_dir()
{
int x, dirs = 0, files = 0, count = 0;
printf("\n Volume in drive A is %s\n Volume Serial Number is %i\n Directory of %s\n\n", \
floppy1.volume_label, floppy1.volume_id, current);
for(x = 0; x < 224; x++)
{
if(!((dir[(x * 32) + 11] & 0x80) || (dir[(x * 32) + 11] & 0x40) || (dir[(x * 32) + 11] & 0x08) || (dir[(x * 32) + 0] == 0xE5) || (dir[(x * 32) + 0] == 0x00)))
{
memdump(dir + (x * 32), 11);
if(dir[(x * 32) + 11] & 0x10)
{
puts(" <DIR>");
dirs++;
}
else
{
putintrm(*((int *)(dir + (x * 32) + 28)), 14);
printf(" %i-%i-%i", 1 + ((*((short *)(dir + (x * 32) + 24))) & 0xF0), 1 + ((*((short *)(dir + (x * 16) + 24))) & 0xF), ((*((short *)(dir + (x * 32) + 24))) & 0x3F00) - 20);
printf(" %i:%i%c", 10, 32, 'p');
putchar(' ');
while(count != 8)
{
if(dir[(x * 32) + count] != ' ')
putchar(dir[(x * 32) + count]);
count++;
}
putchar('.');
count = 0;
while(count != 3)
{
if(dir[(x * 32) + 8 + count] != ' ')
putchar(dir[(x * 32) + 8 + count]);
count++;
}
files++;
}
putchar('\n');
}
}
printf(" %i file(s)\n %i dir(s)\n", files, dirs);
}
Re:Seek 4 Help!!!
- kataklinger
- Member
Member - Posts: 381
- Joined: Fri Nov 04, 2005 12:00 am
- Location: Serbia
- Pype.Clicker
- Member
Member - Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Seek 4 Help!!!
Post by Pype.Clicker »
Code: Select all
/* (from the FAQ) Bytes Meaning
0 - 10 File name with extension
11 Attributes of the file
12 - 21 Reserved Bytes
22 - 23 Indicate the time
24 - 25 Indicate the date
26 - 27 Indicate the entry cluster value
28 - 31 Indicate the size of the file
*/
struct fat_direntry {
unsigned char name[11];
unsigned char attr;
char _reserved[10];
unsigned short time;
unsigned short date;
unsigned short cluster;
unsigned size;
};
Code: Select all
struct fat_direntry* dir;
#define FAT_DELETED 0xE5
#define FAT_END_OF_DIRECTORY 0
void put_dir()
{
int x, dirs = 0, files = 0, count = 0;
printf("\n Volume in drive A is %s\n Volume Serial Number is %i\n Directory of %s\n\n", \
floppy1.volume_label, floppy1.volume_id, current);
for(x = 0; x < 224; x++)
{
if(!((dir[x].attr & 0x80) || (dir[x].attr & 0x40) || dir[x].attr & 0x08) ||
(dir[x].name[0] == FAT_DELETED) || (dir[x].name[0] == FAT_END_OF_DIRECTORY)))
{
memdump(dir[x], 11); // print the name ? debug ?
if(dir[x].attr & 0x10)
{
puts(" <DIR>");
dirs++;
}
else
{
putintrm(dir[x].size, 14);
printf(" %i-%i-%i", 1 + (dir[x].date & 0xF0), 1 + (dir[x].date & 0xF), (dir[x].date & 0x3F00) - 20);
printf(" %i:%i%c", 10, 32, 'p'); // fake time
putchar(' ');
while(count < 8)
{
if(dir[x].name[count] != ' ')
putchar(dir[x].name[count]);
count++;
}
putchar('.');
count = 0;
while(count < 3)
{
if(dir[x].name[count+8] != ' ')
putchar(dir[x].name[count+8]);
count++;
}
files++;
}
putchar('\n');
}
}
printf(" %i file(s)\n %i dir(s)\n", files, dirs);
}
- Pype.Clicker
- Member
Member - Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Seek 4 Help!!!
Post by Pype.Clicker »
so we can later rewrite/* still from the faq
Starting with the right most bit, which is the zero bit and working over to the left most bit the 7th bit the attributes are; read only, hidden, system file, volume label, sub-directory, archive, and the last two bits the 6th and 7th bits indicate resolved. In this particular file it is the 5th bit that is on meaning that it is an achieve file.
*/
Code: Select all
enum fat_attributes {
READ_ONLY=1,
HIDDEN=2,
SYSTEM=4,
VOLUME_LABEL=8,
DIRECTORY=16,
ARCHIVE=32,
WEIRD0=64, // dunno the meaning for these (LFN ?)
WEIRD1=128, //ditto here.
};
Code: Select all
if(!((dir[x].attr & 0x80) || (dir[x].attr & 0x40) || dir[x].attr & 0x08) ||
(dir[x].name[0] == FAT_DELETED) || (dir[x].name[0] == FAT_END_OF_DIRECTORY)))
{
Code: Select all
// any 'unwanted' bit set and we just skip the entry.
if (dir[x].attr&(WEIRD0|WEIRD1|VOLUME_LABEL) continue;
if (dir[x].name[0]==FAT_DELETED || dir[x].name[0]==FAT_END_DIRECTORY) continue;
// rest of the 'if ...' block comes here
- kataklinger
- Member
Member - Posts: 381
- Joined: Fri Nov 04, 2005 12:00 am
- Location: Serbia
- Infection 93
Re:Seek 4 Help!!!
Post by Infection 93 »
Voonwah, can you post me your FAT12 SourceCode or what it is?
Thank you very much!
- Ryu
Re:Seek 4 Help!!!
Post by Ryu »
Nevermind, you didn't hear that GLNeo. :P
- GLneo
Re:Seek 4 Help!!!
Post by GLneo »