nfs-ganesha 1.4

nfs4_op_getfh.c

Go to the documentation of this file.
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 #ifdef HAVE_CONFIG_H
00025 #include "config.h"
00026 #endif
00027 #ifdef _SOLARIS
00028 #include "solaris_port.h"
00029 #endif
00030 #include <stdio.h>
00031 #include <string.h>
00032 #include <pthread.h>
00033 #include <fcntl.h>
00034 #include <sys/file.h>           /* for having FNDELAY */
00035 #include "HashData.h"
00036 #include "HashTable.h"
00037 #include "log.h"
00038 #include "ganesha_rpc.h"
00039 #include "nfs23.h"
00040 #include "nfs4.h"
00041 #include "mount.h"
00042 #include "nfs_core.h"
00043 #include "cache_inode.h"
00044 #include "nfs_exports.h"
00045 #include "nfs_creds.h"
00046 #include "nfs_proto_functions.h"
00047 #include "nfs_proto_tools.h"
00048 #include "nfs_file_handle.h"
00049 #include "nfs_tools.h"
00050 
00069 #define arg_GETFG op->nfs_argop4_u.opgetfh
00070 #define res_GETFH resp->nfs_resop4_u.opgetfh
00071 
00072 int nfs4_op_getfh(struct nfs_argop4 *op, compound_data_t * data, struct nfs_resop4 *resp)
00073 {
00074   char __attribute__ ((__unused__)) funcname[] = "nfs4_op_getfh";
00075 
00076   resp->resop = NFS4_OP_GETFH;
00077   res_GETFH.status = NFS4_OK;
00078 
00079   LogHandleNFS4("NFS4 GETFH BEFORE: %s", &data->currentFH);
00080 
00081   /* Do basic checks on a filehandle */
00082   res_GETFH.status = nfs4_sanity_check_FH(data, 0LL);
00083   if(res_GETFH.status != NFS4_OK)
00084     return res_GETFH.status;
00085 
00086   /* Test if the filehandle is related to a referral */
00087   if(nfs4_Is_Fh_Referral(&(data->currentFH)))
00088     {
00089       res_GETFH.status = NFS4ERR_MOVED;
00090       return res_GETFH.status;
00091     }
00092 
00093 
00094   /* Copy the filehandle to the reply structure */
00095   res_GETFH.status = nfs4_AllocateFH(&(res_GETFH.GETFH4res_u.resok4.object));
00096   if(res_GETFH.status != NFS4_OK)
00097     return res_GETFH.status;
00098 
00099   /* Put the data in place */
00100   res_GETFH.GETFH4res_u.resok4.object.nfs_fh4_len = data->currentFH.nfs_fh4_len;
00101   memcpy(res_GETFH.GETFH4res_u.resok4.object.nfs_fh4_val,
00102          data->currentFH.nfs_fh4_val, data->currentFH.nfs_fh4_len);
00103 
00104   LogHandleNFS4("NFS4 GETFH AFTER: %s", &res_GETFH.GETFH4res_u.resok4.object);
00105 
00106   return NFS4_OK;
00107 }                               /* nfs4_op_getfh */
00108 
00119 void nfs4_op_getfh_Free(GETFH4res * resp)
00120 {
00121   if(resp->status == NFS4_OK)
00122     gsh_free(resp->GETFH4res_u.resok4.object.nfs_fh4_val);
00123   return;
00124 }                               /* nfs4_op_getfh_Free */