xref: /haiku/src/add-ons/kernel/file_systems/ext2/ExtentStream.h (revision 1a76488fc88584bf66b9751d7fb9b6527ac20d87)
1 /*
2  * Copyright 2001-2011, Haiku Inc. All rights reserved.
3  * This file may be used under the terms of the MIT License.
4  *
5  * Authors:
6  *		Jérôme Duval
7  */
8 #ifndef EXTENTSTREAM_H
9 #define EXTENTSTREAM_H
10 
11 
12 #include "ext2.h"
13 #include "Transaction.h"
14 
15 
16 class Inode;
17 class Volume;
18 
19 
20 class ExtentStream
21 {
22 public:
23 					ExtentStream(Volume* volume, Inode* inode,
24 						ext2_extent_stream* stream, off_t size);
25 					~ExtentStream();
26 
27 	status_t		FindBlock(off_t offset, fsblock_t& block,
28 						uint32 *_count = NULL);
29 	status_t		Enlarge(Transaction& transaction, off_t& numBlocks);
30 	status_t		Shrink(Transaction& transaction, off_t& numBlocks);
31 	void			Init();
32 
33 	bool			Check();
34 
35 private:
36 	status_t		_Check(ext2_extent_stream *stream, fileblock_t &block);
37 	status_t		_CheckBlock(ext2_extent_stream *stream, fsblock_t block);
38 
39 	Volume*			fVolume;
40 	Inode*			fInode;
41 	ext2_extent_stream* fStream;
42 	fsblock_t		fFirstBlock;
43 
44 	fsblock_t		fAllocatedPos;
45 
46 	off_t			fNumBlocks;
47 	off_t			fSize;
48 };
49 
50 #endif	// EXTENTSTREAM_H
51 
52