<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Ubixos: ubixfs.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.3.3 --> <h1>ubixfs.h</h1><div class="fragment"><pre>00001 <span class="comment">/**************************************************************************************</span> 00002 <span class="comment"> Copyright (c) 2002 The UbixOS Project</span> 00003 <span class="comment"> All rights reserved.</span> 00004 <span class="comment"></span> 00005 <span class="comment">Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</span> 00006 <span class="comment"></span> 00007 <span class="comment">Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.</span> 00008 <span class="comment">Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors</span> 00009 <span class="comment">in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its</span> 00010 <span class="comment">contributors may be used to endorse or promote products derived from this software without specific prior written permission.</span> 00011 <span class="comment"></span> 00012 <span class="comment">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED</span> 00013 <span class="comment">WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR</span> 00014 <span class="comment">PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,</span> 00015 <span class="comment">INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE</span> 00016 <span class="comment">GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY</span> 00017 <span class="comment">OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY</span> 00018 <span class="comment">OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span> 00019 <span class="comment"></span> 00020 <span class="comment"> $Id$</span> 00021 <span class="comment"></span> 00022 <span class="comment">**************************************************************************************/</span> 00023 00024 <span class="preprocessor">#ifndef _UBIXFS_H</span> 00025 <span class="preprocessor"></span><span class="preprocessor">#define _UBIXFS_H</span> 00026 <span class="preprocessor"></span> 00027 <span class="preprocessor">#include <ubixos/types.h></span> 00028 <span class="preprocessor">#include <sys/device.h></span> 00029 <span class="preprocessor">#include <vfs/file.h></span> 00030 00031 <span class="preprocessor">#define UBIXDISKMAGIC ((uInt32)0x45) </span><span class="comment">/* The disk magic number */</span> 00032 <span class="preprocessor">#define MAXPARTITIONS 4</span> 00033 <span class="preprocessor"></span><span class="preprocessor">#define blockSize 8</span> 00034 <span class="preprocessor"></span><span class="preprocessor">#define blockByteSize blockSize*512</span> 00035 <span class="preprocessor"></span> 00036 <span class="preprocessor">#define EOBC -1</span> 00037 <span class="preprocessor"></span> 00038 00039 <span class="preprocessor">#define typeFile 1</span> 00040 <span class="preprocessor"></span><span class="preprocessor">#define typeContainer 2</span> 00041 <span class="preprocessor"></span><span class="preprocessor">#define typeDirectory 4</span> 00042 <span class="preprocessor"></span><span class="preprocessor">#define typeDeleted 8</span> 00043 <span class="preprocessor"></span> 00044 <span class="comment">//Partition Information</span> 00045 <span class="keyword">struct </span>ubixDiskLabel { 00046 uInt32 magicNum; 00047 uInt32 magicNum2; 00048 uInt16 driveType; 00049 uInt16 numPartitions; 00050 <span class="keyword">struct </span>drivePartitions { <span class="comment">//the partition table</span> 00051 uInt32 pSize; <span class="comment">//number of sectors in partition</span> 00052 uInt32 pOffset; <span class="comment">//starting sector</span> 00053 uInt32 pFsSize; <span class="comment">//filesystem basic fragment size</span> 00054 uInt32 pBatSize; <span class="comment">//BAT size</span> 00055 uInt8 pFsType; <span class="comment">//filesystem type, see below</span> 00056 uInt8 pFrag; <span class="comment">//filesystem fragments per block</span> 00057 } partitions[MAXPARTITIONS]; 00058 }; 00059 00060 <span class="keyword">struct </span>partitionInformation { 00061 uInt32 size; <span class="comment">//Size In Sectors</span> 00062 uInt32 startSector; <span class="comment">//Base Sector Of Partition</span> 00063 uInt32 blockAllocationTable; <span class="comment">//Base Sector Of BAT</span> 00064 uInt32 rootDirectory; <span class="comment">//Base Sector Of Root Directory</span> 00065 }; 00066 00067 <span class="comment">//Block Allocation Table Entry</span> 00068 <span class="keyword">struct </span>blockAllocationTableEntry { 00069 <span class="keywordtype">long</span> attributes; <span class="comment">//Block Attributes</span> 00070 <span class="keywordtype">long</span> realSector; <span class="comment">//Real Sector </span> 00071 <span class="keywordtype">long</span> nextBlock; <span class="comment">//Sector Of Next Block</span> 00072 <span class="keywordtype">long</span> reserved; <span class="comment">//Reserved</span> 00073 }; 00074 00075 <span class="comment">//UbixFS Directory Entry</span> 00076 <span class="keyword">struct </span>directoryEntry { 00077 uInt32 startCluster; <span class="comment">//Starting Cluster Of File</span> 00078 uInt32 size; <span class="comment">//Size Of File</span> 00079 uInt32 creationDate; <span class="comment">//Date Created</span> 00080 uInt32 lastModified; <span class="comment">//Date Last Modified</span> 00081 uInt32 uid; <span class="comment">//UID Of Owner</span> 00082 uInt32 gid; <span class="comment">//GID Of Owner</span> 00083 uShort attributes; <span class="comment">//Files Attributes</span> 00084 uShort permissions; <span class="comment">//Files Permissions</span> 00085 <span class="keywordtype">char</span> fileName[256]; <span class="comment">//File Name</span> 00086 }; 00087 00088 <span class="keyword">struct </span>bootSect { 00089 uChar jmp[4]; 00090 uChar id[6]; 00091 uShort version; 00092 uShort tmp; 00093 uShort fsStart; 00094 uShort tmp2; 00095 uInt32 krnl_start; 00096 uInt BytesPerSector; 00097 uInt SectersPerTrack; 00098 uInt TotalHeads; 00099 uInt32 TotalSectors; 00100 uChar code[479]; 00101 }; 00102 00103 <span class="keyword">struct </span>ubixFsInfo { 00104 <span class="keyword">struct </span>blockAllocationTableEntry *blockAllocationTable; 00105 uInt32 batEntries; 00106 }; 00107 00108 <span class="keywordtype">int</span> readFile(<span class="keywordtype">char</span> *file); 00109 <span class="keywordtype">int</span> writeFileByte(<span class="keywordtype">int</span> ch,fileDescriptor *fd,<span class="keywordtype">long</span> offset); 00110 <span class="keywordtype">int</span> openFileUbixFS(<span class="keywordtype">char</span> *file,fileDescriptor *fd); 00111 <span class="keywordtype">int</span> mkDirUbixFS(<span class="keywordtype">char</span> *dir,fileDescriptor *fd); 00112 <span class="keywordtype">int</span> getFreeBlocks(<span class="keywordtype">int</span> count,fileDescriptor *fd); 00113 <span class="comment">//extern struct ubixDiskLabel *diskLabel;</span> 00114 00115 <span class="comment">//Good Functions</span> 00116 <span class="keywordtype">void</span> initUbixFS(<span class="keyword">struct</span> mountPoints *mp); 00117 <span class="keywordtype">int</span> enableUbixFS(); 00118 <span class="keywordtype">int</span> readUbixFS(fileDescriptor *fd,<span class="keywordtype">char</span> *data,<span class="keywordtype">long</span> offset,<span class="keywordtype">long</span> size); 00119 <span class="keywordtype">int</span> writeUbixFS(fileDescriptor *fd,<span class="keywordtype">char</span> *data,<span class="keywordtype">long</span> offset,<span class="keywordtype">long</span> size); 00120 <span class="keywordtype">void</span> syncBat(<span class="keyword">struct</span> mountPoints *mp); 00121 <span class="keywordtype">int</span> freeBlocks(<span class="keywordtype">int</span> block,fileDescriptor *fd); 00122 <span class="keywordtype">int</span> addDirEntry(<span class="keyword">struct</span> directoryEntry *dir,fileDescriptor *fd); 00123 <span class="keywordtype">void</span> ubixFSUnlink(<span class="keywordtype">char</span> *path,<span class="keyword">struct</span> mountPoints *mp); 00124 00125 <span class="preprocessor">#endif</span> </pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed Apr 28 17:49:42 2004 for Ubixos by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.3 </small></address> </body> </html>