return blkdev_transfer(minor, false, rawflag);
}
+int blkdev_ioctl(uint8_t minor, uint16_t request, char *data)
+{
+ blkdev_t *blk;
+ data; /* unused */
+
+ if(request != BLOCK_FLUSH_CACHE){
+ udata.u_error = ENXIO;
+ return -1;
+ }
+
+ /* we trust that blkdev_open() has already verified that this minor number is valid */
+ blk = &blkdev_table[minor >> 4];
+
+ if(blk->flush)
+ return blk->flush(blk->drive_number);
+ else
+ return 0;
+}
+
/* FIXME: this would tidier and handle odd partition types sanely if split
into blkdev_alloc() - just returns a device, and blkdev_scan() */
/* block device drives should call blkdev_add() for each block device found,
and implement a sector transfer function matching the following prototype. */
typedef bool (*transfer_function_t)(uint8_t drive, uint32_t lba, void *buffer, bool read_notwrite);
-
+typedef int (*flush_function_t)(uint8_t drive);
/* the following details should be required only by partition parsing code */
#define MAX_PARTITIONS 15 /* must be at least 4, at most 15 */
typedef struct {
transfer_function_t transfer; /* function to read and write sectors */
+ flush_function_t flush; /* flush device cache */
uint32_t drive_lba_count; /* count of sectors on raw disk device */
uint32_t lba_first[MAX_PARTITIONS]; /* LBA of first sector of each partition; 0 if partition absent */
uint32_t lba_count[MAX_PARTITIONS]; /* count of sectors in each partition; 0 if partition absent */
extern int blkdev_open(uint8_t minor, uint16_t flags);
extern int blkdev_read(uint8_t minor, uint8_t rawflag, uint8_t flag);
extern int blkdev_write(uint8_t minor, uint8_t rawflag, uint8_t flag);
+extern int blkdev_flush(uint8_t minor);
+extern int blkdev_ioctl(uint8_t minor, uint16_t request, char *data);
#endif