]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - io/io.h
xfs_io: Allow -P and -L to be given to open for O_PATH and O_NOFOLLOW
[thirdparty/xfsprogs-dev.git] / io / io.h
1 /*
2 * Copyright (c) 2003-2005 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 #include "xfs.h"
20 #include "path.h"
21
22 /*
23 * Read/write patterns (default is always "forward")
24 */
25 #define IO_RANDOM ( 0)
26 #define IO_FORWARD ( 1)
27 #define IO_BACKWARD (-1)
28 #define IO_ONCE ( 2)
29
30 /*
31 * File descriptor options
32 */
33 #define IO_READONLY (1<<0)
34 #define IO_DIRECT (1<<1)
35 #define IO_REALTIME (1<<2)
36 #define IO_APPEND (1<<3)
37 #define IO_OSYNC (1<<4)
38 #define IO_CREAT (1<<5)
39 #define IO_TRUNC (1<<6)
40 #define IO_FOREIGN (1<<7)
41 #define IO_NONBLOCK (1<<8)
42 #define IO_TMPFILE (1<<9)
43 #define IO_PATH (1<<10)
44 #define IO_NOFOLLOW (1<<11)
45
46 /*
47 * Regular file I/O control
48 */
49 typedef struct fileio {
50 int fd; /* open file descriptor */
51 int flags; /* flags describing file state */
52 char *name; /* file name at time of open */
53 xfs_fsop_geom_t geom; /* XFS filesystem geometry */
54 struct fs_path fs_path; /* XFS path information */
55 } fileio_t;
56
57 extern fileio_t *filetable; /* open file table */
58 extern int filecount; /* number of open files */
59 extern fileio_t *file; /* active file in file table */
60 extern int filelist_f(void);
61 extern int stat_f(int argc, char **argv);
62 /*
63 * Memory mapped file regions
64 */
65 typedef struct mmap_region {
66 void *addr; /* address of start of mapping */
67 size_t length; /* length of mapping */
68 off64_t offset; /* start offset into backing file */
69 int prot; /* protection mode of the mapping */
70 bool map_sync; /* is this a MAP_SYNC mapping? */
71 char *name; /* name of backing file */
72 } mmap_region_t;
73
74 extern mmap_region_t *maptable; /* mmap'd region array */
75 extern int mapcount; /* #entries in the mapping table */
76 extern mmap_region_t *mapping; /* active mapping table entry */
77 extern int maplist_f(void);
78 extern void *check_mapping_range(mmap_region_t *, off64_t, size_t, int);
79
80 /*
81 * Various xfs_io helper routines/globals
82 */
83
84 extern off64_t filesize(void);
85 extern int openfile(char *, xfs_fsop_geom_t *, int, mode_t,
86 struct fs_path *);
87 extern int addfile(char *, int , xfs_fsop_geom_t *, int,
88 struct fs_path *);
89 extern void printxattr(uint, int, int, const char *, int, int);
90
91 extern unsigned int recurse_all;
92 extern unsigned int recurse_dir;
93
94 extern void *buffer;
95 extern size_t buffersize;
96 extern int vectors;
97 extern struct iovec *iov;
98 extern int alloc_buffer(size_t, int, unsigned int);
99 extern int read_buffer(int, off64_t, long long, long long *,
100 int, int);
101 extern void dump_buffer(off64_t, ssize_t);
102
103 extern void attr_init(void);
104 extern void bmap_init(void);
105 extern void encrypt_init(void);
106 extern void file_init(void);
107 extern void flink_init(void);
108 extern void freeze_init(void);
109 extern void fsync_init(void);
110 extern void getrusage_init(void);
111 extern void help_init(void);
112 extern void imap_init(void);
113 extern void inject_init(void);
114 extern void label_init(void);
115 extern void mmap_init(void);
116 extern void open_init(void);
117 extern void parent_init(void);
118 extern void pread_init(void);
119 extern void prealloc_init(void);
120 extern void pwrite_init(void);
121 extern void quit_init(void);
122 extern void seek_init(void);
123 extern void shutdown_init(void);
124 extern void stat_init(void);
125 extern void swapext_init(void);
126 extern void sync_init(void);
127 extern void truncate_init(void);
128 extern void utimes_init(void);
129
130 #ifdef HAVE_FADVISE
131 extern void fadvise_init(void);
132 #else
133 #define fadvise_init() do { } while (0)
134 #endif
135
136 #ifdef HAVE_RESBLKS
137 extern void resblks_init(void);
138 #else
139 #define resblks_init() do { } while (0)
140 #endif
141
142 #ifdef HAVE_SENDFILE
143 extern void sendfile_init(void);
144 #else
145 #define sendfile_init() do { } while (0)
146 #endif
147
148 #ifdef HAVE_MADVISE
149 extern void madvise_init(void);
150 #else
151 #define madvise_init() do { } while (0)
152 #endif
153
154 #ifdef HAVE_MINCORE
155 extern void mincore_init(void);
156 #else
157 #define mincore_init() do { } while (0)
158 #endif
159
160 #ifdef HAVE_FIEMAP
161 extern void fiemap_init(void);
162 #else
163 #define fiemap_init() do { } while (0)
164 #endif
165
166 #ifdef HAVE_COPY_FILE_RANGE
167 extern void copy_range_init(void);
168 #else
169 #define copy_range_init() do { } while (0)
170 #endif
171
172 #ifdef HAVE_SYNC_FILE_RANGE
173 extern void sync_range_init(void);
174 #else
175 #define sync_range_init() do { } while (0)
176 #endif
177
178 #ifdef HAVE_READDIR
179 extern void readdir_init(void);
180 #else
181 #define readdir_init() do { } while (0)
182 #endif
183
184 extern void reflink_init(void);
185
186 extern void cowextsize_init(void);
187
188 #ifdef HAVE_GETFSMAP
189 extern void fsmap_init(void);
190 #else
191 # define fsmap_init() do { } while (0)
192 #endif
193
194 #ifdef HAVE_DEVMAPPER
195 extern void log_writes_init(void);
196 #else
197 #define log_writes_init() do { } while (0)
198 #endif
199
200 extern void scrub_init(void);