1 /**************************************************************************** 2 * fs/nfs/nfs.h 3 * 4 * Copyright (C) 2012 Gregory Nutt. All rights reserved. 5 * Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved. 6 * Author: Jose Pablo Rojas Vargas <jrojas@nx-engineering.com> 7 * Gregory Nutt <gnutt@nuttx.org> 8 * 9 * Leveraged from OpenBSD: 10 * 11 * Copyright (c) 1989, 1993, 1995 12 * The Regents of the University of California. All rights reserved. 13 * 14 * This code is derived from software contributed to Berkeley by 15 * Rick Macklem at The University of Guelph. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions 19 * are met: 20 * 21 * 1. Redistributions of source code must retain the above copyright 22 * notice, this list of conditions and the following disclaimer. 23 * 2. Redistributions in binary form must reproduce the above copyright 24 * notice, this list of conditions and the following disclaimer in the 25 * documentation and/or other materials provided with the distribution. 26 * 3. Neither the name of the University nor the names of its contributors 27 * may be used to endorse or promote products derived from this software 28 * without specific prior written permission. 29 * 30 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 ****************************************************************************/ 43 44 #ifndef __FS_NFS_NFS_H 45 #define __FS_NFS_NFS_H 46 47 /**************************************************************************** 48 * Included Files 49 ****************************************************************************/ 50 51 #include "nfs_mount.h" 52 53 #ifdef __cplusplus 54 #if __cplusplus 55 extern "C" { 56 #endif /* __cplusplus */ 57 #endif /* __cplusplus */ 58 59 /**************************************************************************** 60 * Debug 61 ****************************************************************************/ 62 63 #ifdef NFS_DEBUG 64 #define nfs_debug_error(format, ...) PRINT_ERR(format, ##__VA_ARGS__) 65 #define nfs_debug_info(format, ...) PRINTK(format, ##__VA_ARGS__) 66 #else 67 #define nfs_debug_error(...) 68 #define nfs_debug_info(...) 69 #endif 70 71 #define nfs_error(format, ...) PRINT_ERR(format, ##__VA_ARGS__) 72 #define nfs_info(format, ...) PRINTK(format, ##__VA_ARGS__) 73 74 /**************************************************************************** 75 * Pre-processor Definitions 76 ****************************************************************************/ 77 78 #define NFS_TICKS 1 /* Number of system ticks */ 79 #define NFS_HZ CLOCKS_PER_SEC /* Ticks/sec */ 80 #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ 81 #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ 82 #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ 83 #define NFS_TIMEOUTMUL 2 /* Timeout/Delay multiplier */ 84 #define NFS_MAXREXMIT 10 /* Stop counting after this many */ 85 #define NFS_RETRANS 5 /* Num of retrans for soft mounts */ 86 #define NFS_WSIZE (8192 * 4) /* Def. write data size <= 8192 */ 87 #define NFS_RSIZE (8192 * 4) /* Def. read data size <= 8192 */ 88 #define NFS_READDIRSIZE 1024 /* Def. readdir size */ 89 #define NFS_NPROCS 23 90 91 /* Ideally, NFS_DIRBLKSIZ should be bigger, but I've seen servers with 92 * broken NFS/ethernet drivers that won't work with anything bigger (Linux..) 93 */ 94 95 #define NFS_DIRBLKSIZ 1024 /* Must be a multiple of DIRBLKSIZ */ 96 97 /* Increment NFS statistics */ 98 99 #ifdef CONFIG_NFS_STATISTICS 100 # define nfs_statistics(n) do { nfsstats.rpccnt[n]++; } while (0) 101 #else 102 # define nfs_statistics(n) 103 #endif 104 105 /**************************************************************************** 106 * Public Data 107 ****************************************************************************/ 108 109 typedef void (*NFSMOUNT_HOOK)(struct nfs_args*); 110 extern uint32_t nfs_true; 111 extern uint32_t nfs_false; 112 extern NFSMOUNT_HOOK g_NFSMOUNT_HOOK; 113 extern uint32_t nfs_xdrneg1; 114 #ifdef CONFIG_NFS_STATISTICS 115 extern struct nfsstats nfsstats; 116 #endif 117 118 /**************************************************************************** 119 * Public Types 120 ****************************************************************************/ 121 122 /* NFS statistics structure */ 123 124 struct nfsstats 125 { 126 uint64_t rpccnt[NFS_NPROCS]; 127 }; 128 129 /**************************************************************************** 130 * Public Function Prototypes 131 ****************************************************************************/ 132 extern void nfs_mux_take(struct nfsmount *nmp); 133 extern void nfs_mux_release(struct nfsmount *nmp); 134 extern int nfs_checkmount(struct nfsmount *nmp); 135 extern int nfs_fsinfo(struct nfsmount *nmp); 136 extern int nfs_request(struct nfsmount *nmp, int procnum, 137 void *request, size_t reqlen, 138 void *response, size_t resplen); 139 extern int nfs_lookup(struct nfsmount *nmp, const char *filename, 140 struct file_handle *fhandle, 141 struct nfs_fattr *obj_attributes, 142 struct nfs_fattr *dir_attributes); 143 extern int nfs_findnode(struct nfsmount *nmp, const char *relpath, 144 struct file_handle *fhandle, 145 struct nfs_fattr *obj_attributes, 146 struct nfs_fattr *dir_attributes); 147 extern int nfs_finddir(struct nfsmount *nmp, const char *relpath, 148 struct file_handle *fhandle, 149 struct nfs_fattr *attributes, char *filename); 150 extern void nfs_attrupdate(struct nfsnode *np, 151 struct nfs_fattr *attributes); 152 extern int nfs_mount(const char *server_ip_and_path, const char *mount_path, 153 unsigned int uid, unsigned int gid); 154 155 156 #ifdef __cplusplus 157 #if __cplusplus 158 } 159 #endif /*__cplusplus */ 160 #endif /*__cplusplus */ 161 162 #endif /* _NFS_NFS_H */ 163