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 00036 #ifdef HAVE_CONFIG_H 00037 #include "config.h" 00038 #endif 00039 00040 #ifdef _SOLARIS 00041 #include "solaris_port.h" 00042 #endif 00043 00044 #include <stdio.h> 00045 #include <string.h> 00046 #include <pthread.h> 00047 #include <fcntl.h> 00048 #include <sys/file.h> /* for having FNDELAY */ 00049 #include "HashData.h" 00050 #include "HashTable.h" 00051 #include "log.h" 00052 #include "ganesha_rpc.h" 00053 #include "nfs23.h" 00054 #include "nfs4.h" 00055 #include "mount.h" 00056 #include "nfs_core.h" 00057 #include "cache_inode.h" 00058 #include "nfs_exports.h" 00059 #include "nfs_creds.h" 00060 #include "nfs_proto_functions.h" 00061 #include "nfs_tools.h" 00062 #include "nfs_proto_tools.h" 00063 00079 static int CreatePUBFH4(nfs_fh4 * fh, compound_data_t * data) 00080 { 00081 pseudofs_entry_t psfsentry; 00082 int status = 0; 00083 00084 psfsentry = *(data->pseudofs->reverse_tab[0]); 00085 00086 if((status = nfs4_AllocateFH(&(data->publicFH))) != NFS4_OK) 00087 return status; 00088 00089 if(!nfs4_PseudoToFhandle(&(data->publicFH), &psfsentry)) 00090 return NFS4ERR_BADHANDLE; 00091 00092 LogHandleNFS4("CREATE PUB FH: ", &data->publicFH); 00093 00094 return NFS4_OK; 00095 } /* CreatePUBFH4 */ 00096 00114 #define arg_PUTPUBFH4 op->nfs_argop4_u.opputpubfh 00115 #define res_PUTPUBFH4 resp->nfs_resop4_u.opputpubfh 00116 00117 int nfs4_op_putpubfh(struct nfs_argop4 *op, 00118 compound_data_t * data, struct nfs_resop4 *resp) 00119 { 00120 char __attribute__ ((__unused__)) funcname[] = "nfs4_op_putpubfh"; 00121 00122 resp->resop = NFS4_OP_PUTPUBFH; 00123 res_PUTPUBFH4.status = NFS4_OK ; 00124 00125 /* For now, GANESHA makes no difference betzeen PUBLICFH and ROOTFH */ 00126 res_PUTPUBFH4.status = CreatePUBFH4(&(data->publicFH), data); 00127 if(res_PUTPUBFH4.status != NFS4_OK) 00128 return res_PUTPUBFH4.status; 00129 00130 /* If there is no currentFH, teh return an error */ 00131 if(nfs4_Is_Fh_Empty(&(data->publicFH))) 00132 { 00133 /* There is no current FH, return NFS4ERR_NOFILEHANDLE */ 00134 res_PUTPUBFH4.status = NFS4ERR_NOFILEHANDLE; 00135 return res_PUTPUBFH4.status; 00136 } 00137 00138 /* If the filehandle is invalid */ 00139 if(nfs4_Is_Fh_Invalid(&(data->publicFH))) 00140 { 00141 res_PUTPUBFH4.status = NFS4ERR_BADHANDLE; 00142 return res_PUTPUBFH4.status; 00143 } 00144 00145 /* Tests if teh Filehandle is expired (for volatile filehandle) */ 00146 if(nfs4_Is_Fh_Expired(&(data->publicFH))) 00147 { 00148 res_PUTPUBFH4.status = NFS4ERR_FHEXPIRED; 00149 return res_PUTPUBFH4.status; 00150 } 00151 00152 /* I copy the root FH to the currentFH and, if not already done, to the publicFH */ 00153 /* For the moment, I choose to have rootFH = publicFH */ 00154 /* For initial mounted_on_FH, I'll use the rootFH, this will change at junction traversal */ 00155 if(data->currentFH.nfs_fh4_len == 0) 00156 { 00157 res_PUTPUBFH4.status = nfs4_AllocateFH(&(data->currentFH)); 00158 if(res_PUTPUBFH4.status != NFS4_OK) 00159 return res_PUTPUBFH4.status; 00160 } 00161 00162 /* Copy the data from current FH to saved FH */ 00163 memcpy((char *)(data->currentFH.nfs_fh4_val), (char *)(data->publicFH.nfs_fh4_val), 00164 data->publicFH.nfs_fh4_len); 00165 00166 res_PUTPUBFH4.status = NFS4_OK ; 00167 00168 return res_PUTPUBFH4.status; 00169 } /* nfs4_op_putpubfh */ 00170 00181 void nfs4_op_putpubfh_Free(PUTPUBFH4res * resp) 00182 { 00183 /* Nothing to be done */ 00184 return; 00185 } /* nfs4_op_putpubfh_Free */