1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
/*
* blkio/blkio.h
*
* Copyright (C) 1998 Russell King
*
* The block I/O interface allows a OS-independent method to access devices
*
* Public structures for block I/O based routines
*/
#ifndef BLKIO_BLKIO_H
#define BLKIO_BLKIO_H
#include "util/types.h"
typedef u_int64_t blk_t;
typedef struct {
u_int cylinders;
u_int heads;
u_int sectors;
u_int sector_size; /* read-only! */
u_int log2secsize; /* read-only! */
} geometry_t;
typedef struct {
#ifdef UNIX
/* Unix specific I/O data */
int fd; /* File descriptor */
#endif
#ifdef RISCOS
/* RiscOS specific I/O data */
u_int swi_describedisc; /* SWI number for xxx_DescribeDisc */
u_int swi_discop; /* SWI number for xxx_DiscOp */
u_int swi_sectorop; /* SWI number for xxx_SectorOp */
u_int swi_controllertype; /* SWI number for xxx_ControllerType */
u_int swi_ideuserop; /* SWI number for xxx_IDEUserOp */
union disc_record *disc_record; /* Disc Record to pass with DiscOp/SectorOp */
u_int drive;
#endif
geometry_t geometry;
int blocksize; /* Size of a block */
} blkio_t;
/* Function: blkio_t *blkio_close (blkio_t *blkio)
* Purpose : close a device previously opened with blkio_open
* Params : blkio - structure returned by blkio_open
* Returns : NULL
*/
extern blkio_t *blkio_close (blkio_t *blkio);
/* Function: u_int blkio_getgeometry (blkio_t *blkio, geometry_t *geo)
* Purpose : Return the geometry for the device opened with blkio_open
* Params : blkio - structure returned by blkio_open
* : geo - pointer to geometry structure
*/
extern u_int blkio_getgeometry (blkio_t *blkio, geometry_t *geo);
/* Function: blkio_t *blkio_open (const char *dev_name)
* Purpose : Open a device, specified in dev_name and return a structure
* Params : dev_name - device name (eg, ADFS::4, /dev/hda etc)
* Returns : pointer to above structure (to be used by all other calls)
*/
extern blkio_t *blkio_open (const char *dev_name);
/* Function: u_int blkio_setblocksize (blkio_t *blkio, u_int blocksize)
* Purpose : Set the block size for all subsequent block IO routines
* Params : blkio - structure returned by blkio_open
* : blocksize - new block size to use
* Returns : block size that will be used
*/
extern u_int blkio_setblocksize (blkio_t *blkio, u_int blocksize);
/* Function: u_int blkio_setgeometry (blkio_t *blkio, geometry_t *geo)
* Purpose : Set the geometry for the device opened with blkio_open
* Params : blkio - structure returned by blkio_open
* : geo - pointer to geometry structure
*/
extern u_int blkio_setgeometry (blkio_t *blkio, const geometry_t *geo);
/* Function: u_int blkio_read (blkio_t *blkio, void *data, blk_t block, u_int nr_blocks)
* Purpose : Read `nr_blocks' blocks starting at `block' from the device previously opened
* with blkio_open into memory area `data'
* Params : blkio - structure returned by blkio_open
* : data - memory area to read into
* : block - block number to read
* : nr_blocks - number of blocks to read
* Returns : number of blocks actually read
*/
extern u_int blkio_read (blkio_t *blkio, void *data, blk_t block, u_int nr_blocks);
/* Function: u_int blkio_write (blkio_t *blkio, const void *data, blk_t block, u_int nr_blocks)
* Purpose : Write `nr_blocks' blocks starting at `block' from the device previously opened
* with blkio_open into memory area `data'
* Params : blkio - structure returned by blkio_open
* : data - memory area to write data from
* : block - block number to write
* : nr_blocks - number of blocks to write
* Returns : number of blocks actually written
*/
extern u_int blkio_write (blkio_t *blkio, const void *data, blk_t block, u_int nr_blocks);
#endif
|