nfs-ganesha 1.4
|
00001 /* 00002 * vim:expandtab:shiftwidth=8:tabstop=8: 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 #ifdef HAVE_CONFIG_H 00038 #include "config.h" 00039 #endif 00040 00041 #ifdef _SOLARIS 00042 #include "solaris_port.h" 00043 #endif 00044 00045 #include <stdio.h> 00046 #include <string.h> 00047 #include <pthread.h> 00048 #include "HashData.h" 00049 #include "HashTable.h" 00050 #include "log.h" 00051 #include "nfs23.h" 00052 #include "nfs4.h" 00053 #include "mount.h" 00054 #include "nfs_core.h" 00055 #include "cache_inode.h" 00056 #include "nfs_exports.h" 00057 #include "nfs_creds.h" 00058 #include "nfs_proto_functions.h" 00059 #include "nfs_proto_tools.h" 00060 #include "nfs_tools.h" 00061 00080 int nfs3_Fsinfo(nfs_arg_t *parg, 00081 exportlist_t *pexport, 00082 fsal_op_context_t *pcontext, 00083 nfs_worker_data_t *pworker, 00084 struct svc_req *preq, 00085 nfs_res_t * pres) 00086 { 00087 cache_inode_status_t cache_status; 00088 cache_entry_t *pentry = NULL; 00089 cache_inode_fsal_data_t fsal_data; 00090 fsal_attrib_list_t attr; 00091 int rc = NFS_REQ_OK; 00092 00093 if(isDebug(COMPONENT_NFSPROTO)) 00094 { 00095 char str[LEN_FH_STR]; 00096 sprint_fhandle3(str, &(parg->arg_fsinfo3.fsroot)); 00097 LogDebug(COMPONENT_NFSPROTO, 00098 "REQUEST PROCESSING: Calling nfs3_Fsinfo handle: %s", str); 00099 } 00100 00101 /* to avoid setting it on each error case */ 00102 pres->res_fsinfo3.FSINFO3res_u.resfail.obj_attributes.attributes_follow = FALSE; 00103 00104 /* Convert file handle into a fsal_handle */ 00105 if(nfs3_FhandleToFSAL(&(parg->arg_fsinfo3.fsroot), &fsal_data.fh_desc, pcontext) == 0) 00106 { 00107 rc = NFS_REQ_DROP; 00108 goto out; 00109 } 00110 00111 /* Get the entry in the cache_inode */ 00112 if((pentry = cache_inode_get(&fsal_data, 00113 &attr, 00114 pcontext, 00115 NULL, 00116 &cache_status)) == NULL) 00117 { 00118 /* Stale NFS FH ? */ 00119 pres->res_fsinfo3.status = NFS3ERR_STALE; 00120 rc = NFS_REQ_OK; 00121 goto out; 00122 } 00123 00124 /* 00125 * New fields were added to nfs_config_t to handle this value. We use 00126 * them 00127 */ 00128 00129 #define FSINFO_FIELD pres->res_fsinfo3.FSINFO3res_u.resok 00130 FSINFO_FIELD.rtmax = pexport->MaxRead; 00131 FSINFO_FIELD.rtpref = pexport->PrefRead; 00132 00133 /* This field is generally unused, it will be removed in V4 */ 00134 FSINFO_FIELD.rtmult = DEV_BSIZE; 00135 00136 FSINFO_FIELD.wtmax = pexport->MaxWrite; 00137 FSINFO_FIELD.wtpref = pexport->PrefWrite; 00138 00139 /* This field is generally unused, it will be removed in V4 */ 00140 FSINFO_FIELD.wtmult = DEV_BSIZE; 00141 00142 FSINFO_FIELD.dtpref = pexport->PrefReaddir; 00143 00144 FSINFO_FIELD.maxfilesize = FSINFO_MAX_FILESIZE; 00145 FSINFO_FIELD.time_delta.seconds = 1; 00146 FSINFO_FIELD.time_delta.nseconds = 0; 00147 00148 LogFullDebug(COMPONENT_NFSPROTO, 00149 "rtmax = %d | rtpref = %d | trmult = %d", 00150 FSINFO_FIELD.rtmax, 00151 FSINFO_FIELD.rtpref, 00152 FSINFO_FIELD.rtmult); 00153 LogFullDebug(COMPONENT_NFSPROTO, 00154 "wtmax = %d | wtpref = %d | wrmult = %d", 00155 FSINFO_FIELD.wtmax, 00156 FSINFO_FIELD.wtpref, 00157 FSINFO_FIELD.wtmult); 00158 LogFullDebug(COMPONENT_NFSPROTO, 00159 "dtpref = %d | maxfilesize = %llu ", 00160 FSINFO_FIELD.dtpref, 00161 FSINFO_FIELD.maxfilesize); 00162 00163 /* 00164 * Allow all kinds of operations to be performed on the server 00165 * through NFS v3 00166 */ 00167 FSINFO_FIELD.properties = FSF3_LINK | FSF3_SYMLINK | 00168 FSF3_HOMOGENEOUS | FSF3_CANSETTIME; 00169 00170 nfs_SetPostOpAttr(pexport, 00171 &attr, 00172 &(pres->res_fsinfo3.FSINFO3res_u.resok.obj_attributes)); 00173 pres->res_fsinfo3.status = NFS3_OK; 00174 00175 out: 00176 00177 if (pentry) 00178 { 00179 cache_inode_put(pentry); 00180 } 00181 00182 return rc; 00183 } /* nfs3_Fsinfo */ 00184 00193 void nfs3_Fsinfo_Free(nfs_res_t * pres) 00194 { 00195 /* Nothing to do */ 00196 return; 00197 } /* nfs3_Fsinfo_Free */