nfs-ganesha 1.4

nfs_proto_tools.h

Go to the documentation of this file.
00001 /*
00002  *
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  * \file nfs_proto_tools.c
00026  * \author  $Author: deniel $
00027  * \date    $Date: 2005/11/28 17:03:23 $
00028  * \version $Revision: 1.9 $
00029  * \brief   A set of functions used to managed NFS.
00030  *
00031  * nfs_proto_tools.c -  A set of functions used to managed NFS.
00032  *
00033  *
00034  */
00035 
00036 #ifndef _NFS_PROTO_TOOLS_H
00037 #define _NFS_PROTO_TOOLS_H
00038 
00039 #include <stdio.h>
00040 #include <string.h>
00041 #include <pthread.h>
00042 #include <fcntl.h>
00043 #include <sys/file.h>           /* for having FNDELAY */
00044 #include "HashData.h"
00045 #include "HashTable.h"
00046 #include "log.h"
00047 #include "ganesha_rpc.h"
00048 #include "nfs23.h"
00049 #include "nfs4.h"
00050 #include "mount.h"
00051 #include "cache_inode.h"
00052 #include "nfs_tools.h"
00053 #include "nfs_creds.h"
00054 #include "nfs_file_handle.h"
00055 #ifdef _PNFS_MDS
00056 #include "sal_data.h"
00057 #endif /* _PNFS_MDS */
00058 
00059 /* type flag into mode field */
00060 #define NFS2_MODE_NFDIR 0040000
00061 #define NFS2_MODE_NFCHR 0020000
00062 #define NFS2_MODE_NFBLK 0060000
00063 #define NFS2_MODE_NFREG 0100000
00064 #define NFS2_MODE_NFLNK 0120000
00065 #define NFS2_MODE_NFNON 0140000
00066 
00067 uint64_t nfs_htonl64(uint64_t arg64);
00068 uint64_t nfs_ntohl64(uint64_t arg64);
00069 
00070 void nfs_FhandleToStr(u_long     rq_vers,
00071                       fhandle2  *pfh2,
00072                       nfs_fh3   *pfh3,
00073                       nfs_fh4   *pfh4,
00074                       char      *str);
00075 
00076 cache_entry_t *nfs_FhandleToCache(u_long rq_vers,
00077                                   fhandle2 * pfh2,
00078                                   nfs_fh3 * pfh3,
00079                                   nfs_fh4 * pfh4,
00080                                   nfsstat2 * pstatus2,
00081                                   nfsstat3 * pstatus3,
00082                                   nfsstat4 * pstatus4,
00083                                   fsal_attrib_list_t * pattr,
00084                                   fsal_op_context_t * pcontext,
00085                                   int *prc);
00086 
00087 void nfs_SetWccData(exportlist_t * pexport,
00088                     fsal_attrib_list_t * pbefore_attr,
00089                     fsal_attrib_list_t * pafter_attr, wcc_data * pwcc_data);
00090 
00091 int nfs_SetPostOpAttr(exportlist_t * pexport,
00092                       const fsal_attrib_list_t * pfsal_attr,
00093                       post_op_attr * presult);
00094 
00095 int nfs_SetPostOpXAttrDir(fsal_op_context_t * pcontext,
00096                           exportlist_t * pexport,
00097                           fsal_attrib_list_t * pfsal_attr, post_op_attr * presult);
00098 
00099 int nfs_SetPostOpXAttrFile(fsal_op_context_t * pcontext,
00100                            exportlist_t * pexport,
00101                            fsal_attrib_list_t * pfsal_attr, post_op_attr * presult);
00102 
00103 void nfs_SetPreOpAttr(fsal_attrib_list_t * pfsal_attr, pre_op_attr * pattr);
00104 
00105 int nfs_RetryableError(cache_inode_status_t cache_status);
00106 
00107 int nfs3_Sattr_To_FSAL_attr(fsal_attrib_list_t * pFSALattr, sattr3 * psattr);
00108 
00109 void nfs_SetFailedStatus(fsal_op_context_t * pcontext,
00110                          exportlist_t * pexport,
00111                          int version,
00112                          cache_inode_status_t status,
00113                          nfsstat2 * pstatus2,
00114                          nfsstat3 * pstatus3,
00115                          cache_entry_t * pentry0,
00116                          post_op_attr * ppost_op_attr,
00117                          cache_entry_t * pentry1,
00118                          fsal_attrib_list_t * ppre_vattr1,
00119                          wcc_data * pwcc_data1,
00120                          cache_entry_t * pentry2,
00121                          fsal_attrib_list_t * ppre_vattr2, wcc_data * pwcc_data2);
00122 
00123 fsal_accessflags_t nfs_get_access_mask(uint32_t op, fsal_attrib_list_t *pattr);
00124 
00125 void nfs3_access_debug(char *label, uint32_t access);
00126 
00127 void nfs4_access_debug(char *label, uint32_t access, fsal_aceperm_t v4mask);
00128 void nfs4_Fattr_Free(fattr4 *fattr);
00129 
00130 
00131 #ifdef _PNFS_MDS
00132 nfsstat4 nfs4_return_one_state(cache_entry_t *entry,
00133                                fsal_op_context_t* context,
00134                                fsal_boolean_t synthetic,
00135                                fsal_boolean_t reclaim,
00136                                layoutreturn_type4 return_type,
00137                                state_t *layout_state,
00138                                struct pnfs_segment spec_segment,
00139                                u_int body_len,
00140                                const char* body_val,
00141                                bool_t* deleted);
00142 fsal_boolean_t nfs4_pnfs_supported(const exportlist_t *export);
00143 #endif /* _PNFS_MDS */
00144 nfsstat4 nfs4_sanity_check_FH(compound_data_t *data,
00145                               cache_inode_file_type_t required_type);
00146 #endif                          /* _NFS_PROTO_TOOLS_H */