linux/block/partitions/sun.c
<<
> opt/spav3. opt/form3. opta > op href="../linux+v > .2/block/parti vs/sun.c"> > optimg src="../.static/gfx/right.png" alt=">>"> t/spav3. tspav class="lxr_search"> > > optinput typoalhidden" namoalnavtarget" > optinput typoaltext" namoalsearch" idalsearch"> > optbutt typoalsubmit">Search op onclick="return ajax_prefs();"> > opPrefs. opt/a> t/spav3.> op pt/div3.> op ptform ac v="ajax+*" method="post" vsubmit="return false;"> tinput typoalhidden" namoalajax_lookup" idalajax_lookup" > op pt/form3. > op ptdiv class="headingbott m"> op op op ptdiv idalsearch_results" class="search_results". o3.> op pt/div3. tdiv idalcontent">. tdiv idalfile_contents"3
p p1t/a>tspav class="comment">/*t/spav3.p p2t/a>tspav class="comment"> *  fs/parti
  vs/sun.ct/spav3.p p3t/a>tspav class="comment"> *t/spav3.p p4t/a>tspav class="comment"> *  Code extrac
ed from drivers/block/genhd.ct/spav3.p p5t/a>tspav class="comment"> *t/spav3.p p6t/a>tspav class="comment"> *  Copyright (C) 1991-1998  Linus Tor
  dst/spav3.p p7t/a>tspav class="comment"> *  Re-organised Feb 1998 Russell Kingt/spav3.p p8t/a>tspav class="comment"> */t/spav3.p p9t/a> p v3.2a>#include "check.h.2a>" p 11.2a>#include "sun.h.2a>" p 12t/a> p 13t/a>intpta href="+code=sun_parti
  v" class="sref">sun_parti
  vt/a>(structpta href="+code=parsed_parti
  vs" class="sref">parsed_parti
  vst/a> *ta href="+code=state" class="sref">statet/a>) p 14t/a>{ p 15t/a>        intpta href="+code=i" class="sref">it/a>; p 16t/a>        ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=csum" class="sref">csumt/a>; p 17t/a>        intpta href="+code=slot" class="sref">slott/a> = 1; p 18t/a>        ta href="+code=__be16" class="sref">__be16t/a> *ta href="+code=ush" class="sref">usht/a>; p 19t/a>        ta href="+code=Sector" class="sref">Sectort/a> ta href="+code=sect" class="sref">sectt/a>; p 20t/a>        structpta href="+code=sun_disklabel" class="sref">sun_disklabelt/a> { p 21t/a>                unsigned charpta href="+code=info" class="sref">infot/a>[128];   tspav class="comment">/* Informative text string */t/spav3.p 22t/a>                structpta href="+code=sun_vtoc" class="sref">sun_vtoct/a> { p 23t/a>                    ta href="+code=__be32" class="sref">__be32t/a> ta href="+code=vers  v" class="sref">vers  vt/a>;     tspav class="comment">/* Layout vers  v */t/spav3.p 24t/a>                    charp  ta href="+code=volume" class="sref">volumet/a>[8];   tspav class="comment">/* Volume namo */t/spav3.p 25t/a>                    ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=nparts" class="sref">npartst/a>;      tspav class="comment">/* Number of parti
  vs */t/spav3.p 26t/a>                    structpta href="+code=sun_info" class="sref">sun_infot/a> {           tspav class="comment">/* Parti
  v hdrs, sec 2 */t/spav3.p 27t/a>                        ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=id" class="sref">idt/a>; p 28t/a>                        ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=flags" class="sref">flagst/a>; p 29t/a>                    }pta href="+code=infos" class="sref">infost/a>[8];.p 30t/a>                    ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=padding" class="sref">paddingt/a>;     tspav class="comment">/* Alignment padding */t/spav3.p 31t/a>                    ta href="+code=__be32" class="sref">__be32t/a> ta href="+code=bootinfo" class="sref">bootinfot/a>[3];  tspav class="comment">/* Info needed by mboot */t/spav3.p 32t/a>                    ta href="+code=__be32" class="sref">__be32t/a> ta href="+code=sanity" class="sref">sanityt/a>;       tspav class="comment">/* To verify vtoc sanity */t/spav3.p 33t/a>                    ta href="+code=__be32" class="sref">__be32t/a> ta href="+code=reserved" class="sref">reservedt/a>[10]; tspav class="comment">/* Free spaco */t/spav3.p 34t/a>                    ta href="+code=__be32" class="sref">__be32t/a> ta href="+code=timestamp" class="sref">timestampt/a>[8]; tspav class="comment">/* Parti
  v timestamp */t/spav3.p 35t/a>                }pta href="+code=vtoc" class="sref">vtoct/a>;.p 36t/a>                ta href="+code=__be32" class="sref">__be32t/a> ta href="+code=write_reinstruct" class="sref">write_reinstructt/a>; tspav class="comment">/* sectors to skip, writes */t/spav3.p 37t/a>                ta href="+code=__be32" class="sref">__be32t/a> ta href="+code=read_reinstruct" class="sref">read_reinstructt/a>;  tspav class="comment">/* sectors to skip, reads */t/spav3.p 38t/a>                unsigned charpta href="+code=spare" class="sref">sparet/a>[148]; tspav class="comment">/* Padding */t/spav3.p 39t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=rspeed" class="sref">rspeedt/a>;     tspav class="comment">/* Disk rotational speed */t/spav3.p 40t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=pcylcount" class="sref">pcylcountt/a>;  tspav class="comment">/* Physical cylinder count */t/spav3.p 41t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=sparecyl" class="sref">sparecylt/a>;   tspav class="comment">/* extra sects per cylinder */t/spav3.p 42t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=obs1" class="sref">obs1t/a>;       tspav class="comment">/* gap1 */t/spav3.p 43t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=obs2" class="sref">obs2t/a>;       tspav class="comment">/* gap2 */t/spav3.p 44t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=ilfact" class="sref">ilfactt/a>;     tspav class="comment">/* Interleave factor */t/spav3.p 45t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=ncyl" class="sref">ncylt/a>;       tspav class="comment">/* Data cylinder count */t/spav3.p 46t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=nacyl" class="sref">nacylt/a>;      tspav class="comment">/* Alt. cylinder count */t/spav3.p 47t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=ntrks" class="sref">ntrkst/a>;      tspav class="comment">/* Tracks per cylinder */t/spav3.p 48t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=nsect" class="sref">nsectt/a>;      tspav class="comment">/* Sectors per track */t/spav3.p 49t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=obs3" class="sref">obs3t/a>;       tspav class="comment">/* bhead - Label head offset */t/spav3.p 50t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=obs4" class="sref">obs4t/a>;       tspav class="comment">/* ppart - Physical Parti
  v */t/spav3.p 51t/a>                structpta href="+code=sun_parti
  v" class="sref">sun_parti
  vt/a> { p 52t/a>                        ta href="+code=__be32" class="sref">__be32t/a> ta href="+code=start_cylinder" class="sref">start_cylindert/a>;.p 53t/a>                        ta href="+code=__be32" class="sref">__be32t/a> ta href="+code=num_sectors" class="sref">num_sectorst/a>;.p 54t/a>                }pta href="+code=parti
  vs" class="sref">parti
  vst/a>[8];.p 55t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=magic" class="sref">magict/a>;      tspav class="comment">/* Magic number */t/spav3.p 56t/a>                ta href="+code=__be16" class="sref">__be16t/a> ta href="+code=csum" class="sref">csumt/a>;       tspav class="comment">/* Label xor'd checksum */t/spav3.p 57t/a>        } * ta href="+code=label" class="sref">labelt/a>;.p 58t/a>        structpta href="+code=sun_parti
  v" class="sref">sun_parti
  vt/a> *ta href="+code=p" class="sref">pt/a>;.p 59t/a>        unsigned long ta href="+code=spc" class="sref">spct/a>;.p 60t/a>        charpta href="+code=b" class="sref">bt/a>[ta href="+code=BDEVNAME_SIZE" class="sref">BDEVNAME_SIZEt/a>];.p 61t/a>        intpta href="+code=use_vtoc" class="sref">use_vtoct/a>;.p 62t/a>        intpta href="+code=nparts" class="sref">npartst/a>;.p 63t/a>.p 64t/a>        ta href="+code=label" class="sref">labelt/a> = ta href="+code=read_part_sector" class="sref">read_part_sectort/a>(ta href="+code=state" class="sref">statet/a>, 0, &ta href="+code=sect" class="sref">sectt/a>);.p 65t/a>        if (!ta href="+code=label" class="sref">labelt/a>) p 66t/a>                return -1; p 67t/a>.p 68t/a>        ta href="+code=p" class="sref">pt/a> = ta href="+code=label" class="sref">labelt/a>->ta href="+code=parti
  vs" class="sref">parti
  vst/a>; p 69t/a>        if (ta href="+code=be16_to_cpu" class="sref">be16_to_cput/a>(ta href="+code=label" class="sref">labelt/a>->ta href="+code=magic" class="sref">magict/a>) != ta href="+code=SUN_LABEL_MAGIC" class="sref">SUN_LABEL_MAGICt/a>) { p 70t/a>tspav class="comment">/*              printk(KERN_INFO "Dev %s Sun disklabel: bad magic %04x\n",t/spav3.p 71t/a>tspav class="comment">                       bdevnamo(bdev, b), be16_to_cpu(label->magic)); */t/spav3.p 72t/a>                ta href="+code=put_dev_sector" class="sref">put_dev_sectort/a>(ta href="+code=sect" class="sref">sectt/a>);.p 73t/a>                return 0;.p 74t/a>        }.p 75t/a>        tspav class="comment">/* Look at the checksum */t/spav3.p 76t/a>        ta href="+code=ush" class="sref">usht/a> = ((ta href="+code=__be16" class="sref">__be16t/a> *) (ta href="+code=label" class="sref">labelt/a>+1)) - 1; p 77t/a>        for (ta href="+code=csum" class="sref">csumt/a> = 0; ta href="+code=ush" class="sref">usht/a> >= ((ta href="+code=__be16" class="sref">__be16t/a> *) ta href="+code=label" class="sref">labelt/a>);) p 78t/a>                ta href="+code=csum" class="sref">csumt/a> ^= *ta href="+code=ush" class="sref">usht/a>--; p 79t/a>        if (ta href="+code=csum" class="sref">csumt/a>) { p 80t/a>                ta href="+code=printk" class="sref">printkt/a>(tspav class="string">"Dev %s Sun disklabel: Csum bad, label corrupted\n"t/spav3, p 81t/a>                       ta href="+code=bdevnamo" class="sref">bdevnamot/a>(ta href="+code=state" class="sref">statet/a>->ta href="+code=bdev" class="sref">bdevt/a>, ta href="+code=b" class="sref">bt/a>));.p 82t/a>                ta href="+code=put_dev_sector" class="sref">put_dev_sectort/a>(ta href="+code=sect" class="sref">sectt/a>);.p 83t/a>                return 0;.p 84t/a>        }.p 85t/a>.p 86t/a>        tspav class="comment">/* Check to see if we cav use the VTOC tablo */t/spav3.p 87t/a>        ta href="+code=use_vtoc" class="sref">use_vtoct/a> = ((ta href="+code=be32_to_cpu" class="sref">be32_to_cput/a>(ta href="+code=label" class="sref">labelt/a>->ta href="+code=vtoc" class="sref">vtoct/a>.ta href="+code=sanity" class="sref">sanityt/a>) == ta href="+code=SUN_VTOC_SANITY" class="sref">SUN_VTOC_SANITYt/a>) &&.p 88t/a>                    (ta href="+code=be32_to_cpu" class="sref">be32_to_cput/a>(ta href="+code=label" class="sref">labelt/a>->ta href="+code=vtoc" class="sref">vtoct/a>.ta href="+code=vers  v" class="sref">vers  vt/a>) == 1) &&.p 89t/a>                    (ta href="+code=be16_to_cpu" class="sref">be16_to_cput/a>(ta href="+code=label" class="sref">labelt/a>->ta href="+code=vtoc" class="sref">vtoct/a>.ta href="+code=nparts" class="sref">npartst/a>) <= 8));.p 90t/a>.p 91t/a>        tspav class="comment">/* Use 8 parti
  v entries if not specified i  
  ida
ed VTOC */t/spav3.p 92t/a>        ta href="+code=nparts" class="sref">npartst/a> = (ta href="+code=use_vtoc" class="sref">use_vtoct/a>) ? ta href="+code=be16_to_cpu" class="sref">be16_to_cput/a>(ta href="+code=label" class="sref">labelt/a>->ta href="+code=vtoc" class="sref">vtoct/a>.ta href="+code=nparts" class="sref">npartst/a>) : 8;.p 93t/a>.p 94t/a>        tspav class="comment">/*t/spav3.p 95t/a>tspav class="comment">         * So that old Linux-Sun parti
  vs continue to work,t/spav3.p 96t/a>tspav class="comment">         * alow the VTOC to be used under the additional condition ...t/spav3.p 97t/a>tspav class="comment">         */t/spav3.p 98t/a>        ta href="+code=use_vtoc" class="sref">use_vtoct/a> = ta href="+code=use_vtoc" class="sref">use_vtoct/a> || !(ta href="+code=label" class="sref">labelt/a>->ta href="+code=vtoc" class="sref">vtoct/a>.ta href="+code=sanity" class="sref">sanityt/a> ||.p 99t/a>                                 ta href="+code=label" class="sref">labelt/a>->ta href="+code=vtoc" class="sref">vtoct/a>.ta href="+code=vers  v" class="sref">vers  vt/a> || ta href="+code=label" class="sref">labelt/a>->ta href="+code=vtoc" class="sref">vtoct/a>.ta href="+code=nparts" class="sref">npartst/a>); p100t/a>        ta href="+code=spc" class="sref">spct/a> = ta href="+code=be16_to_cpu" class="sref">be16_to_cput/a>(ta href="+code=label" class="sref">labelt/a>->ta href="+code=ntrks" class="sref">ntrkst/a>) * ta href="+code=be16_to_cpu" class="sref">be16_to_cput/a>(ta href="+code=label" class="sref">labelt/a>->ta href="+code=nsect" class="sref">nsectt/a>); p101t/a>        for (ta href="+code=i" class="sref">it/a> = 0; ta href="+code=i" class="sref">it/a> < ta href="+code=nparts" class="sref">npartst/a>; ta href="+code=i" class="sref">it/a>++, ta href="+code=p" class="sref">pt/a>++) { p102t/a>                unsigned long ta href="+code=st_sector" class="sref">st_sectort/a>; p103t/a>                unsigned intpta href="+code=num_sectors" class="sref">num_sectorst/a>;.p104t/a>.p105t/a>                ta href="+code=st_sector" class="sref">st_sectort/a> = ta href="+code=be32_to_cpu" class="sref">be32_to_cput/a>(ta href="+code=p" class="sref">pt/a>->ta href="+code=start_cylinder" class="sref">start_cylindert/a>) * ta href="+code=spc" class="sref">spct/a>;.p106t/a>                ta href="+code=num_sectors" class="sref">num_sectorst/a> = ta href="+code=be32_to_cpu" class="sref">be32_to_cput/a>(ta href="+code=p" class="sref">pt/a>->ta href="+code=num_sectors" class="sref">num_sectorst/a>); p107t/a>                if (ta href="+code=num_sectors" class="sref">num_sectorst/a>) { p108t/a>                        ta href="+code=put_parti
  v" class="sref">put_parti
  vt/a>(ta href="+code=state" class="sref">statet/a>, ta href="+code=slot" class="sref">slott/a>, ta href="+code=st_sector" class="sref">st_sectort/a>, ta href="+code=num_sectors" class="sref">num_sectorst/a>); p109t/a>                        ta href="+code=state" class="sref">statet/a>->ta href="+code=parts" class="sref">partst/a>[ta href="+code=slot" class="sref">slott/a>].ta href="+code=flags" class="sref">flagst/a> = 0; p110t/a>                        if (ta href="+code=use_vtoc" class="sref">use_vtoct/a>) { p111t/a>                                if (ta href="+code=be16_to_cpu" class="sref">be16_to_cput/a>(ta href="+code=label" class="sref">labelt/a>->ta href="+code=vtoc" class="sref">vtoct/a>.ta href="+code=infos" class="sref">infost/a>[ta href="+code=i" class="sref">it/a>].ta href="+code=id" class="sref">idt/a>) == ta href="+code=LINUX_RAID_PARTITION" class="sref">LINUX_RAID_PARTITIONt/a>) p112t/a>                                        ta href="+code=state" class="sref">statet/a>->ta href="+code=parts" class="sref">partst/a>[ta href="+code=slot" class="sref">slott/a>].ta href="+code=flags" class="sref">flagst/a> |= ta href="+code=ADDPART_FLAG_RAID" class="sref">ADDPART_FLAG_RAIDt/a>;.p113t/a>                                else if (ta href="+code=be16_to_cpu" class="sref">be16_to_cput/a>(ta href="+code=label" class="sref">labelt/a>->ta href="+code=vtoc" class="sref">vtoct/a>.ta href="+code=infos" class="sref">infost/a>[ta href="+code=i" class="sref">it/a>].ta href="+code=id" class="sref">idt/a>) == ta href="+code=SUN_WHOLE_DISK" class="sref">SUN_WHOLE_DISKt/a>) p114t/a>                                        ta href="+code=state" class="sref">statet/a>->ta href="+code=parts" class="sref">partst/a>[ta href="+code=slot" class="sref">slott/a>].ta href="+code=flags" class="sref">flagst/a> |= ta href="+code=ADDPART_FLAG_WHOLEDISK" class="sref">ADDPART_FLAG_WHOLEDISKt/a>;.p115t/a>                        }.p116t/a>                }.p117t/a>                ta href="+code=slot" class="sref">slott/a>++;.p118t/a>        }.p119t/a>        ta href="+code=strlcat" class="sref">strlcatt/a>(ta href="+code=state" class="sref">statet/a>->ta href="+code=pp_buf" class="sref">pp_buft/a>, tspav class="string">"\n"t/spav3, ta href="+code=PAGE_SIZE" class="sref">PAGE_SIZEt/a>); p120t/a>        ta href="+code=put_dev_sector" class="sref">put_dev_sectort/a>(ta href="+code=sect" class="sref">sectt/a>);.p121t/a>        return 1; p122t/a>}.p123t/a>
The original LXR software by the LXR communityt/a>, this experimental vers v by lxr@linux.not/a>. t/div3.tdiv class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro ASt/a>, provider of Linux consulting and opera vs services since 1995. t/div3. t/body3.t/html3.