vfs.c
vfs/vfs.h
ubixos/vitals.h
lib/kmalloc.h
lib/kprintf.h
lib/string.h
sys/kern_descrip.h
sys/thread.h
ubixos/sched.h
ubixos/vitals.h
ubixos/types.h
sys/_types.h
lib/string.h
ubixos/time.h
vfs/file.h
sys/tss.h
lib/kmalloc.h
vfs/vfs.h
vfs/mount.h
lib/kprintf.h
sys/kern_descrip.h
ubixos/ubthread.h
ubixfs/dirCache.h
sys/sysproto.h
sys/signal.h
ubixos/tty.h
sys/io.h
src/sys/vfs/vfs.c
int int sys_open (struct thread *td, struct open_args *uap) sys_open struct thread * td struct open_args * uap

entry point for open syscall

*td

pointer to callers thread

*uap

pointer to user space arguements for call

index to file descriptor

falloc
file::fd
fopen
open_args::path
file::path
strcpy
thread::td_retval
int int vfs_init () vfs_init vitalsStruct::fileSystems kprintf systemVitals
fileSystem * struct fileSystem* vfsFindFS (int vfsType) vfsFindFS int vfsType vitalsStruct::fileSystems fileSystem::next systemVitals fileSystem::vfsType vfs_mount vfsRegisterFS
int int vfsRegisterFS (struct fileSystem newFS) vfsRegisterFS struct fileSystem newFS

register a file system

This registers a new filesystem into the vfs which is referenced when trying to mount a device

newFS

pointer to fileSystem structure

vitalsStruct::fileSystems
kmalloc
kprintf
memcpy
fileSystem::next
NULL
fileSystem::prev
systemVitals
vfsFindFS
fileSystem::vfsType
x1
devfs_init
ubixfs_init
ufs_init

    /*****************************************************************************************
    Copyright(c)2002-2004TheUbixOSProject
    Allrightsreserved.

    Redistributionanduseinsourceandbinaryforms,withorwithoutmodification,are
    permittedprovidedthatthefollowingconditionsaremet:

    Redistributionsofsourcecodemustretaintheabovecopyrightnotice,thislistof
    conditions,thefollowingdisclaimerandthelistofauthors.Redistributionsinbinary
    formmustreproducetheabovecopyrightnotice,thislistofconditions,thefollowing
    disclaimerandthelistofauthorsinthedocumentationand/orothermaterialsprovided
    withthedistribution.NeitherthenameoftheUbixOSProjectnorthenamesofits
    contributorsmaybeusedtoendorseorpromoteproductsderivedfromthissoftware
    withoutspecificpriorwrittenpermission.

    THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTORS"ASIS"ANDANY
    EXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THEIMPLIEDWARRANTIESOF
    MERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSEAREDISCLAIMED.INNOEVENTSHALL
    THECOPYRIGHTOWNERORCONTRIBUTORSBELIABLEFORANYDIRECT,INDIRECT,INCIDENTAL,
    SPECIAL,EXEMPLARY,ORCONSEQUENTIALDAMAGES(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENT
    OFSUBSTITUTEGOODSORSERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESSINTERRUPTION)
    HOWEVERCAUSEDANDONANYTHEORYOFLIABILITY,WHETHERINCONTRACT,STRICTLIABILITY,OR
    TORT(INCLUDINGNEGLIGENCEOROTHERWISE)ARISINGINANYWAYOUTOFTHEUSEOFTHIS
    SOFTWARE,EVENIFADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGE.

    $Id: vfs_8c.xml 88 2016-01-12 00:11:29Z reddawg $

    *****************************************************************************************/

    #include<vfs/vfs.h>
    #include<ubixos/vitals.h>
    #include<lib/kmalloc.h>
    #include<lib/kprintf.h>
    #include<lib/string.h>
    #include<sys/kern_descrip.h>

    /************************************************************************

    Function:voidvfs_init();

    Description:ThisFunctionInitializesTheVFSLayer

    Notes:

    02/20/2004-Approvedforquality

    ************************************************************************/
    intvfs_init(){
    /*SetupdefaultfileSystemslist*/
    systemVitals->fileSystems=0x0;

    /*Printinformation*/
    kprintf("vfs0:loadedataddress:[0x%X]\n",systemVitals->fileSystems);

    /*Returnsoweknowthingswentwell*/
    return(0x0);
    }

    structfileSystem*vfsFindFS(intvfsType){
    structfileSystem*tmp=0x0;

    /*SearchForFileSystem*/
    for(tmp=systemVitals->fileSystems;tmp;tmp=tmp->next){
    /*IfFoundReturnFileSystem*/
    if(tmp->vfsType==vfsType){
    return(tmp);
    }
    }

    /*IfFSNotFoundReturnNULL*/
    return(0x0);
    }

    intvfsRegisterFS(structfileSystemnewFS){
    /*
    intvfsType,
    void*vfsInitFS,
    void*vfsRead,
    void*vfsWrite,
    void*vfsOpenFile,
    void*vfsUnlink,
    void*vfsMakeDir,
    void*vfsRemDir,
    void*vfsSync){
    */
    structfileSystem*tmpFs=0x0;

    if(vfsFindFS(newFS.vfsType)!=0x0){
    kprintf("FSIsalreadyRegistered\n");
    return(0x1);
    }

    /*AllocateMemory*/
    tmpFs=(structfileSystem*)kmalloc(sizeof(structfileSystem));
    if(tmpFs==NULL){
    kprintf("vfsRegisterFS:memoryallocationfailed\n");
    /*MemoryAllocationFailed*/
    return(0x1);
    }

    /*SetUpFSDefaults*/

    /*20047-16-2004mji
    *Oldmethod:
    *tmpFs->vfsType=newFS.vfsType;
    *tmpFs->vfsInitFS=newFS.vfsInitFS;
    *tmpFs->vfsRead=newFS.vfsRead;
    *tmpFs->vfsWrite=newFS.vfsWrite;
    *tmpFs->vfsOpenFile=newFS.vfsOpenFile;
    *tmpFs->vfsUnlink=newFS.vfsUnlink;
    *tmpFs->vfsMakeDir=newFS.vfsMakeDir;
    *tmpFs->vfsRemDir=newFS.vfsRemDir;
    *tmpFs->vfsSync=newFS.vfsSync;
    */
    /*newmethod:*/

    memcpy(tmpFs,&newFS,sizeof(structfileSystem));
    if(!systemVitals->fileSystems){
    tmpFs->prev=0x0;
    tmpFs->next=0x0;
    systemVitals->fileSystems=tmpFs;
    }
    else{
    tmpFs->prev=0x0;
    tmpFs->next=systemVitals->fileSystems;
    systemVitals->fileSystems->prev=tmpFs;
    systemVitals->fileSystems=tmpFs;
    }

    return(0x0);
    }

    intsys_open(structthread*td,structopen_args*uap){
    interror=0x0;
    intindex=0x0;
    structfile*nfp=0x0;

    error=falloc(td,&nfp,&index);

    if(error)
    return(error);

    strcpy(nfp->path,uap->path);

    nfp->fd=fopen(uap->path,"r");
    if(nfp->fd==0x0)
    td->td_retval[0]=-1;
    else
    td->td_retval[0]=index;
    return(error);
    }

    /***
    END
    ***/