Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / sys / ioc_fbd.h @ 14

History | View | Annotate | Download (1.82 KB)

1 13 up20180614
/*        sys/ioc_fbd.h - Faulty Block Device ioctl() command codes.
2
 *
3
 */
4
5
#ifndef _S_I_FBD_H
6
#define _S_I_FBD_H
7
8
/* FBD rule structure. */
9
10
typedef int fbd_rulenum_t;
11
12
struct fbd_rule {
13
        fbd_rulenum_t num;        /* rule number (1-based) */
14
        u64_t start;                /* start position of area to match */
15
        u64_t end;                /* end position (exclusive) (0 = up to EOF) */
16
        int flags;                /* match read and/or write requests */
17
        unsigned int skip;        /* # matches to skip before activating */
18
        unsigned int count;        /* # times left to trigger (0 = no limit) */
19
        int action;                /* action type to perform when triggered */
20
21
        union {                        /* action parameters */
22
                struct {
23
                        int type;        /* corruption type */
24
                } corrupt;
25
26
                struct {
27
                        int code;        /* error code to return (OK, EIO..) */
28
                } error;
29
30
                struct {
31
                        u64_t start;        /* start position of target area */
32
                        u64_t end;        /* end position of area (excl) */
33
                        u32_t align;        /* alignment to use in target area */
34
                } misdir;
35
36
                struct {
37
                        u32_t lead;        /* # bytes to process normally */
38
                } losttorn;
39
        } params;
40
};
41
42
/* Match flags. */
43
#define FBD_FLAG_READ        0x1                /* match read requests */
44
#define FBD_FLAG_WRITE        0x2                /* match write requests */
45
46
/* Action types. */
47
enum {
48
        FBD_ACTION_CORRUPT,                /* write or return corrupt data */
49
        FBD_ACTION_ERROR,                /* return an I/O error */
50
        FBD_ACTION_MISDIR,                /* perform a misdirected write */
51
        FBD_ACTION_LOSTTORN                /* perform a lost or torn write */
52
};
53
54
/* Corruption types. */
55
enum {
56
        FBD_CORRUPT_ZERO,                /* write or return ..zeroed data */
57
        FBD_CORRUPT_PERSIST,                /* ..consequently the same bad data */
58
        FBD_CORRUPT_RANDOM                /* ..new random data every time */
59
};
60
61
/* The I/O control requests. */
62
#define FBDCADDRULE        _IOW('B', 1, struct fbd_rule)        /* add a rule */
63
#define FBDCDELRULE        _IOW('B', 2, fbd_rulenum_t)        /* delete a rule */
64
#define FBDCGETRULE        _IOWR('B', 3, struct fbd_rule)        /* retrieve a rule */
65
66
#endif /* _S_I_FBD_H */