This repository has been archived by the owner on Jan 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathnfsconf.h
306 lines (267 loc) · 8.68 KB
/
nfsconf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/* $Id$ */
#ifndef _NFSCONF_H_
#define _NFSCONF_H_ 1
/*
* system-specific NFS mount stuff
*/
#ifdef __sun__
# define NFSCLIENT 1
#endif /* __SunOS__ */
#define export _export /* C++ keyword gets used in C */
#ifdef __linux__
/* Linux has some pretty broken header files. */
# ifndef _BSD_SOURCE
# define _BSD_SOURCE 1
# endif /* !_BSD_SOURCE */
#endif /* __linux__ */
#if defined (__FreeBSD__) || defined (__APPLE__)
# define NFS 1
# include <sys/time.h>
# include <nfs/rpcv2.h>
#endif /* __FreeBSD__ || __APPLE__ */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
#if HAVE_NFS_NFSPROTO_H
# include <nfs/nfsproto.h>
#endif /* HAVE_NFS_NFSPROTO_H */
#if NEED_NFS_NFS_H
# include <nfs/nfs.h>
#endif /* NEED_NFS_NFS_H */
#if NEED_NFSCLIENT_NFS_H
# include <nfsclient/nfs.h>
#endif /* NEED_NFSCLIENT_NFS_H */
#if NEED_NFSCLIENT_NFSARGS_H
# include <nfsclient/nfsargs.h>
#endif /* NEED_NFSCLIENT_NFSARGS_H */
#if NEED_NFS_MOUNT_H
# include <nfs/mount.h>
#endif /* NEED_NFS_MOUNT_H */
#if NEED_NFS_NFSMOUNT_H
# include <nfs/nfsmount.h>
#endif /* NEED_NFS_NFSMOUNT_H */
#ifdef HAVE_SYS_MNTENT_H
# include <sys/mntent.h>
#endif /* HAVE_SYS_MNTENT_H */
#if __linux__
# ifndef __GLIBC__
# include <linux/fs.h> /* patch up broken pieces */
# undef LIST_HEAD /* yes, it's *really* broken. */
# endif
# ifndef _NFS_PROT_H_RPCGEN
# define _NFS_PROT_H_RPCGEN
# endif /* !_NFS_PROT_H_RPCGEN */
# define NFS_NEED_KERNEL_TYPES 1
# include <linux/types.h>
# include <linux/version.h>
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
# include <netinet/in.h>
/*
* Getting the NFS file handle structures from the system header files
* is basically impossible. The kernel includes contain tons of
* symbols that clash with libc header files. Moreover, the headers
* differ significantly from distribution to distribution of Linux.
* We therefore block most of the recursive includes from
* <linux/nfs_mount.h> and instead define the needed structures here.
* (Some distributions also use struct nfs_fh for nfs3_fh.)
*
* If you change this, test on as many Linuxes as possible.
*
* I know what you are thinking. "Hey, come on, Linux can't be that
* broken." Then you look in /usr/include/linux and think you've come
* up with a better way of doing things. Well, guess what? Your
* /usr/include/linux is probably very different from most peoples'.
* On half the linux boxes, /usr/include/linux corresponds to the
* kernel you are running. On the other half it corresponds to some
* random kernel at the time the machine was installed. Then there's
* also the question of which libc you are running. libc contains
* header files that should really belong to the kernel. Therefore
* the kernel has to redefine a bunch of things that are also in libc.
* But often the libc and the kernel you are running have incompatible
* definitions.
*
* Give up. The contents of /usr/include/linux is worthless and best
* just avoided.
*/
# define _LINUX_IN_H
# define _LINUX_NFS_H
# define _LINUX_NFS2_H
# define _LINUX_NFS3_H
struct nfs2_fh {
char data[32];
};
struct nfs_fh {
unsigned short size;
unsigned char data[64];
};
struct nfs3_fh {
unsigned short size;
unsigned char data[64];
};
# include <linux/nfs_mount.h>
# else /* LINUX_VERSION_CODE < 2.4.0 */
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
# include <rpc/rpc.h> /* linux libc5 is *broken*! */
# include <sys/uio.h> /* also broken, should be linux/uio.h */
# define _LINUX_NFS_XDR_H
# include <linux/nfs.h>
# define _LINUX_IN_H
# include <linux/nfs_mount.h> /* can't help but include this one. */
# undef _LINUX_NFS_XDR_H
# endif /* LINUX_VERSION_CODE < 2.4.0 */
# undef NFS_NEED_KERNEL_TYPES
# define nfs_args nfs_mount_data
# define NFS_ARGSVERSION NFS_MOUNT_VERSION
#endif /* __linux__ */
#if defined(__ultrix)
/* This doesn't work yet! */
# include <sys/fs_types.h>
# include <nfs/nfs_gfs.h>
# define nfs_args nfs_gfs_mount
# define MOUNT_NFS GT_NFS
#endif /* __ultrix */
#ifdef HAVE_TIUSER_H
# include <tiuser.h>
#endif /* HAVE_TIUSER_H */
#undef export
#if defined (__OpenBSD__) || defined (__FreeBSD__) \
|| defined (__NetBSD__) || defined (__APPLE__)
/* Define this if you can mount a file system on the current working
* directory. */
# define MOUNT_DOT 1
#endif /* systems where you can mount on "." */
#ifndef MOUNT_REMOUNT_FULLPATH
# if defined (__OpenBSD__) || defined (__FreeBSD__)
/* The remount hack doesn't work, so we might as well disable it. */
# define MOUNT_REMOUNT_FULLPATH 0
# else /* not above OSes */
# define MOUNT_REMOUNT_FULLPATH 1
# endif /* os on which remount hack works */
#endif /* !MOUNT_REMOUNT_FULLPATH */
#ifndef MOUNT_NFS
# ifdef MNTTYPE_NFS
# define MOUNT_NFS MNTTYPE_NFS
# else /* !MNTTYPE_NFS */
# define MOUNT_NFS "nfs"
# endif /* !MNTTYPE_NFS */
#endif /* !MOUNT_NFS */
#ifndef MOUNT_NFS3
# ifdef MNTTYPE_NFS3
# define MOUNT_NFS3 MNTTYPE_NFS3
# else /* !MNTTYPE_NFS3 */
# define MOUNT_NFS3 MOUNT_NFS
# endif /* !MNTTYPE_NFS3 */
#endif /* !MOUNT_NFS3 */
#ifndef MNT_NOSUID
# if defined (M_NOSUID)
# define MNT_NOSUID M_NOSUID
# elif defined (MS_NOSUID)
# define MNT_NOSUID MS_NOSUID
# else /* no MNT_NOSUID substitute found */
# define NO_NOSUID 1
# define MNT_NOSUID 0
# endif /* no MNT_NOSUID substitute found */
#endif /* !MNT_NOSUID */
#ifndef MNT_NODEV
# if defined (M_NODEV)
# define MNT_NODEV M_NODEV
# elif defined (MS_NODEV)
# define MNT_NODEV MS_NODEV
# else /* no nodev mount flag */
# define MNT_NODEV 0
# ifndef NFSMNT_NODEV
# define NO_NODEVS 1
# endif /* !NFSMNT_NODEV */
# endif /* no nodev mount flag */
#endif /* !MNT_NODEV */
#ifndef MNT_RDONLY
# if defined (M_RDONLY)
# define MNT_RDONLY M_RDONLY
# elif defined (MS_RDONLY)
# define MNT_RDONLY MS_RDONLY
# else /* no MNT_RDONLY substitute found */
# define MNT_RDONLY 0
# endif /* no MNT_RDONLY substitute found */
#endif /* !MNT_RDONLY */
#ifndef MNT_UPDATE
# if defined (MS_REMOUNT)
# define MNT_UPDATE MS_REMOUNT
# elif defined (M_UPDATE)
# define MNT_UPDATE M_UPDATE
# endif /* M_UPDATE */
#endif /* !MNT_UPDATE */
#ifndef MNT_FORCE
# define MNT_FORCE 0
#endif /* !MNT_FORCE */
#ifdef M_RDONLY
/* Reaaly a "normal" mound syscall, don't let extraneous MS_DATA throw us. */
#undef MS_DATA
#endif /* M_RDONLY */
/* Some more strange Linuxisms */
#if defined(NFS_MOUNT_SOFT) && !defined(NFSMNT_SOFT)
# define NFSMNT_SOFT NFS_MOUNT_SOFT
#endif /* NFS_MOUNT_SOFT && !NFSMNT_SOFT */
#if defined(NFS_MOUNT_INTR) && !defined(NFSMNT_INT)
# define NFSMNT_INT NFS_MOUNT_INTR
#endif /* NFS_MOUNT_INTR && !NFSMNT_INT */
#if defined(NFS_MOUNT_NOAC) && !defined(NFSMNT_NOAC)
# define NFSMNT_NOAC NFS_MOUNT_NOAC
#endif /* NFS_MOUNT_NOAC && !NFSMNT_NOAC */
#if defined(NFS_MOUNT_NOAC) && !defined(NFSMNT_NOAC)
# define NFSMNT_NOAC NFS_MOUNT_NOAC
#endif /* NFS_MOUNT_NOAC && !NFSMNT_NOAC */
#if defined(NFS_MOUNT_TCP) && !defined(NFSMNT_TCP)
# define NFSMNT_TCP NFS_MOUNT_TCP
#endif /* NFS_MOUNT_TCP && !NFSMNT_TCP */
#if defined(NFS_MOUNT_VER3) && !defined(NFSMNT_NFSV3)
# define NFSMNT_NFSV3 NFS_MOUNT_VER3
#endif /* NFS_MOUNT_VER3 && !NFSMNT_NFSV3 */
#if defined(__linux__)
#define SYS_MOUNT(hostname, type, dir, mntflags, args) \
mount (hostname, dir, type, MS_MGC_VAL | mntflags, args)
#elif defined(__ultrix)
/* This doesn't work yet! */
#define SYS_MOUNT(hostname, type, dir, mntflags, args) \
mount (hostname, dir, mntflags, type, args)
#elif defined(MS_DATA) /* SVR4 6 argument mount */
#define SYS_MOUNT(hostname, type, dir, mntflags, args) \
mount (hostname, dir, MS_DATA|mntflags, \
type, args, sizeof (*(args)))
#elif M_NEWTYPE /* SunOS 4 */
#define SYS_MOUNT(hostname, type, dir, mntflags, args) \
mount (type, dir, M_NEWTYPE|mntflags, args)
#elif HAVE_VFSMOUNT /* HPUX9 */
#define SYS_MOUNT(hostname, type, dir, mntflags, args) \
vfsmount (type, dir, mntflags, args)
#else /* normal mount syscall */
#define SYS_MOUNT(hostname, type, dir, mntflags, args) \
mount (type, dir, mntflags, (char *) (args))
#endif /* normal mount syscall */
#define SYS_NFS_MOUNT(type, dir, mntflags, args) \
SYS_MOUNT ((args)->hostname, type, dir, mntflags, args)
#ifdef HAVE_UMOUNT2
# define SYS_UNMOUNT(path, flags) umount2 (path, flags)
#else /* !HAVE_UMOUNT2 */
# ifdef HAVE_UNMOUNT
# define __unmount unmount
# else /* !HAVE_UNMOUNT */
# define __unmount umount
# endif /* !HAVE_UNMOUNT */
# ifdef UNMOUNT_FLAGS
# define SYS_UNMOUNT(path, flags) __unmount (path, flags)
# else /* !UNMOUNT_FLAGS */
# define SYS_UNMOUNT(path, flags) __unmount (path)
# endif /* !UNMOUNT_FLAGS */
#endif /* !HAVE_UMOUNT2 */
#ifdef HAVE_DEV_XFS
# ifndef MOUNT_XFS
# ifdef __IRIX__
# define MOUNT_XFS "xFs"
# else /* !__IRIX__ */
# define MOUNT_XFS "xfs"
# endif /* !__IRIX__ */
# endif /* MOUNT_XFS */
#endif /* HAVE_DEV_XFS */
#endif /* _NFSCONF_H_ */