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 "ganesha_rpc.h" 00052 #include "nfs4.h" 00053 #include "nfs_core.h" 00054 #include "sal_functions.h" 00055 #include "nfs_proto_functions.h" 00056 #include "nfs_proto_tools.h" 00057 00070 #define arg_OPEN_CONFIRM4 op->nfs_argop4_u.opopen_confirm 00071 #define res_OPEN_CONFIRM4 resp->nfs_resop4_u.opopen_confirm 00072 00073 int nfs4_op_open_confirm(struct nfs_argop4 *op, 00074 compound_data_t * data, struct nfs_resop4 *resp) 00075 { 00076 int rc = 0; 00077 state_t * pstate_found = NULL; 00078 state_owner_t * popen_owner; 00079 const char * tag = "OPEN_CONFIRM"; 00080 00081 resp->resop = NFS4_OP_OPEN_CONFIRM; 00082 res_OPEN_CONFIRM4.status = NFS4_OK; 00083 00084 /* 00085 * Do basic checks on a filehandle 00086 * Should not operate on non-file objects 00087 */ 00088 res_OPEN_CONFIRM4.status = nfs4_sanity_check_FH(data, REGULAR_FILE); 00089 if(res_OPEN_CONFIRM4.status != NFS4_OK) 00090 return res_OPEN_CONFIRM4.status; 00091 00092 /* This can't be done on the pseudofs */ 00093 if(nfs4_Is_Fh_Pseudo(&(data->currentFH))) 00094 { 00095 res_OPEN_CONFIRM4.status = NFS4ERR_ROFS; 00096 LogDebug(COMPONENT_STATE, 00097 "NFS4 OPEN_CONFIRM returning NFS4ERR_ROFS"); 00098 return res_OPEN_CONFIRM4.status; 00099 } 00100 00101 if (nfs_export_check_security(data->reqp, data->pexport) == FALSE) 00102 { 00103 res_OPEN_CONFIRM4.status = NFS4ERR_PERM; 00104 return res_OPEN_CONFIRM4.status; 00105 } 00106 00107 /* Check stateid correctness and get pointer to state */ 00108 if((rc = nfs4_Check_Stateid(&arg_OPEN_CONFIRM4.open_stateid, 00109 data->current_entry, 00110 &pstate_found, 00111 data, 00112 STATEID_SPECIAL_FOR_LOCK, 00113 tag)) != NFS4_OK) 00114 { 00115 res_OPEN_CONFIRM4.status = rc; 00116 return res_OPEN_CONFIRM4.status; 00117 } 00118 00119 popen_owner = pstate_found->state_powner; 00120 00121 P(popen_owner->so_mutex); 00122 00123 /* Check seqid */ 00124 if(!Check_nfs4_seqid(popen_owner, arg_OPEN_CONFIRM4.seqid, op, data, resp, tag)) 00125 { 00126 /* Response is all setup for us and LogDebug told what was wrong */ 00127 V(popen_owner->so_mutex); 00128 return res_OPEN_CONFIRM4.status; 00129 } 00130 00131 /* If opened file is already confirmed, retrun NFS4ERR_BAD_STATEID */ 00132 if(popen_owner->so_owner.so_nfs4_owner.so_confirmed == TRUE) 00133 { 00134 V(popen_owner->so_mutex); 00135 res_OPEN_CONFIRM4.status = NFS4ERR_BAD_STATEID; 00136 return res_OPEN_CONFIRM4.status; 00137 } 00138 00139 /* Set the state as confirmed */ 00140 popen_owner->so_owner.so_nfs4_owner.so_confirmed = TRUE; 00141 V(popen_owner->so_mutex); 00142 00143 /* Handle stateid/seqid for success */ 00144 update_stateid(pstate_found, 00145 &res_OPEN_CONFIRM4.OPEN_CONFIRM4res_u.resok4.open_stateid, 00146 data, 00147 tag); 00148 00149 /* Save the response in the open owner */ 00150 Copy_nfs4_state_req(popen_owner, arg_OPEN_CONFIRM4.seqid, op, data, resp, tag); 00151 00152 return res_OPEN_CONFIRM4.status; 00153 } /* nfs4_op_open_confirm */ 00154 00165 void nfs4_op_open_confirm_Free(OPEN_CONFIRM4res * resp) 00166 { 00167 /* Nothing to be done */ 00168 return; 00169 } /* nfs4_op_open_confirm_Free */ 00170 00171 void nfs4_op_open_confirm_CopyRes(OPEN_CONFIRM4res * resp_dst, OPEN_CONFIRM4res * resp_src) 00172 { 00173 /* Nothing to be done */ 00174 return; 00175 }