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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

23.1
date     87.08.26.10.03.10;  author bayes;  state Exp;
branches ;
next     22.1;

22.1
date     87.08.17.10.45.06;  author bayes;  state Exp;
branches ;
next     21.1;

21.1
date     87.08.12.13.31.33;  author bayes;  state Exp;
branches ;
next     20.1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

5.1
date     86.10.28.16.09.20;  author hal;  state Exp;
branches ;
next     4.1;

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

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

3.1
date     86.09.01.11.33.35;  author hal;  state Exp;
branches ;
next     2.2;

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

2.1
date     86.07.30.14.24.47;  author hal;  state Exp;
branches ;
next     1.4;

1.4
date     86.06.12.09.38.05;  author danm;  state Exp;
branches ;
next     1.3;

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

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

1.1
date     86.06.04.08.42.03;  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 11000$
$lines 54$

$partial_eval on$

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

{
{ Low-level calculation routines for getting byte offsets,
{ fragment sizes, etc. etc.  Largely a Pascal implementation of
{ the routines in fs.h, plus a few from param.h and sysmacros.h.
}

module hfscalc;


$search 'hfstuff'$
import hfstuff, iocomasm;

export

{
{ calculate starting byte of various objects
}
function inode_start(fs: super_block_ptr_type;
		     inode_num: integer): integer;
function data_start(fs: super_block_ptr_type;
		    dblock_num: integer): integer;
function cgroup_start(fs: super_block_ptr_type;
		      cgroup_num: integer): integer;

{
{ miscellany
}
function min(a, b: integer): integer;
function max(a, b: integer): integer;
function howmany(x: integer; y: integer): integer;
function roundup(x: integer; y: integer): integer;
function rounddownp2(x: integer; y: integer): integer;
function freespace(fs: super_block_ptr_type;
		   percentreserved: integer): integer;

{
{ bitmap manipulation
}
procedure setbit(anyvar a: freemap_type; i: integer);
procedure clrbit(anyvar a: freemap_type; i: integer);
function isset(anyvar a: freemap_type; i: integer): boolean;
function isclr(anyvar a: freemap_type; i: integer): boolean;
function blkmap(fs: super_block_ptr_type;
		 anyvar map: freemap_type; loc: integer): integer;

{
{ conversion
}
function btodb(i: integer): integer;
function fragstoblks(fs: super_block_ptr_type; frags: integer): integer;
function blkstofrags(fs: super_block_ptr_type; blks: integer): integer;
function cgtod(fs: super_block_ptr_type; c: integer): integer;
function dtog(fs: super_block_ptr_type; d: integer): integer;
function dtogd(fs: super_block_ptr_type; d: integer): integer;
function cbtocylno(fs: super_block_ptr_type; bno: integer): integer;
function cbtorpos(fs: super_block_ptr_type; bno: integer): integer;
function itog(fs: super_block_ptr_type; x: integer): integer;
function fragstobytes(fs: super_block_ptr_type; frags: integer): integer;

{
{ X per Y
}
function nspb(fs: super_block_ptr_type): integer;
function nspf(fs: super_block_ptr_type): integer;
function maxbpc: integer;

{
{ offset calculation
}
function fs_cs(fs: super_block_ptr_type; indx: integer): csumm_ptr_type;
function blkoff(fs: super_block_ptr_type; loc: integer): integer;
function fragoff(fs: super_block_ptr_type; loc: integer): integer;
function lblkno(fs: super_block_ptr_type; loc: integer): integer;
function numfrags(fs: super_block_ptr_type; loc: integer): integer;
function fragroundup(fs: super_block_ptr_type; size: integer): integer;
function blksize(fs: super_block_ptr_type;
		  ip: inode_ptr_type; lbn: integer): integer;
function cgsblock(fs: super_block_ptr_type; c: integer): integer;


implement


{
{ set bit i in bitmap a
{ #define setbit(a,i)     ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
}
procedure setbit(anyvar a: freemap_type; i: integer);
var
    index: integer;
begin
    index := i div NBBY;
    a[index] := binior(a[index], binasl(1, i mod NBBY));
end;


{
{ clr bit i in bitmap a
{ #define clrbit(a,i)     ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
}
procedure clrbit(anyvar a: freemap_type; i: integer);
var
    index: integer;
begin
    index := i div NBBY;
    a[index] := binand(a[index], bincmp(binasl(1, i mod NBBY)));
end;


{
{ is bit i set in bitmap a?
{ #define isset(a,i)      ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
}
function isset(anyvar a: freemap_type; i: integer): boolean;
var
    index: integer;
begin
    index := i div NBBY;
    isset := binand(a[index], binasl(1, i mod NBBY)) <> 0;
end;


{
{ is bit i clr in bitmap a?
{ #define isclr(a,i)      (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
}
function isclr(anyvar a: freemap_type; i: integer): boolean;
var
    index: integer;
begin
    index := i div NBBY;
    isclr := binand(a[index], binasl(1, i mod NBBY)) = 0;
end;


{
{ bytes to device blocks
{ #define btodb(bytes) ((unsigned)(bytes) >> DEV_BSHIFT)
}
function btodb(i: integer): integer;
begin
    btodb := binlsr(i, DEV_BSHIFT);
end;


{
{ inodes per big block
{ #define INOPB(fs)      ((fs)->fs_inopb)
}
function inopb(fs: super_block_ptr_type): integer;
begin
    inopb := fs^.inopb;
end;


{
{ inodes per fragment
{ #define INOPF(fs)      ((fs)->fs_inopb >>(fs)->fs_fragshift)
}
function inopf(fs: super_block_ptr_type): integer;
begin
    inopf := binasr(fs^.inopb, fs^.fragshift);
end;


{
{ how many things of size y cover a thing of size x?
{ #define howmany(x, y)  (((x)+((y)-1))/(y))
}
function howmany(x: integer; y: integer): integer;
begin
    howmany := (x + (y - 1)) DIV y;
end;


{
{ round x up to the next multiple of y
{ #define roundup(x, y)  ((((x)+((y)-1))/(y))*(y))
}
function roundup(x: integer; y: integer): integer;
begin
    roundup := ((x + y - 1) DIV y) * y;
end;


{
{ round x down to the next multiple of y
{ y must be a power of 2
}
function rounddownp2(x: integer; y: integer): integer;
begin
    rounddownp2 := binand(x, bincmp(y - 1));
end;


{
{ number of sectors per big block
{ #define NSPB(fs)       ((fs)->fs_nspf <<(fs)->fs_fragshift)
}
function nspb(fs: super_block_ptr_type): integer;
begin
    nspb := binasl(fs^.nspf, fs^.fragshift);
end;


{
{ number of sectors per fragment
{ #define NSPF(fs)       ((fs)->fs_nspf)
}
function nspf(fs: super_block_ptr_type): integer;
begin
    nspf := fs^.nspf;
end;


{
{ fragments to big blocks }
{ #define fragstoblks(fs, frags)  /* calculates(frags / fs->fs_frag) */ \
{  ((frags) >>(fs)->fs_fragshift)
}
function fragstoblks(fs: super_block_ptr_type; frags: integer): integer;
begin
    fragstoblks := binasr(frags, fs^.fragshift);
end;


{
{ big blocks to fragments }
{ #define blkstofrags(fs, blks)   /* calculates(blks * fs->fs_frag) */ \
{  ((blks) <<(fs)->fs_fragshift)
}
function blkstofrags(fs: super_block_ptr_type; blks: integer): integer;
begin
    blkstofrags := binasl(blks, fs^.fragshift);
end;


{
{ ptr to cylinder summary info for given cg
{ #define fs_cs(fs, indx) \
{     fs_csp[(indx) >>(fs)->fs_csshift][(indx) & ~(fs)->fs_csmask]
{     /*      first index       *//*     second index      */
}
function fs_cs(fs: super_block_ptr_type; indx: integer): csumm_ptr_type;
begin
    with fs^ do
	fs_cs :=
	    addr(csp[binasr(indx,csshift)]^[binand(indx,bincmp(csmask))]);
end;


{
{ max frags per cylinder cycle
/*
 * MAXBPC bounds the size of the rotational layout tables and
 * is limited by the fact that the super block is of size SBSIZE.
 * The size of these tables is INVERSELY proportional to the block
 * size of the file system. It is aggravated by sector sizes that
 * are not powers of two, as this increases the number of cylinders
 * included before the rotational pattern repeats(fs_cpc).
 * Its size is derived from the number of bytes remaining in(struct fs)
 */
{ #define MAXBPC (SBSIZE - sizeof(struct fs))
}
function maxbpc: integer;
begin
    maxbpc := SBSIZE - sizeof(super_block_type);
end;


{
{ max frags per cylinder group
/*
 * MAXBPG bounds the number of blocks of data per cylinder group,
 * and is limited by the fact that cylinder groups are at most one block.
 * Its size is derived from the size of blocks and the(struct cg) size,
 * by the number of remaining bits.
 */
{ #define MAXBPG(fs) \
{   (fragstoblks((fs),(NBBY *((fs)->fs_bsize -(sizeof(struct cg))))))
}
function maxbpg(fs: super_block_ptr_type): integer;
begin
    maxbpg := fragstoblks(fs,
		 NBBY *(fs^.bsize - sizeof(cylinder_group_block_type)));
end;


{
{ fragments to device blocks
{ #define fsbtodb(fs, b) ((b) <<(fs)->fs_fsbtodb)
}
function fsbtodb(fs: super_block_ptr_type; b: integer): integer;
begin
    fsbtodb := binasl(b, fs^.fsbtodb);
end;


{
{ device blocks to fragments
{ #define dbtofsb(fs, b) ((b) >>(fs)->fs_fsbtodb)
}
function dbtofsb(fs: super_block_ptr_type; b: integer): integer;
begin
    dbtofsb := binasr(b, fs^.fsbtodb);
end;


{
{ start address of entire cylinder group, in frags
{ #define cgbase(fs, c)  ((daddr_t)((fs)->fs_fpg *(c)))
}
function cgbase(fs: super_block_ptr_type; c: integer): integer;
begin
    cgbase := fs^.fpg * c;
end;


{
{ start of control area, in frags
{ #define cgstart(fs, c) \
{    (cgbase(fs, c) +(fs)->fs_cgoffset *((c) & ~((fs)->fs_cgmask)))
}
function cgstart(fs: super_block_ptr_type; c: integer): integer;
begin
    cgstart := cgbase(fs, c) + fs^.cgoffset*binand(c, bincmp(fs^.cgmask));
end;


{
{ start of superblock copy, in frags
{ #define cgsblock(fs, c)(cgstart(fs, c) +(fs)->fs_sblkno)
}
function cgsblock(fs: super_block_ptr_type; c: integer): integer;
begin
    cgsblock := cgstart(fs, c) + fs^.sblkno;
end;


{
{ start of cgroup structure, in frags
{ #define cgtod(fs, c)   (cgstart(fs, c) +(fs)->fs_cblkno)
}
function cgtod(fs: super_block_ptr_type; c: integer): integer;
begin
    cgtod := cgstart(fs, c) + fs^.cblkno;
end;


{
{ start of inode section, in frags }
{ #define cgimin(fs, c)  (cgstart(fs, c) +(fs)->fs_iblkno)
}
function cgimin(fs: super_block_ptr_type; c: integer): integer;
begin
    cgimin := cgstart(fs, c) + fs^.iblkno;
end;


{
{ start of data after inode area, in frags }
{ #define cgdmin(fs, c)  (cgstart(fs, c) +(fs)->fs_dblkno)
}
function cgdmin(fs: super_block_ptr_type; c: integer): integer;
begin
    cgdmin := cgstart(fs, c) + fs^.dblkno;
end;


{
{ frag to cylinder group
{ #define dtog(fs, d)    ((d) /(fs)->fs_fpg)
}
function dtog(fs: super_block_ptr_type; d: integer): integer;
begin
    dtog := d DIV fs^.fpg;
end;


{
{ frag offset in fs to frag offset in cg
{ #define dtogd(fs, d)   ((d) %(fs)->fs_fpg)
}
function dtogd(fs: super_block_ptr_type; d: integer): integer;
begin
    dtogd := d MOD fs^.fpg;
end;


{
{ freemap bits for big block loc
/*
 * Extract the bits for a block from a map.
 */
{ #define blkmap(fs, map, loc) \
{  (((map)[loc / NBBY] >>(loc % NBBY)) &(0xff >>(NBBY -(fs)->fs_frag)))
}
function blkmap(fs: super_block_ptr_type;
		anyvar map: freemap_type; loc: integer): integer;
begin
    blkmap := binand(binasr(map[loc div NBBY], (loc MOD NBBY)),
		     binasr(HEXFF, (NBBY - fs^.frag)));
end;


{
{ frag in cylinder group to cylinder in cylinder group
{ #define cbtocylno(fs, bno) \
{     ((bno) * NSPF(fs) /(fs)->fs_spc)
}
function cbtocylno(fs: super_block_ptr_type; bno: integer): integer;
begin
    cbtocylno := (bno * nspf(fs)) DIV fs^.spc;
end;


{
{ frag in cg to rotational position
{ #define cbtorpos(fs, bno) \
{  ((bno) * NSPF(fs) %(fs)->fs_nsect * NRPOS /(fs)->fs_nsect)
}
function cbtorpos(fs: super_block_ptr_type; bno: integer): integer;
begin
    cbtorpos := (((bno * nspf(fs)) MOD fs^.nsect) * NRPOS) DIV fs^.nsect;
end;


{
{ byte offset of loc within big block
{ #define blkoff(fs, loc)         /* calculates(loc % fs->fs_bsize) */ \
{    ((loc) & ~(fs)->fs_bmask)
}
function blkoff(fs: super_block_ptr_type; loc: integer): integer;
begin
    blkoff := binand(loc, bincmp(fs^.bmask));
end;


{
{ byte offset of loc within frag
{ #define fragoff(fs, loc)        /* calculates(loc % fs->fs_fsize) */ \
{     ((loc) & ~(fs)->fs_fmask)
}
function fragoff(fs: super_block_ptr_type; loc: integer): integer;
begin
    fragoff := binand(loc, bincmp(fs^.fmask));
end;


{
{ big block number of byte offset loc
{ #define lblkno(fs, loc)         /* calculates(loc / fs->fs_bsize) */ \
{     ((loc) >>(fs)->fs_bshift)
}
function lblkno(fs: super_block_ptr_type; loc: integer): integer;
begin
	lblkno := binasr(loc, fs^.bshift);
end;


{
{ number of frags in loc bytes(truncated)
{ #define numfrags(fs, loc)       /* calculates(loc / fs->fs_fsize) */ \
{     ((loc) >>(fs)->fs_fshift)
}
function numfrags(fs: super_block_ptr_type; loc: integer): integer;
begin
    numfrags := binasr(loc, fs^.fshift);
end;


{
{ round size bytes up to next big block
{ #define blkroundup(fs, size)   /* calculates roundup(size, fs->fs_bsize) */ \
{      (((size) +(fs)->fs_bsize - 1) &(fs)->fs_bmask)
}
function blkroundup(fs: super_block_ptr_type; size: integer): integer;
begin
    blkroundup := binand((size + fs^.bsize - 1), fs^.bmask);
end;


{
{ round size bytes up to next big block
{ #define fragroundup(fs, size)  /* calculates roundup(size, fs->fs_fsize) */ \
{    (((size) +(fs)->fs_fsize - 1) &(fs)->fs_fmask)
}
function fragroundup(fs: super_block_ptr_type; size: integer): integer;
begin
    fragroundup := binand((size + fs^.fsize - 1), fs^.fmask);
end;


{
{ free space in frags
/*
 * Determine the number of available frags given a
 * percentage to hold in reserve
 */
{ #define freespace(fs, percentreserved) \
{     (blkstofrags((fs),(fs)->fs_cstotal.cs_nbfree) + \
{     (fs)->fs_cstotal.cs_nffree -((fs)->fs_dsize *(percentreserved) / 100))
}
function freespace(fs: super_block_ptr_type;
		   percentreserved: integer): integer;
begin
    freespace := blkstofrags(fs, fs^.cstotal.nbfree)
			+ fs^.cstotal.nffree
			- ((fs^.dsize * percentreserved) DIV 100);
end;


{
{ size in frags of logical block lbn in this file
{ #define blksize(fs, ip, lbn) \
{     (((lbn) >= NDADDR ||(ip)->i_size >=((lbn) + 1) <<(fs)->fs_bshift) \
{     ?(fs)->fs_bsize \
{     : (fragroundup(fs, blkoff(fs,(ip)->i_size))))
}
function blksize(fs: super_block_ptr_type; ip: inode_ptr_type;
		 lbn: integer): integer;
begin
    if (lbn >= NDADDR)
    or (ip^.size.ls >= binasl(lbn + 1, fs^.bshift)) then
	blksize := fs^.bsize
    else
	blksize := fragroundup(fs, blkoff(fs, ip^.size.ls));
end;


{
{ inumber to inumber offset within block
{ #define itoo(fs,x)     ((x) % INOPB(fs))
}
function itoo(fs: super_block_ptr_type; x: integer): integer;
begin
    itoo := x MOD inopb(fs);
end;


{
{ inumber to cg number
{ #define itog(fs,x)     ((x) /(fs) -> fs_ipg)
}
function itog(fs: super_block_ptr_type; x: integer): integer;
begin
    itog := x DIV fs^.ipg;
end;


{
{ fragment number to byte address
}
function fragstobytes(fs: super_block_ptr_type; frags: integer): integer;
begin
    fragstobytes := binasl(frags, fs^.fshift);
end;


{
{ inumber to frag containing it
{ #define itod(fs,x)      \
{     ((daddr_t)(cgimin(fs, itog(fs, x)) + \
{     (blkstofrags((fs),(((x) %(fs) -> fs_ipg) / INOPB(fs))))))
}
function itod(fs: super_block_ptr_type; x: integer): integer;
begin
    itod := cgimin(fs, itog(fs, x))
       + blkstofrags(fs, (x MOD fs^.ipg) DIV inopb(fs));
end;


{
{ byte offset of inode
}
function inode_start(fs: super_block_ptr_type;
		     inode_num: integer): integer;
begin
    inode_start := fsbtodb(fs, itod(fs, inode_num)) * DEV_BSIZE +
		   itoo(fs, inode_num) * sizeof(inode_type);
end;


{
{ byte offset of fragment
}
function data_start(fs: super_block_ptr_type;
		    dblock_num: integer): integer;
begin
    data_start := fsbtodb(fs, dblock_num) * DEV_BSIZE;
end;


{
{ byte offset of cgroup
}
function cgroup_start(fs: super_block_ptr_type;
		      cgroup_num: integer): integer;
begin
    cgroup_start := DEV_BSIZE * fsbtodb(fs, cgtod(fs, cgroup_num));
end;


function min(a, b: integer): integer;
begin
 if a < b then min := a else min := b;
end;


function max(a, b: integer): integer;
begin
 if a > b then max := a else max := b;
end;

end.






@


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


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

$linenum 11000$
$lines 54$

$partial_eval on$

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

{
{ Low-level calculation routines for getting byte offsets,
{ fragment sizes, etc. etc.  Largely a Pascal implementation of
{ the routines in fs.h, plus a few from param.h and sysmacros.h.
}

module hfscalc;


$search 'hfstuff'$
import hfstuff, iocomasm;

export

{
{ calculate starting byte of various objects
}
function inode_start(fs: super_block_ptr_type;
		     inode_num: integer): integer;
function data_start(fs: super_block_ptr_type;
		    dblock_num: integer): integer;
function cgroup_start(fs: super_block_ptr_type;
		      cgroup_num: integer): integer;

{
{ miscellany
}
function min(a, b: integer): integer;
function max(a, b: integer): integer;
function howmany(x: integer; y: integer): integer;
function roundup(x: integer; y: integer): integer;
function rounddownp2(x: integer; y: integer): integer;
function freespace(fs: super_block_ptr_type;
		   percentreserved: integer): integer;

{
{ bitmap manipulation
}
procedure setbit(anyvar a: freemap_type; i: integer);
procedure clrbit(anyvar a: freemap_type; i: integer);
function isset(anyvar a: freemap_type; i: integer): boolean;
function isclr(anyvar a: freemap_type; i: integer): boolean;
function blkmap(fs: super_block_ptr_type;
		 anyvar map: freemap_type; loc: integer): integer;

{
{ conversion
}
function btodb(i: integer): integer;
function fragstoblks(fs: super_block_ptr_type; frags: integer): integer;
function blkstofrags(fs: super_block_ptr_type; blks: integer): integer;
function cgtod(fs: super_block_ptr_type; c: integer): integer;
function dtog(fs: super_block_ptr_type; d: integer): integer;
function dtogd(fs: super_block_ptr_type; d: integer): integer;
function cbtocylno(fs: super_block_ptr_type; bno: integer): integer;
function cbtorpos(fs: super_block_ptr_type; bno: integer): integer;
function itog(fs: super_block_ptr_type; x: integer): integer;
function fragstobytes(fs: super_block_ptr_type; frags: integer): integer;

{
{ X per Y
}
function nspb(fs: super_block_ptr_type): integer;
function nspf(fs: super_block_ptr_type): integer;
function maxbpc: integer;

{
{ offset calculation
}
function fs_cs(fs: super_block_ptr_type; indx: integer): csumm_ptr_type;
function blkoff(fs: super_block_ptr_type; loc: integer): integer;
function fragoff(fs: super_block_ptr_type; loc: integer): integer;
function lblkno(fs: super_block_ptr_type; loc: integer): integer;
function numfrags(fs: super_block_ptr_type; loc: integer): integer;
function fragroundup(fs: super_block_ptr_type; size: integer): integer;
function blksize(fs: super_block_ptr_type;
		  ip: inode_ptr_type; lbn: integer): integer;
function cgsblock(fs: super_block_ptr_type; c: integer): integer;


implement


{
{ set bit i in bitmap a
{ #define setbit(a,i)     ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
}
procedure setbit(anyvar a: freemap_type; i: integer);
var
    index: integer;
begin
    index := i div NBBY;
    a[index] := binior(a[index], binasl(1, i mod NBBY));
end;


{
{ clr bit i in bitmap a
{ #define clrbit(a,i)     ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
}
procedure clrbit(anyvar a: freemap_type; i: integer);
var
    index: integer;
begin
    index := i div NBBY;
    a[index] := binand(a[index], bincmp(binasl(1, i mod NBBY)));
end;


{
{ is bit i set in bitmap a?
{ #define isset(a,i)      ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
}
function isset(anyvar a: freemap_type; i: integer): boolean;
var
    index: integer;
begin
    index := i div NBBY;
    isset := binand(a[index], binasl(1, i mod NBBY)) <> 0;
end;


{
{ is bit i clr in bitmap a?
{ #define isclr(a,i)      (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
}
function isclr(anyvar a: freemap_type; i: integer): boolean;
var
    index: integer;
begin
    index := i div NBBY;
    isclr := binand(a[index], binasl(1, i mod NBBY)) = 0;
end;


{
{ bytes to device blocks
{ #define btodb(bytes) ((unsigned)(bytes) >> DEV_BSHIFT)
}
function btodb(i: integer): integer;
begin
    btodb := binlsr(i, DEV_BSHIFT);
end;


{
{ inodes per big block
{ #define INOPB(fs)      ((fs)->fs_inopb)
}
function inopb(fs: super_block_ptr_type): integer;
begin
    inopb := fs^.inopb;
end;


{
{ inodes per fragment
{ #define INOPF(fs)      ((fs)->fs_inopb >>(fs)->fs_fragshift)
}
function inopf(fs: super_block_ptr_type): integer;
begin
    inopf := binasr(fs^.inopb, fs^.fragshift);
end;


{
{ how many things of size y cover a thing of size x?
{ #define howmany(x, y)  (((x)+((y)-1))/(y))
}
function howmany(x: integer; y: integer): integer;
begin
    howmany := (x + (y - 1)) DIV y;
end;


{
{ round x up to the next multiple of y
{ #define roundup(x, y)  ((((x)+((y)-1))/(y))*(y))
}
function roundup(x: integer; y: integer): integer;
begin
    roundup := ((x + y - 1) DIV y) * y;
end;


{
{ round x down to the next multiple of y
{ y must be a power of 2
}
function rounddownp2(x: integer; y: integer): integer;
begin
    rounddownp2 := binand(x, bincmp(y - 1));
end;


{
{ number of sectors per big block
{ #define NSPB(fs)       ((fs)->fs_nspf <<(fs)->fs_fragshift)
}
function nspb(fs: super_block_ptr_type): integer;
begin
    nspb := binasl(fs^.nspf, fs^.fragshift);
end;


{
{ number of sectors per fragment
{ #define NSPF(fs)       ((fs)->fs_nspf)
}
function nspf(fs: super_block_ptr_type): integer;
begin
    nspf := fs^.nspf;
end;


{
{ fragments to big blocks }
{ #define fragstoblks(fs, frags)  /* calculates(frags / fs->fs_frag) */ \
{  ((frags) >>(fs)->fs_fragshift)
}
function fragstoblks(fs: super_block_ptr_type; frags: integer): integer;
begin
    fragstoblks := binasr(frags, fs^.fragshift);
end;


{
{ big blocks to fragments }
{ #define blkstofrags(fs, blks)   /* calculates(blks * fs->fs_frag) */ \
{  ((blks) <<(fs)->fs_fragshift)
}
function blkstofrags(fs: super_block_ptr_type; blks: integer): integer;
begin
    blkstofrags := binasl(blks, fs^.fragshift);
end;


{
{ ptr to cylinder summary info for given cg
{ #define fs_cs(fs, indx) \
{     fs_csp[(indx) >>(fs)->fs_csshift][(indx) & ~(fs)->fs_csmask]
{     /*      first index       *//*     second index      */
}
function fs_cs(fs: super_block_ptr_type; indx: integer): csumm_ptr_type;
begin
    with fs^ do
	fs_cs :=
	    addr(csp[binasr(indx,csshift)]^[binand(indx,bincmp(csmask))]);
end;


{
{ max frags per cylinder cycle
/*
 * MAXBPC bounds the size of the rotational layout tables and
 * is limited by the fact that the super block is of size SBSIZE.
 * The size of these tables is INVERSELY proportional to the block
 * size of the file system. It is aggravated by sector sizes that
 * are not powers of two, as this increases the number of cylinders
 * included before the rotational pattern repeats(fs_cpc).
 * Its size is derived from the number of bytes remaining in(struct fs)
 */
{ #define MAXBPC (SBSIZE - sizeof(struct fs))
}
function maxbpc: integer;
begin
    maxbpc := SBSIZE - sizeof(super_block_type);
end;


{
{ max frags per cylinder group
/*
 * MAXBPG bounds the number of blocks of data per cylinder group,
 * and is limited by the fact that cylinder groups are at most one block.
 * Its size is derived from the size of blocks and the(struct cg) size,
 * by the number of remaining bits.
 */
{ #define MAXBPG(fs) \
{   (fragstoblks((fs),(NBBY *((fs)->fs_bsize -(sizeof(struct cg))))))
}
function maxbpg(fs: super_block_ptr_type): integer;
begin
    maxbpg := fragstoblks(fs,
		 NBBY *(fs^.bsize - sizeof(cylinder_group_block_type)));
end;


{
{ fragments to device blocks
{ #define fsbtodb(fs, b) ((b) <<(fs)->fs_fsbtodb)
}
function fsbtodb(fs: super_block_ptr_type; b: integer): integer;
begin
    fsbtodb := binasl(b, fs^.fsbtodb);
end;


{
{ device blocks to fragments
{ #define dbtofsb(fs, b) ((b) >>(fs)->fs_fsbtodb)
}
function dbtofsb(fs: super_block_ptr_type; b: integer): integer;
begin
    dbtofsb := binasr(b, fs^.fsbtodb);
end;


{
{ start address of entire cylinder group, in frags
{ #define cgbase(fs, c)  ((daddr_t)((fs)->fs_fpg *(c)))
}
function cgbase(fs: super_block_ptr_type; c: integer): integer;
begin
    cgbase := fs^.fpg * c;
end;


{
{ start of control area, in frags
{ #define cgstart(fs, c) \
{    (cgbase(fs, c) +(fs)->fs_cgoffset *((c) & ~((fs)->fs_cgmask)))
}
function cgstart(fs: super_block_ptr_type; c: integer): integer;
begin
    cgstart := cgbase(fs, c) + fs^.cgoffset*binand(c, bincmp(fs^.cgmask));
end;


{
{ start of superblock copy, in frags
{ #define cgsblock(fs, c)(cgstart(fs, c) +(fs)->fs_sblkno)
}
function cgsblock(fs: super_block_ptr_type; c: integer): integer;
begin
    cgsblock := cgstart(fs, c) + fs^.sblkno;
end;


{
{ start of cgroup structure, in frags
{ #define cgtod(fs, c)   (cgstart(fs, c) +(fs)->fs_cblkno)
}
function cgtod(fs: super_block_ptr_type; c: integer): integer;
begin
    cgtod := cgstart(fs, c) + fs^.cblkno;
end;


{
{ start of inode section, in frags }
{ #define cgimin(fs, c)  (cgstart(fs, c) +(fs)->fs_iblkno)
}
function cgimin(fs: super_block_ptr_type; c: integer): integer;
begin
    cgimin := cgstart(fs, c) + fs^.iblkno;
end;


{
{ start of data after inode area, in frags }
{ #define cgdmin(fs, c)  (cgstart(fs, c) +(fs)->fs_dblkno)
}
function cgdmin(fs: super_block_ptr_type; c: integer): integer;
begin
    cgdmin := cgstart(fs, c) + fs^.dblkno;
end;


{
{ frag to cylinder group
{ #define dtog(fs, d)    ((d) /(fs)->fs_fpg)
}
function dtog(fs: super_block_ptr_type; d: integer): integer;
begin
    dtog := d DIV fs^.fpg;
end;


{
{ frag offset in fs to frag offset in cg
{ #define dtogd(fs, d)   ((d) %(fs)->fs_fpg)
}
function dtogd(fs: super_block_ptr_type; d: integer): integer;
begin
    dtogd := d MOD fs^.fpg;
end;


{
{ freemap bits for big block loc
/*
 * Extract the bits for a block from a map.
 */
{ #define blkmap(fs, map, loc) \
{  (((map)[loc / NBBY] >>(loc % NBBY)) &(0xff >>(NBBY -(fs)->fs_frag)))
}
function blkmap(fs: super_block_ptr_type;
		anyvar map: freemap_type; loc: integer): integer;
begin
    blkmap := binand(binasr(map[loc div NBBY], (loc MOD NBBY)),
		     binasr(HEXFF, (NBBY - fs^.frag)));
end;


{
{ frag in cylinder group to cylinder in cylinder group
{ #define cbtocylno(fs, bno) \
{     ((bno) * NSPF(fs) /(fs)->fs_spc)
}
function cbtocylno(fs: super_block_ptr_type; bno: integer): integer;
begin
    cbtocylno := (bno * nspf(fs)) DIV fs^.spc;
end;


{
{ frag in cg to rotational position
{ #define cbtorpos(fs, bno) \
{  ((bno) * NSPF(fs) %(fs)->fs_nsect * NRPOS /(fs)->fs_nsect)
}
function cbtorpos(fs: super_block_ptr_type; bno: integer): integer;
begin
    cbtorpos := (((bno * nspf(fs)) MOD fs^.nsect) * NRPOS) DIV fs^.nsect;
end;


{
{ byte offset of loc within big block
{ #define blkoff(fs, loc)         /* calculates(loc % fs->fs_bsize) */ \
{    ((loc) & ~(fs)->fs_bmask)
}
function blkoff(fs: super_block_ptr_type; loc: integer): integer;
begin
    blkoff := binand(loc, bincmp(fs^.bmask));
end;


{
{ byte offset of loc within frag
{ #define fragoff(fs, loc)        /* calculates(loc % fs->fs_fsize) */ \
{     ((loc) & ~(fs)->fs_fmask)
}
function fragoff(fs: super_block_ptr_type; loc: integer): integer;
begin
    fragoff := binand(loc, bincmp(fs^.fmask));
end;


{
{ big block number of byte offset loc
{ #define lblkno(fs, loc)         /* calculates(loc / fs->fs_bsize) */ \
{     ((loc) >>(fs)->fs_bshift)
}
function lblkno(fs: super_block_ptr_type; loc: integer): integer;
begin
	lblkno := binasr(loc, fs^.bshift);
end;


{
{ number of frags in loc bytes(truncated)
{ #define numfrags(fs, loc)       /* calculates(loc / fs->fs_fsize) */ \
{     ((loc) >>(fs)->fs_fshift)
}
function numfrags(fs: super_block_ptr_type; loc: integer): integer;
begin
    numfrags := binasr(loc, fs^.fshift);
end;


{
{ round size bytes up to next big block
{ #define blkroundup(fs, size)   /* calculates roundup(size, fs->fs_bsize) */ \
{      (((size) +(fs)->fs_bsize - 1) &(fs)->fs_bmask)
}
function blkroundup(fs: super_block_ptr_type; size: integer): integer;
begin
    blkroundup := binand((size + fs^.bsize - 1), fs^.bmask);
end;


{
{ round size bytes up to next big block
{ #define fragroundup(fs, size)  /* calculates roundup(size, fs->fs_fsize) */ \
{    (((size) +(fs)->fs_fsize - 1) &(fs)->fs_fmask)
}
function fragroundup(fs: super_block_ptr_type; size: integer): integer;
begin
    fragroundup := binand((size + fs^.fsize - 1), fs^.fmask);
end;


{
{ free space in frags
/*
 * Determine the number of available frags given a
 * percentage to hold in reserve
 */
{ #define freespace(fs, percentreserved) \
{     (blkstofrags((fs),(fs)->fs_cstotal.cs_nbfree) + \
{     (fs)->fs_cstotal.cs_nffree -((fs)->fs_dsize *(percentreserved) / 100))
}
function freespace(fs: super_block_ptr_type;
		   percentreserved: integer): integer;
begin
    freespace := blkstofrags(fs, fs^.cstotal.nbfree)
			+ fs^.cstotal.nffree
			- ((fs^.dsize * percentreserved) DIV 100);
end;


{
{ size in frags of logical block lbn in this file
{ #define blksize(fs, ip, lbn) \
{     (((lbn) >= NDADDR ||(ip)->i_size >=((lbn) + 1) <<(fs)->fs_bshift) \
{     ?(fs)->fs_bsize \
{     : (fragroundup(fs, blkoff(fs,(ip)->i_size))))
}
function blksize(fs: super_block_ptr_type; ip: inode_ptr_type;
		 lbn: integer): integer;
begin
    if (lbn >= NDADDR)
    or (ip^.size.ls >= binasl(lbn + 1, fs^.bshift)) then
	blksize := fs^.bsize
    else
	blksize := fragroundup(fs, blkoff(fs, ip^.size.ls));
end;


{
{ inumber to inumber offset within block
{ #define itoo(fs,x)     ((x) % INOPB(fs))
}
function itoo(fs: super_block_ptr_type; x: integer): integer;
begin
    itoo := x MOD inopb(fs);
end;


{
{ inumber to cg number
{ #define itog(fs,x)     ((x) /(fs) -> fs_ipg)
}
function itog(fs: super_block_ptr_type; x: integer): integer;
begin
    itog := x DIV fs^.ipg;
end;


{
{ fragment number to byte address
}
function fragstobytes(fs: super_block_ptr_type; frags: integer): integer;
begin
    fragstobytes := binasl(frags, fs^.fshift);
end;


{
{ inumber to frag containing it
{ #define itod(fs,x)      \
{     ((daddr_t)(cgimin(fs, itog(fs, x)) + \
{     (blkstofrags((fs),(((x) %(fs) -> fs_ipg) / INOPB(fs))))))
}
function itod(fs: super_block_ptr_type; x: integer): integer;
begin
    itod := cgimin(fs, itog(fs, x))
       + blkstofrags(fs, (x MOD fs^.ipg) DIV inopb(fs));
end;


{
{ byte offset of inode
}
function inode_start(fs: super_block_ptr_type;
		     inode_num: integer): integer;
begin
    inode_start := fsbtodb(fs, itod(fs, inode_num)) * DEV_BSIZE +
		   itoo(fs, inode_num) * sizeof(inode_type);
end;


{
{ byte offset of fragment
}
function data_start(fs: super_block_ptr_type;
		    dblock_num: integer): integer;
begin
    data_start := fsbtodb(fs, dblock_num) * DEV_BSIZE;
end;


{
{ byte offset of cgroup
}
function cgroup_start(fs: super_block_ptr_type;
		      cgroup_num: integer): integer;
begin
    cgroup_start := DEV_BSIZE * fsbtodb(fs, cgtod(fs, cgroup_num));
end;


function min(a, b: integer): integer;
begin
 if a < b then min := a else min := b;
end;


function max(a, b: integer): integer;
begin
 if a > b then max := a else max := b;
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.1
log
@Automatic bump of revision number for PWS version 3.2N
@
text
@@


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


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


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.2
log
@Fix for FSDat00867 -- change volume name properly
@
text
@@


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


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


3.2
log
@Some cleanup.  Eliminate unused stuff.
@
text
@@


3.1
log
@Automatic bump of revision number for PWS version 3.2h
@
text
@a0 1
$LINENUM 11000$
d3 9
a17 6
$range off$
$ovflcheck off$
$debug off$

$SEARCH 'hfstuff'$

d21 1
a34 2
function super_start(fs: super_block_ptr_type;
		     super_copy_num: integer): integer;
d94 4
a97 11
type string255 = string[255];

procedure report(m : string255);
var temperr : integer;
begin
 temperr := ioresult;
 writeln(m);
 ioresult := temperr;
end;

{ set bit i in bitmap a }
d107 4
a110 1
{ clr bit i in bitmap a }
d120 4
a123 1
{ is bit i set in bitmap a? }
d133 4
a136 1
{ is bit i clr in bitmap a? }
d146 4
a149 1
{ bytes to device blocks }
a610 12
end;


{
{ byte offset of superblock
}
function super_start(fs: super_block_ptr_type;
		     super_copy_num: integer): integer;
var
    sblkno: integer;
begin
    super_start := DEV_BSIZE * fsbtodb(fs, cgsblock(fs, super_copy_num));
@


2.2
log
@Debug etc now off.
@
text
@@


2.1
log
@Auto bump rev number to 2.1 for sys 3.2e.
@
text
@a9 2
{
{ enable these when done
d12 1
a12 3
}

$debug on$                 {debug OFF when finished}
@


1.4
log
@correction made during first paws build with hfs integrated
@
text
@@


1.3
log
@change of bit shift routine names from bit_* to bin*
@
text
@d465 1
a465 1
	lblkno := BIT_ASR(loc, fs^.bshift);
@


1.2
log
@removal of cbit dependencies
@
text
@d113 1
a113 1
    a[index] := binior(a[index], bit_asl(1, i mod NBBY));
d123 1
a123 1
    a[index] := binand(a[index], bincmp(bit_asl(1, i mod NBBY)));
d133 1
a133 1
    isset := binand(a[index], bit_asl(1, i mod NBBY)) <> 0;
d143 1
a143 1
    isclr := binand(a[index], bit_asl(1, i mod NBBY)) = 0;
d150 1
a150 1
    btodb := bit_lsr(i, DEV_BSHIFT);
d170 1
a170 1
    inopf := bit_asr(fs^.inopb, fs^.fragshift);
d210 1
a210 1
    nspb := bit_asl(fs^.nspf, fs^.fragshift);
d231 1
a231 1
    fragstoblks := bit_asr(frags, fs^.fragshift);
d242 1
a242 1
    blkstofrags := bit_asl(blks, fs^.fragshift);
d256 1
a256 1
	    addr(csp[bit_asr(indx,csshift)]^[binand(indx,bincmp(csmask))]);
d303 1
a303 1
    fsbtodb := bit_asl(b, fs^.fsbtodb);
d313 1
a313 1
    dbtofsb := bit_asr(b, fs^.fsbtodb);
d409 2
a410 2
    blkmap := binand(bit_asr(map[loc div NBBY], (loc MOD NBBY)),
		     bit_asr(HEXFF, (NBBY - fs^.frag)));
d476 1
a476 1
    numfrags := bit_asr(loc, fs^.fshift);
d532 1
a532 1
    or (ip^.size.ls >= bit_asl(lbn + 1, fs^.bshift)) then
d564 1
a564 1
    fragstobytes := bit_asl(frags, fs^.fshift);
@


1.1
log
@Initial revision
@
text
@d18 1
a18 1
$SEARCH 'hfstuff', 'cbit'$
d23 1
a23 1
import hfstuff, cbit, iocomasm;
@
