nfs-ganesha 1.4
|
00001 /* 00002 * 00003 * 00004 * Copyright CEA/DAM/DIF (2008) 00005 * contributeur : Philippe DENIEL philippe.deniel@cea.fr 00006 * Thomas LEIBOVICI thomas.leibovici@cea.fr 00007 * 00008 * 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 3 of the License, or (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 * 00023 * --------------------------------------- 00024 */ 00025 00037 #ifndef _FSAL_TYPES__SPECIFIC_H 00038 #define _FSAL_TYPES__SPECIFIC_H 00039 00040 #ifndef TRUE 00041 #define TRUE 1 00042 #endif 00043 #ifndef FALSE 00044 #define FALSE 0 00045 #endif 00046 00047 /* 00048 * FS relative includes 00049 */ 00050 00051 #ifdef _HAVE_CONFIG_H 00052 #include "config.h" 00053 #endif 00054 00055 #ifdef _SOLARIS 00056 #include <dirent.h> 00057 #endif 00058 00059 /* other includes */ 00060 #include <sys/types.h> 00061 #include <sys/stat.h> 00062 #include <fcntl.h> 00063 #include <sys/param.h> 00064 #include "config_parsing.h" 00065 #include "err_fsal.h" 00066 #include "ganesha_rpc.h" 00067 #include "nfs4.h" 00068 00069 #define CONF_LABEL_FS_SPECIFIC "NFSv4_Proxy" 00070 00071 #define FSAL_PROXY_FILEHANDLE_MAX_LEN 128 00072 #define FSAL_PROXY_SEND_BUFFER_SIZE 32768 00073 #define FSAL_PROXY_RECV_BUFFER_SIZE 32768 00074 #define FSAL_PROXY_NFS_V4 4 00075 #define FSAL_PROXY_RETRY_SLEEPTIME 10 00076 00077 #include "fsal_glue_const.h" 00078 00079 #define fsal_handle_t proxyfsal_handle_t 00080 #define fsal_op_context_t proxyfsal_op_context_t 00081 #define fsal_file_t proxyfsal_file_t 00082 #define fsal_dir_t proxyfsal_dir_t 00083 #define fsal_export_context_t proxyfsal_export_context_t 00084 #define fsal_lockdesc_t proxyfsal_lockdesc_t 00085 #define fsal_cookie_t proxyfsal_cookie_t 00086 #define fs_specific_initinfo_t proxyfs_specific_initinfo_t 00087 #define fsal_cred_t proxyfsal_cred_t 00088 00089 /* some void types for this template... */ 00090 typedef union { 00091 struct 00092 { 00093 uint64_t fileid4; 00094 uint8_t object_type_reminder; 00095 uint8_t srv_handle_len; 00096 char srv_handle_val[FSAL_PROXY_FILEHANDLE_MAX_LEN] ; 00097 } data ; 00098 char pad[FSAL_HANDLE_T_SIZE]; 00099 } proxyfsal_handle_t; 00100 00101 typedef struct 00102 { 00103 fsal_staticfsinfo_t * fe_static_fs_info; /* Must be the first entry in this structure */ 00104 00105 proxyfsal_handle_t root_handle; 00106 } proxyfsal_export_context_t; 00107 00108 #define FSAL_EXPORT_CONTEXT_SPECIFIC( pexport_context ) (uint64_t)(pexport_context->root_handle.fileid4) 00109 00110 typedef struct 00111 { 00112 proxyfsal_export_context_t *export_context; /* Must be the first entry in this structure */ 00113 struct user_credentials credential; 00114 00115 unsigned int retry_sleeptime; 00116 unsigned int srv_prognum; 00117 unsigned int srv_addr; 00118 unsigned int srv_sendsize; 00119 unsigned int srv_recvsize; 00120 unsigned short srv_port; 00121 unsigned int use_privileged_client_port ; 00122 char srv_proto[MAXNAMLEN]; 00123 clientid4 clientid; 00124 time_t clientid_renewed ; 00125 CLIENT *rpc_client; 00126 int socket ; 00127 pthread_mutex_t lock; 00128 proxyfsal_handle_t openfh_wd_handle; 00129 time_t last_lease_renewal; 00130 uint64_t file_counter; 00131 } proxyfsal_op_context_t; 00132 00133 #define FSAL_OP_CONTEXT_TO_UID( pcontext ) ( pcontext->credential.user ) 00134 #define FSAL_OP_CONTEXT_TO_GID( pcontext ) ( pcontext->credential.group ) 00135 00136 typedef struct 00137 { 00138 proxyfsal_handle_t fhandle; 00139 verifier4 verifier; 00140 proxyfsal_op_context_t *pcontext; 00141 } proxyfsal_dir_t; 00142 00143 typedef struct 00144 { 00145 proxyfsal_handle_t fhandle; 00146 unsigned int openflags; 00147 u_int32_t ownerid; 00148 stateid4 stateid; 00149 fsal_off_t current_offset; 00150 proxyfsal_op_context_t *pcontext; 00151 } proxyfsal_file_t; 00152 00153 //# define FSAL_FILENO(_pf) ((_pf)) 00154 00155 typedef union { 00156 nfs_cookie4 data ; 00157 char pad[FSAL_COOKIE_T_SIZE]; 00158 00159 } proxyfsal_cookie_t; 00160 00161 #define FSAL_SET_PCOOKIE_BY_OFFSET( __pfsal_cookie, __cookie ) \ 00162 do \ 00163 { \ 00164 ((proxyfsal_cookie_t *)__pfsal_cookie)->data = (off_t)__cookie ; \ 00165 } while( 0 ) 00166 00167 #define FSAL_SET_OFFSET_BY_PCOOKIE( __pfsal_cookie, __cookie ) \ 00168 do \ 00169 { \ 00170 __cookie = ((proxyfsal_cookie_t *)__pfsal_cookie)->data ; \ 00171 } while( 0 ) 00172 00173 // #define FSAL_READDIR_FROM_BEGINNING 0 00174 00175 typedef struct 00176 { 00177 unsigned int retry_sleeptime; 00178 unsigned int srv_addr; 00179 unsigned int srv_prognum; 00180 unsigned int srv_sendsize; 00181 unsigned int srv_recvsize; 00182 unsigned int srv_timeout; 00183 unsigned short srv_port; 00184 unsigned int use_privileged_client_port ; 00185 char srv_proto[MAXNAMLEN]; 00186 char local_principal[MAXNAMLEN]; 00187 char remote_principal[MAXNAMLEN]; 00188 char keytab[MAXPATHLEN]; 00189 unsigned int cred_lifetime; 00190 unsigned int sec_type; 00191 bool_t active_krb5; 00192 00193 /* initialization info for handle mapping */ 00194 00195 int enable_handle_mapping; 00196 00197 char hdlmap_dbdir[MAXPATHLEN]; 00198 char hdlmap_tmpdir[MAXPATHLEN]; 00199 unsigned int hdlmap_dbcount; 00200 unsigned int hdlmap_hashsize; 00201 unsigned int hdlmap_nb_entry_prealloc; 00202 unsigned int hdlmap_nb_db_op_prealloc; 00203 } proxyfs_specific_initinfo_t; 00204 00205 #endif