kern_descrip.c
sys/kern_descrip.h
ubixos/types.h
sys/sysproto.h
sys/thread.h
lib/kprintf.h
ubixos/endtask.h
lib/kmalloc.h
assert.h
sys/thread.h
ubixos/sched.h
ubixos/endtask.h
ubixos/types.h
sys/_types.h
vfs/file.h
sys/tss.h
lib/kmalloc.h
vfs/mount.h
lib/kprintf.h
sys/kern_descrip.h
assert.h
ubixfs/dirCache.h
sys/sysproto.h
sys/signal.h
src/sys/kernel/kern_descrip.c
ubixos/tty.h
int int close (struct thread *td, struct close_args *uap) close struct thread * td struct close_args * uap close_args::fd kfree kprintf thread::o_files thread::td_retval
int int falloc (struct thread *td, struct file **resultfp, int *resultfd) falloc struct thread * td struct file ** resultfp int * resultfd kmalloc kprintf thread::o_files pipe sys_open
int int fcntl (struct thread *td, struct fcntl_args *uap) fcntl struct thread * td struct fcntl_args * uap fcntl_args::arg fcntl_args::cmd file::f_flag FCNTLFLAGS fcntl_args::fd FFLAGS kprintf O_ACCMODE thread::o_files thread::td_retval
int int fstat (struct thread *td, struct fstat_args *uap) fstat struct thread * td struct fstat_args * uap _current fstat_args::fd kprintf thread::o_files fstat_args::sb stat::st_blksize stat::st_mode taskStruct::td x1000
int int getdtablesize (struct thread *td, struct getdtablesize_args *uap) getdtablesize struct thread * td struct getdtablesize_args * uap

return data table size

kprintf
O_FILES
thread::td_retval
int int getfd (struct thread *td, struct file **fp, int fd) getfd struct thread * td struct file ** fp int fd

get pointer to file fd in specified thread

returns fp

kprintf
thread::o_files
read
int int ioctl (struct thread *td, struct ioctl_args *uap) ioctl struct thread * td struct ioctl_args * uap

ioctl functionality not implimented yet

NULL for now

thread::td_retval

    /*****************************************************************************************
    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: kern__descrip_8c.xml 88 2016-01-12 00:11:29Z reddawg $

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

    #include<sys/kern_descrip.h>
    #include<ubixos/types.h>
    #include<sys/sysproto.h>
    #include<sys/thread.h>
    #include<lib/kprintf.h>
    #include<ubixos/endtask.h>
    #include<lib/kmalloc.h>
    #include<assert.h>

    intfcntl(structthread*td,structfcntl_args*uap){
    structfile*fp=0x0;

    #ifdefDEBUG
    kprintf("[%s:%i]",__FILE__,__LINE__);
    #endif

    if(td->o_files[uap->fd]==0x0){
    kprintf("ERROR!!!\n");
    return(-1);
    }

    fp=(structfile*)td->o_files[uap->fd];
    switch(uap->cmd){
    case3:
    td->td_retval[0]=fp->f_flag;
    break;
    case4:
    fp->f_flag&=~FCNTLFLAGS;
    fp->f_flag|=FFLAGS(uap->arg&~O_ACCMODE)&FCNTLFLAGS;
    break;
    default:
    kprintf("ERRORDEFAULT");
    }

    return(0x0);
    }

    intfalloc(structthread*td,structfile**resultfp,int*resultfd){
    structfile*fp=0x0;
    inti=0;

    #ifdefDEBUG
    kprintf("[%s:%i]",__FILE__,__LINE__);
    #endif

    fp=(structfile*)kmalloc(sizeof(structfile));
    /*First5DescriptorsAreReserved*/
    for(i=5;i<1024;i++){
    if(td->o_files[i]==0x0){
    td->o_files[i]=(uInt32)fp;
    if(resultfd)
    *resultfd=i;
    if(resultfp)
    *resultfp=fp;
    break;
    }
    }
    return(0x0);
    }

    intclose(structthread*td,structclose_args*uap){
    #ifdefDEBUG
    kprintf("[%s:%i]",__FILE__,__LINE__);
    #endif
    kfree((void*)td->o_files[uap->fd]);
    td->o_files[uap->fd]=0x0;
    td->td_retval[0]=0x0;
    return(0x0);
    }

    intgetdtablesize(structthread*td,structgetdtablesize_args*uap){
    #ifdefDEBUG
    kprintf("[%s:%i]",__FILE__,__LINE__);
    #endif
    td->td_retval[0]=O_FILES;
    return(0);
    }

    /*HACK*/
    intfstat(structthread*td,structfstat_args*uap){
    structfile*fp=0x0;

    #ifdefDEBUG
    kprintf("[%s:%i]",__FILE__,__LINE__);
    #endif

    fp=(structfile*)_current->td.o_files[uap->fd];
    uap->sb->st_mode=0x2180;
    uap->sb->st_blksize=0x1000;
    kprintf("fstat:%i",uap->fd);
    return(0x0);
    }

    intioctl(structthread*td,structioctl_args*uap){
    td->td_retval[0]=0x0;
    return(0x0);
    }

    intgetfd(structthread*td,structfile**fp,intfd){
    interror=0x0;

    #ifdefDEBUG
    kprintf("[%s:%i]",__FILE__,__LINE__);
    #endif

    *fp=(structfile*)td->o_files[fd];

    if(fp==0x0)
    error=-1;

    return(error);
    }

    /***
    END
    ***/