# ubixfs.h

Go to the documentation of this file.

    00001 /**************************************************************************************
    00002  Copyright (c) 2002 The UbixOS Project
    00003  All rights reserved.
    00004
    00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    00006
    00007 Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
    00008 Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
    00009 in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
    00010 contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    00011
    00012 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
    00013 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    00014 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    00015 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
    00016 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    00017 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    00018 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00019
    00020  $Id$
    00021
    00022 **************************************************************************************/
    00023
    00024 #ifndef _UBIXFS_H
    00025 #define _UBIXFS_H
    00026
    00027 #include <ubixos/types.h>
    00028 #include <sys/device.h>
    00029 #include <vfs/file.h>
    00030
    00031 #define UBIXDISKMAGIC     ((uInt32)0x45)
    00032 #define MAXPARTITIONS     4
    00033 #define blockSize         8
    00034 #define blockByteSize     blockSize*512
    00035
    00036 #define EOBC              -1
    00037
    00038
    00039 #define typeFile      1
    00040 #define typeContainer 2
    00041 #define typeDirectory 4
    00042 #define typeDeleted   8
    00043
    00045 struct ubixDiskLabel {
    00046   uInt32 magicNum;
    00049   uInt16 numPartitions;
    00051   struct  drivePartitions {
    00052     uInt32 pSize;
    00053     uInt32 pOffset;
    00054     uInt32 pFsSize;
    00055     uInt32 pBatSize;
    00056     uInt8  pFsType;
    00057     uInt8 pFrag;
    00058     } partitions[MAXPARTITIONS];
    00059   };
    00060
    00061 struct partitionInformation {
    00062   uInt32 size;
    00063   uInt32 startSector;
    00064   uInt32 blockAllocationTable;
    00065   uInt32 rootDirectory;
    00066   };
    00067
    00069 struct blockAllocationTableEntry {
    00070   long attributes;
    00071   long realSector;
    00072   long nextBlock;
    00073   long reserved;
    00074   };
    00075
    00077 struct directoryEntry {
    00078   uInt32  startCluster;
    00079   uInt32  size;
    00080   uInt32  creationDate;
    00081   uInt32  lastModified;
    00082   uInt32  uid;
    00083   uInt32  gid;
    00084   uInt16 attributes;
    00085   uInt16 permissions;
    00086   char   fileName[256];
    00087 };
    00088
    00090 struct bootSect {
    00091   uInt8 jmp[4];
    00092   uInt8 id[6];
    00093   uInt16 version;
    00094   uInt16 tmp;
    00095   uInt16 fsStart;
    00096   uInt16 tmp2;
    00097   uInt32 krnl_start;
    00098   uInt BytesPerSector;
    00099   uInt SectersPerTrack;
    00100   uInt TotalHeads;
    00101   uInt32 TotalSectors;
    00102   uInt8 code[479];
    00103   };
    00104
    00106 struct ubixFsInfo {
    00107   struct blockAllocationTableEntry *blockAllocationTable;
    00108   uInt32 batEntries;
    00109   };
    00110
    00111 int readFile(char *file);
    00112 int writeFileByte(int ch,fileDescriptor *fd,long offset);
    00116 int openFileUbixFS(char *file,fileDescriptor *fd);
    00118 int mkDirUbixFS(char *dir,fileDescriptor *fd);
    00119 int getFreeBlocks(int count,fileDescriptor *fd);
    00120
    00121 //Good Functions
    00124 int enableUbixFS();
    00127 void initUbixFS(struct mountPoints *mp);
    00130 int readUbixFS(fileDescriptor *fd,char *data,long offset,long size);
    00133 int writeUbixFS(fileDescriptor *fd,char *data,long offset,long size);
    00134 void syncBat(struct mountPoints *mp);
    00135 int freeBlocks(int block,fileDescriptor *fd);
    00136 /* Adds a file to a directory. Returns 0 */
    00137 int addDirEntry(struct directoryEntry *dir,fileDescriptor *fd);
    00139 void ubixFSUnlink(char *path,struct mountPoints *mp);
    00140
    00141 #endif