head     56.3;
access   paws bayes jws quist brad dew jwh;
symbols  ;
locks    ; strict;
comment  @ * @;


56.3
date     93.01.27.13.38.51;  author jwh;  state Exp;
branches ;
next     56.2;

56.2
date     93.01.27.12.14.01;  author jwh;  state Exp;
branches ;
next     56.1;

56.1
date     91.11.05.09.35.55;  author jwh;  state Exp;
branches ;
next     55.1;

55.1
date     91.08.25.10.14.31;  author jwh;  state Exp;
branches ;
next     54.1;

54.1
date     91.03.18.15.21.29;  author jwh;  state Exp;
branches ;
next     53.1;

53.1
date     91.03.11.19.22.47;  author jwh;  state Exp;
branches ;
next     52.1;

52.1
date     91.02.19.09.06.27;  author jwh;  state Exp;
branches ;
next     51.1;

51.1
date     91.01.30.16.05.37;  author jwh;  state Exp;
branches ;
next     50.1;

50.1
date     90.10.29.16.21.02;  author jwh;  state Exp;
branches ;
next     49.1;

49.1
date     90.08.14.14.05.22;  author jwh;  state Exp;
branches ;
next     48.1;

48.1
date     90.07.26.11.11.06;  author jwh;  state Exp;
branches ;
next     47.1;

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

46.1
date     90.05.07.08.37.30;  author jwh;  state Exp;
branches ;
next     45.1;

45.1
date     90.04.19.15.44.49;  author jwh;  state Exp;
branches ;
next     44.1;

44.1
date     90.04.01.22.02.37;  author jwh;  state Exp;
branches ;
next     43.1;

43.1
date     90.03.20.13.52.30;  author jwh;  state Exp;
branches ;
next     42.1;

42.1
date     90.01.23.17.37.52;  author jwh;  state Exp;
branches ;
next     41.1;

41.1
date     89.12.22.11.20.18;  author jwh;  state Exp;
branches ;
next     40.1;

40.1
date     89.09.29.11.43.00;  author jwh;  state Exp;
branches ;
next     39.1;

39.1
date     89.09.26.16.28.21;  author dew;  state Exp;
branches ;
next     38.1;

38.1
date     89.08.29.11.19.07;  author jwh;  state Exp;
branches ;
next     37.1;

37.1
date     89.05.12.11.32.27;  author dew;  state Exp;
branches ;
next     36.1;

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

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

34.1
date     89.01.23.15.58.43;  author jwh;  state Exp;
branches ;
next     33.1;

33.1
date     89.01.16.11.33.23;  author dew;  state Exp;
branches ;
next     32.1;

32.1
date     89.01.10.11.39.52;  author bayes;  state Exp;
branches ;
next     31.1;

31.1
date     88.12.14.18.00.54;  author bayes;  state Exp;
branches ;
next     30.1;

30.1
date     88.12.09.13.38.56;  author dew;  state Exp;
branches ;
next     29.1;

29.1
date     88.10.31.15.23.07;  author bayes;  state Exp;
branches ;
next     28.1;

28.1
date     88.10.06.10.52.03;  author dew;  state Exp;
branches ;
next     27.1;

27.1
date     88.09.29.11.18.42;  author bayes;  state Exp;
branches ;
next     26.1;

26.1
date     88.09.28.12.37.52;  author bayes;  state Exp;
branches ;
next     25.1;

25.1
date     88.03.02.09.14.35;  author bayes;  state Exp;
branches ;
next     24.1;

24.1
date     87.08.31.09.27.58;  author jws;  state Exp;
branches ;
next     23.1;

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

22.2
date     87.08.20.16.01.15;  author bayes;  state Exp;
branches ;
next     22.1;

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

21.2
date     87.08.13.17.46.41;  author bayes;  state Exp;
branches ;
next     21.1;

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

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

20.1
date     87.07.30.10.44.18;  author bayes;  state Exp;
branches ;
next     19.1;

19.1
date     87.06.01.08.01.57;  author jws;  state Exp;
branches ;
next     18.1;

18.1
date     87.05.20.14.57.09;  author bayes;  state Exp;
branches ;
next     17.1;

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

16.1
date     87.04.26.15.27.07;  author jws;  state Exp;
branches ;
next     15.1;

15.1
date     87.04.13.08.56.23;  author jws;  state Exp;
branches ;
next     14.1;

14.1
date     87.04.01.14.55.16;  author jws;  state Exp;
branches ;
next     13.1;

13.1
date     87.02.28.18.14.35;  author jws;  state Exp;
branches ;
next     12.1;

12.1
date     87.02.02.13.02.49;  author jws;  state Exp;
branches ;
next     11.1;

11.1
date     87.01.19.09.28.26;  author jws;  state Exp;
branches ;
next     10.1;

10.1
date     86.12.24.10.35.31;  author jws;  state Exp;
branches ;
next     9.1;

9.1
date     86.12.12.14.03.05;  author bayes;  state Exp;
branches ;
next     8.1;

8.1
date     86.11.27.11.32.52;  author jws;  state Exp;
branches ;
next     7.1;

7.1
date     86.11.20.13.21.34;  author hal;  state Exp;
branches ;
next     6.1;

6.1
date     86.11.04.17.26.09;  author paws;  state Exp;
branches ;
next     5.1;

5.1
date     86.10.28.16.10.39;  author hal;  state Exp;
branches ;
next     4.2;

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

4.1
date     86.09.30.19.25.03;  author hal;  state Exp;
branches ;
next     3.2;

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

3.1
date     86.09.01.11.34.58;  author hal;  state Exp;
branches ;
next     2.5;

2.5
date     86.08.27.12.38.39;  author hal;  state Exp;
branches ;
next     2.4;

2.4
date     86.08.26.16.19.43;  author hal;  state Exp;
branches ;
next     2.3;

2.3
date     86.08.25.10.43.12;  author hal;  state Exp;
branches ;
next     2.2;

2.2
date     86.08.20.16.38.28;  author hal;  state Exp;
branches ;
next     2.1;

2.1
date     86.07.30.14.25.36;  author hal;  state Exp;
branches ;
next     1.9;

1.9
date     86.07.29.12.56.30;  author hal;  state Exp;
branches ;
next     1.8;

1.8
date     86.07.23.18.41.30;  author hal;  state Exp;
branches ;
next     1.7;

1.7
date     86.07.17.08.30.38;  author hal;  state Exp;
branches ;
next     1.6;

1.6
date     86.07.14.13.48.16;  author hal;  state Exp;
branches ;
next     1.5;

1.5
date     86.07.11.14.21.37;  author hal;  state Exp;
branches ;
next     1.4;

1.4
date     86.07.04.11.12.32;  author hal;  state Exp;
branches ;
next     1.3;

1.3
date     86.06.30.20.45.46;  author danm;  state Exp;
branches ;
next     1.2;

1.2
date     86.06.06.13.41.56;  author danm;  state Exp;
branches ;
next     1.1;

1.1
date     86.06.04.08.44.27;  author geli;  state tmp;
branches ;
next     ;


desc
@Base file for PWS 3.2 release.

@


56.3
log
@
pws2rcs automatic delta on Wed Jan 27 13:14:25 MST 1993
@
text
@$modcal$

$linenum 3000$
$lines 54$

$partial_eval on$
$allow_packed on$

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

module hfs_tm_module;


$search 'hfs'$
import
    hfstuff,
    hfsalloc,
    hfscache,
    hfscalc,
    sysglobals,
    hfsupport, {debug only}
    misc;


export

procedure hfstm(fp: fibp; request: amrequesttype;
		anyvar buffer: window; bufsize, position: integer);

implement

const
    debug = false;

procedure hfstm(fp : fibp; request : amrequesttype;
		anyvar buffer : window; bufsize, position : integer);
label
    999;
var
    tmpioresult: integer; {for debug stuff at end}
    fs: super_block_ptr_type;
    rwflag: bmap_mode;
    bufstart: integer;
    old_tm: amtype;
    ip: inode_ptr_type;
    tmp_fpeof, tmp_fleof, tmp_fileid: integer;
    i: integer;
    xstart, xsize: integer;
    tstart, tsize: integer;
    filetype: integer;
    perm_needed: permission_type;
    reading, writing: boolean;
{-----------------------------------}
{
{ find next disc addr for given position
{ result
{       tstart -- disc addr
{       tsize -- size of xfer allowed
{ tstart 0 => reading hole
}
procedure next_daddr(pos, size: integer);
var
    blocknum, blockoffset: integer;
begin
    blockoffset := blkoff(fs, pos);
    tsize := min(size, fs^.bsize - blockoffset);
    blocknum := get_dbnum(ip, pos, rwflag, tsize);
    if blocknum = BMAP_HOLE then
	tstart := 0
    else
    if blocknum = BMAP_ERROR then
	{don't nuke disc. Not sure if corrupt. But do,
	 fershure, guarantee non-zero ioresult, as we will
	 not complete requested IO.  SFB}
       begin
	 if ioresult = ord(inoerror) then
	  ioresult:=ord(znoblock);     {as bmap is trying to find a
					given (user) data block. SFB}
	 escape(0);
       end
    else
	tstart := fragstobytes(fs, blocknum) + blockoffset;
end;
{-----------------------------------}
{
{ accumulate disc blocks until one is non-contiguous, or
{ until we have the desired xfer size.
{ result
{       xstart -- disc addr
{       xsize -- xfer size
{ tstart <> -1 means tstart/tsize is beginning of this xfer,
{ left over from last call to accumulate.
}
procedure accumulate;
var
    contig: boolean;
begin
    if tstart = -1 then
	next_daddr(position, bufsize);
    xstart := tstart;
    xsize := tsize;
    contig := true;
    while contig and (xsize < bufsize) do begin
	next_daddr(position + xsize, bufsize - xsize);
	if (xstart + xsize = tstart)
	or ((xstart = 0) and (tstart = 0)) then
	    xsize := xsize + tsize
	else
	    contig := false;
    end;
end;
{-----------------------------------}
begin {hfstm}
    old_tm := h_unitable^.tbl[fp^.funit].tm;

    case request of
	readbytes, startread:
	    begin
		reading := true;
		writing := false;
	    end;
	writebytes, startwrite:
	    begin
		reading := false;
		writing := true;
	    end;
	otherwise
	    begin
		reading := false;
		writing := false;
	    end;
    end;
    {
    { some requests go straight to original tm
    }
    if (not reading and not writing)
    or (fp^.pathid = raw_inode)
    or (bufsize = 0) then begin
	call(old_tm, fp, request,
		      buffer, bufsize, position);
	goto 999;
    end;

    {
    { Don't allow HFS writes on a corrupt file system
    }
    if writing then
	with h_unitable^ do
	    if tbl[tbl[fp^.funit].base_unum].fs_corrupt then begin
		ioresult := ord(icorrupt);
		goto 999;
	    end;

    {
    { now we have a real HFS request
    }
    if (position < 0) or (bufsize < 0)
    or (position + bufsize > fp^.fpeof) then begin
	ioresult := ord(ieof);
	goto 999;
    end;

    ioresult := ord(inoerror);
    ip := nil;
    try
	lockup;
	{
	{ change fib so can use old tm to xfer anywhere on disc
	{ fileid has wshdr offset, so add it to position to get raw position
	}
	with fp^ do begin
	    tmp_fpeof := fpeof;
	    fpeof := unitable^[funit].umaxbytes;
	    tmp_fleof := fleof;
	    fleof := fpeof;
	    position := position + fileid;
	    tmp_fileid := fileid;
	    fileid := 0;
	end;

	{ get_superblock never escapes }
	fs := get_superblock(fp^.funit);
	if fs = nil then
	    escape(0);

	{ get_inode escapes on error }
	ip := get_inode(fp^.pathid);

	filetype := itype(ip);
	if (filetype = IFDIR)
	or (filetype = IFCHR)
	or (filetype = IFBLK) then begin
	    ioresult := ord(inoaccess);
	    escape(0);
	end;

	{
	{ Check permission.  This can't always be done at
	{ open time (DAM sees no difference between FS reset and open),
	{ and adds security against faking a FIB.
	}
	if reading then begin
	    rwflag := B_READ;
	    perm_needed := r_permission;
	end
	else begin
	    rwflag := B_WRITE;
	    perm_needed := w_permission;
	end;
	if not permission(ip, perm_needed) then
	    escape(0);

	tstart := -1;
	bufstart := 0;

	while bufsize > 0 do begin
	    { accumulate contiguous xfers in xstart, xsize }
	    accumulate;
	    { xstart 0 means we're reading a hole }
	    if xstart = 0 then
		for i := bufstart to bufstart + xsize - 1 do
		    buffer[i] := #0
	    else begin
		call(old_tm, fp, request,
			     buffer[bufstart], xsize, xstart);
	    end;
	    position := position + xsize;
	    bufstart := bufstart + xsize;
	    bufsize  := bufsize  - xsize;
	end;
	escape(0);

    recover begin
       { reset fib fields to original state }
	with fp^ do begin
	    fpeof  := tmp_fpeof;
	    fleof  := tmp_fleof;
	    fileid := tmp_fileid;
	end;

       {the following can never escape. (cross fingers ;-). SFB}
	put_inode(ip, [release]);       {may be dirty now. SFB}
	put_superblock(fs, [release]);  {may be dirty now. SFB}


       {Note that hfstm never syncs. This is a performance optimization.
	Whenever the tm calls get_dbnum with rwflag = B_WRITE, the file inode
	and superblock cache records are changed and marked dirty. They
	are not flushed yet; that is done by the hfsdam. As long as the
	file is closed, this is OK. Since the OS closes all "supported"
	files (watch out for files on the heap, as these may not be closed)
	when the program exits either normally or by escaping, the strategy
	in general works. This strategy increases write performance a lot,
	but having dirty records in the cache at entry to dam or tm can
	complicate things, especially when the records are for base_unum X,
	and the driver is called on base_unum Y. The driver may need to flush
	a dirty record to get a free cache record; see get/put_bytes for
	details on solving this problem.
	SFB
       }

	if escapecode <> 0 then
	    nuke_unit(fp^.funit);       {assume any untrapped escape in tm
					 corrupts disc. SFB}
	lockdown;
	if (escapecode <> -10) and (escapecode <> 0) then
	    escape(escapecode);
    end;
999:
end;

end.
@


56.2
log
@
pws2rcs automatic delta on Wed Jan 27 11:57:27 MST 1993
@
text
@d1 274
@


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@a0 274
$modcal$

$linenum 3000$
$lines 54$

$partial_eval on$
$allow_packed on$

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

module hfs_tm_module;


$search 'hfs'$
import
    hfstuff,
    hfsalloc,
    hfscache,
    hfscalc,
    sysglobals,
    hfsupport, {debug only}
    misc;


export

procedure hfstm(fp: fibp; request: amrequesttype;
		anyvar buffer: window; bufsize, position: integer);

implement

const
    debug = false;

procedure hfstm(fp : fibp; request : amrequesttype;
		anyvar buffer : window; bufsize, position : integer);
label
    999;
var
    tmpioresult: integer; {for debug stuff at end}
    fs: super_block_ptr_type;
    rwflag: bmap_mode;
    bufstart: integer;
    old_tm: amtype;
    ip: inode_ptr_type;
    tmp_fpeof, tmp_fleof, tmp_fileid: integer;
    i: integer;
    xstart, xsize: integer;
    tstart, tsize: integer;
    filetype: integer;
    perm_needed: permission_type;
    reading, writing: boolean;
{-----------------------------------}
{
{ find next disc addr for given position
{ result
{       tstart -- disc addr
{       tsize -- size of xfer allowed
{ tstart 0 => reading hole
}
procedure next_daddr(pos, size: integer);
var
    blocknum, blockoffset: integer;
begin
    blockoffset := blkoff(fs, pos);
    tsize := min(size, fs^.bsize - blockoffset);
    blocknum := get_dbnum(ip, pos, rwflag, tsize);
    if blocknum = BMAP_HOLE then
	tstart := 0
    else
    if blocknum = BMAP_ERROR then
	{don't nuke disc. Not sure if corrupt. But do,
	 fershure, guarantee non-zero ioresult, as we will
	 not complete requested IO.  SFB}
       begin
	 if ioresult = ord(inoerror) then
	  ioresult:=ord(znoblock);     {as bmap is trying to find a
					given (user) data block. SFB}
	 escape(0);
       end
    else
	tstart := fragstobytes(fs, blocknum) + blockoffset;
end;
{-----------------------------------}
{
{ accumulate disc blocks until one is non-contiguous, or
{ until we have the desired xfer size.
{ result
{       xstart -- disc addr
{       xsize -- xfer size
{ tstart <> -1 means tstart/tsize is beginning of this xfer,
{ left over from last call to accumulate.
}
procedure accumulate;
var
    contig: boolean;
begin
    if tstart = -1 then
	next_daddr(position, bufsize);
    xstart := tstart;
    xsize := tsize;
    contig := true;
    while contig and (xsize < bufsize) do begin
	next_daddr(position + xsize, bufsize - xsize);
	if (xstart + xsize = tstart)
	or ((xstart = 0) and (tstart = 0)) then
	    xsize := xsize + tsize
	else
	    contig := false;
    end;
end;
{-----------------------------------}
begin {hfstm}
    old_tm := h_unitable^.tbl[fp^.funit].tm;

    case request of
	readbytes, startread:
	    begin
		reading := true;
		writing := false;
	    end;
	writebytes, startwrite:
	    begin
		reading := false;
		writing := true;
	    end;
	otherwise
	    begin
		reading := false;
		writing := false;
	    end;
    end;
    {
    { some requests go straight to original tm
    }
    if (not reading and not writing)
    or (fp^.pathid = raw_inode)
    or (bufsize = 0) then begin
	call(old_tm, fp, request,
		      buffer, bufsize, position);
	goto 999;
    end;

    {
    { Don't allow HFS writes on a corrupt file system
    }
    if writing then
	with h_unitable^ do
	    if tbl[tbl[fp^.funit].base_unum].fs_corrupt then begin
		ioresult := ord(icorrupt);
		goto 999;
	    end;

    {
    { now we have a real HFS request
    }
    if (position < 0) or (bufsize < 0)
    or (position + bufsize > fp^.fpeof) then begin
	ioresult := ord(ieof);
	goto 999;
    end;

    ioresult := ord(inoerror);
    ip := nil;
    try
	lockup;
	{
	{ change fib so can use old tm to xfer anywhere on disc
	{ fileid has wshdr offset, so add it to position to get raw position
	}
	with fp^ do begin
	    tmp_fpeof := fpeof;
	    fpeof := unitable^[funit].umaxbytes;
	    tmp_fleof := fleof;
	    fleof := fpeof;
	    position := position + fileid;
	    tmp_fileid := fileid;
	    fileid := 0;
	end;

	{ get_superblock never escapes }
	fs := get_superblock(fp^.funit);
	if fs = nil then
	    escape(0);

	{ get_inode escapes on error }
	ip := get_inode(fp^.pathid);

	filetype := itype(ip);
	if (filetype = IFDIR)
	or (filetype = IFCHR)
	or (filetype = IFBLK) then begin
	    ioresult := ord(inoaccess);
	    escape(0);
	end;

	{
	{ Check permission.  This can't always be done at
	{ open time (DAM sees no difference between FS reset and open),
	{ and adds security against faking a FIB.
	}
	if reading then begin
	    rwflag := B_READ;
	    perm_needed := r_permission;
	end
	else begin
	    rwflag := B_WRITE;
	    perm_needed := w_permission;
	end;
	if not permission(ip, perm_needed) then
	    escape(0);

	tstart := -1;
	bufstart := 0;

	while bufsize > 0 do begin
	    { accumulate contiguous xfers in xstart, xsize }
	    accumulate;
	    { xstart 0 means we're reading a hole }
	    if xstart = 0 then
		for i := bufstart to bufstart + xsize - 1 do
		    buffer[i] := #0
	    else begin
		call(old_tm, fp, request,
			     buffer[bufstart], xsize, xstart);
	    end;
	    position := position + xsize;
	    bufstart := bufstart + xsize;
	    bufsize  := bufsize  - xsize;
	end;
	escape(0);

    recover begin
       { reset fib fields to original state }
	with fp^ do begin
	    fpeof  := tmp_fpeof;
	    fleof  := tmp_fleof;
	    fileid := tmp_fileid;
	end;

       {the following can never escape. (cross fingers ;-). SFB}
	put_inode(ip, [release]);       {may be dirty now. SFB}
	put_superblock(fs, [release]);  {may be dirty now. SFB}


       {Note that hfstm never syncs. This is a performance optimization.
	Whenever the tm calls get_dbnum with rwflag = B_WRITE, the file inode
	and superblock cache records are changed and marked dirty. They
	are not flushed yet; that is done by the hfsdam. As long as the
	file is closed, this is OK. Since the OS closes all "supported"
	files (watch out for files on the heap, as these may not be closed)
	when the program exits either normally or by escaping, the strategy
	in general works. This strategy increases write performance a lot,
	but having dirty records in the cache at entry to dam or tm can
	complicate things, especially when the records are for base_unum X,
	and the driver is called on base_unum Y. The driver may need to flush
	a dirty record to get a free cache record; see get/put_bytes for
	details on solving this problem.
	SFB
       }

	if escapecode <> 0 then
	    nuke_unit(fp^.funit);       {assume any untrapped escape in tm
					 corrupts disc. SFB}
	lockdown;
	if (escapecode <> -10) and (escapecode <> 0) then
	    escape(escapecode);
    end;
999:
end;

end.
@


55.1
log
@Automatic bump of revision number for PWS version 3.25A
@
text
@@


54.1
log
@Automatic bump of revision number for PWS version 3.24
@
text
@@


53.1
log
@Automatic bump of revision number for PWS version 3.24B
@
text
@@


52.1
log
@Automatic bump of revision number for PWS version 3.24A
@
text
@@


51.1
log
@Automatic bump of revision number for PWS version 3.24d
@
text
@@


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


49.1
log
@Automatic bump of revision number for PWS version 3.24b
@
text
@@


48.1
log
@Automatic bump of revision number for PWS version 3.24a
@
text
@@


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


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


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


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


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


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


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


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


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


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


37.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@@


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


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.1
log
@Automatic bump of revision number for PWS version 3.22D
@
text
@@


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


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


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


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


28.1
log
@Automatic bump of revision number for PWS version 3.3b
@
text
@@


27.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@@


26.1
log
@Automatic bump of revision number for PWS version 3.3 Synch
@
text
@@


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


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


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


22.2
log
@Fixed comment delimiter that disabled put_inode( , [release]). :-(
@
text
@@


22.1
log
@Automatic bump of revision number for PWS version 3.2N
@
text
@d243 1
a243 1
       {the following can never escape. (cross fingers ;-). SFB)
@


21.2
log
@Corrected escape/ioresult for get_dbnum fail in get_daddr.
@
text
@@


21.1
log
@Automatic bump of revision number for PWS version 3.2M
@
text
@d74 9
a82 1
	escape(0)
d265 2
a266 2
	    nuke_unit(fp^.funit);       {assume any escape in tm corrupts disc.
					 SFB}
@


20.2
log
@Fixed up main recover block, especially for escapecode <> -10. Fixed up
zero-fill generator loop for reading unallocated blocks. Note that
unit is considered corrupt for all untrapped escapes in tm.
@
text
@@


20.1
log
@Automatic bump of revision number for PWS version 3.2L
@
text
@a107 5
$if debug$
    if printmesg then
	writeln('TM request ', request, ', pos ', position:1,
		', size ', bufsize:1);
$end$
d215 1
a215 1
		for i := bufstart to bufstart + xsize do
a217 4
$if debug$
		if printmesg then
		writeln('old tm, start ', xstart:1, ', size ', xsize:1);
$end$
d228 1
a228 1
	{ reset fib fields to original state }
d235 3
a237 5
	try
	    put_inode(ip, [release]);
	    put_superblock(fs, [release]);
	recover
	     ;
a238 13
	{ sync only if escaping abnormally }
	if escapecode <> 0 then begin
	    { must sync before lockdown before escape }
	    sync;
	    lockdown;
$if debug$
	    tmpioresult := ioresult;
	    writeln('ESCAPE IN TM ', escapecode);
	    ioresult := tmpioresult;
$end$
	    if escapecode <> -10 then
		escape(escapecode);
	end;
d240 19
a258 3
$if debug$
	check_cache;
$end$
d260 2
a263 3
$if debug$
    freeze;
$end$
@


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


4.2
log
@Remove references to hfs_user.
@
text
@@


4.1
log
@Automatic bump of revision number for PWS version 3.2i
@
text
@d16 1
a16 1
$search 'hfs', 'hfs_user'$
@


3.2
log
@$if debug$ (off) around debugging code.
@
text
@@


3.1
log
@Automatic bump of revision number for PWS version 3.2h
@
text
@d1 5
a5 2
$LINENUM 3000$
$LINES 54$
d7 1
a7 2
$MODCAL$
$ALLOW_PACKED ON$
d16 1
a16 1
$search 'hfs'$
d34 3
d108 1
d112 1
d223 1
d226 1
d255 1
d259 1
d264 1
d266 1
d270 1
d272 1
@


2.5
log
@Slight rearrangements for efficiency.
Check get_dbnum for BMAP_ERROR.
@
text
@@


2.4
log
@Some debugging code new.
If get bufsie 0, pass on to old TM.
Don't escape -10; just leave ioresult.
@
text
@d49 1
d68 3
a105 1
    ioresult := ord(inoerror);
a106 1
    ip := nil;
d108 17
d128 1
a128 1
    if not (request in [readbytes,writebytes,startread,startwrite])
d139 1
a139 1
    if request in [writebytes,startwrite] then
d155 2
d194 1
a194 1
	if request in [readbytes,startread] then begin
@


2.3
log
@Debug etc now off.
@
text
@d21 1
d99 3
d110 2
a111 1
    or (fp^.pathid = raw_inode) then begin
d194 3
a196 1
	    else
d199 1
d228 2
a229 1
	    escape(escapecode);
d236 1
@


2.2
log
@Check read/write permission here, not at open.  Reason -- too
early at open time, also better security.
@
text
@d7 3
a9 3
{$range off$ $ovflcheck off$ {want to enable this line when finished}

$debug on$                  {debug OFF when finished}
@


2.1
log
@Auto bump rev number to 2.1 for sys 3.2e.
@
text
@d36 1
a36 1
    tmpioresult: integer;
d47 1
d163 10
a172 3
	if request in [readbytes,startread] then
	    rwflag := B_READ
	else
d174 4
@


1.9
log
@Don't check for corruption until after place where we send
some requests to old tm.  Also, check base unit, not current unit,
for fs_corrupt.
@
text
@@


1.8
log
@Don't allow a write on a corrupt file system.
@
text
@a16 1
    hfsupport, { hfsupport for debugging stuff only }
d36 1
d98 1
a98 9
    with h_unitable^.tbl[fp^.funit] do begin
	{ don't allow writes on a corrupt file system }
	if fs_corrupt and (request in [writebytes,startwrite]) then begin
	    ioresult := ord(icorrupt);
	    goto 999;
	end;
	old_tm := tm;
    end;

d112 10
d205 1
d207 1
a207 1
	    freeze;
@


1.7
log
@Don't xfer data unless it's a file with contents.
Add some debugging code.
@
text
@d98 9
a106 1
    old_tm := h_unitable^.tbl[fp^.funit].tm;
@


1.6
log
@Completely rewritten.  Accumulates contiguous blocks correctly.
Calls get_dbnum correctly (can read and write holey files).
@
text
@d46 1
d144 8
d195 2
@


1.5
log
@remove code that accumulates consecutive big blocks.
fileid handled here now (add to position) rather than in
raw tm.
@
text
@d3 1
a3 1

d5 1
a12 1
$ALLOW_PACKED ON$
d14 9
a22 3
import $SEARCH 'hfs'$ hfstuff, hfsupport, hfsalloc, hfscache, hfscalc,
       iocomasm, sysglobals, sysdevs,
       misc, fs, asm;
d27 2
a28 2
  procedure hfstm(fp : fibp; request : amrequesttype;
			 anyvar buffer : window; bufsize, position : integer);
d32 67
a98 3
  procedure hfstm(fp : fibp; request : amrequesttype;
			 anyvar buffer : window; bufsize, position : integer);
  label 1;      {error exit for after we've done get_inode}
d100 9
a108 12
  var
    superblock  : super_block_ptr_type;
    inodep      : inode_ptr_type;
    bufstart    : integer;
    xstart      : integer;
    xsize       : integer;
    tstart      : integer;
    temppeof    : integer;
    templeof    : integer;
    tempfileid  : integer;
    TEMPERR     : integer;
    readrequest : boolean;
d110 8
a117 7
  function goterror : boolean;
  begin
   goterror := false;
   if (ioresult <> ord(inoerror)) then
    if not ({(ioresult = iocorrupt) and } readrequest) then
     goterror := true;
  end;
d119 15
a133 2
  $RANGE OFF$
  begin {hfstm}
d135 4
a138 6
    {reportn('tm request ',ord(request));
    reportn('peof ',fp^.fpeof);
    reportn('position ',position);
    reportn('bufsize', bufsize);}
    ioresult := ord(inoerror);
    lockup;
d140 2
a141 13
    try
      case request of
	readbytes,
	writebytes,
	startread,
	startwrite :
	  if (fp^.pathid > 1) or (fp^.pathid <-1) then
	  begin
	   superblock := get_superblock(fp^.funit);
	   if superblock <> nil then
	   with superblock^ do
	    begin
	     readrequest := (request = readbytes) or (request = startread);
d143 4
a146 12
	     with fp^ do
	      begin
	       temppeof := fpeof;
	       templeof := fleof;
	       tempfileid := fileid;
	       position := position + fileid;
	       fileid := 0;
	       fpeof    := unitable^[funit].umaxbytes;
	       fleof    := fpeof;
	      end;
	     {reportn('raw position', position);}
	     inodep := get_inode(fp^.pathid);
d148 2
a149 8
	    {we will try to grab as many contiguous bsize blocka here as we
	     need for large user data transfers. we do this by, as long as we
	     have more than data left in the requested transfer, seeing if the
	     next block pointed to on disc for the file is contiguous with the
	     preceding block(s). If it is, we add it to the size of contiguous
	     transfer we can do. When we either run out of requested data, or
	     contiguous blocks, we dump the buffer through the old tm, then
	     start accumulating contiguous blocks again if there's more to do}
d151 15
a165 5
	     if (ioresult = ord(inoerror)) or (readrequest) then
	      if (inodep^.size.ls >= position+bufsize) and (position >= 0)
	       and (bufsize>0) then
	       begin
		bufstart    := 0;
d167 7
a173 45
		while bufsize > 0 do begin
		  xsize       := min(bsize - (position mod bsize), bufsize);
		  {reportn('tm xsize', xsize);}
		  xstart      := get_dbnum(inodep, position, b_read, 0);
		  xstart      := data_start(superblock,xstart);
		  xstart      := xstart + (position mod bsize);
		  {reportn('xstart',xstart);}
		  if goterror then
		   begin
		    reportn('tm error in getting xstart',ioresult);
		    goto 1;
		   end;
		   {reportn('calling old tm, xsize = ',xsize);
		   reportn('                xstart  = ',xstart);}
		   call(h_unitable^[fp^.funit].tm, fp, request,
		       buffer[bufstart], xsize, xstart);
		   if ioresult <> 0 then
		    reportn('error in writebytes',ioresult);
		   position := position + xsize;
		   bufstart := bufstart + xsize;
		   bufsize := bufsize - xsize;
		 end;{while}
		end;{if}
	      1:
		  temperr := ioresult;
	      if temperr <> 0
	       then reportn('hfstm, restore fleof, fpeof',temperr);
	      {reportn('tm restore temppeof ',temppeof);
	      reportn('  templeof ',templeof);}
	      with fp^ do
	       begin
		fpeof := temppeof;
		fleof := templeof;
		fileid := tempfileid;
	       end;
	      put_inode(inodep, [release]);
	    end; {with}
	    put_superblock(superblock, [release]);
	   end {if}
	  else  {pathid = 0 ==> raw tm call}
	   BEGIN
	    report('IN HFSTM RAW ACCESS');
	    call(h_unitable^[fp^.funit].tm, fp, request, buffer,
		 bufsize, position);
	   END;
d175 5
a179 17
	 seekeof,
	 unitstatus,
	 clearunit,
	 flush,
	 writeeol,
	 readtoeol,
	 setcursor,
	 getcursor   : call(h_unitable^[fp^.funit].tm, fp, request,
				buffer, bufsize, position);
       end;      {case request}
     recover begin
	       reportn('tmescape',escapecode);
	       {freeze;}
	     end;
     lockdown;
  {freeze;}
  end;
d181 7
a187 1
end.
d189 5
a193 1
{ watch out for get_dbnum escaping }
d195 1
@


1.4
log
@change obsolete release_* cache calls
@
text
@d8 1
a8 1
$debug ON $                  {debug OFF when finished}
d39 1
d54 1
a54 4
    lockup;

    reportn('tm request ',ord(request));
    reportn('leof ',fp^.fleof);
a55 1
    reportn('bufsize ',bufsize);
d57 1
a57 6
    {
    for xstart:=0 to bufsize-1 do
     write(buffer[xstart]:1);
    writeln;
    }

d59 1
d79 3
d85 1
a85 1

a101 8
		xstart := get_dbnum(inodep, position, b_read, 0);
		xstart      := data_start(superblock,xstart);
		xstart := xstart + (position mod bsize);
		if goterror then
		 begin
		  reportn('tm error in getting xstart',ioresult);
		  goto 1;
		 end;
d103 8
a110 15
		xsize       := bsize - (position mod bsize);
		if bufsize <= xsize then    {buffer fits in current big block
					     or fragments}
		 begin
		  reportn('calling old tm, bufsize = ',bufsize);
		  reportn('                xstart  = ',xstart);
		  call(h_unitable^[fp^.funit].tm, fp, request, buffer,
		       bufsize, xstart);
		  if ioresult <> 0 then
		   reportn('error in writebytes',ioresult);
		 end
		else        {buffer covers more than 1 block}
		 begin
		  bufsize   := bufsize - xsize;
		  while bufsize > 0 do
d112 14
a125 30
		    tstart  := data_start(superblock,
				 get_dbnum(inodep, xstart+xsize, b_read, 0));
		    if goterror then
		     goto 1;
		    reportn('2nd tstart ',tstart);
		    while (tstart=(xstart+xsize)) and (bufsize > xsize) do
		     begin
		      xsize := xsize + bsize;
		      tstart:= data_start(superblock,
				 get_dbnum(inodep, xstart+bsize, b_read, 0));
		      if goterror then
		       goto 1;
		      reportn('nth tstart ',tstart);
		     end;
		    if xsize > bufsize then
		     xsize  := bufsize;
		    call(h_unitable^[fp^.funit].tm, fp, request,
			 buffer[bufstart], xsize, xstart);
		    if ioresult <> ord(inoerror) then
		     goto 1;
		    bufstart:= bufstart + xsize;
		    bufsize := bufsize - xsize;
		    xstart  := tstart;
		    xsize   := bsize;
		   end;   {while bufsize > 0 do}
		 end;     {buffer covers more than 1 block}
	       end        {sizes in range}
	      else
	       if bufsize <> 0 then
		ioresult := ord(ieof);
d130 2
a131 2
	      reportn('tm restore temppeof ',temppeof);
	      reportn('  templeof ',templeof);
d136 1
d138 2
a139 2
	    end;
	    put_inode(inodep, [release]);
d141 1
a141 1
	   end
d161 1
a161 1
	       freeze;
d164 1
d168 3
@


1.3
log
@changes from "newest" dam received 23.06.86 from Scott
@
text
@d173 2
a174 2
	    release_inode(inodep);
	    release_superblock(superblock);
@


1.2
log
@removal of cbit dependencies
@
text
@d135 1
a135 3
		    {
		    writeln('2nd tstart ',tstart:1);
		    }
d143 1
a143 3
		      {
		      writeln('nth tstart ',tstart:1);
		      }
d165 2
a166 4
	      {
	      writeln('tm restore temppeof ',temppeof:1,
		      '  templeof ',templeof:1);
	      }
d193 4
a196 2
     recover reportn('tmescape',escapecode);
     freeze;
@


1.1
log
@Initial revision
@
text
@d14 2
a15 2
import $SEARCH 'hfs'$ hfstuff, hfsupport, hfsalloc, hfscache, hfscalc, cbit,
       sysglobals, sysdevs,
@
