xref: /haiku/src/add-ons/kernel/file_systems/ext2/ExtentStream.h (revision ce4e12ca3e341178e3df50ef67cf7c1d724e9559)
145af882dSJérôme Duval /*
2d482c34eSJérôme Duval  * Copyright 2001-2011, Haiku Inc. All rights reserved.
345af882dSJérôme Duval  * This file may be used under the terms of the MIT License.
445af882dSJérôme Duval  *
545af882dSJérôme Duval  * Authors:
645af882dSJérôme Duval  *		Jérôme Duval
745af882dSJérôme Duval  */
845af882dSJérôme Duval #ifndef EXTENTSTREAM_H
945af882dSJérôme Duval #define EXTENTSTREAM_H
1045af882dSJérôme Duval 
11d482c34eSJérôme Duval 
1245af882dSJérôme Duval #include "ext2.h"
1345af882dSJérôme Duval #include "Transaction.h"
1445af882dSJérôme Duval 
1545af882dSJérôme Duval 
16*ce4e12caSJérôme Duval class Inode;
1745af882dSJérôme Duval class Volume;
1845af882dSJérôme Duval 
1945af882dSJérôme Duval 
2045af882dSJérôme Duval class ExtentStream
2145af882dSJérôme Duval {
2245af882dSJérôme Duval public:
23*ce4e12caSJérôme Duval 					ExtentStream(Volume* volume, Inode* inode,
24*ce4e12caSJérôme Duval 						ext2_extent_stream* stream, off_t size);
2545af882dSJérôme Duval 					~ExtentStream();
2645af882dSJérôme Duval 
2745af882dSJérôme Duval 	status_t		FindBlock(off_t offset, fsblock_t& block,
2845af882dSJérôme Duval 						uint32 *_count = NULL);
2945af882dSJérôme Duval 	status_t		Enlarge(Transaction& transaction, off_t& numBlocks);
3045af882dSJérôme Duval 	status_t		Shrink(Transaction& transaction, off_t& numBlocks);
3145af882dSJérôme Duval 	void			Init();
3245af882dSJérôme Duval 
3345af882dSJérôme Duval 	bool			Check();
3445af882dSJérôme Duval 
3545af882dSJérôme Duval private:
3645af882dSJérôme Duval 	status_t		_Check(ext2_extent_stream *stream, fileblock_t &block);
3745af882dSJérôme Duval 	status_t		_CheckBlock(ext2_extent_stream *stream, fsblock_t block);
3845af882dSJérôme Duval 
3945af882dSJérôme Duval 	Volume*			fVolume;
40*ce4e12caSJérôme Duval 	Inode*			fInode;
4145af882dSJérôme Duval 	ext2_extent_stream* fStream;
4245af882dSJérôme Duval 	fsblock_t		fFirstBlock;
4345af882dSJérôme Duval 
4445af882dSJérôme Duval 	fsblock_t		fAllocatedPos;
4545af882dSJérôme Duval 
4645af882dSJérôme Duval 	off_t			fNumBlocks;
4745af882dSJérôme Duval 	off_t			fSize;
4845af882dSJérôme Duval };
4945af882dSJérôme Duval 
5045af882dSJérôme Duval #endif	// EXTENTSTREAM_H
5145af882dSJérôme Duval 
52