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