ufs.h
ubixos/types.h
vfs/vfs.h
sys/device.h
src/sys/include/ubixos/init.h
src/sys/ufs/ffs.c
src/sys/ufs/ufs.c
src/sys/include/ufs/ufs.h
sys/thread.h
ubixos/types.h
sys/_types.h
vfs/file.h
vfs/vfs.h
vfs/mount.h
ubixfs/dirCache.h
sys/sysproto.h
sys/signal.h
sys/device.h
src/sys/ufs/ffs.c
src/sys/include/ufs/ufs.h
src/sys/ufs/ufs.c
src/sys/init/main.c
src/sys/include/ubixos/init.h
csum
csum_total
dirent
fs
ufs1_dinode
ufs2_dinode
blkoff
fs
loc
/* calculates (loc % fs->fs_bsize) */ \ ((loc) & (fs)->fs_qbmask)
fsread
cgbase
fs
c
(((ufs2_daddr_t)(fs)->fs_fpg) * (c))
cgdmin
fs
c
(cgstart(fs, c) + (fs)->fs_dblkno)
cgimin
fs
c
(cgstart(fs, c) + (fs)->fs_iblkno)
cgsblock
fs
c
(cgstart(fs, c) + (fs)->fs_sblkno)
cgstart
fs
c
((fs)->fs_magic == FS_UFS2_MAGIC ? cgbase(fs, c) : \ (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask))))
cgtod
fs
c
(cgstart(fs, c) + (fs)->fs_cblkno)
dbtofsb
fs
b
((b) >> (fs)->fs_fsbtodb)
DEV_BSHIFT
9
fsread
DEV_BSIZE
(1<<DEV_BSHIFT)
fsfind
fsread
DT_DIR
4
lookup
DT_REG
8
lookup
fragroundup
fs
size
/* calculates roundup(size, fs->fs_fsize) */ \ (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask)
FS_UFS1_MAGIC
0x011954
fsread
FS_UFS2_MAGIC
0x19540119
fsread
fsbtodb
fs
b
((daddr_t)(b) << (fs)->fs_fsbtodb)
fsread
FSMAXSNAP
20
ino_to_cg
fs
x
((x) / (fs)->fs_ipg)
ino_to_fsba
fs
x
((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, x)) + \ (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))
ino_to_fsbo
fs
x
((x) % INOPB(fs))
lblkno
fs
loc
/* calculates (loc / fs->fs_bsize) */ \ ((loc) >> (fs)->fs_bshift)
fsread
MAXBSIZE
65536
fsread
MAXMNTLEN
468
MAXNAMLEN
255
lookup
MAXVOLLEN
32
NDADDR
12
fsread
NIADDR
3
NINDIR
fs
((fs)->fs_nindir)
fsread
NOCSPTRS
((128 / sizeof(void *)) - 4)
NXADDR
2
ROOTINO
((ino_t)2)
lookup
sblksize
fs
size
lbn
(((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \ ? (fs)->fs_bsize \ : (fragroundup(fs, blkoff(fs, (size)))))
fsread
SBLOCK_FLOPPY
0
SBLOCK_PIGGY
262144
SBLOCK_UFS1
8192
SBLOCK_UFS2
65536
SBLOCKSEARCH
{ SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 }
SBLOCKSIZE
8192
__int64_t typedef __int64_t daddr_t daddr_t
int32_t typedef int32_t ufs1_daddr_t ufs1_daddr_t
int64_t typedef int64_t ufs2_daddr_t ufs2_daddr_t
int64_t typedef int64_t ufs_lbn_t ufs_lbn_t
int64_t typedef int64_t ufs_time_t ufs_time_t
int int ufs_init () ufs_init kpanic NULL ufs_initialize ufs_openFile ufs_readFile ufs_writeFile vfsRegisterFS x1
int int ufs_initialize () ufs_initialize 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: ufs_8h.xml 88 2016-01-12 00:11:29Z reddawg $

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

    #ifndef_UFS_H
    #define_UFS_H

    #include<ubixos/types.h>
    #include<vfs/vfs.h>
    #include<sys/device.h>

    #defineDT_REG8
    #defineMAXNAMLEN255
    #defineROOTINO((ino_t)2)
    #defineDT_DIR4
    #defineDEV_BSHIFT9/*log2(DEV_BSIZE)*/
    #defineDEV_BSIZE(1<<DEV_BSHIFT)
    #defineSBLOCK_FLOPPY0
    #defineSBLOCK_UFS18192
    #defineSBLOCK_UFS265536
    #defineSBLOCK_PIGGY262144
    #defineSBLOCKSIZE8192
    #defineSBLOCKSEARCH\
    {SBLOCK_UFS2,SBLOCK_UFS1,SBLOCK_FLOPPY,SBLOCK_PIGGY,-1}
    #defineFS_UFS1_MAGIC0x011954/*UFS1fastfilesystemmagicnumber*/
    #defineFS_UFS2_MAGIC0x19540119/*UFS2fastfilesystemmagicnumber*/
    #defineMAXMNTLEN468
    #defineMAXVOLLEN32
    #defineNOCSPTRS((128/sizeof(void*))-4)
    #defineFSMAXSNAP20
    #defineMAXBSIZE65536
    #defineNINDIR(fs)((fs)->fs_nindir)

    /*
    *Cylindergroupmacrostolocatethingsincylindergroups.
    *Theycalcfilesystemaddressesofcylindergroupdatastructures.
    */
    #definecgbase(fs,c)(((ufs2_daddr_t)(fs)->fs_fpg)*(c))
    #definecgdmin(fs,c)(cgstart(fs,c)+(fs)->fs_dblkno)/*1stdata*/
    #definecgimin(fs,c)(cgstart(fs,c)+(fs)->fs_iblkno)/*inodeblk*/
    #definecgsblock(fs,c)(cgstart(fs,c)+(fs)->fs_sblkno)/*superblk*/
    #definecgtod(fs,c)(cgstart(fs,c)+(fs)->fs_cblkno)/*cgblock*/
    #definecgstart(fs,c)\
    ((fs)->fs_magic==FS_UFS2_MAGIC?cgbase(fs,c):\
    (cgbase(fs,c)+(fs)->fs_old_cgoffset*((c)&~((fs)->fs_old_cgmask))))

    #definefsbtodb(fs,b)((daddr_t)(b)<<(fs)->fs_fsbtodb)
    #definedbtofsb(fs,b)((b)>>(fs)->fs_fsbtodb)

    /*
    *Macrosforhandlinginodenumbers:
    *inodenumbertofilesystemblockoffset.
    *inodenumbertocylindergroupnumber.
    *inodenumbertofilesystemblockaddress.
    */
    #defineino_to_cg(fs,x)((x)/(fs)->fs_ipg)
    #defineino_to_fsba(fs,x)\
    ((ufs2_daddr_t)(cgimin(fs,ino_to_cg(fs,x))+\
    (blkstofrags((fs),(((x)%(fs)->fs_ipg)/INOPB(fs))))))
    #defineino_to_fsbo(fs,x)((x)%INOPB(fs))

    #defineblkoff(fs,loc)/*calculates(loc%fs->fs_bsize)*/\
    ((loc)&(fs)->fs_qbmask)
    #definelblkno(fs,loc)/*calculates(loc/fs->fs_bsize)*/\
    ((loc)>>(fs)->fs_bshift)
    #definefragroundup(fs,size)/*calculatesroundup(size,fs->fs_fsize)*/\
    (((size)+(fs)->fs_qfmask)&(fs)->fs_fmask)

    #definesblksize(fs,size,lbn)\
    (((lbn)>=NDADDR||(size)>=((lbn)+1)<<(fs)->fs_bshift)\
    ?(fs)->fs_bsize\
    :(fragroundup(fs,blkoff(fs,(size)))))

    typedefint32_tufs1_daddr_t;
    typedefint64_tufs2_daddr_t;
    typedefint64_tufs_lbn_t;
    typedefint64_tufs_time_t;
    typedef__int64_tdaddr_t;

    structdirent{
    __uint32_td_fileno;/*filenumberofentry*/
    __uint16_td_reclen;/*lengthofthisrecord*/
    __uint8_td_type;/*filetype,seebelow*/
    __uint8_td_namlen;/*lengthofstringind_name*/
    chard_name[MAXNAMLEN+1];/*namemustbenolongerthanthis*/
    };

    #defineNXADDR2/*Externaladdressesininode.*/
    #defineNDADDR12/*Directaddressesininode.*/
    #defineNIADDR3/*Indirectaddressesininode.*/

    structufs2_dinode{
    u_int16_tdi_mode;/*0:IFMT,permissions;seebelow.*/
    int16_tdi_nlink;/*2:Filelinkcount.*/
    uint32_tdi_uid;/*4:Fileowner.*/
    uint32_tdi_gid;/*8:Filegroup.*/
    uint32_tdi_blksize;/*12:Inodeblocksize.*/
    u_int64_tdi_size;/*16:Filebytecount.*/
    u_int64_tdi_blocks;/*24:Bytesactuallyheld.*/
    ufs_time_tdi_atime;/*32:Lastaccesstime.*/
    ufs_time_tdi_mtime;/*40:Lastmodifiedtime.*/
    ufs_time_tdi_ctime;/*48:Lastinodechangetime.*/
    ufs_time_tdi_birthtime;/*56:Inodecreationtime.*/
    int32_tdi_mtimensec;/*64:Lastmodifiedtime.*/
    int32_tdi_atimensec;/*68:Lastaccesstime.*/
    int32_tdi_ctimensec;/*72:Lastinodechangetime.*/
    int32_tdi_birthnsec;/*76:Inodecreationtime.*/
    int32_tdi_gen;/*80:Generationnumber.*/
    uint32_tdi_kernflags;/*84:Kernelflags.*/
    uint32_tdi_flags;/*88:Statusflags(chflags).*/
    int32_tdi_extsize;/*92:Externalattributesblock.*/
    ufs2_daddr_tdi_extb[NXADDR];/*96:Externalattributesblock.*/
    ufs2_daddr_tdi_db[NDADDR];/*112:Directdiskblocks.*/
    ufs2_daddr_tdi_ib[NIADDR];/*208:Indirectdiskblocks.*/
    int64_tdi_spare[3];/*232:Reserved;currentlyunused*/
    };

    structufs1_dinode{
    u_int16_tdi_mode;/*0:IFMT,permissions;seebelow.*/
    int16_tdi_nlink;/*2:Filelinkcount.*/
    union{
    u_int16_toldids[2];/*4:Ffs:olduserandgroupids.*/
    }di_u;
    u_int64_tdi_size;/*8:Filebytecount.*/
    int32_tdi_atime;/*16:Lastaccesstime.*/
    int32_tdi_atimensec;/*20:Lastaccesstime.*/
    int32_tdi_mtime;/*24:Lastmodifiedtime.*/
    int32_tdi_mtimensec;/*28:Lastmodifiedtime.*/
    int32_tdi_ctime;/*32:Lastinodechangetime.*/
    int32_tdi_ctimensec;/*36:Lastinodechangetime.*/
    ufs1_daddr_tdi_db[NDADDR];/*40:Directdiskblocks.*/
    ufs1_daddr_tdi_ib[NIADDR];/*88:Indirectdiskblocks.*/
    uint32_tdi_flags;/*100:Statusflags(chflags).*/
    int32_tdi_blocks;/*104:Blocksactuallyheld.*/
    int32_tdi_gen;/*108:Generationnumber.*/
    uint32_tdi_uid;/*112:Fileowner.*/
    uint32_tdi_gid;/*116:Filegroup.*/
    int32_tdi_spare[2];/*120:Reserved;currentlyunused*/
    };

    structcsum{
    int32_tcs_ndir;/*numberofdirectories*/
    int32_tcs_nbfree;/*numberoffreeblocks*/
    int32_tcs_nifree;/*numberoffreeinodes*/
    int32_tcs_nffree;/*numberoffreefrags*/
    };
    structcsum_total{
    int64_tcs_ndir;/*numberofdirectories*/
    int64_tcs_nbfree;/*numberoffreeblocks*/
    int64_tcs_nifree;/*numberoffreeinodes*/
    int64_tcs_nffree;/*numberoffreefrags*/
    int64_tcs_numclusters;/*numberoffreeclusters*/
    int64_tcs_spare[3];/*futureexpansion*/
    };

    structfs{
    int32_tfs_firstfield;/*historicfilesystemlinkedlist,*/
    int32_tfs_unused_1;/*usedforincoresuperblocks*/
    int32_tfs_sblkno;/*offsetofsuper-blockinfilesys*/
    int32_tfs_cblkno;/*offsetofcyl-blockinfilesys*/
    int32_tfs_iblkno;/*offsetofinode-blocksinfilesys*/
    int32_tfs_dblkno;/*offsetoffirstdataaftercg*/
    int32_tfs_old_cgoffset;/*cylindergroupoffsetincylinder*/
    int32_tfs_old_cgmask;/*usedtocalcmodfs_ntrak*/
    int32_tfs_old_time;/*lasttimewritten*/
    int32_tfs_old_size;/*numberofblocksinfs*/
    int32_tfs_old_dsize;/*numberofdatablocksinfs*/
    int32_tfs_ncg;/*numberofcylindergroups*/
    int32_tfs_bsize;/*sizeofbasicblocksinfs*/
    int32_tfs_fsize;/*sizeoffragblocksinfs*/
    int32_tfs_frag;/*numberoffragsinablockinfs*/
    /*theseareconfigurationparameters*/
    int32_tfs_minfree;/*minimumpercentageoffreeblocks*/
    int32_tfs_old_rotdelay;/*numofmsforoptimalnextblock*/
    int32_tfs_old_rps;/*diskrevolutionspersecond*/
    /*thesefieldscanbecomputedfromtheothers*/
    int32_tfs_bmask;/*``blkoff''calcofblkoffsets*/
    int32_tfs_fmask;/*``fragoff''calcoffragoffsets*/
    int32_tfs_bshift;/*``lblkno''calcoflogicalblkno*/
    int32_tfs_fshift;/*``numfrags''calcnumberoffrags*/
    /*theseareconfigurationparameters*/
    int32_tfs_maxcontig;/*maxnumberofcontiguousblks*/
    int32_tfs_maxbpg;/*maxnumberofblkspercylgroup*/
    /*thesefieldscanbecomputedfromtheothers*/
    int32_tfs_fragshift;/*blocktofragshift*/
    int32_tfs_fsbtodb;/*fsbtodbanddbtofsbshiftconstant*/
    int32_tfs_sbsize;/*actualsizeofsuperblock*/
    int32_tfs_spare1[2];/*oldfs_csmask*/
    /*oldfs_csshift*/
    int32_tfs_nindir;/*valueofNINDIR*/
    int32_tfs_inopb;/*valueofINOPB*/
    int32_tfs_old_nspf;/*valueofNSPF*/
    /*yetanotherconfigurationparameter*/
    int32_tfs_optim;/*optimizationpreference,seebelow*/
    int32_tfs_old_npsect;/*#sectors/trackincludingspares*/
    int32_tfs_old_interleave;/*hardwaresectorinterleave*/
    int32_tfs_old_trackskew;/*sector0skew,pertrack*/
    int32_tfs_id[2];/*uniquefilesystemid*/
    /*sizesdeterminedbynumberofcylindergroupsandtheirsizes*/
    int32_tfs_old_csaddr;/*blkaddrofcylgrpsummaryarea*/
    int32_tfs_cssize;/*sizeofcylgrpsummaryarea*/
    int32_tfs_cgsize;/*cylindergroupsize*/
    int32_tfs_spare2;/*oldfs_ntrak*/
    int32_tfs_old_nsect;/*sectorspertrack*/
    int32_tfs_old_spc;/*sectorspercylinder*/
    int32_tfs_old_ncyl;/*cylindersinfilesystem*/
    int32_tfs_old_cpg;/*cylinderspergroup*/
    int32_tfs_ipg;/*inodespergroup*/
    int32_tfs_fpg;/*blockspergroup*fs_frag*/
    /*thisdatamustbere-computedaftercrashes*/
    structcsumfs_old_cstotal;/*cylindersummaryinformation*/
    /*thesefieldsareclearedatmounttime*/
    int8_tfs_fmod;/*superblockmodifiedflag*/
    int8_tfs_clean;/*filesystemiscleanflag*/
    int8_tfs_ronly;/*mountedread-onlyflag*/
    int8_tfs_old_flags;/*oldFS_flags*/
    u_charfs_fsmnt[MAXMNTLEN];/*namemountedon*/
    u_charfs_volname[MAXVOLLEN];/*volumename*/
    u_int64_tfs_swuid;/*system-wideuid*/
    int32_tfs_pad;/*duetoalignmentoffs_swuid*/
    /*thesefieldsretainthecurrentblockallocationinfo*/
    int32_tfs_cgrotor;/*lastcgsearched*/
    void*fs_ocsp[NOCSPTRS];/*padding;waslistoffs_csbuffers*/
    u_int8_t*fs_contigdirs;/*(u)#ofcontig.allocateddirs*/
    structcsum*fs_csp;/*(u)cgsummaryinfobuffer*/
    int32_t*fs_maxcluster;/*(u)maxclusterineachcylgroup*/
    u_int*fs_active;/*(u)usedbysnapshotstotrackfs*/
    int32_tfs_old_cpc;/*cylpercycleinpostbl*/
    int32_tfs_maxbsize;/*maximumblockingfactorpermitted*/
    int64_tfs_sparecon64[17];/*oldrotationblocklisthead*/
    int64_tfs_sblockloc;/*byteoffsetofstandardsuperblock*/
    structcsum_totalfs_cstotal;/*(u)cylindersummaryinformation*/
    ufs_time_tfs_time;/*lasttimewritten*/
    int64_tfs_size;/*numberofblocksinfs*/
    int64_tfs_dsize;/*numberofdatablocksinfs*/
    ufs2_daddr_tfs_csaddr;/*blkaddrofcylgrpsummaryarea*/
    int64_tfs_pendingblocks;/*(u)blocksbeingfreed*/
    int32_tfs_pendinginodes;/*(u)inodesbeingfreed*/
    int32_tfs_snapinum[FSMAXSNAP];/*listofsnapshotinodenumbers*/
    int32_tfs_avgfilesize;/*expectedaveragefilesize*/
    int32_tfs_avgfpdir;/*expected#offilesperdirectory*/
    int32_tfs_save_cgsize;/*saverealcgsizetousefs_bsize*/
    int32_tfs_sparecon32[26];/*reservedforfutureconstants*/
    int32_tfs_flags;/*seeFS_flagsbelow*/
    int32_tfs_contigsumsize;/*sizeofclustersummaryarray*/
    int32_tfs_maxsymlinklen;/*maxlengthofaninternalsymlink*/
    int32_tfs_old_inodefmt;/*formatofon-diskinodes*/
    u_int64_tfs_maxfilesize;/*maximumrepresentablefilesize*/
    int64_tfs_qbmask;/*~fs_bmaskforusewith64-bitsize*/
    int64_tfs_qfmask;/*~fs_fmaskforusewith64-bitsize*/
    int32_tfs_state;/*validatefs_cleanfield*/
    int32_tfs_old_postblformat;/*formatofpositionallayouttables*/
    int32_tfs_old_nrpos;/*numberofrotationalpositions*/
    int32_tfs_spare5[2];/*oldfs_postbloff*/
    /*oldfs_rotbloff*/
    int32_tfs_magic;/*magicnumber*/
    };

    intufs_init();
    intufs_initialize();

    #endif

    /***
    END
    ***/