]> git.ipfire.org Git - thirdparty/squid.git/blob - src/fs/ufs/RebuildState.h
Merge from trunk
[thirdparty/squid.git] / src / fs / ufs / RebuildState.h
1 /*
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_FS_UFS_REBUILDSTATE_H
10 #define SQUID_FS_UFS_REBUILDSTATE_H
11
12 #include "base/RefCount.h"
13 #include "store_rebuild.h"
14 #include "UFSSwapDir.h"
15 #include "UFSSwapLogParser.h"
16
17 class StoreEntry;
18
19 namespace Fs
20 {
21 namespace Ufs
22 {
23
24 class RebuildState : public RefCountable
25 {
26 CBDATA_CLASS(RebuildState);
27
28 public:
29 static EVH RebuildStep;
30
31 RebuildState(RefCount<UFSSwapDir> sd);
32 ~RebuildState();
33
34 virtual bool error() const;
35 virtual bool isDone() const;
36 virtual StoreEntry *currentItem();
37
38 RefCount<UFSSwapDir> sd;
39 int n_read;
40 /* FILE *log;*/
41 Fs::Ufs::UFSSwapLogParser *LogParser;
42 int curlvl1;
43 int curlvl2;
44
45 struct Flags {
46 Flags() : need_to_validate(false), clean(false), init(false) {}
47 bool need_to_validate;
48 bool clean;
49 bool init;
50 } flags;
51 int in_dir;
52 int done;
53 int fn;
54
55 dirent_t *entry;
56 DIR *td;
57 char fullpath[MAXPATHLEN];
58 char fullfilename[MAXPATHLEN];
59
60 StoreRebuildData counts;
61
62 private:
63 void rebuildFromDirectory();
64 void rebuildFromSwapLog();
65 void rebuildStep();
66 void undoAdd();
67 int getNextFile(sfileno *, int *size);
68 StoreEntry *currentEntry() const;
69 void currentEntry(StoreEntry *);
70 StoreEntry *e;
71 bool fromLog;
72 bool _done;
73 /// \bug (callback) should be hidden behind a proper human readable name
74 void (callback)(void *cbdata);
75 void *cbdata;
76 };
77
78 } /* namespace Ufs */
79 } /* namespace Fs */
80
81 #endif /* SQUID_FS_UFS_REBUILDSTATE_H */
82