1 | /* disk.h 2 | ------ 3 | 4 | FCFS Disk abstraction. 5 | 6 | $Id: disk.h,v 1.7 2003/10/20 07:18:11 stewart Exp $ 7 | 8 | (C)2003 Stewart Smith 9 | Distributed under the GNU Public License 10 | */ 11 | 12 | #ifndef __DISK_H__ 13 | #define __DISK_H__ 14 | 15 | #include "testkit/block_dev.h" 16 | #include "testkit/types.h" 17 | 18 | struct fcfs_disk { 19 | sector_t blocksnr; /* number of blocks */ 20 | u32 bsize; /* Size of blocks */ 21 | struct fcfs_disk_block *sb_block; 22 | struct fcfs_sb* sb; /* The Disk SuperBlock */ 23 | void* os_private; /* Used by OS for it's structure */ 24 | }; 25 | 26 | struct fcfs_disk_block { 27 | sector_t blocknr; /* Number of block*/ 28 | u32 bsize; /* Size of block*/ 29 | char* data; /* Block data */ 30 | struct fcfs_disk *disk; /* The disk the block is from */ 31 | void* os_private; /* The OS data structure */ 32 | }; 33 | 34 | #define BR_SECTOR_T(disk,br) (((disk)->sb->ag_blocksnr * (br)->allocation_group) + (br)->start) 35 | 36 | struct fcfs_disk* disk_new(struct block_device *bdev); 37 | struct fcfs_disk* disk_free(struct fcfs_disk* disk); 38 | 39 | struct fcfs_disk_block* disk_newblock(struct fcfs_disk *disk,sector_t block); 40 | struct fcfs_disk_block* disk_getblock(struct fcfs_disk *disk,sector_t block); 41 | //static inline struct fcfs_disk_block* disk_freeblock(struct fcfs_disk_block* block); 42 | //static inline struct fcfs_disk_block* disk_writeblock(struct fcfs_disk_block* block); 43 | 44 | /* When finished using a disk block */ 45 | static inline struct fcfs_disk_block* disk_freeblock(struct fcfs_disk_block* block) 46 | { 47 | ((struct buffer_head*)(block->os_private))->b_count--; 48 | return block; 49 | } 50 | 51 | /* Write a disk block immediately. */ 52 | static inline struct fcfs_disk_block* disk_writeblock(struct fcfs_disk_block* block) 53 | { 54 | set_buffer_dirty((struct buffer_head*)block->os_private); 55 | submit_bh(WRITE,(struct buffer_head*)block->os_private); 56 | return block; 57 | } 58 | 59 | 60 | #endif