/************************************************************************************** Copyright (c) 2002 The UbixOS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are prohibited. $Id$ **************************************************************************************/ #include <ubixfs/ubixfs.h> #include <ubixfs/file.h> #include <drivers/fdc.h> #include <drivers/video.h> int startSector; void initUbixFS() { int i=0; struct bootSect *bs; char data[512]; readBlock(0,data,1); bs = (void *)data; if ((bs[0].id[0] == 'U') && (bs[0].id[1] == 'b') && (bs[0].id[2] == 'i') && (bs[0].id[3] == 'x') && (bs[0].id[4] == 'F') && (bs[0].id[5] == 'S')) { startSector = bs[0].fsStart; kprintf("UbixFS Initialized\n"); } else { kprintf("Insert System Disk\n"); initUbixFS(); } for (i=0;i<maxFd;i++) { fdTable[i].status = fdAvail; } } int kstrcmp(char *str1, char *str2) { while(*str1 == *str2 && *str1!=0 && *str2!=0) { str1++; str2++; } if(*str1 == *str2) return 0; if(*str1 > *str2) return 1; if(*str1 < *str2) return -1; return -1; } int readFile(char *file) { struct fileTableEntry ft[1]; char data[2048]; // findFile(file,ft); if (ft->start > 1000) { } else { readBlock(ft->start,data,ft->length); kprint(data); } return(0); } int getFileByte(int fd,int offset) { int ch=0,mp=0; mp = offset/512; if ((offset%512 == 0) && (fdTable[fd].status == fdRead)) { fdTable[fd].status = fdOpen; } if (offset < fdTable[fd].size) { if (fdTable[fd].status != fdRead) { readBlock(fdTable[fd].start+mp,fdTable[fd].buffer,1); fdTable[fd].status = fdRead; } ch = fdTable[fd].buffer[offset-(mp*512)]; } else { ch = -1; fdTable[fd].status = fdEof; } return(ch); } int findFile(char *file,struct fileDescriptorTable *head) { int i=0; struct fileTableEntry *ft; char data[4096]; kprintf("Getting Somewhere\n"); readBlock(startSector,data,8); kprintf("Read Blocks\n"); ft = (void *)data; for (i=0;i<128;i++) { if (!kstrcmp(ft[i].fileName,file)) { head->start = ft[i].start; head->length = ft[i].length; head->size = ft[i].size; return(1); } } return(0); }