Whamcloud - gitweb
LU-2730 mdt: fix erroneous LASSERT in mdt_reint_opcode
[fs/lustre-release.git] / libsysio / include / sysio.h
1 /*
2  *    This Cplant(TM) source code is the property of Sandia National
3  *    Laboratories.
4  *
5  *    This Cplant(TM) source code is copyrighted by Sandia National
6  *    Laboratories.
7  *
8  *    The redistribution of this Cplant(TM) source code is subject to the
9  *    terms of the GNU Lesser General Public License
10  *    (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
11  *
12  *    Cplant(TM) Copyright 1998-2004 Sandia Corporation. 
13  *    Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
14  *    license for use of this work by or on behalf of the US Government.
15  *    Export of this program may require a license from the United States
16  *    Government.
17  */
18
19 /*
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  * 
25  * This library is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  * 
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33  *
34  * Questions or comments about this library should be sent to:
35  *
36  * Lee Ward
37  * Sandia National Laboratories, New Mexico
38  * P.O. Box 5800
39  * Albuquerque, NM 87185-1110
40  *
41  * lee@sandia.gov
42  */
43
44 /*
45  * System IO common information.
46  */
47
48 #include <limits.h>
49 #include <stdarg.h>
50
51 #include "sysio-cmn.h"
52 #include "creds.h"
53
54 #if defined(_DIRENT_H) && _DIRENT_H
55 /*
56  * Need directory access routines too.
57  */
58 #define _DECLARE_DIR_ACCESS             1
59 #else
60 #define _DECLARE_DIR_ACCESS             0
61 #endif
62
63 #ifndef PATH_SEPARATOR
64 /*
65  * Path separator.
66  */
67 #define PATH_SEPARATOR                  '/'
68 #endif
69
70 #ifndef MAX_SYMLINK
71 /*
72  * Max recursion depth allowed when resoving symbolic links.
73  */
74 #define MAX_SYMLINK                     250
75 #endif
76
77 /*
78  * Internally, all directory entries are carried in the 64-bit capable
79  * structure.
80  */
81 #ifdef _LARGEFILE64_SOURCE
82 #define intnl_dirent dirent64
83 #else
84 #define intnl_dirent dirent
85 #endif
86 struct dirent;
87
88 /*
89  * Internally, all file status is carried in the 64-bit capable
90  * structure.
91  */
92 #ifdef _LARGEFILE64_SOURCE
93 #define intnl_stat stat64
94 #else
95 #define intnl_stat stat
96 #endif
97 struct stat;
98
99 #ifdef _HAVE_STATVFS
100 #ifdef _LARGEFILE64_SOURCE
101 #define intnl_statvfs statvfs64
102 #else
103 #define intnl_statvfs statvfs
104 #define INTNL_STATVFS_IS_NATURAL        1
105 #endif
106 struct statvfs;
107 struct intnl_statvfs;
108 #endif
109
110 struct utimbuf;
111
112 struct intnl_stat;
113
114 struct pnode;
115
116 #ifdef DEFER_INIT_CWD
117 extern const char *_sysio_init_cwd;
118 #endif
119
120 extern struct pnode *_sysio_cwd;
121
122 extern mode_t _sysio_umask;
123
124 extern int _sysio_init(void);
125 extern void _sysio_shutdown(void);
126 #ifdef ZERO_SUM_MEMORY
127 extern void _sysio_access_shutdown(void);
128 #endif
129
130 #if 0
131 struct _sysio_boot_ctl {
132         const char *onam;
133         const char *oarg;
134 };
135 #endif
136
137 extern int _sysio_boot(const char *opt, const char *arg);
138
139 /*
140  * Option-value pair information.
141  */
142 struct option_value_info {
143         const char *ovi_name;                                   /* name */
144         char *ovi_value;                                        /* value */
145 };
146
147 extern const char * _sysio_get_token(const char *buf,
148                                      int accepts,
149                                      const char *delim,
150                                      const char *ignore,
151                                      char *tbuf);
152 extern char * _sysio_get_args(char *buf, struct option_value_info *vec);
153
154 #define _SYSIO_LOCAL_TIME()     _sysio_local_time()
155
156 extern time_t _sysio_local_time(void);
157
158 #ifdef SYSIO_TRACING
159 extern void _sysio_cprintf(const char *fmt, ...);
160 #endif
161
162 /*
163  * The following should be defined by the system includes, and probably are,
164  * but it's not illegal to have multiple externs, so long as they are the
165  * same. It helps when building the library in a standalone fashion.
166  */
167 extern int SYSIO_INTERFACE_NAME(access)(const char *path, int amode);
168 extern int SYSIO_INTERFACE_NAME(chdir)(const char *path);
169 extern int SYSIO_INTERFACE_NAME(chmod)(const char *path, mode_t mode);
170 extern int SYSIO_INTERFACE_NAME(fchmod)(int fd, mode_t mode);
171 extern int SYSIO_INTERFACE_NAME(chown)(const char *path, uid_t owner,
172                                        gid_t group);
173 extern int SYSIO_INTERFACE_NAME(fchown)(int fd, uid_t owner, gid_t group);
174 extern int SYSIO_INTERFACE_NAME(close)(int d);
175 extern int SYSIO_INTERFACE_NAME(dup)(int oldfd);
176 extern int SYSIO_INTERFACE_NAME(dup2)(int oldfd, int newfd);
177 extern int SYSIO_INTERFACE_NAME(fcntl)(int fd, int cmd, ...);
178 extern int SYSIO_INTERFACE_NAME(fcntl64)(int fd, int cmd, ...);
179 extern int SYSIO_INTERFACE_NAME(fstat)(int fd, struct stat *buf);
180 #ifdef _LARGEFILE64_SOURCE
181 extern int SYSIO_INTERFACE_NAME(fstat64)(int fd, struct stat64 *buf);
182 extern int SYSIO_INTERFACE_NAME(lstat64)(const char *path, struct stat64 *buf);
183 #endif
184 extern int SYSIO_INTERFACE_NAME(fsync)(int fd);
185 extern char *SYSIO_INTERFACE_NAME(getcwd)(char *buf, size_t size);
186 extern off_t SYSIO_INTERFACE_NAME(lseek)(int fd, off_t offset, int whence);
187 #ifdef _LARGEFILE64_SOURCE
188 extern off64_t SYSIO_INTERFACE_NAME(lseek64)(int fd, off64_t offset, 
189                                              int whence);
190 #endif
191 extern int SYSIO_INTERFACE_NAME(lstat)(const char *path, struct stat *buf);
192 #ifdef BSD
193 extern int SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, int nbytes , 
194                                                long *basep);
195 #else
196 extern ssize_t SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, 
197                                                    size_t nbytes, off_t *basep);
198 #ifdef _LARGEFILE64_SOURCE
199 extern ssize_t SYSIO_INTERFACE_NAME(getdirentries64)(int fd,
200                                                      char *buf,
201                                                      size_t nbytes,
202                                                      off64_t *basep);
203 #endif
204 #endif
205 extern int SYSIO_INTERFACE_NAME(mkdir)(const char *path, mode_t mode);
206 extern int SYSIO_INTERFACE_NAME(open)(const char *path, int flag, ...);
207 #ifdef _LARGEFILE64_SOURCE
208 extern int SYSIO_INTERFACE_NAME(open64)(const char *path, int flag, ...);
209 #endif
210 extern int SYSIO_INTERFACE_NAME(creat)(const char *path, mode_t mode);
211 #ifdef _LARGEFILE64_SOURCE
212 extern int SYSIO_INTERFACE_NAME(creat64)(const char *path, mode_t mode);
213 #endif
214 extern int SYSIO_INTERFACE_NAME(stat)(const char *path, struct stat *buf);
215 #ifdef _LARGEFILE64_SOURCE
216 extern int SYSIO_INTERFACE_NAME(stat64)(const char *path, struct stat64 *buf);
217 #endif
218 extern ssize_t  SYSIO_INTERFACE_NAME(read)(int fd, void *buf, size_t count);
219 extern ssize_t  SYSIO_INTERFACE_NAME(pread)(int fd, void *buf, size_t count,
220                                             off_t offset);
221 extern ssize_t SYSIO_INTERFACE_NAME(readv)(int fd,
222                                            const struct iovec *iov,
223                                            int count);
224 extern ssize_t SYSIO_INTERFACE_NAME(write)(int fd,
225                                            const void *buf,
226                                            size_t count);
227 extern ssize_t SYSIO_INTERFACE_NAME(pwrite)(int fd,
228                                             const void *buf,
229                                             size_t count,
230                                             off_t offset);
231 extern ssize_t SYSIO_INTERFACE_NAME(writev)(int fd,
232                                             const struct iovec *iov,
233                                             int count);
234 #ifdef _HAVE_STATVFS
235 extern int SYSIO_INTERFACE_NAME(statvfs)(const char *path, struct statvfs *buf);
236 #ifdef _LARGEFILE64_SOURCE
237 extern int SYSIO_INTERFACE_NAME(statvfs64)(const char *path, 
238                                 struct statvfs64 *buf);
239 #endif
240 extern int SYSIO_INTERFACE_NAME(fstatvfs)(int fd, struct statvfs *buf);
241 #ifdef _LARGEFILE64_SOURCE
242 extern int SYSIO_INTERFACE_NAME(fstatvfs64)(int fd, struct statvfs64 *buf);
243 #endif
244 #endif
245 extern int SYSIO_INTERFACE_NAME(truncate)(const char *path, off_t length);
246 #ifdef _LARGEFILE64_SOURCE
247 extern int SYSIO_INTERFACE_NAME(truncate64)(const char *path, off64_t length);
248 #endif
249 extern int SYSIO_INTERFACE_NAME(ftruncate)(int fd, off_t length);
250 #ifdef _LARGEFILE64_SOURCE
251 extern int SYSIO_INTERFACE_NAME(ftruncate64)(int fd, off64_t length);
252 #endif
253 extern int SYSIO_INTERFACE_NAME(rmdir)(const char *path);
254 extern int SYSIO_INTERFACE_NAME(symlink)(const char *path1, const char *path2);
255 #ifdef HAVE_POSIX_1003_READLINK
256 extern ssize_t SYSIO_INTERFACE_NAME(readlink)(const char *path,
257 #else
258 extern int SYSIO_INTERFACE_NAME(readlink)(const char *path,
259 #endif
260                                 char *buf,
261                                 size_t bufsiz);
262 extern int SYSIO_INTERFACE_NAME(link)(const char *oldpath, const char *newpath);
263 extern int SYSIO_INTERFACE_NAME(unlink)(const char *path);
264 extern int SYSIO_INTERFACE_NAME(rename)(const char *oldpath, 
265                                         const char *newpath);
266 extern int SYSIO_INTERFACE_NAME(fdatasync)(int fd);
267 extern int SYSIO_INTERFACE_NAME(ioctl)(int fd, unsigned long request, ...);
268 extern mode_t SYSIO_INTERFACE_NAME(umask)(mode_t mask);
269 extern int SYSIO_INTERFACE_NAME(mknod)(const char *path, 
270                                        mode_t mode, dev_t dev);
271 extern int SYSIO_INTERFACE_NAME(utime)(const char *path, 
272                                        const struct utimbuf *buf);
273 extern int SYSIO_INTERFACE_NAME(mount)(const char *source, const char *target,
274                                        const char *filesystemtype,
275                                        unsigned long mountflags,
276                                        const void *data);
277 extern int SYSIO_INTERFACE_NAME(umount)(const char *target);
278 #if _DECLARE_DIR_ACCESS
279 extern DIR *SYSIO_INTERFACE_NAME(opendir)(const char *name);
280 extern int SYSIO_INTERFACE_NAME(closedir)(DIR *dir);
281 extern struct dirent *SYSIO_INTERFACE_NAME(readdir)(DIR *dir);
282
283 extern int SYSIO_INTERFACE_NAME(scandir)(const char *dir,
284                                          struct dirent ***namelist,
285                                          int(*filter)(const struct dirent *),
286 #ifdef HAVE_POSIX2008_SCANDIR
287                                          int(*compar)(const struct dirent **,
288                                                       const struct dirent **)
289 #else
290                                          int(*compar)(const void *, const void *)
291 #endif
292                                         );
293 #if defined(_BSD_SOURCE) || defined(_SVID_SOURCE)
294 extern ssize_t SYSIO_INTERFACE_NAME(getdirentries)(int fd,
295                                                    char *buf,
296                                                    size_t nbytes,
297                                                    off_t *basep);
298 #endif
299 #endif /* _DECLARE_DIR_ACCESS */
300
301 #undef _DECLARE_DIR_ACCESS