<<==============================================================        00010000
                                                                        00012000
                           inclfree - b1                                00014000
                                                                        00016000
      this include file has the code that is common to vinit and        00018000
   free2, which is the procedure pfre.                                  00020000
                                                                        00022000
==============================================================>>        00024000
procedure pfre(fn,all,which'ldev);                                      00026000
   value fn,all,which'ldev;                                             00028000
   integer fn,which'ldev;                                               00030000
   logical all;                                                         00032000
   option privileged,uncallable;                                        00034000
                                                                        00036000
<<===================================================                   00038000
                                                                        00040000
                                                                        00042000
   procedure to print out a histogram of free space. options are        00044000
   for all discs(mounted pv or sys disc) or a single ldev. pfre         00046000
   operates part of the time in split stack mode. this is why           00048000
   any arrays which are used in split stack mode are defined to be      00050000
   direct(not db relative). note that because it operates partially     00052000
   in split stack mode, it will gather information for 1 ldev           00054000
   and then print it out.  this means that if the print file            00056000
   is on that ldev, the print file space wil not show as free space.    00058000
   to modify pfre to include spoolfile space implies that all the       00060000
   information for all ldevs must be gathered before creating the       00062000
   printfile.  this would mean that there would be                      00064000
   (#entries-in-vol-tbl * space'info'sz) words on the stack.            00066000
   this is too much overhead for something trivial.  if the spooler     00068000
   is ever modified to allow easy access to the file label of the       00070000
   spool file, then this modification can be considered.                00072000
   if any errors occur on writting then will print out                  00074000
   print'file'info. if any error occurs accessing the dfsm,             00076000
   it will print out the rel addr where error occured and               00078000
   status word(returned from dfsm routines).                            00080000
                                                                        00082000
   parameters:                                                          00084000
      fn-integer,filenumber of printfile which has already been         00086000
         opened                                                         00088000
      all-logical,has value true when you want a histogram for all      00090000
          ldevs                                                         00092000
      which'ldev-integer,print a histogram for this ldev only.          00094000
                 only has meaning if "all" is false                     00096000
                                                                        00098000
   assumptions on entry:                                                00100000
      print file has already been opened                                00102000
      if there are any errors in accessing the dfsm or writting         00104000
      the print file subroutine err'pfre will exit. if calling          00106000
      procedure is changed, this subroutine must be changed.            00108000
                                                                        00110000
   globals:                                                             00112000
      modifies-ds'page'ptr,ds'word'number,ds'bit'number,                00114000
      uses-ds'io'status,ds'starting'word'number                         00116000
           ,ds'starting'bit'number,ds'descriptor'table                  00118000
      constants-ok'io'status,largest'space,true,false                   00120000
      vol'table-ldev,scratch,unformatted                                00122000
      lpdt-lpdt'entry'size,nsd,ser'forn                                 00124000
                                                                        00126000
   externals:                                                           00128000
      setcritical,getsir,relsir,lock'dfs'data'seg,scan'page             00130000
      ,rel'dfs'data'seg,resetcritical                                   00132000
                                                                        00134000
   intrinsics:                                                          00136000
      fwrite,print'file'info,terminate,quit,ascii,dascii                00138000
                                                                        00140000
   resources:                                                           00142000
      vol tbl sir, uses sys global ptr to access lpdt(does not get      00144000
      lpdt sir before accessing)                                        00146000
      mvtab sir (table not actually accessed)                  ((dfs02))00148000
                                                                        00150000
   callers:                                                             00152000
      print'free2, pfspace(vinit)                                       00154000
                                                                        00156000
   fixid:                                                               00158000
      this procedure was added for support of the new disc free         00160000
      space map.                                                        00162000
                                                                        00164000
   changes:                                                             00166000
                                                               ((dfs02))00168000
      fix to only print free space for private volumes that    ((dfs02))00170000
      are logically mounted.  this is to keep a physical       ((dfs02))00172000
      dismount from happening while free space is being        ((dfs02))00174000
      listed.                                                  ((dfs02))00176000
                                                               ((dfs02))00178000
                                                                        00180000
      changes to print out the number of dfsm pages on a       ((dfs01))00182000
      volume.                                                  ((dfs01  00184000
                                                               ((dfs01  00186000
====================================================>>                  00188000
begin                                                                   00190000
                                                                        00192000
   equate space'info'sz = 32                                            00194000
          ;                                                             00196000
                                                                        00198000
   define zero'space'info = space'info:=0;                              00200000
                            move space'info(1):=space'info,             00202000
                                                 (space'info'sz-1)#;    00204000
                                                                        00206000
   array         space'info(0:space'info'sz-1)=q;                       00208000
   double array  dspace'info(*)=space'info;                             00210000
   array         vol'name(*)=         space'info;                       00212000
   double array  bucket(*)=           dspace'info(%2);                  00214000
   double array  bucket'cnt(*)=       dspace'info(%10);                 00216000
   define        disc'max=            dspace'info(%16)#;                00218000
   define        disc'total=          dspace'info(%17)#;                00220000
                                                                        00222000
   double        tot'sys'space;                                         00224000
                                                                        00226000
   integer       dummy1,dummy2;    <<temp variables>>                   00228000
   integer array dummya(*)=dummy1;                                      00230000
   double        ddummy;                                                00232000
                                                                        00234000
   integer       index;        << for put'into'array >>                 00236000
   double        size;         << and create'the'printout >>            00238000
                                                                        00240000
   equate        print'len=18;   << for create'the'printout >>          00242000
                                                                        00244000
   array         print'line(0:print'len-1);                             00246000
   byte array    bprint'line(*)=print'line;                             00248000
                                                                        00250000
   define        blank'print = print'line:="  ";                        00252000
                               move print'line(1):=print'line,          00254000
                                                        (print'len-1)#; 00256000
   define        print'stars = blank'print;                             00258000
                               print'line:="**";                        00260000
                               move print'line(1):=print'line,          00262000
                                                        (print'len-1);  00264000
                               fwrite(fn,print'line,print'len,%40);     00266000
                               if <> then err'pfre(write'error)#;       00268000
                                                                        00270000
                                                                        00272000
   <<  volume table definitions  >>                                     00274000
                                                                        00276000
   equate         vol'tbl'sir=22                                        00278000
                 ,vol'tbl'dst=29                                        00280000
                 ;                                                      00282000
                                                                        00284000
   pointer        vol'table;                                            00286000
   integer        vol'ent'sz                                            00288000
                 ,vol'index                                             00290000
                 ,num'vol'ent  << tot # ent,not incl header >>          00292000
                 ,num'vol'cntr << run through vol tbl >>                00294000
                 ;                                                      00296000
                                                                        00298000
   logical        volsir'flag                                           00300000
                 ;                                                      00302000
                                                                        00304000
   define         volumename=vol'table#;                                00306000
   define         ldev=int( vol'table(%14).(0:8) )#;                    00308000
   define         scratch=vol'table(%14).(15:1)=1#;                     00310000
   define         unformatted=vol'table(%14).(13:1)=1#;                 00312000
                                                                        00314000
   <<  mask for states which are allowable for ldev. for   >>           00316000
   <<  more info, see pvsys                                >>           00318000
                                                                        00320000
   equate ok'mask=%007470;   << mounted,downpending,down,               00322000
                                reserved,sysdomain,                     00324000
                                notpvtype,notremoveable                 00326000
                             >>                                         00328000
                                                                        00330000
   logical  lstatus;                                                    00332000
                                                                        00334000
   <<     local definitions for  dfsm usage >>                          00336000
                                                                        00338000
   integer       lpage    << to tell "get'page" what page >>            00340000
                ;                                                       00342000
                                                                        00344000
   logical       ldone    << done with this ldev         >>             00346000
                ,lpg'end  << done with this page         >>             00348000
                ,ldfs'locked << dfsm locked and split stack >>          00350000
                ,ldev'found  << when only printing one ldev >>          00352000
                ,lcrit       << setcritical value >>                    00354000
                ,lcrit'set   << flag to show did setcrit >>             00356000
                ,cantfind    << descrs say all pages bad  >>            00358000
                ,cont                                                   00360000
                ,proc'status                                            00362000
                ;                                                       00364000
                                                                        00366000
   double        lsectcnt   << sect cnt, may span pages >>              00368000
                ;                                                       00370000
                                                                        00372000
   <<   use to access the lpdt    >>                                    00374000
                                                                        00376000
   integer pointer lpdt=8;  << sys glob ptr >>                          00378000
   equate lpdt'entry'size = 2;                                          00380000
   define nsd=(4:1)#;                                                   00382000
   define ser'forn = (10:2)#;                                           00384000
   define mounted'pv = (5:1)#;                                 <<03755>>00386000
                                                               <<03755>>00388000
   logical mvtab'sir'flag,                                     <<03755>>00390000
           have'mvtab'sir := false;                            <<03755>>00392000
                                                               <<03755>>00394000
                                                                        00396000
      << see if descriptor entry for page flagged as bad >>             00398000
                                                                        00400000
   define        flagged'bad = ds'descriptor'table(                     00402000
                             (lpage*dt'entry'size) +                    00404000
                              largest'space ) = bad'page#;              00406000
                                                                        00408000
   equate write'error = %01;  << for err'pfre >>                        00410000
                                                                        00412000
   << use this when subroutine exits from procedure >>                  00414000
                                                                        00416000
   define exit'procedure = assemble(exit 3)#;                           00418000
                                                                        00420000
   integer bad'page'count;                                     <<03721>>00422000
   byte pointer bps0 = s - 0;                                  <<03721>>00424000
$page                                                                   00426000
<<        array space'info                                              00428000
                                                                        00430000
      **************************************                            00432000
    0 *                                    *  vol'name(ba)              00434000
      *                                    *                            00436000
      *                                    *                            00438000
      **************************************                            00440000
    5 *         100000 >                   *  bucket(dbl)               00442000
      **************************************                            00444000
      *         10000 - 99999              *                            00446000
      **************************************                            00448000
      *         1000  - 9999               *                            00450000
      **************************************                            00452000
      *         100   - 999                *                            00454000
      **************************************                            00456000
      *         10    - 99                 *                            00458000
      **************************************                            00460000
      *         1     - 9                  *                            00462000
      **************************************                            00464000
  %20 *  count    100000                   *  bucket'cnt(dbl)           00466000
      **************************************                            00468000
      *           10000                    *                            00470000
      **************************************                            00472000
      *           1000                     *                            00474000
      **************************************                            00476000
      *           100                      *                            00478000
      **************************************                            00480000
      *           10                       *                            00482000
      **************************************                            00484000
      *           1                        *                            00486000
      **************************************                            00488000
  %34 *       max free size                *  disc'max(dbl)             00490000
      **************************************                            00492000
  %36 *     total space on disc            *  disc'total(dbl)           00494000
      **************************************                            00496000
                                                                        00498000
      total size of array =%40                                          00500000
>>                                                                      00502000
$page "HEWLETT-PACKARD   SUBROUTINE REL'MVTAB"                 <<04607>>00504000
subroutine rel'mvtab;                                          <<04607>>00506000
begin                                                          <<04607>>00508000
   if have'mvtab'sir then                                      <<04607>>00510000
      begin                                                    <<04607>>00512000
      relsir (mvtabsir,mvtab'sir'flag);                        <<04607>>00514000
      have'mvtab'sir := false;                                 <<04607>>00516000
      end;                                                     <<04607>>00518000
   if lcrit'set then                                           <<04607>>00520000
      begin                                                    <<04607>>00522000
      resetcritical(lcrit);                                    <<04607>>00524000
      lcrit'set := false;                                      <<04607>>00526000
      end;                                                     <<04607>>00528000
end;                                                           <<04607>>00530000
$page " SUBROUTINE ERR'PFRE"                                            00532000
subroutine err'pfre(err);                                               00534000
   value err;                                                           00536000
   logical err;                                                         00538000
                                                                        00540000
<<===================================================                   00542000
                                                                        00544000
   handles any errors on any access to the print file which returned    00546000
   ccg/ccl. it will either print out a tombstone or status word         00548000
   with relative address, depending on type of error.                   00550000
                                                                        00552000
   parameters:                                                          00554000
      take liberties w dfsm status word. assumes that %01               00556000
      is ok status, therefore if you call this routine                  00558000
      w %01 it's an i/o error on list dev                               00560000
                                                                        00562000
   returns:                                                             00564000
      never returns to caller, does an exit                             00566000
                                                                        00568000
   calling id:                                                          00570000
              2.2                                                       00572000
              this subroutine was added for dfsm support                00574000
                                                                        00576000
   fixid:                                                               00578000
                                                                        00580000
   changes:                                                             00582000
                                                                        00584000
====================================================>>                  00586000
begin                                                                   00588000
   if ldfs'locked then unlock'dfs'data'seg;                             00590000
rel'mvtab;                                                     <<04607>>00592000
   if err=write'error then print'file'info(fn)                          00594000
   else                                                                 00596000
      begin                                                             00598000
         blank'print;                                                   00600000
         move bprint'line:="Error status=";                             00602000
         dummy1:=ascii(err,8,bprint'line(13));                          00604000
         move bprint'line(22):="Rel Adr=";                              00606000
         dummy2:=s0;   << rel addr of where error occured >>            00608000
         dummy1:=ascii(dummy2,8,bprint'line(30));                       00610000
         fwrite(fn,print'line,print'len,%40);                           00612000
      end;                                                              00614000
$if x3=on                                                               00616000
      debug;                                                            00618000
$if                                                                     00620000
   exit'procedure;                                                      00622000
end;                                                                    00624000
                                                                        00626000
<<----------------------------------------->>                           00628000
                                                                        00630000
subroutine movefromdataseg(dest,srcdst,offset,cnt);                     00632000
   value dest,srcdst,offset,cnt;                                        00634000
   logical dest,srcdst,offset,cnt;                                      00636000
                                                                        00638000
<<===================================================                   00640000
                                                                        00642000
         this is a subroutine to do a mfds.                             00644000
         because you are passing args                                   00646000
         spl will convert all the argument's                            00648000
         addresses to db relative addresses-                            00650000
         mfds expects this                                              00652000
         never call this in split stack mode                            00654000
         notice also that it destroys x, but you                        00656000
         should never depend on x after subr calls                      00658000
                                                                        00660000
                                                                        00662000
   parameters:                                                          00664000
      dest-address of destination                                       00666000
      srcdst-data seg # of source                                       00668000
      offset-offset into srcdst                                         00670000
      cnt-words to transfer                                             00672000
                                                                        00674000
   returns:                                                             00676000
      data is returned in "dest"                                        00678000
                                                                        00680000
   assumptions on entry:                                                00682000
      allowed to clobber x register                                     00684000
                                                                        00686000
   calling id:                                                          00688000
      2.1                                                               00690000
      this subroutine was added for dfsm support                        00692000
                                                                        00694000
   fixid:                                                               00696000
                                                                        00698000
   changes:                                                             00700000
====================================================>>                  00702000
                                                                        00704000
begin                                                                   00706000
                                                                        00708000
   x:=tos;      << save return addr >>                                  00710000
   assemble(mfds 0);                                                    00712000
   tos:=x;      << restore return addr >>                               00714000
                                                                        00716000
end;                                                                    00718000
$page "SUBROUTINE PUT'INTO'ARRAY"                                       00720000
subroutine put'into'array;                                              00722000
                                                                        00724000
<<===================================================                   00726000
                                                                        00728000
      puts lsectcnt into the array space'info -                         00730000
      both in bucket and bucket'cnt                                     00732000
      also finds the maximum free space size                            00734000
      when done zero out lsectcnt because have                          00736000
      already put into array space'info                                 00738000
      never references anything in dfsm dst                             00740000
      this is called in split stack mode                                00742000
                                                                        00744000
   parameters:                                                          00746000
      none                                                              00748000
                                                                        00750000
   assumptions on entry:                                                00752000
     called in split stack mode                                         00754000
                                                                        00756000
   calling id:                                                          00758000
                2.3                                                     00760000
                this subroutine was added for dfsm support              00762000
                                                                        00764000
   globals:                                                             00766000
      modifies-space'info(bucket,bucket'cnt,disc'max,disc'total)        00768000
                                                                        00770000
   fixid:                                                               00772000
                                                                        00774000
   changes:                                                             00776000
                                                                        00778000
====================================================>>                  00780000
                                                                        00782000
begin                                                                   00784000
                                                                        00786000
   <<     figure out the bucket index for lsectcnt    >>                00788000
                                                                        00790000
   size:=100000d;        << initialize >>                               00792000
   index:=0;                                                            00794000
                                                                        00796000
   while lsectcnt < size do                                             00798000
      begin                                                             00800000
         size:=size/10d;                                                00802000
         index:=index+1;                                                00804000
      end;                                                              00806000
                                                                        00808000
   <<    put into array bucket and incr bucket'cnt   >>                 00810000
                                                                        00812000
   bucket(index):=bucket(index)+lsectcnt;                               00814000
   bucket'cnt(index):=bucket'cnt(index) + 1d;                           00816000
                                                                        00818000
  <<     is  this the max value for this ldev?   >>                     00820000
                                                                        00822000
   if lsectcnt > disc'max then  disc'max:=lsectcnt;                     00824000
                                                                        00826000
   disc'total:=disc'total + lsectcnt;                                   00828000
                                                                        00830000
   lsectcnt:=0d;          << re-initialize >>                           00832000
end;  << put'into'array >>                                              00834000
$page "CREATE'THE'PRINTOUT"                                             00836000
subroutine create'the'printout;                                         00838000
begin                                                                   00840000
                                                                        00842000
<<===================================================                   00844000
                                                                        00846000
       prints out the free2 format for each ldev                        00848000
       gets the information from space'info                             00850000
       uses array print'line                                            00852000
       also incr  tot'sys'space                                         00854000
       assumes not called in split stack mode                           00856000
                                                                        00858000
   parameters:                                                          00860000
      none                                                              00862000
                                                                        00864000
   assumptions on entry:                                                00866000
      not in split stack mode                                           00868000
                                                                        00870000
   globals:                                                             00872000
      uses-space'info(bucket,bucket'cnt,disc'total),all                 00874000
      modifies-print'line,tot'sys'space                                 00876000
                                                                        00878000
   externals:                                                           00880000
                                                                        00882000
   intrinsics:                                                          00884000
      ascii,fwrite,dascii                                               00886000
                                                                        00888000
   calling id:                                                          00890000
              2.4                                                       00892000
              this subroutine was added for dfsm support                00894000
                                                                        00896000
   fixid:                                                               00898000
                                                                        00900000
   changes:                                                             00902000
                                                                        00904000
====================================================>>                  00906000
                                                                        00908000
rel'mvtab;                                                     <<04607>>00910000
   blank'print;    << blank out the line >>                             00912000
   move bprint'line:="VOLUME";                                          00914000
   move print'line(4):=vol'name,(4);                                    00916000
   move bprint'line(27):="LDEV";                                        00918000
   dummy1:=ascii(ldev,10,bprint'line(32));                              00920000
   fwrite(fn,print'line,print'len,%40);                                 00922000
   if <> then err'pfre(write'error);                                    00924000
                                                                        00926000
   blank'print;                                                         00928000
   move bprint'line:="LARGEST FREE AREA=";                              00930000
   dummy1:=dascii(disc'max,10,bprint'line(19));                         00932000
   fwrite(fn,print'line,print'len,%40);                                 00934000
   if <> then err'pfre(write'error);                                    00936000
                                                                        00938000
   blank'print;                                                         00940000
   move bprint'line:="  SIZE  COUNT  SPACE   AVERAGE";                  00942000
   fwrite(fn,print'line,print'len,%40);                                 00944000
   if <> then err'pfre(write'error);                                    00946000
                                                                        00948000
   <<   loop for all the buckets   >>                                   00950000
   size:=100000d;     << initialize >>                                  00952000
   index:=0;                                                            00954000
                                                                        00956000
   do begin                                                             00958000
      blank'print;                                                      00960000
      move bprint'line:=">";                                            00962000
      dummy1:=dascii(size,10,bprint'line(1));                           00964000
      dummy1:=dascii(bucket'cnt(index),10,bprint'line(8));  << cnt >>   00966000
      dummy1:=dascii(bucket(index),10,bprint'line(14));                 00968000
      ddummy:=if bucket'cnt(index) = 0d then 0d  << ave >>              00970000
                 else bucket(index) / bucket'cnt(index);                00972000
      dummy1:=dascii(ddummy,10,bprint'line(23));                        00974000
      fwrite(fn,print'line,print'len,%40);                              00976000
      if <> then err'pfre(write'error);                                 00978000
      index:=index + 1;  << incr >>                                     00980000
      size:=size / 10d;                                                 00982000
   end until index > 5;                                                 00984000
                                                                        00986000
   blank'print;                                                         00988000
   move bprint'line:="TOTAL FREE SPACE=";                               00990000
   dummy1:=dascii(disc'total,10,bprint'line(17));                       00992000
   fwrite(fn,print'line,print'len,%40);                                 00994000
   if <> then err'pfre(write'error);                                    00996000
                                                                        00998000
   print'stars;                                                         01000000
                                                                        01002000
   << print out number of bad pages, if any >>                 <<03721>>01004000
                                                               <<03721>>01006000
   if bad'page'count <> 0 then                                 <<03721>>01008000
      begin  << print bad pages >>                             <<03721>>01010000
                                                               <<03721>>01012000
         blank'print;                                          <<03721>>01014000
         move bprint'line := "LDEV ", 2;                       <<03721>>01016000
         tos := tos + ascii (ldev, 10 ,bps0);                  <<03721>>01018000
         move * := " has ", 2;                                 <<03721>>01020000
         tos := tos + ascii (bad'page'count, 10, bps0);        <<03721>>01022000
         move * := " pages of the Disc Free Space Map ", 2;    <<03721>>01024000
         dummy1 := -(tos - @bprint'line);                      <<03721>>01026000
         fwrite (fn, print'line, dummy1, 0);                   <<03721>>01028000
         if <> then err'pfre (write'error);                    <<03721>>01030000
         blank'print;                                          <<03721>>01032000
         move bprint'line := "marked as bad.  Up to ", 2;      <<03721>>01034000
         tos := tos + dascii (double (bits'per'page) *         <<03721>>01036000
                              double (bad'page'count), 10,     <<03721>>01038000
                              bps0);                           <<03721>>01040000
         move * := " sectors of disc space may be lost.", 2;   <<03721>>01042000
         dummy1 := -(tos - @bprint'line);                      <<03721>>01044000
         fwrite (fn, print'line, dummy1, 0);                   <<03721>>01046000
         if <> then err'pfre (write'error);                    <<03721>>01048000
         print'stars;                                          <<03721>>01050000
                                                               <<03721>>01052000
      end;   << print bad pages >>                             <<03721>>01054000
                                                               <<03721>>01056000
   if all then tot'sys'space:=tot'sys'space + disc'total;               01058000
                                                                        01060000
end;  << create'the'printout >>                                         01062000
$page "PFRE"                                                            01064000
                                                                        01066000
   ldev'found:=false;    << initialize >>                               01068000
   tot'sys'space:=0d;                                                   01070000
                                                                        01072000
   <<   get the initial info from the vol tbl  >>                       01074000
                                                                        01076000
   lcrit:=setcritical;                                                  01078000
   lcrit'set:=true;                                                     01080000
                                                                        01082000
      << get wd 0 from vol tbl header >>                                01084000
                                                                        01086000
   movefromdataseg(@dummy1,vol'tbl'dst,0,1);                            01088000
                                                                        01090000
   resetcritical(lcrit);                                                01092000
   lcrit'set:=false;                                                    01094000
                                                                        01096000
   vol'ent'sz:=dummy1.(8:8);                                            01098000
   num'vol'ent:=dummy1.(0:8);                                           01100000
                                                                        01102000
$page                                                                   01104000
   <<  get the space for the vol tbl ent on stack >>                    01106000
                                                                        01108000
   push(s);                                                             01110000
   tos:=tos+1;                                                          01112000
   @vol'table:=tos;                                                     01114000
   tos:=vol'ent'sz;                                                     01116000
   assemble(adds 0);                                                    01118000
   vol'index:=vol'ent'sz;   << initialize >>                            01120000
   num'vol'cntr:=0;                                                     01122000
                                                                        01124000
   <<                                                                   01126000
     now gather info and print it for each ldev                         01128000
     for each sys disc or pv:                                           01130000
                                                                        01132000
     1. set critical so no interrupts honored while accessing           01134000
        the dfsm                                                        01136000
     2. get vol tbl sir                                                 01138000
     3. copy vol tbl entry and release vol tbl sir                      01140000
     4. find out if a sys disc or mounted pv from lpdt                  01142000
     5. find the 1st good page by looking at the descriptor             01144000
        table. if the whole descriptor table is flagged                 01146000
        as bad, print out a message and then look at next               01148000
        vol entry                                                       01150000
     6. call lock'dfs'data'seg to get the dfsm dst                      01152000
        ***                                 ***                         01154000
        *   now in split stack mode           *                         01156000
        *   db at dfsm dst                    *                         01158000
        ***                                 ***                         01160000
     7. run through the dfsm bit map using routines                     01162000
        "get'page" and "scan'page" who use the dfsm                     01164000
        dst work area                                                   01166000
     8. call "Unlock'Dfs'Data'Seg"                                      01168000
        ***                                 ***                         01170000
        *  not in split stack mode            *                         01172000
        ***                                 ***                         01174000
     9. create the printout for this ldev                               01176000
   >>                                                                   01178000
   do begin                                                             01180000
                                                                        01182000
      lcrit:=setcritical;                                               01184000
      lcrit'set:=true;                                                  01186000
      volsir'flag:=getsir(vol'tbl'sir);                                 01188000
      movefromdataseg(@vol'table,vol'tbl'dst,vol'index,vol'ent'sz);     01190000
      relsir(vol'tbl'sir,volsir'flag);                                  01192000
      bad'page'count := 0;                                     <<03721>>01194000
                                                                        01196000
      << check the bit setting in the vol tbl before going >>           01198000
      <<  to the lpdt                                      >>           01200000
                                                                        01202000
      if ldev = 0 or scratch or unformatted then                        01204000
         go to next'vol;                                                01206000
                                                                        01208000
      << check to see if deleted vol - vol table entry >>               01210000
      << wd 0 = 0                                      >>               01212000
                                                                        01214000
      if vol'table = 0 then go to next'vol;                             01216000
                                                                        01218000
                                                                        01220000
      << do the same kind of checking as pfentries does  >>             01222000
      << this is different from what free2 used to do     >>            01224000
                                                                        01226000
                                                                        01228000
      checkdisc(ldev,lstatus);                                          01230000
      if (lstatus lor ok'mask) <> ok'mask then go to next'vol;          01232000
                                                                        01234000
      << is it a foreign or serial disc ? >>                            01236000
                                                                        01238000
      if lpdt(ldev*lpdt'entry'size + 1).nsd = 1                         01240000
         and                                                            01242000
         lpdt(ldev*lpdt'entry'size + 1).ser'forn <> 0                   01244000
         then  go to next'vol;                                          01246000
                                                                        01248000
      if not all then << is this the correct ldev? >>                   01250000
         begin                                                          01252000
            if ldev = which'ldev                                        01254000
               then                                                     01256000
                  ldev'found:=true                                      01258000
            else                                                        01260000
               go to next'vol;                                          01262000
         end;                                                           01264000
          << good vol, get the information >>                           01266000
                                                                        01268000
      zero'space'info;                                                  01270000
      move vol'name:=volumename,(4);  << into space'info >>             01272000
      lpage:=0;    << start at page 0 >>                                01274000
                                                                        01276000
         <<===============================                              01278000
           going into split stack mode                                  01280000
           be very careful about refs                                   01282000
           any name that begins with                                    01284000
           "ds" is from the dfsm dst                                    01286000
           =============================>>                              01288000
      << if the ldev is a pv, then it must be logically >>     <<03755>>01290000
      << mounted to list the free space (so it can not  >>     <<03755>>01292000
      << be physically dismounted under us).  if it is  >>     <<03755>>01294000
      << logically mounted we hold the mvtab sir until  >>     <<03755>>01296000
      << listing of free space is complete to prevent   >>     <<03755>>01298000
      << a dismount.                                    >>     <<03755>>01300000
                                                               <<03755>>01302000
      if lpdt (ldev*lpdt'entry'size + 1).nsd = 1 then          <<03755>>01304000
         begin  << its a pv >>                                 <<03755>>01306000
                                                               <<03755>>01308000
            mvtab'sir'flag := getsir (mvtabsir);               <<03755>>01310000
            have'mvtab'sir := true;                            <<03755>>01312000
            if lpdt (ldev*lpdt'entry'size + 1).mounted'pv      <<03755>>01314000
               = 0 then                                        <<03755>>01316000
               begin  << not logically mounted >>              <<03755>>01318000
                                                               <<03755>>01320000
              rel'mvtab;                                       <<04607>>01322000
                  if not all then                              <<03755>>01324000
                     genmsg (pvmsgset, 34);                    <<03755>>01326000
                                                               <<03755>>01330000
                  goto next'vol;                               <<03755>>01332000
                                                               <<03755>>01334000
               end;   << not logically mounted >>              <<03755>>01336000
                                                               <<03755>>01338000
         end;   << its a pv >>                                 <<03755>>01340000
                                                               <<03755>>01342000
                                                                        01344000
      proc'status:=lock'dfs'data'seg(ldev);                             01346000
      if not(proc'status) then                                          01348000
         begin                                                          01350000
         rel'mvtab;                                            <<04607>>01352000
            blank'print;                                                01354000
            move bprint'line:=                                          01356000
            "Allocation has been ";                                     01358000
            fwrite(fn,print'line,print'len,%40);                        01360000
            if <> then err'pfre(write'error);                           01362000
            blank'print;                                                01364000
            move bprint'line:="disabled on LDEV";                       01366000
            dummy1:=ascii(ldev,10,bprint'line(17));                     01368000
            fwrite(fn,print'line,print'len,%40);                        01370000
            if <> then err'pfre(write'error);                           01372000
            print'stars;                                                01374000
            go to next'vol;                                             01376000
         end;                                                           01378000
      ldfs'locked:=true;                                                01380000
                                                                        01382000
        << get the dfsm set up                                          01384000
          find the first page which has good                            01386000
          descriptors                                                   01388000
        >>                                                              01390000
      cantfind:=false;                                                  01392000
      cont:=true;                                                       01394000
      while cont do                                                     01396000
         begin                                                          01398000
            if flagged'bad then                                         01400000
               begin                                                    01402000
                  lpage:=lpage+1;                                       01404000
                  bad'page'count := bad'page'count + 1;        <<03721>>01406000
                  if lpage > ds'last'page'of'map then                   01408000
                     begin                                              01410000
                        cantfind:=true;                                 01412000
                        cont:=false;                                    01414000
                     end;                                               01416000
               end                                                      01418000
            else    cont:=false;                                        01420000
         end;                                                           01422000
      if cantfind then                                                  01424000
         begin                                                          01426000
            << whole descriptor table marked bad >>                     01428000
            << still in split stack mode         >>                     01430000
            unlock'dfs'data'seg;                                        01432000
            ldfs'locked:=false;                                         01434000
                               << not in split stack >>                 01436000
         rel'mvtab;                                            <<04607>>01438000
            blank'print;                                                01440000
            move bprint'line:="LDEV ";                                  01442000
            dummy1:=ascii(ldev,10,bprint'line(5));                      01444000
            dummy1:=dummy1<<ldev>> +1<<sp>> + 5<<"LDEV">>;              01446000
            move bprint'line(dummy1):="has bad DFSM";                   01448000
            fwrite(fn,print'line,print'len,%40);                        01450000
            if <> then err'pfre(write'error);                           01452000
            print'stars;                                                01454000
            go to next'vol;                                             01456000
         end;                                                           01458000
                                                                        01460000
        << initialize values for "Scan'Page" >>                         01462000
      @ds'page'ptr:=get'page(lpage);                                    01464000
      if not(ds'error'status) then err'pfre(ds'error'status);           01466000
      ds'word'number:=0;                                                01468000
      ds'bit'number:=0;                                                 01470000
      lsectcnt:=0d;                                                     01472000
      ldone:=false;                                                     01474000
                                                                        01476000
           << now loop on pages for this ldev                           01478000
              lsectcnt is the local number of                           01480000
              sectors. have to have this because                        01482000
              "scan'page" doesnt handle disc space                      01484000
              which spans page boundaries.                              01486000
              lsectcnt is what "put'into'array" puts                    01488000
              into bucket                             >>                01490000
                                                                        01492000
      << while scanning pages have to worry about encountering          01494000
         bad pages, if space really does span pages...                  01496000
      >>                                                                01498000
                                                                        01500000
      do begin                                                          01502000
         lpg'end:=scan'page;                                            01504000
         if lsectcnt = 0d and ds'bit'count = 0 then                     01506000
            go to next'ent;    << didnt find anything >>                01508000
         if lpg'end then       << at end of a page    >>                01510000
            begin                                                       01512000
               if lpage = ds'last'page'of'map  << last pg     >>        01514000
                  then begin                                            01516000
                     <<  last pg, last entry  >>                        01518000
                     lsectcnt:=lsectcnt + dbl(ds'bit'count);            01520000
                     put'into'array;                                    01522000
                  end                                                   01524000
               else             << not last pg >>                       01526000
                  begin                                                 01528000
                     if ds'bit'count = 0 then                           01530000
                        begin                                           01532000
                           << space from prev pg >>                     01534000
                           put'into'array;                              01536000
                        end                                             01538000
                     else    << maybe more contg sp on next pg >>       01540000
                        lsectcnt:=lsectcnt + dbl(ds'bit'count);         01542000
               end;           << lpage = ds'last'page'of'map >>         01544000
            end               << lpg'end = true      >>                 01546000
         else                                                           01548000
            begin             << space somewhere in middle of pg >>     01550000
               if lsectcnt = 0d then                                    01552000
                  begin                                                 01554000
                     << found space in middle >>                        01556000
                     lsectcnt:=dbl(ds'bit'count);                       01558000
                     put'into'array;                                    01560000
                  end                                                   01562000
               else            << lsectcnt <> 0 >>                      01564000
                  begin                                                 01566000
                     if ds'starting'word'number = 0 and                 01568000
                        ds'starting'bit'number  = 0                     01570000
                        then begin                                      01572000
                           << sp on prev pg and at front current >>     01574000
                           << but havent hit the end of the page >>     01576000
                           lsectcnt:=lsectcnt + dbl(ds'bit'count);      01578000
                           put'into'array;                              01580000
                        end                                             01582000
                     else                                               01584000
                        begin                                           01586000
                           << had sp on prev pg, none in front >>       01588000
                           << but found some somewhere in pg   >>       01590000
                           put'into'array;                              01592000
                           lsectcnt:=dbl(ds'bit'count);                 01594000
                           put'into'array;                              01596000
                     end;      << ds'starting'word... >>                01598000
               end;            << lsectcnt = and <> 0 >>                01600000
            end;               << lpg'end  t and f    >>                01602000
next'ent:                                                               01604000
                << didnt find anything from "Scan'Page" >>              01606000
                                                                        01608000
         << see if have to swap pages; find the next good page          01610000
            if the next page is marked as bad in the descriptor         01612000
            table, then any space that is in lsectcnt must be           01614000
            put into space'info since there will be no contiguous       01616000
            space across pages                                          01618000
         >>                                                             01620000
         if lpg'end then                                                01622000
            begin                                                       01624000
               if lpage = ds'last'page'of'map then ldone:=true          01626000
               else                                                     01628000
                  begin                                                 01630000
                     ldone:=false;   << more pages to go >>             01632000
                     lpage:=lpage+1;                                    01634000
                     cantfind:=true;                                    01636000
                     do begin  << find pg w good descr entry >>         01638000
                        if flagged'bad then                             01640000
                           begin                                        01642000
                              if lsectcnt <> 0d then put'into'array;    01644000
                              lpage:=lpage+1;                           01646000
                              bad'page'count :=                <<03721>>01648000
                                       bad'page'count + 1;     <<03721>>01650000
                           end                                          01652000
                        else                                            01654000
                           begin                                        01656000
                              @ds'page'ptr:=get'page(lpage);            01658000
                              if ds'error'status then  << good status >>01660000
                                 begin                                  01662000
                                    cantfind:=false;                    01664000
                                    ds'word'number:=0; << init  >>      01666000
                                    ds'bit'number:=0;                   01668000
                                 end                                    01670000
                              else   lpage:=lpage+1;                    01672000
                        end;    << flagged'bad  t f >>                  01674000
                     end until lpage > ds'last'page'of'map              01676000
                            or not(cantfind);                           01678000
                     if lpage > ds'last'page'of'map then ldone:=true;   01680000
                  end;    << lpage = <> last page >>                    01682000
               end;       << lpg'end  t           >>                    01684000
                                                                        01686000
      end until ldone;         << done with this disc >>                01688000
                                                                        01690000
      unlock'dfs'data'seg;                                              01692000
      ldfs'locked:=false;  << not locked and no split stack >>          01694000
                                                                        01696000
             <<===============================                          01698000
               not in split stack mode anymore                          01700000
               ===============================>>                        01702000
                                                                        01706000
      create'the'print'out;                                             01708000
                                                                        01710000
next'vol:                                                               01712000
                        << look at next vol entry in vol tbl >>         01714000
      rel'mvtab;                                               <<04607>>01716000
      vol'index:=vol'index + vol'ent'sz;  << offset into vol tbl >>     01720000
                                                                        01722000
   end until ldev'found<< only 1 dev>>  or                              01724000
             (num'vol'cntr:=num'vol'cntr + 1) = num'vol'ent;            01726000
                                                                        01728000
           << now print out the system total  >>                        01730000
                                                                        01732000
   if all then << print total because printing for all discs >>         01734000
      begin                                                             01736000
         blank'print;                                                   01738000
         move bprint'line:="SYSTEM TOTAL FREE SPACE=";                  01740000
         dummy1:=dascii(tot'sys'space,10,bprint'line(24));              01742000
         fwrite(fn,print'line,print'len,%40);                           01744000
         if <> then err'pfre(write'error);                              01746000
      end                                                               01748000
   else                                                                 01750000
      begin                                                             01752000
         if not ldev'found  << only 1 dev, didnt find it >>             01754000
            then begin                                                  01756000
               blank'print;                                             01758000
               move bprint'line:="LDEV ";                               01760000
               dummy1:=ascii(which'ldev,10,bprint'line(5));             01762000
               dummy1:=dummy1<<ldev>> + 5<<"LDEV">> + 1<<sp>>;          01764000
               move bprint'line(dummy1):=                               01766000
                  "not mounted or has no DFSM";                         01768000
               fwrite(fn,print'line,print'len,%40);                     01770000
               if <> then err'pfre(write'error);                        01772000
            end;                                                        01774000
     end;        << all  not ldev'found >>                              01776000
                                                                        01778000
end;  << pfre >>                                                        01780000
<<==============================================================        01782000
                                                                        01784000
                       end of inclfree - b1                             01786000
                                                                        01788000
==============================================================>>        01790000
