vfs: check userland buffers before reading them.
[haiku.git] / src / system / boot / loader / file_systems / fat / CachedBlock.h
blobab6f6f5342b002fb6a3fb0241f3003eceb53346d
1 /*
2 * Copyright 2008, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * François Revol <revol@free.fr>
7 */
8 #ifndef CACHED_BLOCK_H
9 #define CACHED_BLOCK_H
12 #include "Volume.h"
15 namespace FATFS {
18 class CachedBlock {
19 public:
20 enum {
21 READ = 0x01,
22 CLEAR = 0x02,
23 FORCE = 0x04,
26 public:
27 CachedBlock(Volume &volume);
28 CachedBlock(Volume &volume, off_t block);
29 ~CachedBlock();
31 uint8 *SetTo(off_t block);
32 status_t SetTo(off_t blockNumber, uint32 flags);
33 status_t Flush();
35 void Unset();
37 uint8 *Block() const { return fBlock; }
38 off_t BlockNumber() const { return fBlockNumber; }
39 uint32 BlockSize() const { return fVolume.BlockSize(); }
40 uint32 BlockShift() const { return fVolume.BlockShift(); }
42 private:
43 Volume &fVolume;
44 off_t fBlockNumber;
45 uint8 *fBlock;
49 inline void
50 CachedBlock::Unset()
52 fBlockNumber = -1;
56 } // namespace FATFS
59 #endif /* CACHED_BLOCK_H */