vm: fix potential null deref
[minix.git] / servers / ext2 / buf.h
blobb4bfae4ca99a4607797117fc3f5cb632a520bb06
1 /* Buffer (block) cache. To acquire a block, a routine calls get_block(),
2 * telling which block it wants. The block is then regarded as "in use"
3 * and has its 'b_count' field incremented. All the blocks that are not
4 * in use are chained together in an LRU list, with 'front' pointing
5 * to the least recently used block, and 'rear' to the most recently used
6 * block. A reverse chain, using the field b_prev is also maintained.
7 * Usage for LRU is measured by the time the put_block() is done. The second
8 * parameter to put_block() can violate the LRU order and put a block on the
9 * front of the list, if it will probably not be needed soon. If a block
10 * is modified, the modifying routine must set b_dirt to DIRTY, so the block
11 * will eventually be rewritten to the disk.
14 #ifndef EXT2_BUF_H
15 #define EXT2_BUF_H
17 #include <dirent.h>
19 union fsdata_u {
20 char b__data[_MAX_BLOCK_SIZE]; /* ordinary user data */
21 /* indirect block */
22 block_t b__ind[_MAX_BLOCK_SIZE/sizeof(block_t)];
23 /* bit map block */
24 bitchunk_t b__bitmap[FS_BITMAP_CHUNKS(_MAX_BLOCK_SIZE)];
27 /* A block is free if b_dev == NO_DEV. */
29 /* These defs make it possible to use to bp->b_data instead of bp->b.b__data */
30 #define b_data(bp) ((union fsdata_u *) bp->data)->b__data
31 #define b_ind(bp) ((union fsdata_u *) bp->data)->b__ind
32 #define b_bitmap(bp) ((union fsdata_u *) bp->data)->b__bitmap
34 #endif /* EXT2_BUF_H */