nfs-ganesha 1.4

nfs4_op_nverify.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  */
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 <fcntl.h>
00049 #include <sys/file.h>           /* for having FNDELAY */
00050 #include "HashData.h"
00051 #include "HashTable.h"
00052 #include "log.h"
00053 #include "ganesha_rpc.h"
00054 #include "nfs23.h"
00055 #include "nfs4.h"
00056 #include "mount.h"
00057 #include "nfs_core.h"
00058 #include "cache_inode.h"
00059 #include "nfs_exports.h"
00060 #include "nfs_creds.h"
00061 #include "nfs_proto_functions.h"
00062 #include "nfs_proto_tools.h"
00063 #include "nfs_tools.h"
00064 #include "nfs_file_handle.h"
00065 
00080 #define arg_NVERIFY4 op->nfs_argop4_u.opnverify
00081 #define res_NVERIFY4 resp->nfs_resop4_u.opnverify
00082 
00083 int nfs4_op_nverify(struct nfs_argop4 *op,
00084                     compound_data_t * data, struct nfs_resop4 *resp)
00085 {
00086   char __attribute__ ((__unused__)) funcname[] = "nfs4_op_nverify";
00087 
00088   fsal_attrib_list_t   file_attr;
00089   cache_inode_status_t cache_status;
00090   fattr4               file_attr4;
00091   int                  rc = 0;
00092 
00093   resp->resop = NFS4_OP_NVERIFY;
00094   res_NVERIFY4.status = NFS4_OK;
00095 
00096   /* Do basic checks on a filehandle */
00097   res_NVERIFY4.status = nfs4_sanity_check_FH(data, 0LL);
00098   if(res_NVERIFY4.status != NFS4_OK)
00099     return res_NVERIFY4.status;
00100 
00101   /* operation is always permitted on pseudofs */
00102   if(nfs4_Is_Fh_Pseudo(&(data->currentFH)))
00103     {
00104       res_NVERIFY4.status = NFS4_OK;
00105       return res_NVERIFY4.status;
00106     }
00107 
00108   /* Get only attributes that are allowed to be read */
00109   if(!nfs4_Fattr_Check_Access(&arg_NVERIFY4.obj_attributes, FATTR4_ATTR_READ))
00110     {
00111       res_NVERIFY4.status = NFS4ERR_INVAL;
00112       return res_NVERIFY4.status;
00113     }
00114 
00115   /* Ask only for supported attributes */
00116   if(!nfs4_Fattr_Supported(&arg_NVERIFY4.obj_attributes))
00117     {
00118       res_NVERIFY4.status = NFS4ERR_ATTRNOTSUPP;
00119       return res_NVERIFY4.status;
00120     }
00121 
00122   /* Get the cache inode attribute */
00123   if((cache_status = cache_inode_getattr(data->current_entry,
00124                                          &file_attr,
00125                                          data->pcontext,
00126                                          &cache_status)) != CACHE_INODE_SUCCESS)
00127     {
00128       res_NVERIFY4.status = NFS4ERR_INVAL;
00129       return res_NVERIFY4.status;
00130     }
00131 
00132   if(nfs4_FSALattr_To_Fattr(data->pexport,
00133                             &file_attr,
00134                             &file_attr4,
00135                             data,
00136                             &(data->currentFH),
00137                             &(arg_NVERIFY4.obj_attributes.attrmask)) != 0)
00138     {
00139       res_NVERIFY4.status = NFS4ERR_SERVERFAULT;
00140       return res_NVERIFY4.status;
00141     }
00142 
00143   if((rc = nfs4_Fattr_cmp(&(arg_NVERIFY4.obj_attributes), &file_attr4)) == FALSE)
00144     res_NVERIFY4.status = NFS4_OK;
00145   else
00146     {
00147       if(rc == -1)
00148         res_NVERIFY4.status = NFS4ERR_INVAL;
00149       else
00150         res_NVERIFY4.status = NFS4ERR_SAME;
00151     }
00152 
00153   nfs4_Fattr_Free(&file_attr4);
00154   return res_NVERIFY4.status;
00155 }                               /* nfs4_op_nverify */
00156 
00167 void nfs4_op_nverify_Free(NVERIFY4res * resp)
00168 {
00169   /* Nothing to be done */
00170   return;
00171 }                               /* nfs4_op_nverify_Free */