linux/fs/hpfs/alloc.c
<<
opti v/spa v/form va opti href="../linux+v34781/fs/hpfs/alloc.c">opti vimg src="../.static/gfx/right.png" alt=">>">opv/spa opvspa class="lxr_search">optiopti vinput typionhidden" namionnavtarget" /option">opti vinput typiontext" namionsearch" idonsearch">opti vbutt.8Searchopti Prefs v/a>opv/spa ti v/div ti vform ac.8" ="ajax+*" method="post" onsubmit="return false;">opvinput typionhidden" namionajax_lookup" idonajax_lookup" /option">oti v/form oti vdiv class="headingbott.m">
vdiv idonfile_contents"
   1v/a>vspa
 class="comment">/*v/spa
	    2v/a>vspa
 class="comment"> *  linux/fs/hpfs/alloc.cv/spa
	    3v/a>vspa
 class="comment"> *v/spa
	    4v/a>vspa
 class="comment"> *  Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999v/spa
	    5v/a>vspa
 class="comment"> *v/spa
	    6v/a>vspa
 class="comment"> *  HPFS bitmap opera.8"
sv/spa
	    7v/a>vspa
 class="comment"> */v/spa
	    8v/a>o   9v/a>#include "hpfs_fn.hv/a>"o  8.42a>o  11v/a>vspa
 class="comment">/*v/spa
	   12v/a>vspa
 class="comment"> * Check if a sector is allocated in bitmapv/spa
	   13v/a>vspa
 class="comment"> * This is really slow. Turned .8  14v/a>vspa
 class="comment"> */v/spa
	   1542a>o  16v/a>static int va href="+code=chk_if_allocated" class="sref">chk_if_allocatedv/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, va href="+code=secno" class="sref">secnov/a> va href="+code=sec" class="sref">secv/a>, char *va href="+code=msg" class="sref">msgv/a>)o  17v/a>{o  18v/a>        struct va href="+code=quad_buffer_head" class="sref">quad_buffer_headv/a> va href="+code=qbh" class="sref">qbhv/a>;o  19v/a>        va href="+code=__le32" class="sref">__le32v/a> *va href="+code=bmp" class="sref">bmpv/a>;o  20v/a>        if (!(va href="+code=bmp" class="sref">bmpv/a> = va href="+code=hpfs_map_bitmap" class="sref">hpfs_map_bitmapv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=sec" class="sref">secv/a> >> 14, &va href="+code=qbh" class="sref">qbhv/a>, vspa
 class="string">"chk"failv/a>;o  21v/a>        if ((va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[(va href="+code=sec" class="sref">secv/a> & 0x3fff) >> 5]) >> (va href="+code=sec" class="sref">secv/a> & 0x1f)) & 1) {o  22v/a>                va href="+code=hpfs_error" class="sref">hpfs_errorv/a>(va href="+code=s" class="sref">sv/a>, vspa
 class="string">"sector '%s' - %08x not allocated in bitmap"msgv/a>, va href="+code=sec" class="sref">secv/a>);o  23v/a>                goto va href="+code=fail1" class="sref">fail1v/a>;o  24v/a>        }o  25v/a>        va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o  26v/a>        if (va href="+code=sec" class="sref">secv/a> >= va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a> && va href="+code=sec" class="sref">secv/a> < va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a> + va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_dirband_size" class="sref">sb_dirband_sizev/a>) {o  27v/a>                unsigned va href="+code=ssec" class="sref">ssecv/a> = (va href="+code=sec" class="sref">secv/a> - va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a>) / 4;o  28v/a>                if (!(va href="+code=bmp" class="sref">bmpv/a> = va href="+code=hpfs_map_dnode_bitmap" class="sref">hpfs_map_dnode_bitmapv/a>(va href="+code=s" class="sref">sv/a>, &va href="+code=qbh" class="sref">qbhv/a>))) goto va href="+code=fail" class="sref">failv/a>;o  29v/a>                if ((va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[va href="+code=ssec" class="sref">ssecv/a> >> 5]) >> (va href="+code=ssec" class="sref">ssecv/a> & 0x1f)) & 1) {o  30v/a>                        va href="+code=hpfs_error" class="sref">hpfs_errorv/a>(va href="+code=s" class="sref">sv/a>, vspa
 class="string">"sector '%s' - %08x not allocated in directory bitmap"msgv/a>, va href="+code=sec" class="sref">secv/a>);o  31v/a>                        goto va href="+code=fail1" class="sref">fail1v/a>;o  32v/a>                }o  33v/a>                va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o  34v/a>        }o  35v/a>        return 0;o  36v/a>        va href="+code=fail1" class="sref">fail1v/a>:o  37v/a>        va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o  38v/a>        va href="+code=fail" class="sref">failv/a>:o  39v/a>        return 1;o  40v/a>}o  4142a>o  42v/a>vspa
 class="comment">/*v/spa
	   43v/a>vspa
 class="comment"> * Check if sector(s) have proper number and addi.8"
ally check if they'rev/spa
	   44v/a>vspa
 class="comment"> * allocated in bitmap.v/spa
	   45v/a>vspa
 class="comment"> */v/spa
	   46v/a>           47v/a>int va href="+code=hpfs_chk_sectors" class="sref">hpfs_chk_sectorsv/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, va href="+code=secno" class="sref">secnov/a> va href="+code=start" class="sref">startv/a>, int va href="+code=len" class="sref">lenv/a>, char *va href="+code=msg" class="sref">msgv/a>)o  48v/a>{o  49v/a>        if (va href="+code=start" class="sref">startv/a> + va href="+code=len" class="sref">lenv/a> < va href="+code=start" class="sref">startv/a> || va href="+code=start" class="sref">startv/a> < 0x12 ||   50v/a>            va href="+code=start" class="sref">startv/a> + va href="+code=len" class="sref">lenv/a> > va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_fs_size" class="sref">sb_fs_sizev/a>) {o  51v/a>                va href="+code=hpfs_error" class="sref">hpfs_errorv/a>(va href="+code=s" class="sref">sv/a>, vspa
 class="string">"sector(s) '%s' badly placed at %08x"msgv/a>, va href="+code=start" class="sref">startv/a>);o  52v/a>                return 1;o  53v/a>        }o  54v/a>        if (va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_chk" class="sref">sb_chkv/a>>=2) {o  55v/a>                int va href="+code=i" class="sref">iv/a>;o  56v/a>                for (va href="+code=i" class="sref">iv/a> = 0; va href="+code=i" class="sref">iv/a> < va href="+code=len" class="sref">lenv/a>; va href="+code=i" class="sref">iv/a>++)o  57v/a>                        if (va href="+code=chk_if_allocated" class="sref">chk_if_allocatedv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=start" class="sref">startv/a> + va href="+code=i" class="sref">iv/a>, va href="+code=msg" class="sref">msgv/a>)) return 1;o  58v/a>        }o  59v/a>        return 0;o  60v/a>}o  6142a>o  62v/a>static va href="+code=secno" class="sref">secnov/a> va href="+code=alloc_in_bmp" class="sref">alloc_in_bmpv/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, va href="+code=secno" class="sref">secnov/a> va href="+code=near" class="sref">nearv/a>, unsigned va href="+code=n" class="sref">nv/a>, unsigned va href="+code=forward" class="sref">forwardv/a>)o  63v/a>{o  64v/a>        struct va href="+code=quad_buffer_head" class="sref">quad_buffer_headv/a> va href="+code=qbh" class="sref">qbhv/a>;o  65v/a>        va href="+code=__le32" class="sref">__le32v/a> *va href="+code=bmp" class="sref">bmpv/a>;o  66v/a>        unsigned va href="+code=bs" class="sref">bsv/a> = va href="+code=near" class="sref">nearv/a> & ~0x3fff;o  67v/a>        unsigned va href="+code=nr" class="sref">nrv/a> = (va href="+code=near" class="sref">nearv/a> & 0x3fff) & ~(va href="+code=n" class="sref">nv/a> - 1);o  68v/a>        vspa
 class="comment">/*unsigned mnr;*/v/spa
	   69v/a>        unsigned va href="+code=i" class="sref">iv/a>, va href="+code=q" class="sref">qv/a>;o  70v/a>        int va href="+code=a" class="sref">av/a>, va href="+code=b" class="sref">bv/a>;o  71v/a>        va href="+code=secno" class="sref">secnov/a> va href="+code=ret" class="sref">retv/a> = 0;o  72v/a>        if (va href="+code=n" class="sref">nv/a> != 1 && va href="+code=n" class="sref">nv/a> != 4) {o  73v/a>                va href="+code=hpfs_error" class="sref">hpfs_errorv/a>(va href="+code=s" class="sref">sv/a>, vspa
 class="string">"Bad allocat3.8nv/a>);o  74v/a>                return 0;o  75v/a>        }o  76v/a>        if (va href="+code=bs" class="sref">bsv/a> != ~0x3fff) {o  77v/a>                if (!(va href="+code=bmp" class="sref">bmpv/a> = va href="+code=hpfs_map_bitmap" class="sref">hpfs_map_bitmapv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=near" class="sref">nearv/a> >> 14, &va href="+code=qbh" class="sref">qbhv/a>, vspa
 class="string">"aib"ulsv/a>;o  78v/a>        } else {o  79v/a>                if (!(va href="+code=bmp" class="sref">bmpv/a> = va href="+code=hpfs_map_dnode_bitmap" class="sref">hpfs_map_dnode_bitmapv/a>(va href="+code=s" class="sref">sv/a>, &va href="+code=qbh" class="sref">qbhv/a>))) goto va href="+code=uls" class="sref">ulsv/a>;o  80v/a>        }o  81v/a>        if (!va href="+code=tstbits" class="sref">tstbitsv/a>(va href="+code=bmp" class="sref">bmpv/a>, va href="+code=nr" class="sref">nrv/a>, va href="+code=n" class="sref">nv/a> + va href="+code=forward" class="sref">forwardv/a>)) {o  82v/a>                va href="+code=ret" class="sref">retv/a> = va href="+code=bs" class="sref">bsv/a> + va href="+code=nr" class="sref">nrv/a>;o  83v/a>                goto va href="+code=rt" class="sref">rtv/a>;o  84v/a>        }o  85v/a>        va href="+code=q" class="sref">qv/a> = va href="+code=nr" class="sref">nrv/a> + va href="+code=n" class="sref">nv/a>; va href="+code=b" class="sref">bv/a> = 0;o  86v/a>        while ((va href="+code=a" class="sref">av/a> = va href="+code=tstbits" class="sref">tstbitsv/a>(va href="+code=bmp" class="sref">bmpv/a>, va href="+code=q" class="sref">qv/a>, va href="+code=n" class="sref">nv/a> + va href="+code=forward" class="sref">forwardv/a>)) != 0) {o  87v/a>                va href="+code=q" class="sref">qv/a> += va href="+code=a" class="sref">av/a>;o  88v/a>                if (va href="+code=n" class="sref">nv/a> != 1) va href="+code=q" class="sref">qv/a> = ((va href="+code=q" class="sref">qv/a>-1)&~(va href="+code=n" class="sref">nv/a>-1))+va href="+code=n" class="sref">nv/a>;o  89v/a>                if (!va href="+code=b" class="sref">bv/a>) {o  90v/a>                        if (va href="+code=q" class="sref">qv/a>>>5 != va href="+code=nr" class="sref">nrv/a>>>5) {o  91v/a>                                va href="+code=b" class="sref">bv/a> = 1;o  92v/a>                                va href="+code=q" class="sref">qv/a> = va href="+code=nr" class="sref">nrv/a> & 0x1f;o  93v/a>                        }o  94v/a>                } else if (va href="+code=q" class="sref">qv/a> > va href="+code=nr" class="sref">nrv/a>) break;o  95v/a>        }o  96v/a>        if (!va href="+code=a" class="sref">av/a>) {o  97v/a>                va href="+code=ret" class="sref">retv/a> = va href="+code=bs" class="sref">bsv/a> + va href="+code=q" class="sref">qv/a>;o  98v/a>                goto va href="+code=rt" class="sref">rtv/a>;o  99v/a>        }o 100v/a>        va href="+code=nr" class="sref">nrv/a> >>= 5;o 101v/a>        vspa
 class="comment">/*for (i = nr + 1; i != nr; i++, i &= 0x1ff) */v/spa
	  102v/a>        va href="+code=i" class="sref">iv/a> = va href="+code=nr" class="sref">nrv/a>;o 103v/a>        do {o 104v/a>                if (!va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[va href="+code=i" class="sref">iv/a>])) goto va href="+code=cont" class="sref">contv/a>;o 105v/a>                if (va href="+code=n" class="sref">nv/a> + va href="+code=forward" class="sref">forwardv/a> >= 0x3f && va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[va href="+code=i" class="sref">iv/a>]) != 0xffffffff) goto va href="+code=cont" class="sref">contv/a>;o 106v/a>                va href="+code=q" class="sref">qv/a> = va href="+code=i" class="sref">iv/a><<5;o 107v/a>                if (va href="+code=i" class="sref">iv/a> > 0) {o 108v/a>                        unsigned va href="+code=k" class="sref">kv/a> = va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[va href="+code=i" class="sref">iv/a>-1]);o 109v/a>                        while (va href="+code=k" class="sref">kv/a> & 0x80000000) {o 110v/a>                                va href="+code=q" class="sref">qv/a>--; va href="+code=k" class="sref">kv/a> <<= 1;o 111v/a>                        }o 112v/a>                }o 113v/a>                if (va href="+code=n" class="sref">nv/a> != 1) va href="+code=q" class="sref">qv/a> = ((va href="+code=q" class="sref">qv/a>-1)&~(va href="+code=n" class="sref">nv/a>-1))+va href="+code=n" class="sref">nv/a>;o 114v/a>                while ((va href="+code=a" class="sref">av/a> = va href="+code=tstbits" class="sref">tstbitsv/a>(va href="+code=bmp" class="sref">bmpv/a>, va href="+code=q" class="sref">qv/a>, va href="+code=n" class="sref">nv/a> + va href="+code=forward" class="sref">forwardv/a>)) != 0) {o 115v/a>                        va href="+code=q" class="sref">qv/a> += va href="+code=a" class="sref">av/a>;o 116v/a>                        if (va href="+code=n" class="sref">nv/a> != 1) va href="+code=q" class="sref">qv/a> = ((va href="+code=q" class="sref">qv/a>-1)&~(va href="+code=n" class="sref">nv/a>-1))+va href="+code=n" class="sref">nv/a>;o 117v/a>                        if (va href="+code=q" class="sref">qv/a>>>5 > va href="+code=i" class="sref">iv/a>) break;o 118v/a>                }o 119v/a>                if (!va href="+code=a" class="sref">av/a>) {o 120v/a>                        va href="+code=ret" class="sref">retv/a> = va href="+code=bs" class="sref">bsv/a> + va href="+code=q" class="sref">qv/a>;o 121v/a>                        goto va href="+code=rt" class="sref">rtv/a>;o 122v/a>                }o 123v/a>                va href="+code=cont" class="sref">contv/a>:o 124v/a>                va href="+code=i" class="sref">iv/a>++, va href="+code=i" class="sref">iv/a> &= 0x1ff;o 125v/a>        } while (va href="+code=i" class="sref">iv/a> != va href="+code=nr" class="sref">nrv/a>);o 126v/a>        va href="+code=rt" class="sref">rtv/a>:o 127v/a>        if (va href="+code=ret" class="sref">retv/a>) {o 128v/a>                if (va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_chk" class="sref">sb_chkv/a> && ((va href="+code=ret" class="sref">retv/a> >> 14) != (va href="+code=bs" class="sref">bsv/a> >> 14) || (va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[(va href="+code=ret" class="sref">retv/a> & 0x3fff) >> 5]) | ~(((1 << va href="+code=n" class="sref">nv/a>) - 1) << (va href="+code=ret" class="sref">retv/a> & 0x1f))) != 0xffffffff)) {o 129v/a>                        va href="+code=hpfs_error" class="sref">hpfs_errorv/a>(va href="+code=s" class="sref">sv/a>, vspa
 class="string">"Allocat3.8nv/a>, va href="+code=ret" class="sref">retv/a>);o 130v/a>                        va href="+code=ret" class="sref">retv/a> = 0;o 131v/a>                        goto va href="+code=b" class="sref">bv/a>;o 132v/a>                }o 133v/a>                va href="+code=bmp" class="sref">bmpv/a>[(va href="+code=ret" class="sref">retv/a> & 0x3fff) >> 5] &= va href="+code=cpu_to_le32" class="sref">cpu_to_le32v/a>(~(((1 << va href="+code=n" class="sref">nv/a>) - 1) << (va href="+code=ret" class="sref">retv/a> & 0x1f)));o 134v/a>                va href="+code=hpfs_mark_4buffers_dirty" class="sref">hpfs_mark_4buffers_dirtyv/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 135v/a>        }o 136v/a>        va href="+code=b" class="sref">bv/a>:o 137v/a>        va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 138v/a>        va href="+code=uls" class="sref">ulsv/a>:o 139v/a>        return va href="+code=ret" class="sref">retv/a>;o 140v/a>}o 14142a>o 142v/a>vspa
 class="comment">/*v/spa
	  143v/a>vspa
 class="comment"> * Allocat3.8 144v/a>vspa
 class="comment"> *                      2) search bitmap where free sectors last foundv/spa
	  145v/a>vspa
 class="comment"> *                      3) search all bitmapsv/spa
	  146v/a>vspa
 class="comment"> *                      4) search all bitmaps ignoring number of pre-allocatedv/spa
	  147v/a>vspa
 class="comment"> *                              sectorsv/spa
	  148v/a>vspa
 class="comment"> */v/spa
	  149v/a>  150v/a>va href="+code=secno" class="sref">secnov/a> va href="+code=hpfs_alloc_sector" class="sref">hpfs_alloc_sectorv/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, va href="+code=secno" class="sref">secnov/a> va href="+code=near" class="sref">nearv/a>, unsigned va href="+code=n" class="sref">nv/a>, int va href="+code=forward" class="sref">forwardv/a>)o 151v/a>{o 152v/a>        va href="+code=secno" class="sref">secnov/a> va href="+code=sec" class="sref">secv/a>;o 153v/a>        int va href="+code=i" class="sref">iv/a>;o 154v/a>        unsigned va href="+code=n_bmps" class="sref">n_bmpsv/a>;o 155v/a>        struct va href="+code=hpfs_sb_info" class="sref">hpfs_sb_infov/a> *va href="+code=sbi" class="sref">sbiv/a> = va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>);o 156v/a>        int va href="+code=f_p" class="sref">f_pv/a> = 0;o 157v/a>        int va href="+code=near_bmp" class="sref">near_bmpv/a>;o 158v/a>        if (va href="+code=forward" class="sref">forwardv/a> < 0) {o 159v/a>                va href="+code=forward" class="sref">forwardv/a> = -va href="+code=forward" class="sref">forwardv/a>;o 160v/a>                va href="+code=f_p" class="sref">f_pv/a> = 1;o 161v/a>        }o 162v/a>        va href="+code=n_bmps" class="sref">n_bmpsv/a> = (va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_fs_size" class="sref">sb_fs_sizev/a> + 0x4000 - 1) >> 14;o 163v/a>        if (va href="+code=near" class="sref">nearv/a> && va href="+code=near" class="sref">nearv/a> < va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_fs_size" class="sref">sb_fs_sizev/a>) {o 164v/a>                if ((va href="+code=sec" class="sref">secv/a> = va href="+code=alloc_in_bmp" class="sref">alloc_in_bmpv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=near" class="sref">nearv/a>, va href="+code=n" class="sref">nv/a>, va href="+code=f_p" class="sref">f_pv/a> ? va href="+code=forward" class="sref">forwardv/a> : va href="+code=forward" class="sref">forwardv/a>/4))) goto va href="+code=ret" class="sref">retv/a>;o 165v/a>                va href="+code=near_bmp" class="sref">near_bmpv/a> = va href="+code=near" class="sref">nearv/a> >> 14;o 166v/a>        } else va href="+code=near_bmp" class="sref">near_bmpv/a> = va href="+code=n_bmps" class="sref">n_bmpsv/a> / 2;o 167v/a>        vspa
 class="comment">/*v/spa
	  168v/a>vspa
 class="comment">        if (b != -1) {v/spa
	  169v/a>vspa
 class="comment">                if ((sec = alloc_in_bmp(s, b<<14, n, f_p ? forward : forward/2))) {v/spa
	  170v/a>vspa
 class="comment">                        b &= 0x0fffffff;v/spa
	  171v/a>vspa
 class="comment">                        goto ret;v/spa
	  172v/a>vspa
 class="comment">                }v/spa
	  173v/a>vspa
 class="comment">                if (b > 0x10000000) if ((sec = alloc_in_bmp(s, (b&0xfffffff)<<14, n, f_p ? forward : 0))) goto ret;v/spa
	  174v/a>vspa
 class="comment">        */v/spa
	  175v/a>        if (!va href="+code=f_p" class="sref">f_pv/a>) if (va href="+code=forward" class="sref">forwardv/a> > va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_max_fwd_alloc" class="sref">sb_max_fwd_allocv/a>) va href="+code=forward" class="sref">forwardv/a> = va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_max_fwd_alloc" class="sref">sb_max_fwd_allocv/a>;o 176v/a>        va href="+code=less_fwd" class="sref">less_fwdv/a>:o 177v/a>        for (va href="+code=i" class="sref">iv/a> = 0; va href="+code=i" class="sref">iv/a> < va href="+code=n_bmps" class="sref">n_bmpsv/a>; va href="+code=i" class="sref">iv/a>++) {o 178v/a>                if (va href="+code=near_bmp" class="sref">near_bmpv/a>+va href="+code=i" class="sref">iv/a> < va href="+code=n_bmps" class="sref">n_bmpsv/a> && ((va href="+code=sec" class="sref">secv/a> = va href="+code=alloc_in_bmp" class="sref">alloc_in_bmpv/a>(va href="+code=s" class="sref">sv/a>, (va href="+code=near_bmp" class="sref">near_bmpv/a>+va href="+code=i" class="sref">iv/a>) << 14, va href="+code=n" class="sref">nv/a>, va href="+code=forward" class="sref">forwardv/a>)))) {o 179v/a>                        va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_c_bitmap" class="sref">sb_c_bitmapv/a> = va href="+code=near_bmp" class="sref">near_bmpv/a>+va href="+code=i" class="sref">iv/a>;o 180v/a>                        goto va href="+code=ret" class="sref">retv/a>;o 181v/a>                }       o 182v/a>                if (!va href="+code=forward" class="sref">forwardv/a>) {o 183v/a>                        if (va href="+code=near_bmp" class="sref">near_bmpv/a>-va href="+code=i" class="sref">iv/a>-1 >= 0 && ((va href="+code=sec" class="sref">secv/a> = va href="+code=alloc_in_bmp" class="sref">alloc_in_bmpv/a>(va href="+code=s" class="sref">sv/a>, (va href="+code=near_bmp" class="sref">near_bmpv/a>-va href="+code=i" class="sref">iv/a>-1) << 14, va href="+code=n" class="sref">nv/a>, va href="+code=forward" class="sref">forwardv/a>)))) {o 184v/a>                                va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_c_bitmap" class="sref">sb_c_bitmapv/a> = va href="+code=near_bmp" class="sref">near_bmpv/a>-va href="+code=i" class="sref">iv/a>-1;o 185v/a>                                goto va href="+code=ret" class="sref">retv/a>;o 186v/a>                        }o 187v/a>                } else {o 188v/a>                        if (va href="+code=near_bmp" class="sref">near_bmpv/a>+va href="+code=i" class="sref">iv/a> >= va href="+code=n_bmps" class="sref">n_bmpsv/a> && ((va href="+code=sec" class="sref">secv/a> = va href="+code=alloc_in_bmp" class="sref">alloc_in_bmpv/a>(va href="+code=s" class="sref">sv/a>, (va href="+code=near_bmp" class="sref">near_bmpv/a>+va href="+code=i" class="sref">iv/a>-va href="+code=n_bmps" class="sref">n_bmpsv/a>) << 14, va href="+code=n" class="sref">nv/a>, va href="+code=forward" class="sref">forwardv/a>)))) {o 189v/a>                                va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_c_bitmap" class="sref">sb_c_bitmapv/a> = va href="+code=near_bmp" class="sref">near_bmpv/a>+va href="+code=i" class="sref">iv/a>-va href="+code=n_bmps" class="sref">n_bmpsv/a>;o 190v/a>                                goto va href="+code=ret" class="sref">retv/a>;o 191v/a>                        }o 192v/a>                }o 193v/a>                if (va href="+code=i" class="sref">iv/a> == 1 && va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_c_bitmap" class="sref">sb_c_bitmapv/a> != -1 && ((va href="+code=sec" class="sref">secv/a> = va href="+code=alloc_in_bmp" class="sref">alloc_in_bmpv/a>(va href="+code=s" class="sref">sv/a>, (va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_c_bitmap" class="sref">sb_c_bitmapv/a>) << 14, va href="+code=n" class="sref">nv/a>, va href="+code=forward" class="sref">forwardv/a>)))) {o 194v/a>                        goto va href="+code=ret" class="sref">retv/a>;o 195v/a>                }o 196v/a>        }o 197v/a>        if (!va href="+code=f_p" class="sref">f_pv/a>) {o 198v/a>                if (va href="+code=forward" class="sref">forwardv/a>) {o 199v/a>                        va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_max_fwd_alloc" class="sref">sb_max_fwd_allocv/a> = va href="+code=forward" class="sref">forwardv/a> * 3 / 4;o 200v/a>                        va href="+code=forward" class="sref">forwardv/a> /= 2;o 201v/a>                        goto va href="+code=less_fwd" class="sref">less_fwdv/a>;o 202v/a>                }o 203v/a>        }o 204v/a>        va href="+code=sec" class="sref">secv/a> = 0;o 205v/a>        va href="+code=ret" class="sref">retv/a>:o 206v/a>        if (va href="+code=sec" class="sref">secv/a> && va href="+code=f_p" class="sref">f_pv/a>) {o 207v/a>                for (va href="+code=i" class="sref">iv/a> = 0; va href="+code=i" class="sref">iv/a> < va href="+code=forward" class="sref">forwardv/a>; va href="+code=i" class="sref">iv/a>++) {o 208v/a>                        if (!va href="+code=hpfs_alloc_if_possible" class="sref">hpfs_alloc_if_possiblev/a>(va href="+code=s" class="sref">sv/a>, va href="+code=sec" class="sref">secv/a> + va href="+code=i" class="sref">iv/a> + 1)) {o 209v/a>                                va href="+code=hpfs_error" class="sref">hpfs_errorv/a>(va href="+code=s" class="sref">sv/a>, vspa
 class="string">"Preallocforwardv/a>, va href="+code=sec" class="sref">secv/a>, va href="+code=i" class="sref">iv/a>);o 210v/a>                                va href="+code=sec" class="sref">secv/a> = 0;o 211v/a>                                break;o 212v/a>                        }o 213v/a>                }o 214v/a>        }o 215v/a>        return va href="+code=sec" class="sref">secv/a>;o 216v/a>}o 217v/a>o 218v/a>static va href="+code=secno" class="sref">secnov/a> va href="+code=alloc_in_dirband" class="sref">alloc_in_dirbandv/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, va href="+code=secno" class="sref">secnov/a> va href="+code=near" class="sref">nearv/a>)o 219v/a>{o 220v/a>        unsigned va href="+code=nr" class="sref">nrv/a> = va href="+code=near" class="sref">nearv/a>;o 221v/a>        va href="+code=secno" class="sref">secnov/a> va href="+code=sec" class="sref">secv/a>;o 222v/a>        struct va href="+code=hpfs_sb_info" class="sref">hpfs_sb_infov/a> *va href="+code=sbi" class="sref">sbiv/a> = va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>);o 223v/a>        if (va href="+code=nr" class="sref">nrv/a> < va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a>)o 224v/a>                va href="+code=nr" class="sref">nrv/a> = va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a>;o 225v/a>        if (va href="+code=nr" class="sref">nrv/a> >= va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a> + va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_dirband_size" class="sref">sb_dirband_sizev/a>)o 226v/a>                va href="+code=nr" class="sref">nrv/a> = va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a> + va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_dirband_size" class="sref">sb_dirband_sizev/a> - 4;o 227v/a>        va href="+code=nr" class="sref">nrv/a> -= va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a>;o 228v/a>        va href="+code=nr" class="sref">nrv/a> >>= 2;o 229v/a>        va href="+code=sec" class="sref">secv/a> = va href="+code=alloc_in_bmp" class="sref">alloc_in_bmpv/a>(va href="+code=s" class="sref">sv/a>, (~0x3fff) | va href="+code=nr" class="sref">nrv/a>, 1, 0);o 230v/a>        if (!va href="+code=sec" class="sref">secv/a>) return 0;o 231v/a>        return ((va href="+code=sec" class="sref">secv/a> & 0x3fff) << 2) + va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a>;o 232v/a>}o 233v/a>o 234v/a>vspa
 class="comment">/* Alloc sector if it's free */v/spa
	  235v/a>  236v/a>int va href="+code=hpfs_alloc_if_possible" class="sref">hpfs_alloc_if_possiblev/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, va href="+code=secno" class="sref">secnov/a> va href="+code=sec" class="sref">secv/a>)  237v/a>{o 238v/a>        struct va href="+code=quad_buffer_head" class="sref">quad_buffer_headv/a> va href="+code=qbh" class="sref">qbhv/a>;o 239v/a>        va href="+code=__le32" class="sref">__le32v/a> *va href="+code=bmp" class="sref">bmpv/a>;o 240v/a>        if (!(va href="+code=bmp" class="sref">bmpv/a> = va href="+code=hpfs_map_bitmap" class="sref">hpfs_map_bitmapv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=sec" class="sref">secv/a> >> 14, &va href="+code=qbh" class="sref">qbhv/a>, vspa
 class="string">"aip"endv/a>;o 241v/a>        if (va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[(va href="+code=sec" class="sref">secv/a> & 0x3fff) >> 5]) & (1 << (va href="+code=sec" class="sref">secv/a> & 0x1f))) {o 242v/a>                va href="+code=bmp" class="sref">bmpv/a>[(va href="+code=sec" class="sref">secv/a> & 0x3fff) >> 5] &= va href="+code=cpu_to_le32" class="sref">cpu_to_le32v/a>(~(1 << (va href="+code=sec" class="sref">secv/a> & 0x1f)));o 243v/a>                va href="+code=hpfs_mark_4buffers_dirty" class="sref">hpfs_mark_4buffers_dirtyv/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 244v/a>                va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 245v/a>                return 1;o 246v/a>        }o 247v/a>        va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 248v/a>        va href="+code=end" class="sref">endv/a>:o 249v/a>        return 0;o 250v/a>}o 25142a>o 252v/a>vspa
 class="comment">/* Free sectors in bitmaps */v/spa
	  253v/a>o 254v/a>void va href="+code=hpfs_free_sectors" class="sref">hpfs_free_sectorsv/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, va href="+code=secno" class="sref">secnov/a> va href="+code=sec" class="sref">secv/a>, unsigned va href="+code=n" class="sref">nv/a>)  255v/a>{o 256v/a>        struct va href="+code=quad_buffer_head" class="sref">quad_buffer_headv/a> va href="+code=qbh" class="sref">qbhv/a>;o 257v/a>        va href="+code=__le32" class="sref">__le32v/a> *va href="+code=bmp" class="sref">bmpv/a>;o 258v/a>        struct va href="+code=hpfs_sb_info" class="sref">hpfs_sb_infov/a> *va href="+code=sbi" class="sref">sbiv/a> = va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>);o 259v/a>        vspa
 class="comment">/*printk("2 - ");*/v/spa
	  260v/a>        if (!va href="+code=n" class="sref">nv/a>) return;o 261v/a>        if (va href="+code=sec" class="sref">secv/a> < 0x12) {o 262v/a>                va href="+code=hpfs_error" class="sref">hpfs_errorv/a>(va href="+code=s" class="sref">sv/a>, vspa
 class="string">"Trying to free reserved sector %08x"secv/a>);o 263v/a>                return;o 264v/a>        }o 265v/a>        va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_max_fwd_alloc" class="sref">sb_max_fwd_allocv/a> += va href="+code=n" class="sref">nv/a> > 0xffff ? 0xffff : va href="+code=n" class="sref">nv/a>;o 266v/a>        if (va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_max_fwd_alloc" class="sref">sb_max_fwd_allocv/a> > 0xffffff) va href="+code=sbi" class="sref">sbiv/a>->va href="+code=sb_max_fwd_alloc" class="sref">sb_max_fwd_allocv/a> = 0xffffff;o 267v/a>        va href="+code=new_map" class="sref">new_mapv/a>:o 268v/a>        if (!(va href="+code=bmp" class="sref">bmpv/a> = va href="+code=hpfs_map_bitmap" class="sref">hpfs_map_bitmapv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=sec" class="sref">secv/a> >> 14, &va href="+code=qbh" class="sref">qbhv/a>, vspa
 class="string">"free" 269v/a>                return;o 270v/a>        }       o 271v/a>        va href="+code=new_tst" class="sref">new_tstv/a>:o 272v/a>        if ((va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[(va href="+code=sec" class="sref">secv/a> & 0x3fff) >> 5]) >> (va href="+code=sec" class="sref">secv/a> & 0x1f) & 1)) {o 273v/a>                va href="+code=hpfs_error" class="sref">hpfs_errorv/a>(va href="+code=s" class="sref">sv/a>, vspa
 class="string">"sector %08x not allocated"secv/a>);o 274v/a>                va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 275v/a>                return;o 276v/a>        }o 277v/a>        va href="+code=bmp" class="sref">bmpv/a>[(va href="+code=sec" class="sref">secv/a> & 0x3fff) >> 5] |= va href="+code=cpu_to_le32" class="sref">cpu_to_le32v/a>(1 << (va href="+code=sec" class="sref">secv/a> & 0x1f));o 278v/a>        if (!--va href="+code=n" class="sref">nv/a>) {o 279v/a>                va href="+code=hpfs_mark_4buffers_dirty" class="sref">hpfs_mark_4buffers_dirtyv/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 280v/a>                va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 281v/a>                return;o 282v/a>        }       o 283v/a>        if (!(++va href="+code=sec" class="sref">secv/a> & 0x3fff)) {o 284v/a>                va href="+code=hpfs_mark_4buffers_dirty" class="sref">hpfs_mark_4buffers_dirtyv/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 285v/a>                va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 286v/a>                goto va href="+code=new_map" class="sref">new_mapv/a>;o 287v/a>        }o 288v/a>        goto va href="+code=new_tst" class="sref">new_tstv/a>;o 289v/a>}o 290v/a>o 291v/a>vspa
 class="comment">/*v/spa
	  292v/a>vspa
 class="comment"> * Check if there are at least n free dnodes on the filesystem.v/spa
	  293v/a>vspa
 class="comment"> * Called before adding to dnode. If we run out of space whilev/spa
	  294v/a>vspa
 class="comment"> * splitting dnodes, it would corrupt dnode tree.v/spa
	  295v/a>vspa
 class="comment"> */v/spa
	  296v/a>  297v/a>int va href="+code=hpfs_check_free_dnodes" class="sref">hpfs_check_free_dnodesv/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, int va href="+code=n" class="sref">nv/a>)  298v/a>{o 299v/a>        int va href="+code=n_bmps" class="sref">n_bmpsv/a> = (va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_fs_size" class="sref">sb_fs_sizev/a> + 0x4000 - 1) >> 14;o 300v/a>        int va href="+code=b" class="sref">bv/a> = va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_c_bitmap" class="sref">sb_c_bitmapv/a> & 0x0fffffff;o 301v/a>        int va href="+code=i" class="sref">iv/a>, va href="+code=j" class="sref">jv/a>;o 302v/a>        va href="+code=__le32" class="sref">__le32v/a> *va href="+code=bmp" class="sref">bmpv/a>;o 303v/a>        struct va href="+code=quad_buffer_head" class="sref">quad_buffer_headv/a> va href="+code=qbh" class="sref">qbhv/a>;o 304v/a>        if ((va href="+code=bmp" class="sref">bmpv/a> = va href="+code=hpfs_map_dnode_bitmap" class="sref">hpfs_map_dnode_bitmapv/a>(va href="+code=s" class="sref">sv/a>, &va href="+code=qbh" class="sref">qbhv/a>))) {o 305v/a>                for (va href="+code=j" class="sref">jv/a> = 0; va href="+code=j" class="sref">jv/a> < 512; va href="+code=j" class="sref">jv/a>++) {o 306v/a>                        unsigned va href="+code=k" class="sref">kv/a>;o 307v/a>                        if (!va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[va href="+code=j" class="sref">jv/a>])) continue;o 308v/a>                        for (va href="+code=k" class="sref">kv/a> = va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[va href="+code=j" class="sref">jv/a>]); va href="+code=k" class="sref">kv/a>; va href="+code=k" class="sref">kv/a> >>= 1) if (va href="+code=k" class="sref">kv/a> & 1) if (!--va href="+code=n" class="sref">nv/a>) {o 309v/a>                                va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 310v/a>                                return 0;o 311v/a>                        }o 312v/a>                }o 313v/a>        }o 314v/a>        va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 315v/a>        va href="+code=i" class="sref">iv/a> = 0;o 316v/a>        if (va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_c_bitmap" class="sref">sb_c_bitmapv/a> != -1) {o 317v/a>                va href="+code=bmp" class="sref">bmpv/a> = va href="+code=hpfs_map_bitmap" class="sref">hpfs_map_bitmapv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=b" class="sref">bv/a>, &va href="+code=qbh" class="sref">qbhv/a>, vspa
 class="string">"chkdn1" 318v/a>                goto va href="+code=chk_bmp" class="sref">chk_bmpv/a>;o 319v/a>        }o 320v/a>        va href="+code=chk_next" class="sref">chk_nextv/a>:o 321v/a>        if (va href="+code=i" class="sref">iv/a> == va href="+code=b" class="sref">bv/a>) va href="+code=i" class="sref">iv/a>++;o 322v/a>        if (va href="+code=i" class="sref">iv/a> >= va href="+code=n_bmps" class="sref">n_bmpsv/a>) return 1;o 323v/a>        va href="+code=bmp" class="sref">bmpv/a> = va href="+code=hpfs_map_bitmap" class="sref">hpfs_map_bitmapv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=i" class="sref">iv/a>, &va href="+code=qbh" class="sref">qbhv/a>, vspa
 class="string">"chkdn2" 324v/a>        va href="+code=chk_bmp" class="sref">chk_bmpv/a>:o 325v/a>        if (va href="+code=bmp" class="sref">bmpv/a>) {o 326v/a>                for (va href="+code=j" class="sref">jv/a> = 0; va href="+code=j" class="sref">jv/a> < 512; va href="+code=j" class="sref">jv/a>++) {o 327v/a>                        va href="+code=u32" class="sref">u32v/a> va href="+code=k" class="sref">kv/a>;o 328v/a>                        if (!va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[va href="+code=j" class="sref">jv/a>])) continue;o 329v/a>                        for (va href="+code=k" class="sref">kv/a> = 0xf; va href="+code=k" class="sref">kv/a>; va href="+code=k" class="sref">kv/a> <<= 4)  330v/a>                                if ((va href="+code=le32_to_cpu" class="sref">le32_to_cpuv/a>(va href="+code=bmp" class="sref">bmpv/a>[va href="+code=j" class="sref">jv/a>]) & va href="+code=k" class="sref">kv/a>) == va href="+code=k" class="sref">kv/a>) {o 331v/a>                                        if (!--va href="+code=n" class="sref">nv/a>) {o 332v/a>                                                va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 333v/a>                                                return 0;o 334v/a>                                        }o 335v/a>                                }o 336v/a>                }o 337v/a>                va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 338v/a>        }o 339v/a>        va href="+code=i" class="sref">iv/a>++;o 340v/a>        goto va href="+code=chk_next" class="sref">chk_nextv/a>;o 341v/a>}o 342v/a>o 343v/a>void va href="+code=hpfs_free_dnode" class="sref">hpfs_free_dnodev/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, va href="+code=dnode_secno" class="sref">dnode_secnov/a> va href="+code=dno" class="sref">dnov/a>)o 344v/a>{o 345v/a>        if (va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_chk" class="sref">sb_chkv/a>) if (va href="+code=dno" class="sref">dnov/a> & 3) {o 346v/a>                va href="+code=hpfs_error" class="sref">hpfs_errorv/a>(va href="+code=s" class="sref">sv/a>, vspa
 class="string">"hpfs_free_dnode: dnode %08x not aligned"dnov/a>);o 347v/a>                return;o 348v/a>        }o 349v/a>        if (va href="+code=dno" class="sref">dnov/a> < va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a> ||o 350v/a>            va href="+code=dno" class="sref">dnov/a> >= va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a> + va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_dirband_size" class="sref">sb_dirband_sizev/a>) {o 351v/a>                va href="+code=hpfs_free_sectors" class="sref">hpfs_free_sectorsv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=dno" class="sref">dnov/a>, 4);o 352v/a>        } else {o 353v/a>                struct va href="+code=quad_buffer_head" class="sref">quad_buffer_headv/a> va href="+code=qbh" class="sref">qbhv/a>;o 354v/a>                va href="+code=__le32" class="sref">__le32v/a> *va href="+code=bmp" class="sref">bmpv/a>;o 355v/a>                unsigned va href="+code=ssec" class="sref">ssecv/a> = (va href="+code=dno" class="sref">dnov/a> - va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_dirband_start" class="sref">sb_dirband_startv/a>) / 4;o 356v/a>                if (!(va href="+code=bmp" class="sref">bmpv/a> = va href="+code=hpfs_map_dnode_bitmap" class="sref">hpfs_map_dnode_bitmapv/a>(va href="+code=s" class="sref">sv/a>, &va href="+code=qbh" class="sref">qbhv/a>))) {o 357v/a>                        return;o 358v/a>                }o 359v/a>                va href="+code=bmp" class="sref">bmpv/a>[va href="+code=ssec" class="sref">ssecv/a> >> 5] |= va href="+code=cpu_to_le32" class="sref">cpu_to_le32v/a>(1 << (va href="+code=ssec" class="sref">ssecv/a> & 0x1f));o 360v/a>                va href="+code=hpfs_mark_4buffers_dirty" class="sref">hpfs_mark_4buffers_dirtyv/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 361v/a>                va href="+code=hpfs_brelse4" class="sref">hpfs_brelse4v/a>(&va href="+code=qbh" class="sref">qbhv/a>);o 362v/a>        }o 363v/a>}o 364v/a>o 365v/a>struct va href="+code=dnode" class="sref">dnodev/a> *va href="+code=hpfs_alloc_dnode" class="sref">hpfs_alloc_dnodev/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, va href="+code=secno" class="sref">secnov/a> va href="+code=near" class="sref">nearv/a>,o 366v/a>                         va href="+code=dnode_secno" class="sref">dnode_secnov/a> *va href="+code=dno" class="sref">dnov/a>, struct va href="+code=quad_buffer_head" class="sref">quad_buffer_headv/a> *va href="+code=qbh" class="sref">qbhv/a>)o 367v/a>{o 368v/a>        struct va href="+code=dnode" class="sref">dnodev/a> *va href="+code=d" class="sref">dv/a>;o 369v/a>        if (va href="+code=hpfs_count_one_bitmap" class="sref">hpfs_count_one_bitmapv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=hpfs_sb" class="sref">hpfs_sbv/a>(va href="+code=s" class="sref">sv/a>)->va href="+code=sb_dmap" class="sref">sb_dmapv/a>) > va href="+code=FREE_DNODES_ADD" class="sref">FREE_DNODES_ADDv/a>) {o 370v/a>                if (!(*va href="+code=dno" class="sref">dnov/a> = va href="+code=alloc_in_dirband" class="sref">alloc_in_dirbandv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=near" class="sref">nearv/a>)))o 371v/a>                        if (!(*va href="+code=dno" class="sref">dnov/a> = va href="+code=hpfs_alloc_sector" class="sref">hpfs_alloc_sectorv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=near" class="sref">nearv/a>, 4, 0))) return va href="+code=NULL" class="sref">NULLv/a>;o 372v/a>        } else {o 373v/a>                if (!(*va href="+code=dno" class="sref">dnov/a> = va href="+code=hpfs_alloc_sector" class="sref">hpfs_alloc_sectorv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=near" class="sref">nearv/a>, 4, 0)))o 374v/a>                        if (!(*va href="+code=dno" class="sref">dnov/a> = va href="+code=alloc_in_dirband" class="sref">alloc_in_dirbandv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=near" class="sref">nearv/a>))) return va href="+code=NULL" class="sref">NULLv/a>;o 375v/a>        }o 376v/a>        if (!(va href="+code=d" class="sref">dv/a> = va href="+code=hpfs_get_4sectors" class="sref">hpfs_get_4sectorsv/a>(va href="+code=s" class="sref">sv/a>, *va href="+code=dno" class="sref">dnov/a>, va href="+code=qbh" class="sref">qbhv/a>))) {o 377v/a>                va href="+code=hpfs_free_dnode" class="sref">hpfs_free_dnodev/a>(va href="+code=s" class="sref">sv/a>, *va href="+code=dno" class="sref">dnov/a>);o 378v/a>                return va href="+code=NULL" class="sref">NULLv/a>;o 379v/a>        }o 380v/a>        va href="+code=memset" class="sref">memsetv/a>(va href="+code=d" class="sref">dv/a>, 0, 2048);o 381v/a>        va href="+code=d" class="sref">dv/a>->va href="+code=magic" class="sref">magicv/a> = va href="+code=cpu_to_le32" class="sref">cpu_to_le32v/a>(va href="+code=DNODE_MAGIC" class="sref">DNODE_MAGICv/a>);o 382v/a>        va href="+code=d" class="sref">dv/a>->va href="+code=first_free" class="sref">first_freev/a> = va href="+code=cpu_to_le32" class="sref">cpu_to_le32v/a>(52);o 383v/a>        va href="+code=d" class="sref">dv/a>->va href="+code=dirent" class="sref">direntv/a>[0] = 32;o 384v/a>        va href="+code=d" class="sref">dv/a>->va href="+code=dirent" class="sref">direntv/a>[2] = 8;o 385v/a>        va href="+code=d" class="sref">dv/a>->va href="+code=dirent" class="sref">direntv/a>[30] = 1;o 386v/a>        va href="+code=d" class="sref">dv/a>->va href="+code=dirent" class="sref">direntv/a>[31] = 255;o 387v/a>        va href="+code=d" class="sref">dv/a>->va href="+code=self" class="sref">selfv/a> = va href="+code=cpu_to_le32" class="sref">cpu_to_le32v/a>(*va href="+code=dno" class="sref">dnov/a>);o 388v/a>        return va href="+code=d" class="sref">dv/a>;o 389v/a>}o 390v/a>o 391v/a>struct va href="+code=fnode" class="sref">fnodev/a> *va href="+code=hpfs_alloc_fnode" class="sref">hpfs_alloc_fnodev/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, va href="+code=secno" class="sref">secnov/a> va href="+code=near" class="sref">nearv/a>, va href="+code=fnode_secno" class="sref">fnode_secnov/a> *va href="+code=fno" class="sref">fnov/a>,o 392v/a>                          struct va href="+code=buffer_head" class="sref">buffer_headv/a> **va href="+code=bh" class="sref">bhv/a>)o 393v/a>{o 394v/a>        struct va href="+code=fnode" class="sref">fnodev/a> *va href="+code=f" class="sref">fv/a>;o 395v/a>        if (!(*va href="+code=fno" class="sref">fnov/a> = va href="+code=hpfs_alloc_sector" class="sref">hpfs_alloc_sectorv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=near" class="sref">nearv/a>, 1, va href="+code=FNODE_ALLOC_FWD" class="sref">FNODE_ALLOC_FWDv/a>))) return va href="+code=NULL" class="sref">NULLv/a>;o 396v/a>        if (!(va href="+code=f" class="sref">fv/a> = va href="+code=hpfs_get_sector" class="sref">hpfs_get_sectorv/a>(va href="+code=s" class="sref">sv/a>, *va href="+code=fno" class="sref">fnov/a>, va href="+code=bh" class="sref">bhv/a>))) {o 397v/a>                va href="+code=hpfs_free_sectors" class="sref">hpfs_free_sectorsv/a>(va href="+code=s" class="sref">sv/a>, *va href="+code=fno" class="sref">fnov/a>, 1);o 398v/a>                return va href="+code=NULL" class="sref">NULLv/a>;o 399v/a>        }       o 400v/a>        va href="+code=memset" class="sref">memsetv/a>(va href="+code=f" class="sref">fv/a>, 0, 512);o 401v/a>        va href="+code=f" class="sref">fv/a>->va href="+code=magic" class="sref">magicv/a> = va href="+code=cpu_to_le32" class="sref">cpu_to_le32v/a>(va href="+code=FNODE_MAGIC" class="sref">FNODE_MAGICv/a>);o 402v/a>        va href="+code=f" class="sref">fv/a>->va href="+code=ea_offs" class="sref">ea_offsv/a> = va href="+code=cpu_to_le16" class="sref">cpu_to_le16v/a>(0xc4);o 403v/a>        va href="+code=f" class="sref">fv/a>->va href="+code=btree" class="sref">btreev/a>.va href="+code=n_free_nodes" class="sref">n_free_nodesv/a> = 8;o 404v/a>        va href="+code=f" class="sref">fv/a>->va href="+code=btree" class="sref">btreev/a>.va href="+code=first_free" class="sref">first_freev/a> = va href="+code=cpu_to_le16" class="sref">cpu_to_le16v/a>(8);o 405v/a>        return va href="+code=f" class="sref">fv/a>;o 406v/a>}o 407v/a>o 408v/a>struct va href="+code=anode" class="sref">anodev/a> *va href="+code=hpfs_alloc_anode" class="sref">hpfs_alloc_anodev/a>(struct va href="+code=super_block" class="sref">super_blockv/a> *va href="+code=s" class="sref">sv/a>, va href="+code=secno" class="sref">secnov/a> va href="+code=near" class="sref">nearv/a>, va href="+code=anode_secno" class="sref">anode_secnov/a> *va href="+code=ano" class="sref">anov/a>,o 409v/a>                          struct va href="+code=buffer_head" class="sref">buffer_headv/a> **va href="+code=bh" class="sref">bhv/a>)o 410v/a>{o 411v/a>        struct va href="+code=anode" class="sref">anodev/a> *va href="+code=a" class="sref">av/a>;o 412v/a>        if (!(*va href="+code=ano" class="sref">anov/a> = va href="+code=hpfs_alloc_sector" class="sref">hpfs_alloc_sectorv/a>(va href="+code=s" class="sref">sv/a>, va href="+code=near" class="sref">nearv/a>, 1, va href="+code=ANODE_ALLOC_FWD" class="sref">ANODE_ALLOC_FWDv/a>))) return va href="+code=NULL" class="sref">NULLv/a>;o 413v/a>        if (!(va href="+code=a" class="sref">av/a> = va href="+code=hpfs_get_sector" class="sref">hpfs_get_sectorv/a>(va href="+code=s" class="sref">sv/a>, *va href="+code=ano" class="sref">anov/a>, va href="+code=bh" class="sref">bhv/a>))) {o 414v/a>                va href="+code=hpfs_free_sectors" class="sref">hpfs_free_sectorsv/a>(va href="+code=s" class="sref">sv/a>, *va href="+code=ano" class="sref">anov/a>, 1);o 415v/a>                return va href="+code=NULL" class="sref">NULLv/a>;o 416v/a>        }o 417v/a>        va href="+code=memset" class="sref">memsetv/a>(va href="+code=a" class="sref">av/a>, 0, 512);o 418v/a>        va href="+code=a" class="sref">av/a>->va href="+code=magic" class="sref">magicv/a> = va href="+code=cpu_to_le32" class="sref">cpu_to_le32v/a>(va href="+code=ANODE_MAGIC" class="sref">ANODE_MAGICv/a>);o 419v/a>        va href="+code=a" class="sref">av/a>->va href="+code=self" class="sref">selfv/a> = va href="+code=cpu_to_le32" class="sref">cpu_to_le32v/a>(*va href="+code=ano" class="sref">anov/a>);o 420v/a>        va href="+code=a" class="sref">av/a>->va href="+code=btree" class="sref">btreev/a>.va href="+code=n_free_nodes" class="sref">n_free_nodesv/a> = 40;o 421v/a>        va href="+code=a" class="sref">av/a>->va href="+code=btree" class="sref">btreev/a>.va href="+code=n_used_nodes" class="sref">n_used_nodesv/a> = 0;o 422v/a>        va href="+code=a" class="sref">av/a>->va href="+code=btree" class="sref">btreev/a>.va href="+code=first_free" class="sref">first_freev/a> = va href="+code=cpu_to_le16" class="sref">cpu_to_le16v/a>(8);o 423v/a>        return va href="+code=a" class="sref">av/a>;o 424v/a>}o 425v/a>
lxr.linux.no kindly hosted by Redpill Linpro ASv/a>, provider of Linux consulting and operations services since 1995.