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