00001 /***************************************************************************************** 00002 Copyright (c) 2002-2004 The UbixOS Project 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, are 00006 permitted provided that the following conditions are met: 00007 00008 Redistributions of source code must retain the above copyright notice, this list of 00009 conditions, the following disclaimer and the list of authors. Redistributions in binary 00010 form must reproduce the above copyright notice, this list of conditions, the following 00011 disclaimer and the list of authors in the documentation and/or other materials provided 00012 with the distribution. Neither the name of the UbixOS Project nor the names of its 00013 contributors may be used to endorse or promote products derived from this software 00014 without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 00017 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00019 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00020 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00021 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00022 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 00023 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00024 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 00026 $Id$ 00027 00028 *****************************************************************************************/ 00029 00030 #include <vfs/vfs.h> 00031 #include <ubixos/vitals.h> 00032 #include <lib/kmalloc.h> 00033 #include <lib/kprintf.h> 00034 #include <lib/string.h> 00035 00036 /************************************************************************ 00037 00038 Function: void vfs_init(); 00039 00040 Description: This Function Initializes The VFS Layer 00041 00042 Notes: 00043 00044 02/20/2004 - Approved for quality 00045 00046 ************************************************************************/ 00047 int vfs_init() { 00048 /* Set up default fileSystems list */ 00049 systemVitals->fileSystems = 0x0; 00050 00051 /* Print information */ 00052 kprintf("vfs0: loaded at address: [0x%X]\n",systemVitals->fileSystems); 00053 00054 /* Return so we know things went well */ 00055 return(0x0); 00056 } 00057 00058 struct fileSystem *vfsFindFS(int vfsType) { 00059 struct fileSystem *tmp = 0x0; 00060 00061 /* Search For File System */ 00062 for (tmp=systemVitals->fileSystems;tmp;tmp=tmp->next) { 00063 /* If Found Return File System */ 00064 if (tmp->vfsType == vfsType) { 00065 return(tmp); 00066 } 00067 } 00068 00069 /* If FS Not Found Return NULL */ 00070 return(0x0); 00071 } 00072 00073 int vfsRegisterFS(struct fileSystem newFS) { 00074 /* 00075 int vfsType, 00076 void *vfsInitFS, 00077 void *vfsRead, 00078 void *vfsWrite, 00079 void *vfsOpenFile, 00080 void *vfsUnlink, 00081 void *vfsMakeDir, 00082 void *vfsRemDir, 00083 void *vfsSync) { 00084 */ 00085 struct fileSystem *tmpFs = 0x0; 00086 00087 if (vfsFindFS(newFS.vfsType) != 0x0) { 00088 kprintf("FS Is already Registered\n"); 00089 return(0x1); 00090 } 00091 00092 /* Allocate Memory */ 00093 tmpFs = (struct fileSystem *)kmalloc(sizeof(struct fileSystem)); 00094 if (tmpFs == NULL) { 00095 kprintf("vfsRegisterFS: memory allocation failed\n"); 00096 /* Memory Allocation Failed */ 00097 return(0x1); 00098 } 00099 00100 /* Set Up FS Defaults */ 00101 00102 /* 2004 7-16-2004 mji 00103 * Old method: 00104 * tmpFs->vfsType = newFS.vfsType; 00105 * tmpFs->vfsInitFS = newFS.vfsInitFS; 00106 * tmpFs->vfsRead = newFS.vfsRead; 00107 * tmpFs->vfsWrite = newFS.vfsWrite; 00108 * tmpFs->vfsOpenFile = newFS.vfsOpenFile; 00109 * tmpFs->vfsUnlink = newFS.vfsUnlink; 00110 * tmpFs->vfsMakeDir = newFS.vfsMakeDir; 00111 * tmpFs->vfsRemDir = newFS.vfsRemDir; 00112 * tmpFs->vfsSync = newFS.vfsSync; 00113 */ 00114 /* new method: */ 00115 00116 memcpy(tmpFs, &newFS, sizeof(struct fileSystem)); 00117 if (!systemVitals->fileSystems) { 00118 tmpFs->prev = 0x0; 00119 tmpFs->next = 0x0; 00120 systemVitals->fileSystems = tmpFs; 00121 } 00122 else { 00123 tmpFs->prev = 0x0; 00124 tmpFs->next = systemVitals->fileSystems; 00125 systemVitals->fileSystems->prev = tmpFs; 00126 systemVitals->fileSystems = tmpFs; 00127 } 00128 00129 return(0x0); 00130 } 00131 00132 /*** 00133 END 00134 ***/ 00135
 1.4.7
 1.4.7