head     56.1;
access   paws bayes jws quist brad dew jwh;
symbols  ;
locks    ; strict;
comment  @# @;


56.1
date     91.11.05.09.36.55;  author jwh;  state Exp;
branches ;
next     55.2;

55.2
date     91.11.04.16.13.11;  author jwh;  state Exp;
branches ;
next     55.1;

55.1
date     91.08.25.10.15.29;  author jwh;  state Exp;
branches ;
next     54.2;

54.2
date     91.08.21.14.15.27;  author jwh;  state Exp;
branches ;
next     54.1;

54.1
date     91.03.18.15.22.06;  author jwh;  state Exp;
branches ;
next     53.3;

53.3
date     91.03.18.14.04.07;  author jwh;  state Exp;
branches ;
next     53.2;

53.2
date     91.03.15.15.39.12;  author jwh;  state Exp;
branches ;
next     53.1;

53.1
date     91.03.11.19.23.21;  author jwh;  state Exp;
branches ;
next     52.2;

52.2
date     91.03.11.17.20.00;  author jwh;  state Exp;
branches ;
next     52.1;

52.1
date     91.02.19.09.07.02;  author jwh;  state Exp;
branches ;
next     51.2;

51.2
date     91.02.18.21.16.04;  author jwh;  state Exp;
branches ;
next     51.1;

51.1
date     91.01.30.16.06.14;  author jwh;  state Exp;
branches ;
next     50.2;

50.2
date     91.01.30.09.52.41;  author jwh;  state Exp;
branches ;
next     50.1;

50.1
date     90.10.29.16.21.36;  author jwh;  state Exp;
branches ;
next     49.2;

49.2
date     90.10.29.14.40.56;  author jwh;  state Exp;
branches ;
next     49.1;

49.1
date     90.08.14.14.05.56;  author jwh;  state Exp;
branches ;
next     48.2;

48.2
date     90.08.14.10.05.34;  author jwh;  state Exp;
branches ;
next     48.1;

48.1
date     90.07.26.11.11.43;  author jwh;  state Exp;
branches ;
next     47.2;

47.2
date     90.07.24.15.27.13;  author jwh;  state Exp;
branches ;
next     47.1;

47.1
date     90.05.14.10.51.05;  author dew;  state Exp;
branches ;
next     46.1;

46.1
date     90.05.07.08.38.23;  author jwh;  state Exp;
branches ;
next     45.2;

45.2
date     90.05.04.15.20.44;  author jwh;  state Exp;
branches ;
next     45.1;

45.1
date     90.04.19.15.45.44;  author jwh;  state Exp;
branches ;
next     44.2;

44.2
date     90.04.19.13.50.25;  author jwh;  state Exp;
branches ;
next     44.1;

44.1
date     90.04.01.22.03.32;  author jwh;  state Exp;
branches ;
next     43.4;

43.4
date     90.04.01.16.49.29;  author jwh;  state Exp;
branches ;
next     43.3;

43.3
date     90.03.26.15.58.18;  author dew;  state Exp;
branches ;
next     43.2;

43.2
date     90.03.22.11.48.29;  author jwh;  state Exp;
branches ;
next     43.1;

43.1
date     90.03.20.13.53.35;  author jwh;  state Exp;
branches ;
next     42.2;

42.2
date     90.03.19.16.37.54;  author jwh;  state Exp;
branches ;
next     42.1;

42.1
date     90.01.23.17.38.56;  author jwh;  state Exp;
branches ;
next     41.2;

41.2
date     90.01.20.17.14.22;  author jwh;  state Exp;
branches ;
next     41.1;

41.1
date     89.12.22.11.21.16;  author jwh;  state Exp;
branches ;
next     40.4;

40.4
date     89.12.21.15.35.57;  author jwh;  state Exp;
branches ;
next     40.3;

40.3
date     89.10.31.16.56.13;  author dew;  state Exp;
branches ;
next     40.2;

40.2
date     89.10.24.14.06.38;  author dew;  state Exp;
branches ;
next     40.1;

40.1
date     89.09.29.11.44.00;  author jwh;  state Exp;
branches ;
next     39.2;

39.2
date     89.09.28.17.51.53;  author jwh;  state Exp;
branches ;
next     39.1;

39.1
date     89.09.26.16.29.12;  author dew;  state Exp;
branches ;
next     38.3;

38.3
date     89.09.26.15.10.56;  author dew;  state Exp;
branches ;
next     38.2;

38.2
date     89.09.14.14.08.21;  author dew;  state Exp;
branches ;
next     38.1;

38.1
date     89.08.29.11.19.59;  author jwh;  state Exp;
branches ;
next     37.2;

37.2
date     89.08.28.12.52.53;  author jwh;  state Exp;
branches ;
next     37.1;

37.1
date     89.05.12.11.33.21;  author dew;  state Exp;
branches ;
next     36.3;

36.3
date     89.05.12.09.54.35;  author quist;  state Exp;
branches ;
next     36.2;

36.2
date     89.05.11.12.24.43;  author quist;  state Exp;
branches ;
next     36.1;

36.1
date     89.02.06.10.12.14;  author dew;  state Exp;
branches ;
next     35.1;

35.1
date     89.02.02.13.24.36;  author dew;  state Exp;
branches ;
next     34.1;

34.1
date     89.01.23.15.59.44;  author jwh;  state Exp;
branches ;
next     33.2;

33.2
date     89.01.20.17.03.38;  author jwh;  state Exp;
branches ;
next     33.1;

33.1
date     89.01.16.11.34.10;  author dew;  state Exp;
branches ;
next     32.3;

32.3
date     89.01.13.11.59.59;  author dew;  state Exp;
branches ;
next     32.2;

32.2
date     89.01.11.10.27.18;  author jws;  state Exp;
branches ;
next     32.1;

32.1
date     89.01.10.11.40.44;  author bayes;  state Exp;
branches ;
next     31.2;

31.2
date     89.01.09.12.39.14;  author dew;  state Exp;
branches ;
next     31.1;

31.1
date     88.12.14.18.01.50;  author bayes;  state Exp;
branches ;
next     30.2;

30.2
date     88.12.14.14.10.02;  author bayes;  state Exp;
branches ;
next     30.1;

30.1
date     88.12.09.13.39.45;  author dew;  state Exp;
branches ;
next     29.2;

29.2
date     88.12.08.16.21.04;  author bayes;  state Exp;
branches ;
next     29.1;

29.1
date     88.10.31.15.23.59;  author bayes;  state Exp;
branches ;
next     28.2;

28.2
date     88.10.31.11.19.13;  author bayes;  state Exp;
branches ;
next     28.1;

28.1
date     88.10.06.10.52.45;  author dew;  state Exp;
branches ;
next     27.2;

27.2
date     88.10.05.18.20.23;  author bayes;  state Exp;
branches ;
next     27.1;

27.1
date     88.09.29.11.19.35;  author bayes;  state Exp;
branches ;
next     26.6;

26.6
date     88.09.28.12.47.57;  author bayes;  state Exp;
branches ;
next     26.5;

26.5
date     88.09.28.12.47.40;  author bayes;  state Exp;
branches ;
next     26.4;

26.4
date     88.09.28.12.47.21;  author bayes;  state Exp;
branches ;
next     26.3;

26.3
date     88.09.28.12.47.03;  author bayes;  state Exp;
branches ;
next     26.2;

26.2
date     88.09.28.12.46.50;  author bayes;  state Exp;
branches ;
next     26.1;

26.1
date     88.09.28.12.46.27;  author bayes;  state Exp;
branches ;
next     24.1;

24.1
date     87.08.31.09.30.19;  author jws;  state Exp;
branches ;
next     23.2;

23.2
date     87.08.30.15.22.51;  author jws;  state Exp;
branches ;
next     23.1;

23.1
date     87.08.26.10.06.42;  author bayes;  state Exp;
branches ;
next     22.2;

22.2
date     87.08.25.19.03.30;  author jws;  state Exp;
branches ;
next     22.1;

22.1
date     87.08.17.10.48.43;  author bayes;  state Exp;
branches ;
next     21.2;

21.2
date     87.08.15.17.03.57;  author larry;  state Exp;
branches ;
next     21.1;

21.1
date     87.08.12.13.34.56;  author bayes;  state Exp;
branches ;
next     20.2;

20.2
date     87.08.12.10.33.23;  author bayes;  state Exp;
branches ;
next     20.1;

20.1
date     87.07.30.10.46.51;  author bayes;  state Exp;
branches ;
next     19.2;

19.2
date     87.07.29.18.11.17;  author larry;  state Exp;
branches ;
next     19.1;

19.1
date     87.06.01.08.04.26;  author jws;  state Exp;
branches ;
next     18.3;

18.3
date     87.05.31.15.08.18;  author jws;  state Exp;
branches ;
next     18.2;

18.2
date     87.05.26.17.09.48;  author larry;  state Exp;
branches ;
next     18.1;

18.1
date     87.05.20.14.59.29;  author bayes;  state Exp;
branches ;
next     17.2;

17.2
date     87.05.20.10.42.15;  author bayes;  state Exp;
branches ;
next     17.1;

17.1
date     87.04.30.10.16.18;  author jws;  state Exp;
branches ;
next     16.1;

16.1
date     87.04.26.15.29.21;  author jws;  state Exp;
branches ;
next     15.2;

15.2
date     87.04.24.18.17.40;  author jws;  state Exp;
branches ;
next     15.1;

15.1
date     87.04.13.08.59.36;  author jws;  state Exp;
branches ;
next     14.2;

14.2
date     87.04.12.17.03.48;  author jws;  state Exp;
branches ;
next     14.1;

14.1
date     87.04.01.14.58.42;  author jws;  state Exp;
branches ;
next     13.2;

13.2
date     87.04.01.09.31.55;  author jws;  state Exp;
branches ;
next     13.1;

13.1
date     87.02.28.18.16.34;  author jws;  state Exp;
branches ;
next     12.2;

12.2
date     87.02.28.15.52.49;  author jws;  state Exp;
branches ;
next     12.1;

12.1
date     87.02.02.13.05.02;  author jws;  state Exp;
branches ;
next     11.2;

11.2
date     87.02.02.10.27.04;  author jws;  state Exp;
branches ;
next     11.1;

11.1
date     87.01.19.09.30.47;  author jws;  state Exp;
branches ;
next     10.2;

10.2
date     87.01.18.19.10.36;  author jws;  state Exp;
branches ;
next     10.1;

10.1
date     86.12.24.10.38.05;  author jws;  state Exp;
branches ;
next     9.3;

9.3
date     86.12.23.17.06.08;  author jws;  state Exp;
branches ;
next     9.2;

9.2
date     86.12.16.10.49.53;  author jws;  state Exp;
branches ;
next     9.1;

9.1
date     86.12.12.14.07.41;  author bayes;  state Exp;
branches ;
next     8.5;

8.5
date     86.12.12.10.33.34;  author bayes;  state Exp;
branches ;
next     8.4;

8.4
date     86.12.05.12.33.36;  author jws;  state Exp;
branches ;
next     8.3;

8.3
date     86.12.05.12.27.37;  author jws;  state Exp;
branches ;
next     8.2;

8.2
date     86.12.02.11.33.51;  author jws;  state Exp;
branches ;
next     8.1;

8.1
date     86.11.27.11.35.26;  author jws;  state Exp;
branches ;
next     7.4;

7.4
date     86.11.26.17.09.28;  author jws;  state Exp;
branches ;
next     7.3;

7.3
date     86.11.21.16.00.17;  author hal;  state Exp;
branches ;
next     7.2;

7.2
date     86.11.21.14.18.25;  author hal;  state Exp;
branches ;
next     7.1;

7.1
date     86.11.20.13.24.00;  author hal;  state Exp;
branches ;
next     6.4;

6.4
date     86.11.19.16.07.54;  author bayes;  state Exp;
branches ;
next     6.3;

6.3
date     86.11.05.11.05.50;  author hal;  state Exp;
branches ;
next     6.2;

6.2
date     86.11.05.09.51.19;  author hal;  state Exp;
branches ;
next     6.1;

6.1
date     86.11.04.17.28.22;  author paws;  state Exp;
branches ;
next     5.2;

5.2
date     86.11.04.12.50.38;  author paws;  state Exp;
branches ;
next     5.1;

5.1
date     86.10.28.16.15.02;  author hal;  state Exp;
branches ;
next     4.5;

4.5
date     86.10.28.11.42.29;  author hal;  state Exp;
branches ;
next     4.4;

4.4
date     86.10.13.16.50.41;  author geli;  state Exp;
branches ;
next     4.3;

4.3
date     86.10.09.12.34.27;  author hal;  state Exp;
branches ;
next     4.2;

4.2
date     86.10.08.17.19.00;  author hal;  state Exp;
branches ;
next     4.1;

4.1
date     86.09.30.19.26.53;  author hal;  state Exp;
branches ;
next     3.5;

3.5
date     86.09.24.12.57.54;  author hal;  state Exp;
branches ;
next     3.4;

3.4
date     86.09.19.17.04.40;  author hal;  state Exp;
branches ;
next     3.3;

3.3
date     86.09.15.13.41.01;  author hal;  state Exp;
branches ;
next     3.2;

3.2
date     86.09.13.13.15.56;  author hal;  state Exp;
branches ;
next     3.1;

3.1
date     86.09.01.11.37.46;  author hal;  state Exp;
branches ;
next     1.1;

1.1
date     86.08.29.12.37.29;  author hal;  state tmp;
branches ;
next     ;


desc
@Base file for PWS 3.2 release.

@


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@{
{ Shell for mkfs.
}
{}
$search 'mkfs',
	'PCLIB:CLIBRARY2',
	'INIT:CS80',
	'INIT:DRVASM',
	'INIT:DISCHPIB',
	'IOLIB:KERNEL',
	'SCSI:SCSILIB.'$
{{
$SEARCH 'mkfs',
	'CLIBRARY2',
	'CS80',
	'DRVASM',
	'DISCHPIB',
	'KERNEL',
	'*SCSILIB.'$
{}


$modcal$

$debug off$
$range off$
$ovflcheck off$

$partial_eval on$
$allow_packed$

program mkfsui(input, output, keyboard);


{
{==========================================================
{ Volume identification
}
module volid;

import
    sysglobals,
    cs80,
    misc,
    bkgnd,
    fs,
    discHPIB,
    cs80dsr,
    SCSILIB;

export

procedure volid_info(lun, oioresult: integer;
		     fvid: vid;
		     var sectspertrack,
			 trackspercyl,
			 fssize,
			 rps: integer);

function on_same_medium(flun: unitnum; uep: uep_type): boolean;

implement

type
    sup_dev_type = (M,N,U,V,W,H,F,C,D,P,X,B,R,Q,S); {supported devices} {08-89 DEW added scsi}
    string27 = string[27];
    dev_name_type = array [M..R] of string27;                   {rdq}

var
    describe_bytes: describe_type;
    describe_read: boolean;             { describe_bytes valid? }
    device: sup_dev_type;
    devicename: string255;
    saved_ioresult: integer;

const
    dev_name = {device names}
      dev_name_type
	[ {M}  'internal minifloppy',
	  {N}  'HP8290X series minifloppy',
	  {U}  'HP913XA series hard disc',
	  {V}  'HP913XB series hard disc',
	  {W}  'HP913XC series hard disc',
	  {H}  'HP9895 flexible disc',
	  {F}  'HP9885 flexible disc',
	  {C}  'HP7906 removeable hard disc',
	  {D}  'HP7906 fixed hard disc',
	  {P}  'HP7920 hard disc',
	  {X}  'HP7925 hard disc',
	  {B}  'HP98259 bubble memory',
	  {R}  'Memory volume' ];

    nonabortive_ioresult_set = [ord(inoerror), ord(zbadblock), ord(znoblock),
				ord(zuninitialized), ord(inodirectory)];


procedure fatal_ioresult(message: string255; iores: integer);
  begin {fatal_ioresult}
    writeln(message);
    getioerrmsg(message, iores);
    writeln('  ',message);
    escape(-1);
  end; {fatal_ioresult}


function on_same_medium(flun: unitnum; uep: uep_type): boolean;
  begin {on_same_medium}
    with unitable^[flun] do
      on_same_medium := (sc=uep^.sc) and (ba=uep^.ba) and
			(du=uep^.du) and (dv=uep^.dv) and
			(letter=uep^.letter)
			{ RAM volumes never on same device }
			and (letter<>'R');
  end; {on_same_medium}


procedure other_volume_check(lun: integer);
  var
    warning_issued: boolean;
    flun: unitnum;
    line: shortint;
    CRTline, CRTcolumn, stopline: integer;
    fvid: vid;
  const
    maxlines = 10;
    fieldwidth = 16;
  begin {other_volume_check}

    warning_issued := false;

    for flun := 1 to maxunit do
      if on_same_medium(flun, addr(unitable^[lun])) then
	with unitable^[flun] do
	  begin
	    if flun<>lun then
	      begin
		if not warning_issued then
		  begin
		    writeln('WARNING: the initialization will also DESTROY:');
		    warning_issued := true;
		    line := 1;
		  end; {if}

		fgetxy(output,CRTcolumn, CRTline);
		write(' #',flun:1);
		fgotoxy(output,CRTcolumn+5, CRTline);
		call(dam, fvid, flun, getvolumename);
		if strlen(fvid)>0
		  then write(fvid,':')
		  else write('<no dir>');
		if CRTcolumn=0
		  then writeln               {scrolls the screen if necessary}
		  else fgotoxy(output,CRTcolumn, CRTline+1);

		line := line+1;
		if line>maxlines then
		  begin
		    fgetxy(output,CRTcolumn, stopline);
		    fgotoxy(output,CRTcolumn+fieldwidth, stopline-maxlines);
		    line := 1;
		  end; {if}

	      end; {if flun<>lun}
	    umediavalid := false;
	  end; {with}

    if warning_issued and (CRTcolumn<>0) then
      fgotoxy(output,0, stopline);

end; {other_volume_check}

{
{ Set devicename for a CS80 (type Q) device.
{ Sets describe_bytes, describe_read as side effect.
}
procedure Qdevicename(uep: uep_type);
var
    retry_required: boolean;
    index: integer;
    bcd_product_number: {within the describe bytes}
      packed record case integer of
	0: (dn:  unsgn24);
	1: (bcd: packed array[1..6] of unsgn4);
      end;
    product_number: integer;
    fixed_vol_byte:
      packed record case integer of
	0: (byte: unsgn8);
	1: (bit:  packed array[0..7] of boolean);
      end;

  begin {Qdevicename}

    ioresult := ord(inoerror);
    initialize_bkgnd;

    try
      allocate_bkgnd_info(uep);

      if HPIBamigo_identify(uep) div 256<>2 then
	ioresc_bkgnd(uep, znodevice);

      repeat
	retry_required := false;
	if set_unitvol(uep)<>0 then
	  handle_bad_status(uep, true, retry_required);
      until not retry_required;

      repeat
	retry_required := false;
	if describe(uep, describe_bytes)<>0 then
	  handle_bad_status(uep, true, retry_required);
      until not retry_required;

      deallocate_bkgnd_info(uep);
    recover
      begin
	deallocate_bkgnd_info(uep);
	if escapecode<>-10 then escape(escapecode);
	ioresult := uep^.dvrtemp;  {flag problem with describe}
	if saved_ioresult=ord(inoerror) then  {report to caller}
	  saved_ioresult := ioresult;
      end; {recover}

    describe_read := (ioresult = ord(inoerror));
    if ioresult=ord(inoerror) then
      with describe_bytes do
	begin

	  bcd_product_number.dn := dn;
	  product_number := 0;
	  for index := 1 to 5 do
	    product_number := product_number*10+bcd_product_number.bcd[index];

	  devicename := 'HP';
	  strwrite(devicename, 3, index, product_number:1);

	  case dt of
	    0:        devicename := devicename+' fixed disc';
	    1:        begin
			fixed_vol_byte.byte := describe_bytes.fvb;
			if fixed_vol_byte.bit[7-uep^.dv]
			  then devicename := devicename+' fixed disc'
			  else devicename := devicename+' removeable disc';
		      end;
	    2:        devicename := devicename+' tape';
	    otherwise {can't further describe the generic device type};

	  end; {case}
	end {with}
    else
      devicename := '<inaccessible CS80 device>';

end; {Qdevicename}

procedure Sdevicename(pUnit:uep_type);
var
	sb:SessionBlockType;
	DAV:DeviceAddressVectorsType;
	DevType, AnsiVersion:integer;
	Removable:boolean;
	s:string255;
begin
	with pUnit^ do
	begin
		DAV.sc := sc;
		DAV.ba := ba;
		DAV.du := du;
		DAV.dv := dv;
	end;
	ScsiSBInit(addr(sb), addr(DAV));
	ScsiDevInfo(addr(sb), DevType, AnsiVersion, Removable, s);
	devicename := s;
	if saved_ioresult=ord(inoerror) then
	  saved_ioresult := ioresult;
end;

procedure Ssize(    pUnit:uep_type;
		 var sectspertrack, trackspercyl, fssize, rps: integer);
var
	sb:SessionBlockType;
	DAV:DeviceAddressVectorsType;
	NumBytesBlock, NumBlocksTrack, NumTracksCylinder, NumCylinders:integer;
begin
	with pUnit^ do
	begin
		DAV.sc := sc;
		DAV.ba := ba;
		DAV.du := du;
		DAV.dv := dv;
	end;
	ScsiSBInit(addr(sb), addr(DAV));
	ScsiDiscSize(addr(sb), NumBytesBlock, NumBlocksTrack, NumTracksCylinder, NumCylinders);
	if ioresult <> ord(inoerror) then
		escape(-10);
	if saved_ioresult = ord(inoerror) then
	begin
		{
		  now convert ScsiDiscSize parms to hfs parms.
		  NOTE:
			sectspertrack = # 1k sectors (blocks) on a track
			fssize        = Total 1K sectors (blocks) on disk.
		}
		if NumBytesBlock >= 1024 then {block sizes are in powers of 2 so following is o.k.}
			sectspertrack := (NumBytesBlock Div 1024) * NumBlocksTrack
		else
			sectspertrack := NumBlocksTrack Div (1024 Div NumBytesBlock);
		trackspercyl := NumTracksCylinder;
		fssize := sectspertrack * NumTracksCylinder * NumCylinders;
		rps := 60; {standard value of 60 revolutions per second}
	end;
end;

{
{ Set "device" and "devicename" for the given unit number.
}
procedure get_device_and_devicename(uep: uep_type);
begin
    with uep^ do
	case letter of
	  'M':               device := M;
	  'N':               device := N;
	  'U':               device := U;
	  'V':               device := V;
	  'W':               device := W;
	  'H':               device := H;
	  'F':               device := F;
	  'C':  if dv=0 then device := C
			else device := D;
	  'P':               device := P;
	  'X':               device := X;
	  'B':               device := B;                       {rdq}
	  'Q':               device := Q;
	  'R':               device := R;
	  'S':               device := S;                       {08/89 DEW}
	  otherwise
	    begin
	      writeln('MKHFS does not support this device');
	      escape(-1);
	    end;
	end; {case}

    if device=Q then
      {may do I/O, alter saved_ioresult}
      Qdevicename(uep)
    else if device = S then                                     {08/89 DEW}
      Sdevicename(uep)
    else
      devicename := dev_name[device];
end;

{
{ Get the device parameters
}
procedure get_dev_parms(    uep:uep_type;                       {08/89 DEW}
			var sectspertrack, trackspercyl, fssize, rps: integer);
label
    999;
var
    dbper1kb: integer;
begin
    { show not set }
    sectspertrack := 0;
    trackspercyl := 0;
    fssize := 0;
    rps := 0;

    case device of
      Q:
	begin
	    if not describe_read then
		goto 999;
	    with describe_bytes do begin
		{ disk blocks per 1K block }
		dbper1kb := 1024 div nbpb;
		fssize := (maxsvadd.lfb+1) div dbper1kb;
		if (maxcadd <> 0) or (maxhadd <> 0) then begin
		    sectspertrack := (maxsadd+1) div dbper1kb;
		    trackspercyl := maxhadd + 1;
		    rps := 1000000 div (blocktime * (maxsadd+1));
		end;
	    end;
	end;

      S:  Ssize(uep, sectspertrack, trackspercyl, fssize, rps);        {08/89 DEW}

      {LAF 870521 code for U, V, W }
      (* The values for Amigo devices listed below are not reality,
      (* but they're the ones HP-UX uses.  See /etc/disktab on any
      (* HP-UX machine
      (**)
      U:        {  5 Mbyte Amigo, single volume }
	begin
	sectspertrack :=    31;
	trackspercyl  :=     1;
	fssize        :=  4712;
	rps           :=    60;
	end;
      V:        { 10 Mbyte Amigo, single volume }
	begin
	sectspertrack :=    31;
	trackspercyl  :=     1;
	fssize        :=  9455;
	rps           :=    60;
	end;
      W:        { 15 Mbyte Amigo, single volume }
	begin
	sectspertrack :=     9;
	trackspercyl  :=     5;
	fssize        := 14175;
	rps           :=    60;
	end;
      otherwise
	;
    end;
999:
end;

{
{ Get volume info.  unum is the unit.  If we can't get the
{ info, set parameters to zero.  Print description of
{ volume suitable for confirmation request.
}
procedure volid_info(lun, oioresult: integer;
		     fvid: vid;
		     var sectspertrack,
			 trackspercyl,
			 fssize,
			 rps: integer);
var
    saved_ioresult: integer;
    uep: uep_type;
begin
    saved_ioresult := oioresult;
    uep := addr(unitable^[lun]);

    get_device_and_devicename(uep);

    writeln;
    write('Device: ',devicename);

    with uep^ do begin
      if device <> R then begin
	if device<>M then {it has a select code & possibly a bus address}
	  if (device=F) or (device=B) {it has a select code only}       {rdq}
	    then write(', ',sc:1)
	    else write(', ',100*sc+ba:1);
	if device<>B then write(', ',du:1);                     {rdq}
	if device in [C,D,Q,S] then write(', ',dv:1);
      end;
      writeln;
    end; {with uep^}

    write('Logical unit #',lun:1,' - ');
    if fvid[1]<>'#' then writeln('''',fvid,':''')               {rdq}
    else                                                        {rdq}
      if (saved_ioresult in nonabortive_ioresult_set) or        {rdq}
	 ((device=B) and (saved_ioresult<>ord(znodevice)) and   {rdq}
	  (saved_ioresult<>ord(zbadhardware)))                  {rdq}
      then writeln('<no directory>')                            {rdq}
      else
	fatal_ioresult('<MKHFS aborted>', saved_ioresult);

    other_volume_check(lun);

    { get the device parameters }
    get_dev_parms(uep, sectspertrack, trackspercyl, fssize, rps);       {08/89 DEW, added uep}

end;

end; {module volid}

{
{==================================================================
{ Write a LIF volume header
}
module lifhdr;

import sysglobals, fs, misc, sysdevs;

export

procedure write_lif_header(var fname: string255);

implement

type
    vname = packed array[1..6] of char;
    lifname = packed array[1..10] of char;
    bcd = 0..15;
    word = 0..65535;
    integer16 = -32768..32767;
    word15 = 0..32767;
    tdate = packed array[1..12] of bcd;
    lvhdr = packed record
	discid: word;
	volname: vname;
	dstart: integer;
	dummy1: integer16;
	dummy2: integer16;
	dsize: integer;
	version: integer16;
	dummy3: integer16;
	tps: integer;
	spm: integer;
	spt: integer;
	cdate: tdate;
	filler: packed array[21..123] of integer16;
	sdate: tdate;
	dummy4: integer16;
    end;
    direntry = packed record
	fname: lifname;
	ftype: integer16;
	fstart: integer;
	fsize: integer;
	fdate: tdate;
	lastvol: boolean;
	volnumber: word15;
	extension: integer;
    end;

const
    SECTORSIZE = 256;
    LIFDISCID = 32768;
    LIFDUMMY1 = 4096;
    LIF_END_HDR = -1;
    DIRPB = SECTORSIZE div sizeof(direntry);    { dir entries per block }
    HPUX_BOOT = -5822;
    DIRSTART = 1;       { directory start, in sectors, 0-based }
    DIRBLKS = 2;        { how many dir sectors }
    LOADADDR = hex('FFFF0800');

var
    hdr: lvhdr;
    dirblk: array[1..DIRPB] of direntry;
    bootblk: array[1..SECTORSIZE div sizeof(integer)] of integer;
    boot_start['bootasm_start']: integer;
    boot_size['bootasm_size']: integer;
    liffib: fib;
    lifposition: integer;
    dummywindow: shortint;
    liffile: file of char;

{
{ write from buf to the volume
}
function volwrite(f: integer; buf: windowp; count: integer): integer;
begin
  call(unitable^[f].tm, addr(liffib), writebytes, buf^, count, lifposition);
  lifposition := lifposition + count;
  if ioresult <> 0 then
    volwrite := -1
  else
    volwrite := count;
end;

procedure volclose(f: integer);
begin
  fcloseit(liffib, 'save');
end;

{
{ open the volume
}
function volopen(var volname: string255; mode: integer): integer;
label
  999;
var
  i, volume: integer;
  fvid: vid;
  ftitle: fid;
  fsegs: integer;
  fkind: filekind;
begin
  volopen := -1;

  { legal file name? }
  if not scantitle(volname, fvid, ftitle, fsegs, fkind) then
    goto 999;

  { just a volume id? }
  if ftitle <> '' then
    goto 999;

  { get volume number }
  volume := findvolume(fvid, TRUE);
  if (volume = 0) then goto 999;

  { and set up the unit }
  finitb(liffib, addr(dummywindow), 1);
  liffib.funit := volume;
  call(unitable^[volume].dam, liffib, volume, openunit);
  if ioresult <> 0 then goto 999;
  lifposition := 0;
  volopen := volume;
999:
end;

procedure fatal_ioerr;
begin
    if ioresult = 0 then
	ioresult := ord(inofile);
    escape(-10);
end;

procedure setdate(var d:tdate);
var
  doy:daterec;        tod:timerec;
begin
  sysdate(doy);       systime(tod);
  with doy, tod do
  begin
    {LAF 880101 added "mod 10" to "div 10"}
    d[1]  := year div 10 mod 10;d[2]  := year mod 10;
    d[3]  := month div 10;  d[4]  := month mod 10;
    d[5]  := day div 10;    d[6]  := day mod 10;
    d[7]  := hour div 10;   d[8]  := hour mod 10;
    d[9]  := minute div 10; d[10] := minute mod 10;
    d[11] := (centisecond div 100) div 10;
    d[12] := (centisecond div 100) mod 10;
  end;
end;

procedure write_lif_header(var fname: string255);
var
    result: integer;
    unit, nameunit: integer;
    boot_sectors: integer;
    i, j: integer;
begin
    unit := volopen(fname, 0);
    if unit < 0 then fatal_ioerr;
    boot_sectors := (boot_size + (SECTORSIZE-1)) div SECTORSIZE;

    { sector 0 -- volume header }
    with hdr do begin
	discid := LIFDISCID;
	volname := 'V  ';
	if h_unitable <> nil then
	    nameunit := h_unitable^.tbl[unit].base_unum
	else
	    nameunit := unit;
	if nameunit < 10 then
	    volname[2] := chr(ord('0') + nameunit)
	else begin
	    volname[2] := chr(ord('0') + nameunit div 10);
	    volname[3] := chr(ord('0') + nameunit mod 10);
	end;
	dstart := DIRSTART;
	dummy1 := LIFDUMMY1;
	dummy2 := 0;
	dsize := DIRBLKS;
	setdate(cdate);
	version := 1;
	tps := 1;
	spm := 1;
	spt := DIRSTART + DIRBLKS + boot_sectors;
    end;
    result := volwrite(unit, addr(hdr), SECTORSIZE);
    if result <> SECTORSIZE then fatal_ioerr;

    { zeroes }
    for i := 1 to DIRSTART - 1 do begin
	result := volwrite(unit, addr(bootblk), SECTORSIZE);
	if result <> SECTORSIZE then fatal_ioerr;
    end;

    { directory sector(s) }
    for i := 1 to DIRBLKS do begin
	for j := 1 to DIRPB do begin
	    with dirblk[j] do begin
		fname := '          ';
		ftype := LIF_END_HDR;
		fstart := DIRSTART + DIRBLKS;
		fsize := boot_sectors;
		lastvol := true;
		volnumber := 1;
		extension := LOADADDR;
	    end;
	end;
	result := volwrite(unit, addr(dirblk), SECTORSIZE);
	if result <> SECTORSIZE then fatal_ioerr;
    end;

    { now the boot program }
    result := volwrite(unit, addr(boot_start), boot_sectors*SECTORSIZE);
    if result <> boot_sectors*SECTORSIZE then fatal_ioerr;

    volclose(unit);

end;

end; {module lifhdr}

{
{====================================================================
{ MKFSUI
}


import
  sysglobals, fs, misc, sysdevs, mkfs, volid, lifhdr, clib, initunits;

const
  menu_begin_line = 3;          { leave space for header }

type
  {
  { The order of the following list determines the order of the
  { user menu.  It can be reordered by just changing this list.
  }
  param_name_type = (
	first_name,
	devsize,
	swapsize,
	nsect,
	ntrack,
	blksize,
	fragsize,
	ncpg,
	minfree,
	rps,
	nbpi,
	last_name
  );
  char_set_type = set of char;
  state_type = (not_set, set_ok, use_default);
  param_type = record
	  value: integer;
	  state: state_type;
	  default_ok: boolean;
	  letter: char;
	  prompt: string[80];
	end;
  param_array_type = array[param_name_type] of param_type;

var
  vol_name: string255;
  listing_name: string255;
  vol_unit: integer;
  vol_vid: vid;
  base_unit: integer;           {LAF 870424}
  save_unitable: unitableptr;   {LAF 870424 FSDat01154}
  keyboard: text;
  param: param_array_type;
  findvolume_ioresult: integer;
  cmd_char_set: char_set_type;
  input_column: integer;
  prompt_line: integer;

{--------------------------------------------------------------------------}
{
{ Make a character upper case.
}
procedure to_upper(var c: char);
begin
  if c in ['a'..'z'] then
    c := chr(ord(c) - ord('a') + ord('A'));
end;

{--------------------------------------------------------------------------}
{
{ Read 1 char from the user.  Ignore it and repeat if not in the
{ given list.
}
function read_char(chars_allowed: char_set_type): char;
var
  c: char;
begin
  repeat
    read(keyboard, c);
    to_upper(c);
  until c in chars_allowed;
  read_char := c;
end;

{--------------------------------------------------------------------------}
{
{ Init.
{ state = not_set: user (or drive or disktab) must supply value
{ state = set_ok:  value is ok
{ state = use_default: value calculated from others
{ default_ok: 'default' ok as parameter value
{ parameter order in this routine is irrelevant.
{ menu order determined by definition of param_name_type.
}
procedure init;
var
  i: param_name_type;
begin
  { init the state }
  for i := succ(first_name) to pred(last_name) do
    with param[i] do begin
      state := not_set;
      default_ok := false;
    end;

  { the menu ID letters }
  param[devsize].letter  := 'D';
  param[swapsize].letter := 'H';
  param[nsect].letter    := 'S';
  param[ntrack].letter   := 'T';
  param[blksize].letter  := 'B';
  param[fragsize].letter := 'F';
  param[ncpg].letter     := 'C';
  param[minfree].letter  := 'M';
  param[rps].letter      := 'R';
  param[nbpi].letter     := 'I';

  { check the cmd letters }
  cmd_char_set := ['Y','N'];
  for i := succ(first_name) to pred(last_name) do
    with param[i] do begin
      if letter in cmd_char_set then begin
	writeln('MENU CONFIG ERROR');
	escape(-1);
      end
      else
	cmd_char_set := cmd_char_set + [letter];
    end;

  { the menu strings }
  param[devsize].prompt  := 'Device size in 1Kb blocks';
  param[swapsize].prompt := 'HP-UX swap space, 1Kb blocks';
  param[nsect].prompt    := 'Sectors (1Kb) per track';
  param[ntrack].prompt   := 'Tracks per cylinder';
  param[blksize].prompt  := 'Block size in bytes';
  param[fragsize].prompt := 'Fragment size in bytes';
  param[ncpg].prompt     := 'Cylinders per group';
  param[minfree].prompt  := 'Minimum percent free blocks';
  param[rps].prompt      := 'Rotations per second';
  param[nbpi].prompt     := 'data bytes per Inode';

  { find the right input column }
  input_column := 0;
  for i := succ(first_name) to pred(last_name) do
    with param[i] do
      if input_column < strlen(prompt) then
	input_column := strlen(prompt);
  { letter + 2 blanks + max strlen + colon + 2 blanks }
  input_column := 1 + 2 + input_column + 1 + 2;

  prompt_line := ord(last_name) - ord(first_name) + menu_begin_line + 3;

  { parameters with initial values }
  param[blksize].value := 8192;
  param[blksize].state := set_ok;

  param[fragsize].value := 1024;
  param[fragsize].state := set_ok;

  param[ncpg].state := use_default;
  param[ncpg].default_ok := true;

  param[minfree].value := 10;
  param[minfree].state := set_ok;

  param[nbpi].value := 2048;
  param[nbpi].state := set_ok;

  param[swapsize].value := 0;
  param[swapsize].state := set_ok;
end;

{-------------------------------------------------------------------------}
{
{ physical size of this unit
{ just add up all umaxbytes that refer to it
{ The initial call to ueovbytes means that this function works
{ even on RAM volumes, where on_same_medium ALWAYS returns false.
{ The byteoffset check prevents counting #3 and #43 both.
}
function physical_size(unit: unitnum): integer;
var
    total_size: integer;
    i: unitnum;
begin
    total_size := ueovbytes(unit);
    with unitable^[unit] do
	for i := 1 to maxunit do
	    if (i <> unit)
	    and on_same_medium(unit, addr(unitable^[i]))
	    and (unitable^[i].byteoffset <> byteoffset) then
		total_size := total_size + ueovbytes(i);
    physical_size := total_size;
end;


{--------------------------------------------------------------------------}
{
{ Get volume info from the driver.
{ Only works if CS80/SS80 disc.
}
procedure get_volume_info;
const
    tab_size = 10;
type
    entry_type = packed record
	size: integer;
	sectors: ushort;
	tracks: ushort;
	rots: ushort;
    end;
    entry_type_table = array[1..tab_size] of entry_type;
const
    def_table = entry_type_table[
	entry_type[             { 8290xM, 9121D/S }
	    size: 264,
	    sectors: 4,
	    tracks: 2,
	    rots: 5],
	entry_type[             { 913xA, 9133V Opt 4 }
	    size: 1125,
	    sectors: 7,
	    tracks: 2,
	    rots: 60],
	entry_type[             { 913xA Opt 10 }
	    size: 4712,
	    sectors: 7,
	    tracks: 4,
	    rots: 60],
	entry_type[             { 913xB }
	    size: 9455,
	    sectors: 7,
	    tracks: 4,
	    rots: 60],
	entry_type[             { 9133V }
	    size: 4727,
	    sectors: 7,
	    tracks: 2,
	    rots: 60],
	entry_type[             { 913xXV }
	    size: 14182,
	    sectors: 7,
	    tracks: 6,
	    rots: 60],
	entry_type[             { 9885, 9895 single }
	    size: 472,
	    sectors: 7,
	    tracks: 1,
	    rots: 5],
	entry_type[             { 9895 double }
	    size: 1125,
	    sectors: 7,
	    tracks: 2,
	    rots: 5],
	entry_type[             { 9130K }
	    size: 264,
	    sectors: 4,
	    tracks: 2,
	    rots: 5],
	entry_type[             { bubble }
	    size: 128,
	    sectors: 4, {LAF 870424 FSDat00992}
	    tracks: 2,  {LAF 870424 FSDat00992}
	    rots: 1]
    ];
var
    i: 1..tab_size;
begin
    volid_info(vol_unit,
	       findvolume_ioresult,
	       vol_vid,
	       param[nsect].value,
	       param[ntrack].value,
	       param[devsize].value,
	       param[rps].value);

    { may need to calculate physical size }
    if param[devsize].value = 0 then
	param[devsize].value := physical_size(vol_unit) div 1024;

    { special hook for devices that don't give back info }
    if param[nsect].value = 0 then begin
	if unitable^[vol_unit].letter = 'R' then begin
	    { RAM volume -- numbers irrelevant }
	    param[nsect].value  := 32;  {LAF 870424}
	    param[ntrack].value := 32;  {LAF 870424}
	    param[rps].value    := 1;
	end
	else
	if unitable^[vol_unit].letter = 'Q' then begin
	    { 913xD/H/L -- use defaults for entire group }
	    param[nsect].value  := 8;
	    param[ntrack].value := 4;
	    param[rps].value    := 60;
	end
	else
	for i := 1 to tab_size do
	    with def_table[i] do
		if size = param[devsize].value then begin
		    param[nsect].value  := sectors;
		    param[ntrack].value := tracks;
		    param[rps].value    := rots;
		end;
    end;

    { volid info sets unknown params to 0 }
    if param[nsect].value <> 0 then
	param[nsect].state := set_ok;
    if param[ntrack].value <> 0 then
	param[ntrack].state := set_ok;
    if param[devsize].value <> 0 then
	param[devsize].state := set_ok;
    if param[rps].value <> 0 then
	param[rps].state := set_ok;

    { minfree always 0 on floppies and RAM volumes }
    if not unitable^[vol_unit].uisfixed
    or (unitable^[vol_unit].letter = 'R') then  {LAF 870424 FSDat01087}
      param[minfree].value := 0;
end;

{--------------------------------------------------------------------------}
{
{ See if user wants to change the defaults (return true),
{ or is happy the way they are (return false).
}
function change_defaults: boolean;
var
  ansc: char;
begin
  write('Change or examine default parameters? (y/n) ');
  ansc := read_char(char_set_type['Y','N']);
  writeln(ansc);
  change_defaults := (ansc = 'Y');
end;

{--------------------------------------------------------------------------}
{
{ Input volume name.
{       listing_name -- name of listing file
{       vol_name -- name of volume (or file) to be mkfs'd
{       vol_unit -- unit number for vol_name
}
procedure input_vol_name;
label
  1;
var
  f: text;
  ansc: char;
  ftitle: fid;
  fsegs: integer;
  fkind: filekind;
  scantitle_ok: boolean;
  commapos: integer;
{-------------}
function max(a,b: integer): integer;
begin
  if a < b then max := b else max := a;
end;
{-------------}
begin
1:
  { get the volume name }
  write('Volume ID? ');
  readln(vol_name);
  if (strlen(vol_name) = 0) then
    escape(0);

  { pull out listing_name }
  setstrlen(listing_name, 0);
  commapos := strpos(',', vol_name);
  if commapos <> 0 then begin
    listing_name := str(vol_name, commapos+1,
			max(strlen(vol_name)-commapos,0));
    vol_name := str(vol_name, 1, commapos-1);
    if (strlen(vol_name) = 0) or (strlen(listing_name) = 0) then begin
      writeln('Bad syntax');
      goto 1;
    end;
    try
      rewrite(f, listing_name);
    recover
      begin
	  writeln('Cannot open listing file ', listing_name);
	  goto 1;
      end;
    close(f, 'save');
  end;


  { split vol_name into pieces and check syntax }
  if not scantitle(vol_name, vol_vid, ftitle, fsegs, fkind)
  or (ftitle <> '') then begin
    writeln('Illegal filename syntax');
    goto 1;
  end;

  { be sure it's a real volume }
  vol_unit := findvolume(vol_vid, true);
  findvolume_ioresult := ioresult;
  if vol_unit = 0 then begin
    writeln('No such volume');
    goto 1;
  end;
end;

{--------------------------------------------------------------------------}
{
{ Confirm that user wants to overwrite this volume.
{ vol_unit is the unit number.
}
procedure confirm_volume;
var
  saved_ioresult: integer;
  ansc: char;
begin
  write('Are you SURE you want to overwrite the disc? (y/n) ');
  ansc := read_char(char_set_type['Y','N']);
  writeln(ansc);
  if ansc = 'N' then escape(0);
end;

{-------------------------------------------------------------------------}
{
{ Report a parameter error.
}
procedure param_error(s: string255);
var
  c: char;
begin
  fgotoxy(output, 0, prompt_line);
  writeln(s);
  write('Press any key to continue ');
  read(keyboard, c);
  fgotoxy(output, 0, prompt_line);
  writeln(cteol);
  write(cteol);
end;

{-------------------------------------------------------------------------}
{
{ Gather info with menu, since user has requested it, or we could not
{ get the info automatically.
}
procedure menu;
type
  action_type = (display_old, read_new);
var
  cmd_char: char;
  i: param_name_type;
{----------------------}
{
{ Is the string s numeric?
}
function is_numeric(s: string255): boolean;
var
  i: integer;
begin
  is_numeric := strlen(s) > 0;
  for i := 1 to strlen(s) do
    if (s[i] < '0') or (s[i] > '9') then
      is_numeric := false;
end;

{----------------------}
{
{ Ascii to integer.
}
function atoi(s: string255): integer;
var
  i, n: integer;
begin
  n := 0;
  for i := 1 to strlen(s) do
    n := n * 10 + ord(s[i]) - ord('0');
  atoi := n;
end;
{----------------------}
{
{ Write the menu onto the screen.
}
procedure display_menu;
var
  i: param_name_type;
begin
  fgotoxy(output, 0, menu_begin_line);
  write(cteos);
  for i := succ(first_name) to pred(last_name) do
    writeln(param[i].letter, '  ', param[i].prompt, ':');
  writeln;
  writeln('Y  Yes, continue');
  writeln('N  No, quit without changing the disc');
end;
{----------------------}
{
{ Display or read in a single parameter.
{ action tells which to do.
}
procedure menu_param(line: param_name_type; action: action_type);
var
  answer: string255;
  i: integer;
begin
  fgotoxy(output, input_column, menu_begin_line+ord(line)-1);
  with param[line] do
  case action of

    display_old:
      begin
	case state of
	  not_set:     {leave blank} ;
	  set_ok:      write(value:1);
	  use_default: write('default');
	end;
	write(cteol);
      end; {display_old}

    read_new:
      begin
	write(cteol);
	readln(answer);
	for i := 1 to strlen(answer) do
	  to_upper(answer[i]);
	if answer = 'DEFAULT' then
	  if default_ok then
	    state := use_default
	  else begin
	    param_error('No default for that parameter');
	    menu_param(line, display_old);
	  end
	else
	{ error if non-numeric }
	if not is_numeric(answer) then begin
	  if answer <> '' then
	    param_error('That value must be numeric');
	  menu_param(line, display_old);
	end
	else begin
	  { numeric, so assign the value }
	  value := atoi(answer);
	  state := set_ok;
	end;
      end; {read_new}

  end; {case}
end;
{----------------------}

begin
  display_menu;
  for i := succ(first_name) to pred(last_name) do
    menu_param(i, display_old);
  repeat
    fgotoxy(output, 0, prompt_line);
    write('command? ');
    cmd_char := read_char(cmd_char_set);
    fgotoxy(output, 0, prompt_line);
    write(cteol);
    case cmd_char of
      'Y':
	 { do nothing };
      'N':
	escape(0);
      otherwise
	for i := succ(first_name) to pred(last_name) do
	  if param[i].letter = cmd_char then
	    menu_param(i, read_new);
    end;
  until cmd_char = 'Y';
end;

{----------------------------------------------------------------------------}
{
{ zap this unit to make it unuseable
}
procedure zap_unit(u: unitnum);
begin
    with unitable^[u] do begin
	sc := 0;
	ba := 0;
	du := 0;
	dv := 0;
	byteoffset := 0;
	devid := 0;
	uvid := '';
	letter := #0;
	uisinteractive := false;
	uisfixed := false;
	umaxbytes := 0;
	dam := nodam;
	tm := nounit;
    end;
end;

{---------------------------------------------------------------------------}
{
{ coalesce all units on this physical disk
{ other units on this disk are zapped
{ our unit becomes the whole disk
}
procedure coalesce_units(unit: unitnum; phys_size: integer);
var
    i: unitnum;
begin
    base_unit := unit;  {LAF}
    with unitable^[unit] do begin
	for i := 1 to maxunit do
	    if on_same_medium(unit, addr(unitable^[i]))
	    and (unit <> i)
	    and (unitable^[i].byteoffset <> byteoffset) then
		begin
		if base_unit>i then base_unit:=i;       {LAF}
		zap_unit(i);
		end;
	if letter <> 'R' then
	    begin
	    {LAF 870526 FSDat01088  don't change size of RAM volume}
	    umaxbytes := phys_size;
	    byteoffset := 0;
	    end;
    end;
end;

{---------------------------------------------------------------------------}
{
{ fix param[devsize].value for RAM volumes
{ set it back to umaxbytes div 1024
{ (coalesce_units does not change umaxbytes for RAM volumes)
{ this routine: LAF 870526 FSDat01088
}
procedure fix_for_ram(unit: unitnum);
begin
with unitable^[unit] do
  if letter = 'R' then
    param[devsize].value := umaxbytes div 1024;
end;


{--------------------------------------------------------------------------}
{
{ See if all parameters are defined.  Defaults are OK, but
{ 4 parameters have no default.  Depends on init to assign
{ these 4 not_set, and other parameters other states.
}
function all_params_defined: boolean;
var
  i: param_name_type;
begin
  all_params_defined := true;
  for i := succ(first_name) to pred(last_name) do
    if param[i].state = not_set then
      all_params_defined := false;
end;

{--------------------------------------------------------------------------}
{
{ Check the parameters so can give warning before mkfs does.
{ Currently just make sure they're defined.
{ We could do a lot more checking, but we will let mkfs do it
{ and clean up the error messages there.
}
function params_ok: boolean;
label
  999;
begin
  params_ok := false;
  if not all_params_defined then begin
    param_error('Please supply missing parameter values');
    goto 999;
  end;
  params_ok := true;
999:
end;


{----------------------------------------------------------------------------}
{
{ The disk is not recognizable.
{ Ask if we should go on.
}
procedure weird_disc;
var
  ansc: char;
begin
  write('Unrecognized disc type.  Proceed anyway? (y/n) ');
  ansc := read_char(char_set_type['Y','N']);
  writeln;
  if ansc = 'N' then escape(0);
end;


{--------------------------------------------------------------------------}
{
{ Write a verbose header so you know it's PAWS
{ Why isn't this in a library somewhere?
}
procedure write_program_header;

const
  previd = daterec[year:91, day:28, month:10];
  prevno = '3.25';
  programname = 'MKHFS';        {title}
  copyright1  = '  Copyright Hewlett-Packard Co.,1987,1991.';
  copyright2 =  '             All rights reserved.';
  monthstr = 'JanFebMarAprMayJunJulAugSepOctNovDec';

var
  date: daterec;
  time: timerec;
  i: integer;
  seconds: integer;
  todaysdate: string[9];
  timestring: string[8];

begin {write_program_header}

  sysdate(date);
  systime(time);

  with date do
    {LAF 880101 added "mod 10" to "div 10" and removed "year<100" test}
    if (month in [1..12]) and (day>0) then
      begin
	todaysdate := '  -'+str(monthstr, month*3-2, 3)+'-  ';
	if day>9 then todaysdate[1] := chr(day div 10 + ord('0'));
	todaysdate[2] := chr(day mod 10 + ord('0'));
	todaysdate[8] := chr(year div 10 mod 10 + ord('0'));
	todaysdate[9] := chr(year mod 10 + ord('0'));
      end {then}
    else
      todaysdate := '         ';

  setstrlen(timestring,0);
  i := 1;
  if time.hour<10 then
    strwrite(timestring,i,i,'0');
  strwrite(timestring,i,i,time.hour:1,':');
  if time.minute<10 then
    strwrite(timestring,i,i,'0');
  strwrite(timestring,i,i,time.minute:1,':');
  seconds := time.centisecond div 100;
  if seconds<10 then
    strwrite(timestring,i,i,'0');
  strwrite(timestring,i,i,seconds:1);

  writeln(programname,' [Rev ',prevno,' ',previd.month:2,'/',previd.day:2,
	  '/',previd.year:2,']',todaysdate:10,' ',timestring);
  writeln;
  writeln(copyright1);
  writeln(copyright2);
  writeln;

end; {write_program_header}

{----------------------------------------------------------------------------}
{
{ hfs_done
{ 1.  If unit is not hfs_unit, and hfs is installed, then invalidate
{         the cache for the base unit.  This allows a MKHFS on #3, when
{         #43 is an HFS unit with data in its cache.
{         If unit IS hfs unit, then the cache is already gone, so we
{         don't do it again.
{ 2.  Reset corrupt bit for base unit.
{ 3.  Reset all prefixes on the disk to /.
}
procedure hfs_done(unum: integer);
var
    base: integer;
    i: unitnum;
begin
    if (unum <> 0) and (h_unitable <> nil) then
	with h_unitable^ do begin
	    if not tbl[unum].is_hfsunit then
		call(inval_cache_proc, tbl[unum].base_unum);
	    base := tbl[unum].base_unum;
	    tbl[base].fs_corrupt := false;
	    for i := 1 to maxunit do
		if tbl[i].base_unum = base then begin
		    tbl[i].prefix := 2 {root_inode};
		    unitable^[i].uvid := '';
		end;
	end;
end;

{-------------------------------------------------------------------------}
{
{ Exchange unitable entries for vol_unit and base_unit, if different.
{ Set vol_unit to base_unit.
{ Base_unit was set by coalesce_units as the lowest-number unit assigned
{   to the same multi-volume physical device as vol_unit.
}
procedure change_to_base_unit;
begin
if vol_unit<>base_unit then
  begin
  unitable^[base_unit]:=unitable^[vol_unit];
  zap_unit(vol_unit);
  vol_unit:=base_unit;
  end;
end;

{-------------------------------------------------------------------------}
{
{ Invoke mkfs with the parameters obtained.
{ argv order is fixed by mkfs, of course, and cannot be changed.
}
procedure do_mkfs;
const
  mkfs_argc = 11;
type
  argvtype = array[1..mkfs_argc+1] of string255ptr;
var
  argv: argvtype;
  argc, i, dummy: integer;
begin
  if listing_name <> '' then
    argc := mkfs_argc + 1
  else
    argc := mkfs_argc;

  for i := 1 to argc do begin
    new(argv[i]);
    setstrlen(argv[i]^, 0);
  end;

  argv[1]^ := 'mkfs';

  argv[2]^ := vol_name;

  strwrite(argv[3]^, 1, dummy, (param[devsize].value-param[swapsize].value):1);

  strwrite(argv[4]^, 1, dummy, param[nsect].value);

  strwrite(argv[5]^, 1, dummy, param[ntrack].value);

  strwrite(argv[6]^, 1, dummy, param[blksize].value);

  strwrite(argv[7]^, 1, dummy, param[fragsize].value);

  if param[ncpg].state <> use_default then
    strwrite(argv[8]^, 1, dummy, param[ncpg].value:1)
  else
    strwrite(argv[8]^, 1, dummy, 0:1);

  strwrite(argv[9]^, 1, dummy, param[minfree].value);

  strwrite(argv[10]^, 1, dummy, param[rps].value);

  strwrite(argv[11]^, 1, dummy, param[nbpi].value);

  if listing_name <> '' then
    argv[12]^ := listing_name;

  { contort argv for C }
  for i := 1 to argc do begin
    setstrlen(argv[i]^, strlen(argv[i]^)+1);
    argv[i]^[strlen(argv[i]^)] := chr(0);
    argv[i] := anyptr(addr(argv[i]^, 1));
  end;

  try
    i := main(argc, addr(argv));
  recover
    if escapecode <> 0 then escape(escapecode);

end;
{-----------------------------------------------------------------------}

begin

new(save_unitable);   {LAF 870424 FSDat01154}
save_unitable^:=unitable^;    {LAF 870424 FSDat01154}
  try
  init;
  write_program_header;
  input_vol_name;
  if vol_unit <> 0 then
    get_volume_info;
  if not all_params_defined then
    weird_disc;
  if (not all_params_defined) or change_defaults then
    repeat
      menu
    until params_ok;
  confirm_volume;
  coalesce_units(vol_unit, param[devsize].value * 1024);
  fix_for_ram(vol_unit);
  write_lif_header(vol_name);
  do_mkfs;
  hfs_done(vol_unit);
  change_to_base_unit; (*base_unit computed in coalesce_units*) {LAF 870424}
  recover
    begin
    unitable^:=save_unitable^;  {LAF 870424 FSDat01154}
    if escapecode=-20 then
      begin
	writeln;
	writeln('MKHFS stopped by user');
      end
    else
      escape(escapecode);
    end;

end.
@


55.2
log
@
pws2rcs automatic delta on Mon Nov  4 13:45:04 MST 1991
@
text
@@


55.1
log
@Automatic bump of revision number for PWS version 3.25A
@
text
@d1393 2
a1394 2
  previd = daterec[year:91, day:13, month:08];
  prevno = '3.25A';
@


54.2
log
@
pws2rcs automatic delta on Wed Aug 21 13:42:03 MDT 1991
@
text
@@


54.1
log
@Automatic bump of revision number for PWS version 3.24
@
text
@d1393 2
a1394 2
  previd = daterec[year:91, day:16, month:3];
  prevno = '3.24';
@


53.3
log
@
pws2rcs automatic delta on Mon Mar 18 13:19:08 MST 1991
@
text
@@


53.2
log
@Updated copyright message.
@
text
@d1393 2
a1394 2
  previd = daterec[year:91, day:10, month:3];
  prevno = '3.24B';
@


53.1
log
@Automatic bump of revision number for PWS version 3.24B
@
text
@d1396 1
a1396 1
  copyright1  = '  Copyright Hewlett-Packard Co.,1987,1990.';
@


52.2
log
@
pws2rcs automatic delta on Mon Mar 11 16:41:32 MST 1991
@
text
@@


52.1
log
@Automatic bump of revision number for PWS version 3.24A
@
text
@d1393 2
a1394 2
  previd = daterec[year:91, day:16, month:02];
  prevno = '3.24A';
@


51.2
log
@
pws2rcs automatic delta on Mon Feb 18 20:38:36 MST 1991
@
text
@@


51.1
log
@Automatic bump of revision number for PWS version 3.24d
@
text
@d1393 2
a1394 2
  previd = daterec[year:91, day:28, month:1];
  prevno = '3.24d';
@


50.2
log
@
pws2rcs automatic delta on Wed Jan 30 09:08:19 MST 1991
@
text
@@


50.1
log
@Automatic bump of revision number for PWS version 3.23c
@
text
@d1393 2
a1394 2
  previd = daterec[year:90, day:26, month:10];
  prevno = '3.24c';
@


49.2
log
@
pws2rcs automatic delta on Mon Oct 29 14:00:44 MST 1990
@
text
@@


49.1
log
@Automatic bump of revision number for PWS version 3.24b
@
text
@d1393 2
a1394 2
  previd = daterec[year:90, day:13, month:08];
  prevno = '3.24b';
@


48.2
log
@
pws2rcs automatic delta on Tue Aug 14 09:29:26 MDT 1990
@
text
@@


48.1
log
@Automatic bump of revision number for PWS version 3.24a
@
text
@d1393 2
a1394 2
  previd = daterec[year:90, day:23, month:07];
  prevno = '3.24a';
@


47.2
log
@
pws2rcs automatic delta on Tue Jul 24 14:47:20 MDT 1990
@
text
@@


47.1
log
@Automatic bump of revision number for PWS version 3.23
@
text
@d1393 2
a1394 2
  previd = daterec[year:90, day:03, month:05];
  prevno = '3.23';
@


46.1
log
@Automatic bump of revision number for PWS version 3.23
@
text
@@


45.2
log
@
pws2rcs automatic delta on Fri May  4 14:44:01 MDT 1990
@
text
@@


45.1
log
@Automatic bump of revision number for PWS version 3.23C
@
text
@d1393 2
a1394 2
  previd = daterec[year:90, day:18, month:04];
  prevno = '3.23C';
@


44.2
log
@
pws2rcs automatic delta on Thu Apr 19 13:13:04 MDT 1990
@
text
@@


44.1
log
@Automatic bump of revision number for PWS version 3.23B
@
text
@d1393 2
a1394 2
  previd = daterec[year:90, day:31, month:03];
  prevno = '3.23B';
@


43.4
log
@
pws2rcs automatic delta on Sun Apr  1 16:13:30 MDT 1990
@
text
@@


43.3
log
@Updated the search strings for better control of the local development
environement.

Updated all calls to ScsiSBInit to reflect new interface.
@
text
@d1393 2
a1394 2
  previd = daterec[year:90, day:16, month:03];
  prevno = '3.23A';
@


43.2
log
@Fixed copyright date.
@
text
@d13 7
a19 7
$SEARCH 'support/mkfs',
	'support/CLIBRARY2',
	'support/CS80',
	'support/DRVASM',
	'support/DISCHPIB',
	'support/KERNEL',
	'SCSILIB.'$
d259 1
d264 8
a271 1
	ScsiSBInit(addr(sb), pUnit);
d282 1
d285 8
a292 1
	ScsiSBInit(addr(sb), pUnit);
@


43.1
log
@Automatic bump of revision number for PWS version 3.23aA
@
text
@d1380 1
a1380 1
  copyright1  = '  Copyright Hewlett-Packard Co.,1987,1989.';
@


42.2
log
@
pws2rcs automatic delta on Mon Mar 19 16:00:53 MST 1990
@
text
@@


42.1
log
@Automatic bump of revision number for PWS version 3.23e
@
text
@d1377 2
a1378 2
  previd = daterec[year:90, day:19, month:01];
  prevno = '3.23e';
@


41.2
log
@
pws2rcs automatic delta on Sat Jan 20 16:32:46 MST 1990
@
text
@@


41.1
log
@Automatic bump of revision number for PWS version 3.23d
@
text
@d1377 2
a1378 2
  previd = daterec[year:89, day:19, month:12];
  prevno = '3.23d';
@


40.4
log
@
pws2rcs automatic delta on Thu Dec 21 14:54:59 MST 1989
@
text
@@


40.3
log
@Correct a search pathname for scsi.
@
text
@d11 1
a11 1
	'SCSI:SCSIDVR.'$
d19 1
a19 1
	'SCSIDVR.'$
d49 1
a49 1
    SCSIIF;
d1377 2
a1378 2
  previd = daterec[year:89, day:27, month:09];
  prevno = '3.23c';
@


40.2
log
@Update MKHFS to work with new SCSI programmer's interface definition.
@
text
@d11 1
a11 1
	'SCSI:SCSIDVR'$
d19 1
a19 1
	'SCSIDVR'$
@


40.1
log
@Automatic bump of revision number for PWS version 3.23c
@
text
@d11 1
a11 1
	'SCSI:SCSIIF'$
d19 1
a19 1
	'SCSIIF'$
a48 1
    SCSI_DEFS,
d277 1
a277 1
	ScsiDiskSize(addr(sb), NumBytesBlock, NumBlocksTrack, NumTracksCylinder, NumCylinders);
d283 1
a283 1
		  now convert ScsiDiskSize parms to hfs parms.
@


39.2
log
@
pws2rcs automatic delta on Thu Sep 28 17:16:32 MDT 1989
@
text
@@


39.1
log
@Automatic bump of revision number for PWS version 3.23b
@
text
@d1378 2
a1379 2
  previd = daterec[year:89, day:25, month:9];
  prevno = '3.22b';
@


38.3
log
@
pws2rcs automatic delta on Tue Sep 26 14:31:31 MDT 1989
@
text
@@


38.2
log
@Added support for SCSI disk drives.
@
text
@d11 1
a11 1
	'SCSI:SCSIF'$
d1378 2
a1379 2
  previd = daterec[year:89, day:11, month:05];
  prevno = '3.3a';
@


38.1
log
@Automatic bump of revision number for PWS version 3.23a
@
text
@d4 1
d10 11
a20 1
	'IOLIB:KERNEL'$
d22 1
d34 1
d48 3
a50 1
    cs80dsr;
d66 1
a66 1
    sup_dev_type = (M,N,U,V,W,H,F,C,D,P,X,B,R,Q); {supported devices}
d257 42
d320 1
d328 1
a328 1
    if device=Q
d330 5
a334 2
      then Qdevicename(uep)
      else devicename := dev_name[device];
d340 2
a341 2
procedure get_dev_parms(var sectspertrack,
			    trackspercyl, fssize, rps: integer);
d369 3
d434 1
a434 1
	if device in [C,D,Q] then write(', ',dv:1);
d452 1
a452 1
    get_dev_parms(sectspertrack, trackspercyl, fssize, rps);
d1378 2
a1379 2
  previd = daterec[year:89, day:25, month:08];
  prevno = '3.23a';
@


37.2
log
@
pws2rcs automatic delta on Mon Aug 28 12:16:08 MDT 1989
@
text
@@


37.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@d1314 2
a1315 2
  previd = daterec[year:89, day:11, month:05];
  prevno = '3.3a';
@


36.3
log
@
pws2rcs automatic delta on Fri May 12 09:00:42 MDT 1989
@
text
@@


36.2
log
@
pws2rcs automatic delta on Thu May 11 11:32:36 MDT 1989
@
text
@d1314 1
a1314 1
  previd = daterec[year:89, day:10, month:05];
@


36.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@d1314 2
a1315 2
  previd = daterec[year:89, day:20, month:01];
  prevno = '3.22';
@


35.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


34.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


33.2
log
@
pws2rcs automatic delta on Fri Jan 20 16:16:31 MST 1989
@
text
@@


33.1
log
@Automatic bump of revision number for PWS version 3.22D
@
text
@d1314 2
a1315 2
  previd = daterec[year:89, day:12, month:01];
  prevno = '3.22D';
@


32.3
log
@
pws2rcs automatic delta on Fri Jan 13 11:19:22 MST 1989
@
text
@@


32.2
log
@Fix copyright message

@
text
@d1314 2
a1315 2
  previd = daterec[year:89, day:06, month:01];
  prevno = '3.22C';
@


32.1
log
@Automatic bump of revision number for PWS version 3.22C
@
text
@d1317 1
a1317 1
  copyright1  = '   Copyright Hewlett-Packard Company, 1987.';
@


31.2
log
@
pws2rcs automatic delta on Mon Jan  9 11:50:34 MST 1989
@
text
@@


31.1
log
@Automatic bump of revision number for PWS version 3.22B
@
text
@d1314 2
a1315 2
  previd = daterec[year:88, day:12, month:12];
  prevno = '3.22B';
@


30.2
log
@
pws2rcs automatic delta on Wed Dec 14 13:22:28 MST 1988
@
text
@@


30.1
log
@Automatic bump of revision number for PWS version 3.22A
@
text
@d1314 2
a1315 2
  previd = daterec[year:88, day:07, month:12];
  prevno = '3.22A';
@


29.2
log
@
pws2rcs automatic delta on Thu Dec  8 15:31:09 MST 1988
@
text
@@


29.1
log
@Automatic bump of revision number for PWS version 3.22b
@
text
@d1314 2
a1315 2
  previd = daterec[year:88, day:27, month:10];
  prevno = '3.22b';
@


28.2
log
@
ipws2rcs automatic delta on Mon Oct 31 10:34:17 MST 1988
:w
:q
@
text
@@


28.1
log
@Automatic bump of revision number for PWS version 3.3b
@
text
@d1314 2
a1315 2
  previd = daterec[year:88, day:5, month:10];
  prevno = '3.3a';
@


27.2
log
@pws2rcs automatic delta on Wed Oct  5 17:32:00 MDT 1988

@
text
@@


27.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@d1314 2
a1315 2
  previd = daterec[year:88, day:16, month:3];
  prevno = '3.21b';
@


26.6
log
@
Comment from auto synch of clock fix:
date: 88/03/18 09:39:43;  author: quist;  state: Exp;  lines added/del: 2/2
Pws2unix automatic delta on Fri Mar 18 09:13:54 MST 1988
@
text
@@


26.5
log
@
Comment from auto synch of clock fix:
date: 88/03/09 08:28:52;  author: quist;  state: Exp;  lines added/del: 2/2
Pws2unix automatic delta on Wed Mar 9 08:03:11 MST 1988
@
text
@d1314 2
a1315 2
  previd = daterec[year:88, day:8, month:3];
  prevno = '3.21a';
@


26.4
log
@
Comment from auto synch of clock fix:
date: 88/03/02 17:36:10;  author: quist;  state: Exp;  lines added/del: 7/5
SYSDATE fixes, RDQ
@
text
@d1314 2
a1315 2
  previd = daterec[year:87, day:29, month:8];
  prevno = '3.2';
@


26.3
log
@
Comment from auto synch of clock fix:
date: 88/03/02 09:16:01;  author: bayes;  state: Exp;  lines added/del: 0/0
Automatic bump of revision number for PWS version 3.2Y
@
text
@d535 2
a536 1
    d[1]  := year div 10;   d[2]  := year mod 10;
d1314 2
a1315 2
  previd = daterec[year:88, day:12, month:2];
  prevno = '3.2Y';
d1335 2
a1336 1
    if (month in [1..12]) and (day>0) and (year<100) then
d1341 1
a1341 1
	todaysdate[8] := chr(year div 10 + ord('0'));
@


26.2
log
@
Comment from auto synch of clock fix:
date: 88/03/01 09:26:11;  author: bayes;  state: Exp;  lines added/del: 5/3
Pws2unix automatic delta on Tue Mar 1 09:01:42 MST 1988
@
text
@@


26.1
log
@Automatic bump of revision number for PWS version 3.3 Synch
@
text
@d1310 5
a1314 3
procedure write_program_header;const
  previd = daterec[year:87, day:29, month:8];
  prevno = '3.2';
@


24.1
log
@Automatic bump of revision number for PWS version 3.2
@
text
@@


23.2
log
@Pws2unix automatic delta on Sun Aug 30 14:43:47 MDT 1987
@
text
@@


23.1
log
@Automatic bump of revision number for PWS version 3.2P
@
text
@d1311 2
a1312 2
  previd = daterec[year:87, day:25, month:8];
  prevno = '3.2P';
@


22.2
log
@Pws2unix automatic delta on Tue Aug 25 18:23:33 MDT 1987
@
text
@@


22.1
log
@Automatic bump of revision number for PWS version 3.2N
@
text
@d1311 2
a1312 2
  previd = daterec[year:87, day:14, month:8];
  prevno = '3.2N';
d1314 2
a1315 2
  copyright1  = '   Copyright 1986 Hewlett-Packard Company.';
  copyright2 =  '            All rights reserved.';
@


21.2
log
@Pws2unix automatic delta on Sat Aug 15 16:14:36 MDT 1987
@
text
@@


21.1
log
@Automatic bump of revision number for PWS version 3.2M
@
text
@d1311 2
a1312 2
  previd = daterec[year:87, day:11, month:8];
  prevno = '3.2M';
@


20.2
log
@Pws2unix automatic delta on Wed Aug 12 09:47:30 MDT 1987
@
text
@@


20.1
log
@Automatic bump of revision number for PWS version 3.2L
@
text
@d1311 2
a1312 2
  previd = daterec[year:87, day:28, month:7];
  prevno = '3.2L';
@


19.2
log
@Pws2unix automatic delta on Wed Jul 29 17:29:01 MDT 1987
@
text
@@


19.1
log
@Automatic bump of revision number for PWS version 3.2K
@
text
@d1311 2
a1312 2
  previd = daterec[year:87, day:30, month:5];
  prevno = '3.2K';
@


18.3
log
@Pws2unix automatic delta on Sun May 31 14:33:16 MDT 1987
@
text
@@


18.2
log
@fixed a bunch of bugs:
FSDat00992: MKHFS complains when making fs on BUBBLES
FSDat01087: MKHFS gives RAM vols minfree default of 10%. should be 0??
FSDat01088: MKHFS on RAM vol can change RAM outside volume, if D option large
FSDat01154: device size specified too small gives err -10 and changes unitable
FSDat01156: message given when minfree or data/inode bad uses word "bogus"
and a few more that Scott and I talked about
@
text
@d1311 2
a1312 2
  previd = daterec[year:87, day:1, month:5];
  prevno = '3.2Ix';
@


18.1
log
@Automatic bump of revision number for PWS version 3.2J
@
text
@d308 26
d663 2
d875 2
a876 2
	    sectors: 1,
	    tracks: 1,
d898 2
a899 2
	    param[nsect].value  := 4;
	    param[ntrack].value := 2;
d929 3
a931 2
    { minfree always 0 on floppies }
    if not unitable^[vol_unit].uisfixed then
d1218 1
d1224 2
d1227 1
a1227 1
	umaxbytes := phys_size;
d1229 3
d1233 1
d1237 13
d1251 1
d1311 2
a1312 2
  previd = daterec[year:87, day:19, month:5];
  prevno = '3.2J';
d1397 17
d1481 2
d1497 1
d1501 1
d1503 2
d1512 1
a1514 3



@


17.2
log
@Pws2unix automatic delta on Wed May 20 09:57:02 MDT 1987
@
text
@@


17.1
log
@Automatic bump of revision number for PWS version 3.2I+
@
text
@d1261 2
a1262 2
  previd = daterec[year:87, day:24, month:4];
  prevno = '3.2I';
@


16.1
log
@Automatic bump of revision number for PWS version 3.2I
@
text
@@


15.2
log
@Pws2unix automatic delta on Fri Apr 24 18:41:36 MDT 1987
@
text
@@


15.1
log
@Automatic bump of revision number for PWS version 3.2H
@
text
@d1261 2
a1262 2
  previd = daterec[year:87, day:11, month:4];
  prevno = '3.2H';
@


14.2
log
@Pws2unix automatic delta on Sun Apr 12 17:10:24 MDT 1987
@
text
@@


14.1
log
@Automatic bump of revision number for PWS version 3.2G
@
text
@d1261 2
a1262 2
  previd = daterec[year:87, day:31, month:3];
  prevno = '3.2G';
@


13.2
log
@Pws2unix automatic delta on Wed Apr  1 08:30:27 MST 1987
@
text
@@


13.1
log
@Automatic bump of revision number for PWS version 3.2F
@
text
@d1261 2
a1262 2
  previd = daterec[year:87, day:27, month:2];
  prevno = '3.2F';
@


12.2
log
@Pws2unix automatic delta on Sat Feb 28 15:17:33 MST 1987
@
text
@@


12.1
log
@Automatic bump of revision number for PWS version 3.2E
@
text
@d1261 2
a1262 2
  previd = daterec[year:87, day:30, month:01];
  prevno = '3.2';
@


11.2
log
@Pws2unix automatic delta on Mon Feb  2 09:47:34 MST 1987
@
text
@@


11.1
log
@Automatic bump of revision number for PWS version 3.2D
@
text
@d1261 2
a1262 2
  previd = daterec[year:87, day:18, month:1];
  prevno = '3.2D';
@


10.2
log
@Pws2unix automatic delta on Sun Jan 18 18:33:43 MST 1987
@
text
@@


10.1
log
@Automatic bump of revision number for PWS version 3.2C
@
text
@d1261 2
a1262 2
  previd = daterec[year:86, day:23, month:12];
  prevno = '3.2C';
@


9.3
log
@Pws2unix automatic delta on Tue Dec 23 16:24:27 MST 1986
@
text
@@


9.2
log
@Fix for FSDat00685 -- Put today's date/time in LIF header
@
text
@d1261 2
a1262 2
  previd = daterec[year:86, day:26, month:11];
  prevno = '3.2A';
@


9.1
log
@Automatic bump of revision number for PWS version 3.2B
@
text
@d18 1
d374 1
a374 1
import sysglobals, fs, misc;
d502 17
d548 1
d1261 2
a1262 2
  previd = daterec[year:86, day:11, month:12];
  prevno = '3.2B';
@


8.5
log
@Pws2unix automatic delta on Fri Dec 12 09:42:40 MST 1986
@
text
@@


8.4
log
@Fixes RAM volume problems (hang, etc.) Note: 8.3 fixed physical size problem
for RAM volumes.
@
text
@d1242 2
a1243 2
  previd = daterec[year:86, day:26, month:11];
  prevno = '3.2A';
@


8.3
log
@FSDat00594 -- Fix physical size so don't count same device twice
FSDat00639 -- Fix coalesce_volumes so units with same byteoffset not zapped.
@
text
@d1177 2
a1178 1
	byteoffset := 0;
@


8.2
log
@Bug fixes in 3.2A
@
text
@d743 3
d752 7
a758 4
    total_size := 0;
    for i := 1 to maxunit do
	if on_same_medium(unit, addr(unitable^[i])) then
	    total_size := total_size + ueovbytes(i);
a1169 3
    for i := 1 to maxunit do
	if on_same_medium(unit, addr(unitable^[i])) and (unit <> i) then
	    zap_unit(i);
d1171 5
a1420 2


@


8.1
log
@Automatic bump of revision number for PWS version 3.2A
@
text
@d424 2
a425 2
    DIRSTART = 2;       { directory start, in sectors, 0-based }
    DIRBLKS = 1;        { how many dir sectors }
d444 2
a445 6
  if f = 0 then
    fwritebytes(liffile, buf^, count)
  else begin
    call(unitable^[f].tm, addr(liffib), writebytes, buf^, count, lifposition);
    lifposition := lifposition + count;
  end;
d454 1
a454 4
  if f = 0 then
    try close(liffile, 'save'); recover
  else
    fcloseit(liffib, 'save');
d477 1
a477 10
  if ftitle <> '' then begin
    { not a volume.  try to do io through file, shown as unit 0 }
$if 1=0$
    try
      open(liffile, volname);
    recover
      ;
    if ioresult = 0 then
      volopen := 0;
$end$
a478 1
  end;
d550 1
a550 1
		fstart := 2 + DIRBLKS;
d892 1
a892 1
  writeln;
d901 1
a901 1
{       vol_unit -- unit number for vol_name, or 0 if not a volume
d951 2
a952 1
  if not scantitle(vol_name, vol_vid, ftitle, fsegs, fkind) then begin
d957 6
a962 16
  { allow ordinary filename if user says OK }
  if ftitle <> '' then begin
    write('That is an ordinary file, not a volume.  OK? (y/n) ');
    ansc := read_char(char_set_type['Y','N']);
    writeln;
    if ansc = 'N' then goto 1;
    vol_unit := 0;
  end
  { not an ordinary filename, so be sure it's a real volume }
  else begin
    vol_unit := findvolume(vol_vid, true);
    findvolume_ioresult := ioresult;
    if vol_unit = 0 then begin
      writeln('No such volume');
      goto 1;
    end;
d978 1
a978 1
  writeln;
d1413 2
@


7.4
log
@Pws2unix automatic delta on Wed Nov 26 16:18:22 MST 1986
@
text
@@


7.3
log
@LIF BOOT dir gets name Vxx, not BOOTxx, where xx is the unit number.
@
text
@d5 5
a9 5
	'CLIBRARY2',
	'CS80',
	'DRVASM',
	'DISCHPIB',
	'KERNEL'$
d1259 2
a1260 2
  previd = daterec[year:86, day:3, month:11];
  prevno = '3.2k';
@


7.2
log
@Coalesce automatically if more than one unit on disk.  Use
physical size, not size in unitable.
@
text
@d532 1
a532 1
	volname := 'BOOT  ';
d538 1
a538 1
	    volname[5] := chr(ord('0') + nameunit)
d540 2
a541 2
	    volname[5] := chr(ord('0') + nameunit div 10);
	    volname[6] := chr(ord('0') + nameunit mod 10);
@


7.1
log
@Automatic bump of revision number for PWS version 3.2l
@
text
@d5 5
a9 5
	'PCLIB:CLIBRARY2',
	'INIT:CS80',
	'INIT:DRVASM',
	'INIT:DISCHPIB',
	'IOLIB:KERNEL'$
d45 2
d595 1
a595 1
  sysglobals, fs, misc, sysdevs, mkfs, volid, lifhdr, clib;
d756 18
d854 3
a856 2
    { ignore physical size, since we will go through tm anyway }
    param[devsize].value := ueovbytes(vol_unit) div 1024;
d1157 43
d1237 16
d1259 2
a1260 2
  previd = daterec[year:86, day:10, month:11];
  prevno = '3.2l';
d1418 2
d1425 1
@


6.4
log
@Pws2unix automatic delta on Wed Nov 19 15:16:12 MST 1986
@
text
@@


6.3
log
@Fix on_same_medium so that it doesn't say that 2 RAM volumes are
on the same medium.  Otherwise, the "will also destroy"
warning is wrong.
@
text
@d1179 2
a1180 2
  previd = daterec[year:86, day:3, month:11];
  prevno = '3.2k';
@


6.2
log
@Remove code that puts SYSTEM_P entry into boot directory.  OSINSTALL
is the right tool for this.
@
text
@d94 3
a96 1
			(letter=uep^.letter);
@


6.1
log
@Automatic bump of revision number for PWS version 3.2k
@
text
@a569 4
	{TMP FOR DEMO}
	dirblk[1].fname := 'SYSTEM_P'#0#0;
	dirblk[1].ftype := HPUX_BOOT;
	{END OF TMP FOR DEMO}
@


5.2
log
@Pws2unix automatic delta on Tue Nov  4 11:36:56 MEZ 1986
@
text
@@


5.1
log
@Automatic bump of revision number for PWS version 3.2j
@
text
@d1181 2
a1182 2
  previd = daterec[year:86, day:23, month:10];
  prevno = '3.2j';
@


4.5
log
@Pws2unix automatic delta on Tue Oct 28 10:57:29 MEZ 1986
@
text
@@


4.4
log
@$SEARCH for PCLIB:CLIBRARY2$
@
text
@d4 1
a4 1
$search 'MKFSC',
d1180 3
a1182 5
procedure write_program_header;

const
  previd = daterec[year:86, day:28, month:8];
  prevno = '3.2g';
@


4.3
log
@After mkfs runs, set all prefixes for this disk
to /, and all uvids to ''.
@
text
@d5 1
a5 1
	'CLIBRARY',
@


4.2
log
@Add listing file capability.  Also, turn off debug, range, ovflcheck.
@
text
@d1246 1
d1249 3
d1257 7
a1263 1
	    tbl[tbl[unum].base_unum].fs_corrupt := false;
@


4.1
log
@Automatic bump of revision number for PWS version 3.2i
@
text
@d12 5
a16 1
$debug on$
d632 1
d897 1
d905 1
d911 3
d915 4
d926 23
a948 1
  { split into pieces and check syntax }
d1266 1
a1266 1
  argvtype = array[1..mkfs_argc] of string255ptr;
d1269 1
a1269 1
  i, dummy: integer;
d1271 6
a1276 1
  for i := 1 to mkfs_argc do begin
d1306 3
d1310 1
a1310 1
  for i := 1 to mkfs_argc do begin
d1317 1
a1317 1
    i := main(mkfs_argc, addr(argv));
@


3.5
log
@Reorder confirmation prompts to prevent abruptly overwriting disk
if user says "n" to "Change or examine default parameters? (y/n)".
@
text
@@


3.4
log
@Change volume name from HFSdd to BOOTdd.  Also, use base volume
number if available.  Result -- MKHFS on #43 (or #3) produces BOOT3 on #3,
hfs3 on #43.
@
text
@d116 1
a116 1
		    writeln('WARNING: the initialization will also destroy:');
d947 1
a947 1
  write('Are you SURE you want to proceed? (y/n) ');
d1286 1
a1286 1
  if vol_unit <> 0 then begin
a1287 2
    confirm_volume;
  end;
d1292 1
@


3.3
log
@Add table of sector/track layout for disks that don't
identify themselves.  CS80 913xD/H/L devices all set to nsect 8, 
ntrack 4.  RAM volumes given default too.  Result -- very few
disks will cause MKHFS to ask for parameters.
@
text
@d513 1
a513 1
    unit: integer;
d524 7
a530 3
	volname := 'HFS   ';
	if unit < 10 then
	    volname[4] := chr(ord('0') + unit)
d532 2
a533 2
	    volname[4] := chr(ord('0') + unit div 10);
	    volname[5] := chr(ord('0') + unit mod 10);
@


3.2
log
@Allows MKHFS on a memory volume.
@
text
@d753 65
d829 25
@


3.1
log
@Automatic bump of revision number for PWS version 3.2h
@
text
@d44 1
a44 1
    sup_dev_type = (M,N,U,V,W,H,F,C,D,P,X,B,Q); {supported devices}
d46 1
a46 1
    dev_name_type = array [M..B] of string27;                   {rdq}
d69 2
a70 1
	  {B}  'HP98259 bubble memory'];                        {rdq}
d253 1
d329 1
d336 2
a337 1
	writeln;
@


1.1
log
@Initial revision
@
text
@@
