block_dev.h
-----------
$Id: block_dev.h,v 1.13 2003/10/01 05:42:06 stewart Exp $
Designed to be rather similar to the Linux Buffer Cache,
i.e. with functions like bread() et al that function similarly.
Should allow testing and development of filesystems purely in
userspace and purely in an application.
User Mode Linux could be used for this, but this suite is designed
for even earlier in the design process.
(C)2003 Stewart Smith
Distributed under the GNU Public License.
Some data structures have been constructed out of those
present in the Linux Kernel (v2.5.69). They are copyright
of their respective owners.
Included Files
- #include </usr/include/glib-1.2/glib.h>
Preprocessor definitions
#define __GXX_ABI_VERSION 102
#define __SIZE_TYPE__
#define __PTRDIFF_TYPE__ int
#define __WCHAR_TYPE__
#define __WINT_TYPE__
#define __SCHAR_MAX__ 127
#define __SHRT_MAX__ 32767
#define __INT_MAX__ 2147483647
#define __LONG_MAX__ 2147483647L
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __WCHAR_MAX__ 2147483647
#define __CHAR_BIT__ 8
#define __FLT_EVAL_METHOD__ 0
#define __FLT_RADIX__ 2
#define __FLT_MANT_DIG__ 24
#define __FLT_DIG__ 6
#define __FLT_MIN_EXP__ -125
#define __FLT_MIN_10_EXP__ -37
#define __FLT_MAX_EXP__ 128
#define __FLT_MAX_10_EXP__ 38
#define __FLT_MAX__ 3.40282347e+38F
#define __FLT_MIN__ 1.17549435e-38F
#define __FLT_EPSILON__ 1.19209290e-7F
#define __FLT_DENORM_MIN__ 1.40129846e-45F
#define __DBL_MANT_DIG__ 53
#define __DBL_DIG__ 15
#define __DBL_MIN_EXP__ -1021
#define __DBL_MIN_10_EXP__ -307
#define __DBL_MAX_EXP__ 1024
#define __DBL_MAX_10_EXP__ 308
#define __DBL_MAX__ 1.7976931348623157e+308
#define __DBL_MIN__ 2.2250738585072014e-308
#define __DBL_EPSILON__ 2.2204460492503131e-16
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __LDBL_MANT_DIG__ 53
#define __LDBL_DIG__ 15
#define __LDBL_MIN_EXP__ -1021
#define __LDBL_MIN_10_EXP__ -307
#define __LDBL_MAX_EXP__ 1024
#define __LDBL_MAX_10_EXP__ 308
#define __DECIMAL_DIG__ 17
#define __LDBL_MAX__ 1.7976931348623157e+308L
#define __LDBL_MIN__ 2.2250738585072014e-308L
#define __LDBL_EPSILON__ 2.2204460492503131e-16L
#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
#define __REGISTER_PREFIX__
#define __USER_LABEL_PREFIX__
#define __VERSION__ "3.3.2 (Debian)"
#define __STDC_HOSTED__ 1
#define __NO_INLINE__ 1
#define __FINITE_MATH_ONLY__ 0
#define __CHAR_UNSIGNED__ 1
#define _ARCH_PPC 1
#define __BIG_ENDIAN__ 1
#define _BIG_ENDIAN 1
#define _CALL_SYSV 1
#define __PPC 1
#define __PPC__ 1
#define PPC 1
#define __ELF__ 1
#define __powerpc 1
#define __powerpc__ 1
#define powerpc 1
#define __GNUC__ 3
#define __GNUC_MINOR__ 3
#define __GNUC_PATCHLEVEL__ 2
#define __unix__ 1
#define __gnu_linux__ 1
#define __linux__ 1
#define unix 1
#define __unix 1
#define linux 1
#define __linux 1
#define __BLOCK_DEV_H__
Macro tricks to exapnd the set_buffer_foo(), clear_buffer_foo()
and buffer_foo() functions
#define BUFFER_FNS( bit, name )
test_set_buffer_foo() and test_clear_buffer_foo()
#define TAS_BUFFER_FNS( bit, name )
for submit_bh
#define READ 1
#define WRITE 2
struct block_device
-------------------
A really simple block_device structure.
$Id: block_dev.h,v 1.13 2003/10/01 05:42:06 stewart Exp $
struct block_device
struct block_device |
|
{ |
|
char* name; |
|
int file_on_disk; |
|
u64 block_size; |
|
u64 num_blocks; |
|
u64 cache_hit; | Internal
|
u64 cache_hit_clear; |
|
u64 cache_miss; |
|
u64 cache_miss_clear; |
|
} |
|
struct super_block
struct super_block |
|
{ |
|
unsigned long s_blocksize; | ev_t s_dev; /* search index; _not_ kdev_t */
|
unsigned long s_old_blocksize; |
|
unsigned char s_blocksize_bits; |
|
unsigned char s_dirt; |
|
unsigned long long s_maxbytes; | Max file size
|
unsigned long s_flags; | truct export_operations *s_export_op;
|
unsigned long s_magic; |
|
int s_count; | truct semaphore s_lock;
|
int s_syncing; |
|
int s_need_sync_fs; |
|
void* s_security; | tomic_t s_active;
|
struct block_device* s_bdev; | truct list_head s_files;
|
char s_id[32]; | Informational name
|
void* s_fs_info; | Filesystem private info
|
} |
|
bh_state-bits
-------------
straight from include/linux/buffer_head.h (kernel 2.5.69)
enum bh_state_bits
enum bh_state_bits |
|
{ |
|
BH_Uptodate; | Contains valid data
|
BH_Dirty; | Is dirty
|
BH_Lock; | Is locked
|
BH_Req; | Has been submitted for I/O
|
BH_Mapped; | Has a disk mapping
|
BH_New; | Disk mapping was newly created by get_block
|
BH_Async_Read; | Is under end_buffer_async_read I/O
|
BH_Async_Write; | Is under end_buffer_async_write I/O
|
BH_Delay; | Buffer is not yet allocated on disk
|
BH_Boundary; | Block is followed by a discontiguity
|
BH_PrivateStart; | not a state bit, but the first bit available
* for private allocation by other entities
|
} |
|
buffer_head
-----------
straight from include/linux/buffer_head.h (kernel 2.5.69)
We've comment out things we don't really care too much about.
$Id: block_dev.h,v 1.13 2003/10/01 05:42:06 stewart Exp $
struct buffer_head
struct buffer_head |
|
{ |
|
unsigned long b_state; | buffer state bitmap (see above)
|
atomic_t b_count; | users using this block
|
struct buffer_head* b_this_page; | circular list of page's buffers
|
sector_t b_blocknr; | block number
|
u32 b_size; | block size
|
char* b_data; | pointer to data block
|
struct block_device* b_bdev; |
|
} |
|
static inline int buffer_async_read ( struct buffer_head* bh )
static inline int buffer_async_write ( struct buffer_head* bh )
static inline int buffer_boundary ( struct buffer_head* bh )
static inline int buffer_delay ( struct buffer_head* bh )
static inline int buffer_dirty ( struct buffer_head* bh )
static inline int buffer_locked ( struct buffer_head* bh )
static inline int buffer_mapped ( struct buffer_head* bh )
static inline int buffer_new ( struct buffer_head* bh )
static inline int buffer_req ( struct buffer_head* bh )
static inline int buffer_uptodate ( struct buffer_head* bh )
static inline void clear_buffer_async_read ( struct buffer_head* bh )
static inline void clear_buffer_async_write ( struct buffer_head* bh )
static inline void clear_buffer_boundary ( struct buffer_head* bh )
static inline void clear_buffer_delay ( struct buffer_head* bh )
static inline void clear_buffer_dirty ( struct buffer_head* bh )
static inline void clear_buffer_locked ( struct buffer_head* bh )
static inline void clear_buffer_mapped ( struct buffer_head* bh )
static inline void clear_buffer_new ( struct buffer_head* bh )
static inline void clear_buffer_req ( struct buffer_head* bh )
static inline void clear_buffer_uptodate ( struct buffer_head* bh )
reads block as per super block info
static inline struct buffer_head* sb_bread ( struct super_block* sb, sector_t block )
static inline void set_buffer_async_read ( struct buffer_head* bh )
static inline void set_buffer_async_write ( struct buffer_head* bh )
static inline void set_buffer_boundary ( struct buffer_head* bh )
static inline void set_buffer_delay ( struct buffer_head* bh )
static inline void set_buffer_dirty ( struct buffer_head* bh )
static inline void set_buffer_locked ( struct buffer_head* bh )
static inline void set_buffer_mapped ( struct buffer_head* bh )
static inline void set_buffer_new ( struct buffer_head* bh )
static inline void set_buffer_req ( struct buffer_head* bh )
Emit the buffer bitops functions.
static inline void set_buffer_uptodate ( struct buffer_head* bh )
static inline int test_clear_buffer_dirty ( struct buffer_head* bh )
static inline int test_clear_buffer_locked ( struct buffer_head* bh )
static inline int test_set_buffer_dirty ( struct buffer_head* bh )
static inline int test_set_buffer_locked ( struct buffer_head* bh )