1 /* $NetBSD: nfs_prot_linux.h,v 1.1.1.2 2009/03/20 20:26:51 christos Exp $ */ 2 3 /* 4 * Copyright (c) 1997-2009 Erez Zadok 5 * Copyright (c) 1990 Jan-Simon Pendry 6 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 7 * Copyright (c) 1990 The Regents of the University of California. 8 * All rights reserved. 9 * 10 * This code is derived from software contributed to Berkeley by 11 * Jan-Simon Pendry at Imperial College, London. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 3. All advertising materials mentioning features or use of this software 22 * must display the following acknowledgment: 23 * This product includes software developed by the University of 24 * California, Berkeley and its contributors. 25 * 4. Neither the name of the University nor the names of its contributors 26 * may be used to endorse or promote products derived from this software 27 * without specific prior written permission. 28 * 29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * 42 * File: am-utils/conf/nfs_prot/nfs_prot_linux.h 43 * 44 */ 45 46 #ifndef _AMU_NFS_PROT_H 47 #define _AMU_NFS_PROT_H 48 49 #ifdef HAVE_RPCSVC_NFS_PROT_H 50 # include <rpcsvc/nfs_prot.h> 51 #endif /* HAVE_RPCSVC_NFS_PROT_H */ 52 53 /* 54 * Hard-code support for some file systems so the built amd 55 * binary can always run them. Also, this helps detection of iso9660 56 * file system for which the module isn't named as the file system mount 57 * name. 58 */ 59 #include <linux/version.h> 60 #ifndef KERNEL_VERSION 61 # define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 62 #endif /* not KERNEL_VERSION */ 63 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) 64 # ifndef MS_BIND 65 # define MS_BIND 4096 66 # endif /* not MS_BIND */ 67 68 # ifndef MNTTYPE_LOFS 69 # define MNTTYPE_LOFS "bind" 70 # endif /* not MNTTYPE_LOFS */ 71 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) */ 72 73 #ifndef MNTTYPE_ISO9660 74 # define MNTTYPE_ISO9660 "iso9660" 75 #endif /* not MNTTYPE_ISO9660 */ 76 77 #ifndef FHSIZE 78 # define FHSIZE 32 79 #endif /* not FHSIZE */ 80 #ifndef FHSIZE3 81 # define FHSIZE3 64 82 #endif /* not FHSIZE3 */ 83 84 #ifdef HAVE_FS_NFS3 85 #ifndef MNTTYPE_NFS3 86 # define MNTTYPE_NFS3 "nfs" 87 #endif /* not MNTTYPE_NFS3 */ 88 #endif /* HAVE_FS_NFS3 */ 89 90 /* 91 * These two force/lazy unmount flags are sometimes missing from some linux 92 * systems' headers. 93 */ 94 #ifdef HAVE_UMOUNT2 95 # ifndef MNT_FORCE 96 # define MNT_FORCE 0x1 /* from <sys/mount.h> */ 97 # endif /* not MNT_FORCE */ 98 # ifndef MNT_DETACH 99 # define MNT_DETACH 0x2 /* from kernel <linux/fs.h> */ 100 # endif /* not MNT_DETACH */ 101 #endif /* HAVE_UMOUNT2 */ 102 103 /* XXX: hack until we have a better way to detect /dev/loop devices */ 104 #ifdef HAVE_LINUX_LOOP_H 105 # define HAVE_LOOP_DEVICE 106 extern char *setup_loop_device(const char *file); 107 extern int delete_loop_device(const char *device); 108 #endif /* HAVE_LINUX_LOOP_H */ 109 110 111 /* 112 * MACROS: 113 */ 114 #define dr_drok_u diropres 115 #define ca_attributes attributes 116 #define ca_where where 117 #define da_fhandle dir 118 #define da_name name 119 #define dl_entries entries 120 #define dl_eof eof 121 #define dr_status status 122 #define dr_u diropres_u 123 #define drok_attributes attributes 124 #define drok_fhandle file 125 #define fh_data data 126 #define fhsize root.size 127 #define la_fhandle from 128 #define la_to to 129 #define na_atime atime 130 #define na_blocks blocks 131 #define na_blocksize blocksize 132 #define na_ctime ctime 133 #define na_fileid fileid 134 #define na_fsid fsid 135 #define na_gid gid 136 #define na_mode mode 137 #define na_mtime mtime 138 #define na_nlink nlink 139 #define na_rdev rdev 140 #define na_size size 141 #define na_type type 142 #define na_uid uid 143 #define ne_cookie cookie 144 #define ne_fileid fileid 145 #define ne_name name 146 #define ne_nextentry nextentry 147 #define ns_attr_u attributes 148 #define ns_status status 149 #define ns_u attrstat_u 150 #define nt_seconds seconds 151 #define nt_useconds useconds 152 #define ra_count count 153 #define ra_fhandle file 154 #define ra_offset offset 155 #define ra_totalcount totalcount 156 #define raok_attributes attributes 157 #define raok_len_u data_len 158 #define raok_u data 159 #define raok_val_u data_val 160 #define rda_cookie cookie 161 #define rda_count count 162 #define rda_fhandle dir 163 #define rdr_reply_u reply 164 #define rdr_status status 165 #define rdr_u readdirres_u 166 #define rlr_data_u data 167 #define rlr_status status 168 #define rlr_u readlinkres_u 169 #define rna_from from 170 #define rna_to to 171 #define rr_reply_u reply 172 #define rr_status status 173 #define rr_u readres_u 174 #define sa_atime atime 175 #define sa_gid gid 176 #define sa_mode mode 177 #define sa_mtime mtime 178 #define sa_size size 179 #define sa_uid uid 180 #define sag_attributes attributes 181 #define sag_fhandle file 182 #define sfr_reply_u reply 183 #define sfr_status status 184 #define sfr_u statfsres_u 185 #define sfrok_bavail bavail 186 #define sfrok_bfree bfree 187 #define sfrok_blocks blocks 188 #define sfrok_bsize bsize 189 #define sfrok_tsize tsize 190 #define sla_attributes attributes 191 #define sla_from from 192 #define sla_to to 193 #define wra_beginoffset beginoffset 194 #define wra_fhandle file 195 #define wra_len_u data_len 196 #define wra_offset offset 197 #define wra_totalcount totalcount 198 #define wra_u data 199 #define wra_val_u data_val 200 201 202 /* 203 * TYPEDEFS: 204 */ 205 typedef attrstat nfsattrstat; 206 typedef createargs nfscreateargs; 207 typedef dirlist nfsdirlist; 208 typedef diropargs nfsdiropargs; 209 typedef diropokres nfsdiropokres; 210 typedef diropres nfsdiropres; 211 typedef entry nfsentry; 212 typedef fattr nfsfattr; 213 typedef ftype nfsftype; 214 typedef linkargs nfslinkargs; 215 typedef readargs nfsreadargs; 216 typedef readdirargs nfsreaddirargs; 217 typedef readdirres nfsreaddirres; 218 typedef readlinkres nfsreadlinkres; 219 typedef readokres nfsreadokres; 220 typedef readres nfsreadres; 221 typedef renameargs nfsrenameargs; 222 typedef sattr nfssattr; 223 typedef sattrargs nfssattrargs; 224 typedef statfsokres nfsstatfsokres; 225 typedef statfsres nfsstatfsres; 226 typedef symlinkargs nfssymlinkargs; 227 typedef writeargs nfswriteargs; 228 229 /* Autofs trick */ 230 typedef int autofs_args_t; 231 232 /* 233 * We use our own definitions here, because the definitions in the 234 * kernel change the API (though not the ABI) *way* too often. 235 */ 236 #undef nfs_args_t 237 struct nfs2_fh { 238 char data[FHSIZE]; 239 }; 240 241 struct nfs3_fh { 242 u_short size; 243 u_char data[FHSIZE3]; 244 }; 245 246 struct nfs_args { 247 int version; /* 1 */ 248 int fd; /* 1 */ 249 struct nfs2_fh old_root; /* 1 */ 250 int flags; /* 1 */ 251 int rsize; /* 1 */ 252 int wsize; /* 1 */ 253 int timeo; /* 1 */ 254 int retrans; /* 1 */ 255 int acregmin; /* 1 */ 256 int acregmax; /* 1 */ 257 int acdirmin; /* 1 */ 258 int acdirmax; /* 1 */ 259 struct sockaddr_in addr; /* 1 */ 260 char hostname[256]; /* 1 */ 261 int namlen; /* 2 */ 262 unsigned int bsize; /* 3 */ 263 struct nfs3_fh root; /* 4 */ 264 int pseudoflavor; /* 5 */ 265 char context[256 + 1];/* 6 */ 266 }; 267 typedef struct nfs_args nfs_args_t; 268 269 /* 270 * Missing definitions on redhat alpha linux 271 */ 272 #ifdef _SELECTBITS_H 273 # ifndef __FD_ZERO 274 /* This line MUST be split! Otherwise m4 will not change it. */ 275 # define __FD_ZERO(set) \ 276 ((void) memset ((__ptr_t) (set), 0, sizeof(fd_set))) 277 # endif /* not __FD_ZERO */ 278 # ifndef __FD_SET 279 # define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) 280 # endif /* not __FD_SET */ 281 # ifndef __FD_CLR 282 # define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) 283 # endif /* not __FD_CLR */ 284 # ifndef __FD_ISSET 285 # define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) 286 # endif /* not __FD_ISSET */ 287 288 #endif /* _SELECTBITS_H */ 289 290 /* turn off this (b/c of hlfsd) */ 291 #undef HAVE_RPC_AUTH_DES_H 292 293 extern int linux_version_code(); 294 /* use a private mapper from errno's to NFS errors */ 295 extern int linux_nfs_error(int e); 296 #define nfs_error(e) linux_nfs_error(e) 297 298 #endif /* not _AMU_NFS_PROT_H */ 299