1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <mach.h>
include "fmio.h"
# FMIO_BIND -- Called when a new datafile is being created, to bind the
# current datafile parameters set in the descriptor to the physical datafile.
procedure fmio_bind (fm)
pointer fm #I FMIO descriptor
pointer ft, pti, pt
int chan, szbpage, ftoff, ftlen, ptioff, ptilen, ptlen
begin
if (FM_ACTIVE(fm) != NO)
return
# Initialize buffer sizes.
call fmio_setbuf (fm)
chan = FM_CHAN(fm)
szbpage = FM_SZBPAGE(fm)
ftoff = LEN_DHSTRUCT + 1
ftlen = (FM_NLFILES(fm) + 1) * LEN_FTE
ptioff = ftoff + (FM_NLFILES(fm) + 1) * LEN_FTEX
ptilen = FM_PTILEN(fm)
ptlen = szbpage / (SZ_SHORT * SZB_CHAR)
# Determine the byte offset of the first data page.
FM_DATASTART(fm) = max (1,
(((ptioff+ptilen-1) * SZ_INT*SZB_CHAR) + szbpage-1) /
szbpage) * szbpage + 1
# Initialize the file table.
call calloc (ft, ftlen, TY_STRUCT)
FM_FTOFF(fm) = ftoff
FM_FTLASTNF(fm) = 0
FM_FTABLE(fm) = ft
# Initialize the page table index.
call calloc (pti, ptilen, TY_INT)
FM_PTIOFF(fm) = ptioff
FM_PTINPTI(fm) = 0
FM_PTINDEX(fm) = pti
# Initialize the page table, stored in the data pages. Note that the
# page table length must be an integral multiple of the page size.
call calloc (pt, ptlen, TY_SHORT)
FM_PTLEN(fm) = ptlen
FM_PTNPTE(fm) = 0
FM_PTLUPTE(fm) = 0
FM_PTABLE(fm) = pt
FM_ACTIVE(fm) = YES
FM_DHMODIFIED(fm) = YES
call fm_sync (fm)
end
|