Whamcloud - gitweb
* fix build breakage when this branch is built in a real SLES10 env
[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
53 #if defined(_DIRENT_H) && _DIRENT_H
54 /*
55  * Need directory access routines too.
56  */
57 #define _DECLARE_DIR_ACCESS             1
58 #else
59 #define _DECLARE_DIR_ACCESS             0
60 #endif
61
62 #ifndef PATH_SEPARATOR
63 /*
64  * Path separator.
65  */
66 #define PATH_SEPARATOR                  '/'
67 #endif
68
69 #ifndef MAX_SYMLINK
70 /*
71  * Max recursion depth allowed when resoving symbolic links.
72  */
73 #define MAX_SYMLINK                     250
74 #endif
75
76 /*
77  * Internally, all directory entries are carried in the 64-bit capable
78  * structure.
79  */
80 #if _LARGEFILE64_SOURCE
81 #define intnl_dirent dirent64
82 #else
83 #define intnl_dirent dirent
84 #endif
85 struct dirent;
86
87 /*
88  * Internally, all file status is carried in the 64-bit capable
89  * structure.
90  */
91 #if _LARGEFILE64_SOURCE
92 #define intnl_stat stat64
93 #else
94 #define intnl_stat stat
95 #endif
96 struct stat;
97
98 #ifdef _HAVE_STATVFS
99 #if _LARGEFILE64_SOURCE
100 #define intnl_statvfs statvfs64
101 #else
102 #define intnl_statvfs statvfs
103 #define INTNL_STATVFS_IS_NATURAL        1
104 #endif
105 struct statvfs;
106 struct intnl_statvfs;
107 #endif
108
109 struct utimbuf;
110
111 struct intnl_stat;
112
113 struct pnode;
114
115 #ifdef DEFER_INIT_CWD
116 extern const char *_sysio_init_cwd;
117 #endif
118
119 extern struct pnode *_sysio_cwd;
120
121 extern mode_t _sysio_umask;
122
123 extern int _sysio_init(void);
124 extern void _sysio_shutdown(void);
125
126 #if 0
127 struct _sysio_boot_ctl {
128         const char *onam;
129         const char *oarg;
130 };
131 #endif
132
133 extern int _sysio_boot(const char *opt, const char *arg);
134
135 /*
136  * Option-value pair information.
137  */
138 struct option_value_info {
139         const char *ovi_name;                                   /* name */
140         char *ovi_value;                                        /* value */
141 };
142
143 extern const char * _sysio_get_token(const char *buf,
144                                      int accepts,
145                                      const char *delim,
146                                      const char *ignore,
147                                      char *tbuf);
148 extern char * _sysio_get_args(char *buf, struct option_value_info *vec);
149
150 #define _SYSIO_LOCAL_TIME()     _sysio_local_time()
151
152 extern time_t _sysio_local_time(void);
153
154 #ifdef SYSIO_TRACING
155 extern void _sysio_cprintf(const char *fmt, ...);
156 #endif
157
158 /*
159  * The following should be defined by the system includes, and probably are,
160  * but it's not illegal to have multiple externs, so long as they are the
161  * same. It helps when building the library in a standalone fashion.
162  */
163 extern int SYSIO_INTERFACE_NAME(access)(const char *path, int amode);
164 extern int SYSIO_INTERFACE_NAME(chdir)(const char *path);
165 extern int SYSIO_INTERFACE_NAME(chmod)(const char *path, mode_t mode);
166 extern int SYSIO_INTERFACE_NAME(fchmod)(int fd, mode_t mode);
167 extern int SYSIO_INTERFACE_NAME(chown)(const char *path, uid_t owner,
168                                        gid_t group);
169 extern int SYSIO_INTERFACE_NAME(fchown)(int fd, uid_t owner, gid_t group);
170 extern int SYSIO_INTERFACE_NAME(close)(int d);
171 extern int SYSIO_INTERFACE_NAME(dup)(int oldfd);
172 extern int SYSIO_INTERFACE_NAME(dup2)(int oldfd, int newfd);
173 extern int SYSIO_INTERFACE_NAME(fcntl)(int fd, int cmd, ...);
174 extern int SYSIO_INTERFACE_NAME(fcntl64)(int fd, int cmd, ...);
175 extern int SYSIO_INTERFACE_NAME(fstat)(int fd, struct stat *buf);
176 #if _LARGEFILE64_SOURCE
177 extern int SYSIO_INTERFACE_NAME(fstat64)(int fd, struct stat64 *buf);
178 #endif
179 extern int SYSIO_INTERFACE_NAME(fsync)(int fd);
180 extern char *SYSIO_INTERFACE_NAME(getcwd)(char *buf, size_t size);
181 extern off_t SYSIO_INTERFACE_NAME(lseek)(int fd, off_t offset, int whence);
182 #if _LARGEFILE64_SOURCE
183 extern off64_t SYSIO_INTERFACE_NAME(lseek64)(int fd, off64_t offset, 
184                                              int whence);
185 #endif
186 extern int SYSIO_INTERFACE_NAME(lstat)(const char *path, struct stat *buf);
187 #ifdef BSD
188 extern int SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, int nbytes , 
189                                                long *basep);
190 #else
191 extern ssize_t SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, 
192                                                    size_t nbytes, off_t *basep);
193 #if _LARGEFILE64_SOURCE
194 extern ssize_t SYSIO_INTERFACE_NAME(getdirentries64)(int fd,
195                                                      char *buf,
196                                                      size_t nbytes,
197                                                      off64_t *basep);
198 #endif
199 #endif
200 extern int SYSIO_INTERFACE_NAME(mkdir)(const char *path, mode_t mode);
201 extern int SYSIO_INTERFACE_NAME(open)(const char *path, int flag, ...);
202 #if _LARGEFILE64_SOURCE
203 extern int SYSIO_INTERFACE_NAME(open64)(const char *path, int flag, ...);
204 #endif
205 extern int SYSIO_INTERFACE_NAME(creat)(const char *path, mode_t mode);
206 #if _LARGEFILE64_SOURCE
207 extern int SYSIO_INTERFACE_NAME(creat64)(const char *path, mode_t mode);
208 #endif
209 extern int SYSIO_INTERFACE_NAME(stat)(const char *path, struct stat *buf);
210 #if _LARGEFILE64_SOURCE
211 extern int SYSIO_INTERFACE_NAME(stat64)(const char *path, struct stat64 *buf);
212 #endif
213 extern ssize_t  SYSIO_INTERFACE_NAME(read)(int fd, void *buf, size_t count);
214 extern ssize_t  SYSIO_INTERFACE_NAME(pread)(int fd, void *buf, size_t count,
215                                             off_t offset);
216 extern ssize_t SYSIO_INTERFACE_NAME(readv)(int fd,
217                                            const struct iovec *iov,
218                                            int count);
219 extern ssize_t SYSIO_INTERFACE_NAME(write)(int fd,
220                                            const void *buf,
221                                            size_t count);
222 extern ssize_t SYSIO_INTERFACE_NAME(pwrite)(int fd,
223                                             const void *buf,
224                                             size_t count,
225                                             off_t offset);
226 extern ssize_t SYSIO_INTERFACE_NAME(writev)(int fd,
227                                             const struct iovec *iov,
228                                             int count);
229 #ifdef _HAVE_STATVFS
230 extern int SYSIO_INTERFACE_NAME(statvfs)(const char *path, struct statvfs *buf);
231 #if _LARGEFILE64_SOURCE
232 extern int SYSIO_INTERFACE_NAME(statvfs64)(const char *path, 
233                                 struct statvfs64 *buf);
234 #endif
235 extern int SYSIO_INTERFACE_NAME(fstatvfs)(int fd, struct statvfs *buf);
236 #if _LARGEFILE64_SOURCE
237 extern int SYSIO_INTERFACE_NAME(fstatvfs64)(int fd, struct statvfs64 *buf);
238 #endif
239 #endif
240 extern int SYSIO_INTERFACE_NAME(truncate)(const char *path, off_t length);
241 #if _LARGEFILE64_SOURCE
242 extern int SYSIO_INTERFACE_NAME(truncate64)(const char *path, off64_t length);
243 #endif
244 extern int SYSIO_INTERFACE_NAME(ftruncate)(int fd, off_t length);
245 #if _LARGEFILE64_SOURCE
246 extern int SYSIO_INTERFACE_NAME(ftruncate64)(int fd, off64_t length);
247 #endif
248 extern int SYSIO_INTERFACE_NAME(rmdir)(const char *path);
249 extern int SYSIO_INTERFACE_NAME(symlink)(const char *path1, const char *path2);
250 #ifdef HAVE_POSIX_1003_READLINK
251 extern ssize_t SYSIO_INTERFACE_NAME(readlink)(const char *path,
252 #else
253 extern int SYSIO_INTERFACE_NAME(readlink)(const char *path,
254 #endif
255                                 char *buf,
256                                 size_t bufsiz);
257 extern int SYSIO_INTERFACE_NAME(link)(const char *oldpath, const char *newpath);
258 extern int SYSIO_INTERFACE_NAME(unlink)(const char *path);
259 extern int SYSIO_INTERFACE_NAME(rename)(const char *oldpath, 
260                                         const char *newpath);
261 extern int SYSIO_INTERFACE_NAME(fdatasync)(int fd);
262 extern int SYSIO_INTERFACE_NAME(ioctl)(int fd, unsigned long request, ...);
263 extern mode_t SYSIO_INTERFACE_NAME(umask)(mode_t mask);
264 extern int SYSIO_INTERFACE_NAME(mknod)(const char *path, 
265                                        mode_t mode, dev_t dev);
266 extern int SYSIO_INTERFACE_NAME(utime)(const char *path, 
267                                        const struct utimbuf *buf);
268 extern int SYSIO_INTERFACE_NAME(mount)(const char *source, const char *target,
269                                        const char *filesystemtype,
270                                        unsigned long mountflags,
271                                        const void *data);
272 extern int SYSIO_INTERFACE_NAME(umount)(const char *target);
273 #if _DECLARE_DIR_ACCESS
274 extern DIR *SYSIO_INTERFACE_NAME(opendir)(const char *name);
275 extern int SYSIO_INTERFACE_NAME(closedir)(DIR *dir);
276 extern struct dirent *SYSIO_INTERFACE_NAME(readdir)(DIR *dir);
277 extern int SYSIO_INTERFACE_NAME(scandir)(const char *dir,
278                                          struct dirent ***namelist,
279                                          int(*filter)(const struct dirent *),
280                                          int(*compar)(const void *,
281                                                       const void *));
282 #if defined(_BSD_SOURCE) || defined(_SVID_SOURCE)
283 extern ssize_t SYSIO_INTERFACE_NAME(getdirentries)(int fd,
284                                                    char *buf,
285                                                    size_t nbytes,
286                                                    off_t *basep);
287 #endif
288 #endif /* _DECLARE_DIR_ACCESS */
289
290 #undef _DECLARE_DIR_ACCESS