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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include "fmset.h"
include "fmio.h"
# FM_DEBUG -- Print debug info on the contents of a datafile.
#
# Flags:
# FMD_HEADER general header parameters
# FMD_FTABLE summarize file table contents
# FMD_PTINDEX print page table index
# FMD_PTABLE print page table
# FMD_ALL print everything
procedure fm_debug (fm, out, what)
pointer fm #I FMIO descriptor
int out #I output file
int what #I what to print
pointer ft, lf
bool deleted
int nlfiles, nlfdeleted, nlfinuse, i
int szbpage, spaceinuse, filesize, freespace
long clktime()
errchk fmio_bind
define end_header_ 91
define end_ftable_ 92
define end_ptindex_ 93
define end_ptable_ 94
begin
call fmio_bind (fm)
ft = FM_FTABLE(fm)
nlfiles = FM_NLFILES(fm)
szbpage = FM_SZBPAGE(fm)
# Print header and summary information?
if (and (what, FMD_HEADER) == 0)
goto end_header_
# Scan the file table and compute some important statistics.
spaceinuse = 0
nlfdeleted = 0
nlfinuse = 0
do i = 0, nlfiles {
lf = ft + i * LEN_FTE
deleted = (and (LF_FLAGS(lf), LFF_DELETED) != 0)
if (deleted)
nlfdeleted = nlfdeleted + 1
if (!deleted) {
if (LF_FSIZE(lf) > 0)
spaceinuse = spaceinuse + LF_FSIZE(lf)
if (and (LF_FLAGS(lf), LFF_ALLOCATED) != 0)
nlfinuse = nlfinuse + 1
}
}
filesize = FM_PTNPTE(fm) * szbpage + FM_DATASTART(fm) - 1
freespace = max (0, filesize - spaceinuse - (FM_DATASTART(fm)-1))
call fprintf (out,
"FMIO V%d.%d: datafile=%s, pagesize=%d, nlfiles=%d\n")
call pargi (FM_DFVERSION(fm) / 100)
call pargi (mod(FM_DFVERSION(fm),100))
call pargstr (FM_DFNAME(fm))
call pargi (szbpage)
call pargi (nlfiles)
call fprintf (out,
"nlfinuse=%d, nlfdeleted=%d, nlffree=%d, ftoff=%d, ftlastnf=%d\n")
call pargi (nlfinuse)
call pargi (nlfdeleted)
call pargi (nlfiles - nlfinuse)
call pargi (FM_FTOFF(fm))
call pargi (FM_FTLASTNF(fm))
call fprintf (out,
"headersize=%d, filesize=%d, freespace=%d bytes (%d%%)\n")
call pargi (FM_DATASTART(fm) - 1)
call pargi (filesize)
call pargi (freespace)
if (freespace <= 0)
call pargi (0)
else
call pargi (freespace * 100 / filesize)
call fprintf (out,
"fm=%xX, chan=%d, mode=%d, time since last sync=%d seconds\n")
call pargi (fm)
call pargi (FM_CHAN(fm))
call pargi (FM_MODE(fm))
call pargi (clktime (FM_LSYNCTIME(fm)))
call fprintf (out,
"datastart=%d, devblksize=%d, optbufsize=%d, maxbufsize=%d\n")
call pargi (FM_DATASTART(fm))
call pargi (FM_DEVBLKSIZE(fm))
call pargi (FM_OPTBUFSIZE(fm))
call pargi (FM_MAXBUFSIZE(fm))
call fprintf (out, "ptioff=%d, ptilen=%d, npti=%d, ")
call pargi (FM_PTIOFF(fm))
call pargi (FM_PTILEN(fm))
call pargi (FM_PTINPTI(fm))
call fprintf (out, "ptlen=%d, npte=%d, lupte=%d\n")
call pargi (FM_PTLEN(fm))
call pargi (FM_PTNPTE(fm))
call pargi (FM_PTLUPTE(fm))
end_header_
# Print file table?
if (and (what, FMD_FTABLE) == 0)
goto end_ftable_
call fprintf (out,
"====================== file table =======================\n")
do i = 0, nlfiles {
lf = ft + i * LEN_FTE
if (LF_FSIZE(lf) == 0)
next
call fprintf (out, " %4d size=%d")
call pargi (i)
call pargi (LF_FSIZE(lf))
if (i == 0)
call fprintf (out, " [page table]")
if (LF_PAGEMAP(lf) != NULL) {
call fprintf (out, " npages=%d pmlen=%d")
call pargi (LF_NPAGES(lf))
call pargi (LF_PMLEN(lf))
}
if (and (LF_FLAGS(lf), LFF_ALLOCATED) != 0)
call fprintf (out, " allocated")
if (and (LF_FLAGS(lf), LFF_DELETED) != 0)
call fprintf (out, " deleted")
if (and (LF_FLAGS(lf), LFF_TEXTFILE) != 0)
call fprintf (out, " textfile")
call fprintf (out, "\n")
}
end_ftable_
# Print page table index?
if (and (what, FMD_PTINDEX) == 0)
goto end_ptindex_
call fprintf (out,
"=================== page table index ====================\n")
do i = 0, FM_PTINPTI(fm) - 1 {
call fprintf (out, " %4d")
call pargi (Memi[FM_PTINDEX(fm)+i])
if (mod (i+1, 15) == 0)
call fprintf (out, "\n")
}
if (mod (FM_PTINPTI(fm), 15) != 0)
call fprintf (out, "\n")
end_ptindex_
# Print page table?
if (and (what, FMD_PTABLE) == 0)
goto end_ptable_
call fprintf (out,
"====================== page table =======================\n")
do i = 0, FM_PTNPTE(fm) - 1 {
call fprintf (out, " %4d")
call pargs (Mems[FM_PTABLE(fm)+i])
if (mod (i+1, 15) == 0)
call fprintf (out, "\n")
}
if (mod (FM_PTINPTI(fm), 15) != 0)
call fprintf (out, "\n")
end_ptable_
call flush (out)
end
|