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