xref: /haiku/src/add-ons/kernel/file_systems/ext2/RevokeManager.cpp (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 /*
2  * Copyright 2001-2010, Haiku Inc. All rights reserved.
3  * This file may be used under the terms of the MIT License.
4  *
5  * Authors:
6  *		Janito V. Ferreira Filho
7  */
8 
9 
10 #include "RevokeManager.h"
11 
12 
13 //#define TRACE_EXT2
14 #ifdef TRACE_EXT2
15 #	define TRACE(x...) dprintf("\33[34mext2:\33[0m " x)
16 #else
17 #	define TRACE(x...) ;
18 #endif
19 
20 
21 RevokeManager::RevokeManager()
22 	:
23 	fRevokeCount(0)
24 {
25 }
26 
27 
28 RevokeManager::~RevokeManager()
29 {
30 }
31 
32 
33 status_t
34 RevokeManager::ScanRevokeBlock(JournalRevokeHeader* revokeBlock,
35 	uint32 commitID)
36 {
37 	TRACE("RevokeManager::ScanRevokeBlock(): Commit ID: %" B_PRIu32 "\n",
38 		commitID);
39 	int count = revokeBlock->NumBytes() / 4;
40 
41 	for (int i = 0; i < count; ++i) {
42 		TRACE("RevokeManager::ScanRevokeBlock(): Found a revoked block: %"
43 			B_PRIu32 "\n", revokeBlock->RevokeBlock(i));
44 		status_t status = Insert(revokeBlock->RevokeBlock(i), commitID);
45 
46 		if (status != B_OK) {
47 			TRACE("RevokeManager::ScanRevokeBlock(): Error inserting\n");
48 			return status;
49 		}
50 	}
51 
52 	return B_OK;
53 }
54 
55