-
Notifications
You must be signed in to change notification settings - Fork 2
/
stats.c
116 lines (103 loc) · 2.05 KB
/
stats.c
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
/* $Id: stats.c 49096 2014-07-01 18:48:17Z twilen $ */
/* $Log: stats.c $
* Revision 1.4 1999/05/28 05:07:33 Michiel
* Fixed bug occuring on empty directory blocks
* Added rbl.always fix; improved rbl.disksize fix
* Reduced cachesize
*
* Revision 1.3 1999/05/04 17:59:09 Michiel
* check mode, logfile, search rootblock implemented
* bugfixes
*
* Revision 1.2 1999/05/04 04:27:13 Michiel
* debugged upto buildrext
*
* Revision 1.1 1999/04/22 15:24:28 Michiel
* Initial revision
* */
#include <exec/types.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "pfs3.h"
#include "doctor.h"
static char msgbuffer[512];
static BOOL error = FALSE;
static BOOL fixed = FALSE;
void clearstats(void)
{
stats.numfiles =
stats.numdirs =
stats.numsoftlink =
stats.numhardlink =
stats.numrollover =
stats.fragmentedfiles =
stats.anodesused = 0;
volume.updatestats();
}
void adderror(char *message, ...)
{
if (!error)
{
if (stats.blocknr)
error = TRUE;
stats.numerrors++;
}
if (message)
{
va_list parms;
va_start(parms, message);
strcpy(msgbuffer, "ERROR:");
vsprintf(msgbuffer + strlen(msgbuffer), message, parms);
va_end(parms);
strcat(msgbuffer, "\n");
volume.showmsg(msgbuffer);
}
volume.updatestats();
}
void fixederror(char *message, ...)
{
if (mode == check)
{
adderror(message);
return;
}
adderror(NULL);
if (!fixed)
{
if (stats.blocknr)
fixed = TRUE;
stats.errorsfixed++;
}
if (message)
{
va_list parms;
va_start(parms, message);
strcpy(msgbuffer, "FIXED:");
vsprintf(msgbuffer + strlen(msgbuffer), message, parms);
va_end(parms);
strcat(msgbuffer, "\n");
volume.showmsg(msgbuffer);
}
else
volume.showmsg("FIXED\n");
volume.updatestats();
}
void enterblock(uint32 blknr)
{
if (blknr != stats.blocknr)
{
if (stats.blocknr)
stats.prevblknr = stats.blocknr;
stats.blocknr = blknr;
error = fixed = FALSE;
stats.blockschecked++;
volume.updatestats(); /* optimise !! */
}
}
void exitblock(void)
{
stats.blocknr = stats.prevblknr;
stats.prevblknr = 0;
return;
}