xfstests: remove unsupported conditionals
[xfstests-dev.git] / ltp / doio.h
1 /*
2  * Copyright (c) 2000 Silicon Graphics, Inc.
3  * All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it would be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write the Free Software Foundation,
16  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 /*
19  * Define io syscalls supported by doio
20  */
21
22 #define READ    1
23 #define WRITE   2
24 #define READA   3
25 #define WRITEA  4
26 #define SSREAD  5
27 #define SSWRITE 6
28 #define LISTIO  7
29 #define LREAD   10              /* listio - single stride, single entry */
30 #define LREADA  11
31 #define LWRITE  12
32 #define LWRITEA 13
33 #define LSREAD  14              /* listio - multi-stride, single entry */
34 #define LSREADA 15
35 #define LSWRITE 16
36 #define LSWRITEA 17
37 #define LEREAD  18              /* listio - single stride, multiple entry */
38 #define LEREADA 19
39 #define LEWRITE 20
40 #define LEWRITEA 21
41
42 /* System Calls */
43 #define PREAD   100
44 #define PWRITE  101
45 #define READV   102
46 #define WRITEV  103
47 #define AREAD   104
48 #define AWRITE  105
49 #define LLREAD  110
50 #define LLAREAD 111
51 #define LLWRITE 112
52 #define LLAWRITE 113
53 #define MMAPR   120
54 #define MMAPW   121
55 #define RESVSP  122             /* xfsctl(XFS_IOC_RESVSP) */
56 #define UNRESVSP 123            /* xfsctl(XFS_IOC_UNRESVSP) */
57 #define FSYNC2  125             /* fsync(2) */
58 #define FDATASYNC 126           /* fdatasync(2) */
59 #define DOIO_MAGIC  07116601
60
61 /*
62  * Define various user flags (r_uflag field) that io requests can have
63  * specified.
64  */
65
66 #define F_WORD_ALIGNED          0001    /* force request to be word aligned */
67
68 /*
69  * define various doio exit status's
70  */
71
72 #define E_NORMAL    000         /* normal completion                    */
73 #define E_USAGE     001         /* cmdline usage error                  */
74 #define E_SETUP     002         /* any of a million setup conditions    */
75 #define E_COMPARE   004         /* data compare error from doio child   */
76 #define E_INTERNAL  010         /* various internal errors              */
77 #define E_LOCKD     020         /* lockd startup/timeout errors         */
78 #define E_SIGNAL    040         /* killed by signal                     */
79
80 /*
81  * Define async io completion strategies supported by doio.
82  */
83
84 #define A_POLL          1               /* poll iosw for completion     */
85 #define A_SIGNAL        2               /* get signal for completion    */
86 #define A_RECALL        3               /* use recall(2) to wait        */
87 #define A_RECALLA       4               /* use recalla(2) to wait       */
88 #define A_RECALLS       5               /* use recalls(2) to wait       */
89 #define A_SUSPEND       6               /* use aio_suspend(2) to wait   */
90 #define A_CALLBACK      7               /* use a callback signal op.    */
91
92 /*
93  * Define individual structures for each syscall type.  These will all be
94  * unionized into a single io_req structure which io generators fill in and
95  * pass to doio.
96  *
97  * Note:        It is VERY important that the r_file, r_oflags, r_offset, and
98  *              r_nbytes fields occupy the same record positions in the
99  *              read_req, reada_req, write_req, and writea_req structures and
100  *              that they have the same type.  It is also that r_pattern
101  *              has the same type/offset in the write_req and writea_req
102  *              structures.
103  *
104  *              Since doio.c accesses all information through the r_data
105  *              union in io_req, if the above assumptions hold, the above
106  *              fields can be accessed without regard to structure type.
107  *              This is an allowed assumption in C.
108  */
109
110 #define MAX_FNAME_LENGTH    128
111
112 struct read_req {
113     char    r_file[MAX_FNAME_LENGTH];
114     int     r_oflags;                   /* open flags */
115     int     r_offset;
116     int     r_nbytes;
117     int     r_uflags;                   /* user flags: mem alignment */
118     int     r_aio_strat;                /* asynch read completion strategy */
119     int     r_nstrides;                 /* listio: multiple strides */
120     int     r_nent;                     /* listio: multiple list entries */
121 };
122
123 struct write_req {
124     char    r_file[MAX_FNAME_LENGTH];
125     int     r_oflags;
126     int     r_offset;
127     int     r_nbytes;
128     char    r_pattern;
129     int     r_uflags;                   /* user flags: mem alignment */
130     int     r_aio_strat;                /* asynch write completion strategy */
131     int     r_nstrides;                 /* listio: multiple strides */
132     int     r_nent;                     /* listio: multiple list entries */
133 };
134
135 struct ssread_req {
136     int     r_nbytes;
137 };
138
139 struct sswrite_req {
140     int     r_nbytes;
141     char    r_pattern;
142 };
143
144 struct listio_req {
145         char    r_file[MAX_FNAME_LENGTH];
146         int     r_cmd;                  /* LC_START or LC_WAIT */
147         int     r_offset;               /* file offset */
148         int     r_opcode;               /* LO_READ, or LO_WRITE */
149         int     r_nbytes;               /* bytes per stride */
150         int     r_nstrides;             /* how many strides to make */
151         int     r_nent;                 /* how many listreq entries to make */
152         int     r_filestride;           /* always 0 for now */
153         int     r_memstride;            /* always 0 for now */
154         char    r_pattern;              /* for LO_WRITE operations */
155         int     r_oflags;               /* open(2) flags */
156         int     r_aio_strat;            /* async I/O completion strategy */
157         int     r_uflags;               /* user flags: memory alignment */
158 };
159
160 #define rw_req  listio_req      /* listio is superset of everything */
161
162 /*
163  * Main structure for sending a request to doio.  Any tools which form IO
164  * for doio must present it using one of these structures.
165  */
166
167 struct io_req {
168     int     r_type;             /* must be one of the #defines above        */
169     int     r_magic;            /* must be set to DOIO_MAGIC by requestor   */
170     union {
171         struct read_req         read;
172         struct write_req        write;
173         struct ssread_req       ssread;
174         struct sswrite_req      sswrite;
175         struct listio_req       listio;
176         struct rw_req           io;
177     } r_data;
178 };