]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - io/io.h
Merge branch 'progs-misc-fixes-2' into for-next
[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
21 /*
22 * Read/write patterns (default is always "forward")
23 */
24 #define IO_RANDOM ( 0)
25 #define IO_FORWARD ( 1)
26 #define IO_BACKWARD (-1)
27
28 /*
29 * File descriptor options
30 */
31 #define IO_READONLY (1<<0)
32 #define IO_DIRECT (1<<1)
33 #define IO_REALTIME (1<<2)
34 #define IO_APPEND (1<<3)
35 #define IO_OSYNC (1<<4)
36 #define IO_CREAT (1<<5)
37 #define IO_TRUNC (1<<6)
38 #define IO_FOREIGN (1<<7)
39 #define IO_NONBLOCK (1<<8)
40 #define IO_TMPFILE (1<<9)
41
42 /*
43 * Regular file I/O control
44 */
45 typedef struct fileio {
46 int fd; /* open file descriptor */
47 int flags; /* flags describing file state */
48 char *name; /* file name at time of open */
49 xfs_fsop_geom_t geom; /* XFS filesystem geometry */
50 } fileio_t;
51
52 extern fileio_t *filetable; /* open file table */
53 extern int filecount; /* number of open files */
54 extern fileio_t *file; /* active file in file table */
55 extern int filelist_f(void);
56
57 /*
58 * Memory mapped file regions
59 */
60 typedef struct mmap_region {
61 void *addr; /* address of start of mapping */
62 size_t length; /* length of mapping */
63 off64_t offset; /* start offset into backing file */
64 int prot; /* protection mode of the mapping */
65 char *name; /* name of backing file */
66 } mmap_region_t;
67
68 extern mmap_region_t *maptable; /* mmap'd region array */
69 extern int mapcount; /* #entries in the mapping table */
70 extern mmap_region_t *mapping; /* active mapping table entry */
71 extern int maplist_f(void);
72 extern void *check_mapping_range(mmap_region_t *, off64_t, size_t, int);
73
74 /*
75 * Various xfs_io helper routines/globals
76 */
77
78 extern off64_t filesize(void);
79 extern int openfile(char *, xfs_fsop_geom_t *, int, mode_t);
80 extern int addfile(char *, int , xfs_fsop_geom_t *, int);
81 extern void printxattr(uint, int, int, const char *, int, int);
82
83 extern unsigned int recurse_all;
84 extern unsigned int recurse_dir;
85
86 extern void *buffer;
87 extern size_t buffersize;
88 extern int vectors;
89 extern struct iovec *iov;
90 extern int alloc_buffer(size_t, int, unsigned int);
91 extern int read_buffer(int, off64_t, long long, long long *,
92 int, int);
93 extern void dump_buffer(off64_t, ssize_t);
94
95 extern void attr_init(void);
96 extern void bmap_init(void);
97 extern void file_init(void);
98 extern void flink_init(void);
99 extern void freeze_init(void);
100 extern void fsync_init(void);
101 extern void getrusage_init(void);
102 extern void help_init(void);
103 extern void imap_init(void);
104 extern void inject_init(void);
105 extern void mmap_init(void);
106 extern void open_init(void);
107 extern void parent_init(void);
108 extern void pread_init(void);
109 extern void prealloc_init(void);
110 extern void pwrite_init(void);
111 extern void quit_init(void);
112 extern void seek_init(void);
113 extern void shutdown_init(void);
114 extern void sync_init(void);
115 extern void truncate_init(void);
116
117 #ifdef HAVE_FADVISE
118 extern void fadvise_init(void);
119 #else
120 #define fadvise_init() do { } while (0)
121 #endif
122
123 #ifdef HAVE_RESBLKS
124 extern void resblks_init(void);
125 #else
126 #define resblks_init() do { } while (0)
127 #endif
128
129 #ifdef HAVE_SENDFILE
130 extern void sendfile_init(void);
131 #else
132 #define sendfile_init() do { } while (0)
133 #endif
134
135 #ifdef HAVE_MADVISE
136 extern void madvise_init(void);
137 #else
138 #define madvise_init() do { } while (0)
139 #endif
140
141 #ifdef HAVE_MINCORE
142 extern void mincore_init(void);
143 #else
144 #define mincore_init() do { } while (0)
145 #endif
146
147 #ifdef HAVE_FIEMAP
148 extern void fiemap_init(void);
149 #else
150 #define fiemap_init() do { } while (0)
151 #endif
152
153 #ifdef HAVE_SYNC_FILE_RANGE
154 extern void sync_range_init(void);
155 #else
156 #define sync_range_init() do { } while (0)
157 #endif
158
159 #ifdef HAVE_READDIR
160 extern void readdir_init(void);
161 #else
162 #define readdir_init() do { } while (0)
163 #endif