ldivmod, uldivmod: fix qdivrem calls
[minix.git] / servers / mfs / buf.h
blobd6a20dfa33ceaaaceda61de1b7876300ca08f770
1 #ifndef __MFS_BUF_H__
2 #define __MFS_BUF_H__
4 #include "clean.h"
6 /* Buffer (block) cache. To acquire a block, a routine calls get_block(),
7 * telling which block it wants. The block is then regarded as "in use"
8 * and has its 'b_count' field incremented. All the blocks that are not
9 * in use are chained together in an LRU list, with 'front' pointing
10 * to the least recently used block, and 'rear' to the most recently used
11 * block. A reverse chain, using the field b_prev is also maintained.
12 * Usage for LRU is measured by the time the put_block() is done. The second
13 * parameter to put_block() can violate the LRU order and put a block on the
14 * front of the list, if it will probably not be needed soon. If a block
15 * is modified, the modifying routine must set b_dirt to DIRTY, so the block
16 * will eventually be rewritten to the disk.
19 #include <dirent.h>
21 union fsdata_u {
22 char b__data[_MAX_BLOCK_SIZE]; /* ordinary user data */
23 /* directory block */
24 struct direct b__dir[NR_DIR_ENTRIES(_MAX_BLOCK_SIZE)];
25 /* V1 indirect block */
26 zone1_t b__v1_ind[V1_INDIRECTS];
27 /* V2 indirect block */
28 zone_t b__v2_ind[V2_INDIRECTS(_MAX_BLOCK_SIZE)];
29 /* V1 inode block */
30 d1_inode b__v1_ino[V1_INODES_PER_BLOCK];
31 /* V2 inode block */
32 d2_inode b__v2_ino[V2_INODES_PER_BLOCK(_MAX_BLOCK_SIZE)];
33 /* bit map block */
34 bitchunk_t b__bitmap[FS_BITMAP_CHUNKS(_MAX_BLOCK_SIZE)];
37 /* A block is free if b_dev == NO_DEV. */
40 /* These defs make it possible to use to bp->b_data instead of bp->b.b__data */
41 #define b_data(b) ((union fsdata_u *) b->data)->b__data
42 #define b_dir(b) ((union fsdata_u *) b->data)->b__dir
43 #define b_v1_ind(b) ((union fsdata_u *) b->data)->b__v1_ind
44 #define b_v2_ind(b) ((union fsdata_u *) b->data)->b__v2_ind
45 #define b_v1_ino(b) ((union fsdata_u *) b->data)->b__v1_ino
46 #define b_v2_ino(b) ((union fsdata_u *) b->data)->b__v2_ino
47 #define b_bitmap(b) ((union fsdata_u *) b->data)->b__bitmap
49 #endif