Add fbd -- Faulty Block Device driver
This driver can be loaded as an overlay on top of a real block device, and can then be used to generate block-level failures for certain transfer requests. Specifically, a rule-based system allows the user to introduce (overt and silent) data corruption and errors. It exposes itself through /dev/fbd, and a file system can be mounted on top of it. The new fbdctl(8) tool can be used to control the driver; see ``man fbdctl'' for details. It also comes with a test set, located in test/fbdtest.
This commit is contained in:
@@ -30,7 +30,7 @@ enum dev_style { STYLE_NDEV, STYLE_DEV, STYLE_DEVA, STYLE_TTY, STYLE_CTTY,
|
||||
#define FILTER_MAJOR 11 /* 11 = /dev/filter (filter driver) */
|
||||
/* 12 = /dev/c3 */
|
||||
#define AUDIO_MAJOR 13 /* 13 = /dev/audio (audio driver) */
|
||||
/* 14 = not used */
|
||||
#define FBD_MAJOR 14 /* 14 = /dev/fbd (faulty block dev)*/
|
||||
#define LOG_MAJOR 15 /* 15 = /dev/klog (log driver) */
|
||||
#define RANDOM_MAJOR 16 /* 16 = /dev/random (random driver) */
|
||||
#define HELLO_MAJOR 17 /* 17 = /dev/hello (hello driver) */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
.PATH: ${MINIXSRCDIR}/common/include/sys
|
||||
|
||||
INCS+= elf32.h elf64.h elf_common.h elf_generic.h \
|
||||
ioc_block.h ioc_file.h ioc_tape.h ioc_disk.h \
|
||||
ioc_block.h ioc_fbd.h ioc_file.h ioc_tape.h ioc_disk.h \
|
||||
ioc_memory.h ioc_sound.h ioc_tty.h \
|
||||
kbdio.h mtio.h svrctl.h video.h vm.h procfs.h elf_core.h exec_elf.h
|
||||
|
||||
|
||||
66
common/include/sys/ioc_fbd.h
Normal file
66
common/include/sys/ioc_fbd.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* sys/ioc_fbd.h - Faulty Block Device ioctl() command codes.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _S_I_FBD_H
|
||||
#define _S_I_FBD_H
|
||||
|
||||
/* FBD rule structure. */
|
||||
|
||||
typedef int fbd_rulenum_t;
|
||||
|
||||
struct fbd_rule {
|
||||
fbd_rulenum_t num; /* rule number (1-based) */
|
||||
u64_t start; /* start position of area to match */
|
||||
u64_t end; /* end position (exclusive) (0 = up to EOF) */
|
||||
int flags; /* match read and/or write requests */
|
||||
unsigned int skip; /* # matches to skip before activating */
|
||||
unsigned int count; /* # times left to trigger (0 = no limit) */
|
||||
int action; /* action type to perform when triggered */
|
||||
|
||||
union { /* action parameters */
|
||||
struct {
|
||||
int type; /* corruption type */
|
||||
} corrupt;
|
||||
|
||||
struct {
|
||||
int code; /* error code to return (OK, EIO..) */
|
||||
} error;
|
||||
|
||||
struct {
|
||||
u64_t start; /* start position of target area */
|
||||
u64_t end; /* end position of area (excl) */
|
||||
u32_t align; /* alignment to use in target area */
|
||||
} misdir;
|
||||
|
||||
struct {
|
||||
u32_t lead; /* # bytes to process normally */
|
||||
} losttorn;
|
||||
} params;
|
||||
};
|
||||
|
||||
/* Match flags. */
|
||||
#define FBD_FLAG_READ 0x1 /* match read requests */
|
||||
#define FBD_FLAG_WRITE 0x2 /* match write requests */
|
||||
|
||||
/* Action types. */
|
||||
enum {
|
||||
FBD_ACTION_CORRUPT, /* write or return corrupt data */
|
||||
FBD_ACTION_ERROR, /* return an I/O error */
|
||||
FBD_ACTION_MISDIR, /* perform a misdirected write */
|
||||
FBD_ACTION_LOSTTORN /* perform a lost or torn write */
|
||||
};
|
||||
|
||||
/* Corruption types. */
|
||||
enum {
|
||||
FBD_CORRUPT_ZERO, /* write or return ..zeroed data */
|
||||
FBD_CORRUPT_PERSIST, /* ..consequently the same bad data */
|
||||
FBD_CORRUPT_RANDOM /* ..new random data every time */
|
||||
};
|
||||
|
||||
/* The I/O control requests. */
|
||||
#define FBDCADDRULE _IOW('F', 1, struct fbd_rule) /* add a rule */
|
||||
#define FBDCDELRULE _IOW('F', 2, fbd_rulenum_t) /* delete a rule */
|
||||
#define FBDCGETRULE _IORW('F', 3, struct fbd_rule) /* retrieve a rule */
|
||||
|
||||
#endif /* _S_I_FBD_H */
|
||||
Reference in New Issue
Block a user