Whamcloud - gitweb
c6139d765ab7fc47367888af25a47b38525657b9
[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 #ifndef PATH_SEPARATOR
54 /*
55  * Path separator.
56  */
57 #define PATH_SEPARATOR                  '/'
58 #endif
59
60 #ifndef MAX_SYMLINK
61 /*
62  * Max recursion depth allowed when resoving symbolic links.
63  */
64 #define MAX_SYMLINK                     250
65 #endif
66
67 /*
68  * Internally, all directory entries are carried in the 64-bit capable
69  * structure.
70  */
71 #if _LARGEFILE64_SOURCE
72 #define intnl_dirent dirent64
73 #else
74 #define intnl_dirent dirent
75 #endif
76 struct dirent;
77
78 /*
79  * Internally, all file status is carried in the 64-bit capable
80  * structure.
81  */
82 #if _LARGEFILE64_SOURCE
83 #define intnl_stat stat64
84 #else
85 #define intnl_stat stat
86 #endif
87 struct stat;
88
89 #ifdef _HAVE_STATVFS
90 #if _LARGEFILE64_SOURCE
91 #define intnl_statvfs statvfs64
92 #else
93 #define intnl_statvfs statvfs
94 #define INTNL_STATVFS_IS_NATURAL        1
95 #endif
96 struct statvfs;
97 struct intnl_statvfs;
98 #endif
99
100 struct utimbuf;
101
102 struct intnl_stat;
103
104 struct pnode;
105
106 #if DEFER_INIT_CWD
107 extern const char *_sysio_init_cwd;
108 #endif
109
110 extern struct pnode *_sysio_cwd;
111
112 extern mode_t _sysio_umask;
113
114 extern int _sysio_init(void);
115 extern void _sysio_shutdown(void);
116 #if DEFER_INIT_CWD
117 extern int _sysio_boot(const char *buf, const char *path);
118 #else
119 extern int _sysio_boot(const char *buf);
120 #endif
121
122 /*
123  * Option-value pair information.
124  */
125 struct option_value_info {
126         const char *ovi_name;                                   /* name */
127         char *ovi_value;                                        /* value */
128 };
129
130 extern const char * _sysio_get_token(const char *buf,
131                                      int accepts,
132                                      const char *delim,
133                                      const char *ignore,
134                                      char *tbuf);
135 extern char * _sysio_get_args(char *buf, struct option_value_info *vec);
136
137 #define _SYSIO_LOCAL_TIME()     _sysio_local_time()
138
139 extern time_t _sysio_local_time(void);
140
141 /*
142  * The following should be defined by the system includes, and probably are,
143  * but it's not illegal to have multiple externs, so long as they are the
144  * same. It helps when building the library in a standalone fashion.
145  */
146 extern int SYSIO_INTERFACE_NAME(access)(const char *path, int amode);
147 extern int SYSIO_INTERFACE_NAME(chdir)(const char *path);
148 extern int SYSIO_INTERFACE_NAME(chmod)(const char *path, mode_t mode);
149 extern int SYSIO_INTERFACE_NAME(fchmod)(int fd, mode_t mode);
150 extern int SYSIO_INTERFACE_NAME(chown)(const char *path, uid_t owner,
151                                        gid_t group);
152 extern int SYSIO_INTERFACE_NAME(fchown)(int fd, uid_t owner, gid_t group);
153 extern int SYSIO_INTERFACE_NAME(close)(int d);
154 extern int SYSIO_INTERFACE_NAME(dup)(int oldfd);
155 extern int SYSIO_INTERFACE_NAME(dup2)(int oldfd, int newfd);
156 extern int SYSIO_INTERFACE_NAME(fcntl)(int fd, int cmd, ...);
157 extern int SYSIO_INTERFACE_NAME(fstat)(int fd, struct stat *buf);
158 extern int SYSIO_INTERFACE_NAME(fsync)(int fd);
159 extern char *SYSIO_INTERFACE_NAME(getcwd)(char *buf, size_t size);
160 extern off_t SYSIO_INTERFACE_NAME(lseek)(int fd, off_t offset, int whence);
161 #if _LARGEFILE64_SOURCE
162 extern off64_t SYSIO_INTERFACE_NAME(lseek64)(int fd, off64_t offset, 
163                                              int whence);
164 #endif
165 extern int SYSIO_INTERFACE_NAME(lstat)(const char *path, struct stat *buf);
166 #ifdef BSD
167 extern int SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, int nbytes , 
168                                                long *basep);
169 #else
170 extern ssize_t SYSIO_INTERFACE_NAME(getdirentries)(int fd, char *buf, 
171                                                    size_t nbytes, off_t *basep);
172 #if _LARGEFILE64_SOURCE
173 extern ssize_t SYSIO_INTERFACE_NAME(getdirentries64)(int fd,
174                                                      char *buf,
175                                                      size_t nbytes,
176                                                      off64_t *basep);
177 #endif
178 #endif
179 extern int SYSIO_INTERFACE_NAME(mkdir)(const char *path, mode_t mode);
180 extern int SYSIO_INTERFACE_NAME(open)(const char *path, int flag, ...);
181 #if _LARGEFILE64_SOURCE
182 extern int SYSIO_INTERFACE_NAME(open64)(const char *path, int flag, ...);
183 #endif
184 extern int SYSIO_INTERFACE_NAME(creat)(const char *path, mode_t mode);
185 #if _LARGEFILE64_SOURCE
186 extern int SYSIO_INTERFACE_NAME(creat64)(const char *path, mode_t mode);
187 #endif
188 extern int SYSIO_INTERFACE_NAME(stat)(const char *path, struct stat *buf);
189 #if _LARGEFILE64_SOURCE
190 extern int SYSIO_INTERFACE_NAME(stat64)(const char *path, struct stat64 *buf);
191 #endif
192 #ifdef _HAVE_STATVFS
193 extern int SYSIO_INTERFACE_NAME(statvfs)(const char *path, struct statvfs *buf);
194 #if _LARGEFILE64_SOURCE
195 extern int SYSIO_INTERFACE_NAME(statvfs64)(const char *path, 
196                                 struct statvfs64 *buf);
197 #endif
198 extern int SYSIO_INTERFACE_NAME(fstatvfs)(int fd, struct statvfs *buf);
199 #if _LARGEFILE64_SOURCE
200 extern int SYSIO_INTERFACE_NAME(fstatvfs64)(int fd, struct statvfs64 *buf);
201 #endif
202 #endif
203 extern int SYSIO_INTERFACE_NAME(truncate)(const char *path, off_t length);
204 #if _LARGEFILE64_SOURCE
205 extern int SYSIO_INTERFACE_NAME(truncate64)(const char *path, off64_t length);
206 #endif
207 extern int SYSIO_INTERFACE_NAME(ftruncate)(int fd, off_t length);
208 #if _LARGEFILE64_SOURCE
209 extern int SYSIO_INTERFACE_NAME(ftruncate64)(int fd, off64_t length);
210 #endif
211 extern int SYSIO_INTERFACE_NAME(rmdir)(const char *path);
212 extern int SYSIO_INTERFACE_NAME(symlink)(const char *path1, const char *path2);
213 extern int SYSIO_INTERFACE_NAME(readlink)(const char *path,
214                                 char *buf,
215                                 size_t bufsiz);
216 extern int SYSIO_INTERFACE_NAME(link)(const char *oldpath, const char *newpath);
217 extern int SYSIO_INTERFACE_NAME(unlink)(const char *path);
218 extern int SYSIO_INTERFACE_NAME(rename)(const char *oldpath, 
219                                         const char *newpath);
220 extern int SYSIO_INTERFACE_NAME(fdatasync)(int fd);
221 extern int SYSIO_INTERFACE_NAME(ioctl)(int fd, unsigned long request, ...);
222 extern mode_t SYSIO_INTERFACE_NAME(umask)(mode_t mask);
223 extern int SYSIO_INTERFACE_NAME(mknod)(const char *path, 
224                                        mode_t mode, dev_t dev);
225 extern int SYSIO_INTERFACE_NAME(utime)(const char *path, 
226                                        const struct utimbuf *buf);
227 extern int SYSIO_INTERFACE_NAME(mount)(const char *source, const char *target,
228                                        const char *filesystemtype,
229                                        unsigned long mountflags,
230                                        const void *data);
231 extern int SYSIO_INTERFACE_NAME(umount)(const char *target);