nfs-ganesha 1.4

nfs3_Pathconf.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 "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 
00081 int nfs3_Pathconf(nfs_arg_t *parg,
00082                   exportlist_t *pexport,
00083                   fsal_op_context_t *pcontext,
00084                   nfs_worker_data_t *pworker,
00085                   struct svc_req *preq,
00086                   nfs_res_t *pres)
00087 {
00088   cache_inode_status_t cache_status;
00089   cache_entry_t *pentry = NULL;
00090   cache_inode_fsal_data_t fsal_data;
00091   fsal_attrib_list_t attr;
00092   fsal_staticfsinfo_t * pstaticinfo = pcontext->export_context->fe_static_fs_info;
00093   int rc = NFS_REQ_OK;
00094 
00095   if(isDebug(COMPONENT_NFSPROTO))
00096     {
00097       char str[LEN_FH_STR];
00098       sprint_fhandle3(str, &(parg->arg_pathconf3.object));
00099       LogDebug(COMPONENT_NFSPROTO,
00100                "REQUEST PROCESSING: Calling nfs3_Pathconf handle: %s", str);
00101     }
00102 
00103   /* to avoid setting it on each error case */
00104   pres->res_pathconf3.PATHCONF3res_u.resfail.obj_attributes.attributes_follow = FALSE;
00105 
00106   /* Convert file handle into a fsal_handle */
00107   if(nfs3_FhandleToFSAL(&(parg->arg_pathconf3.object), &fsal_data.fh_desc, pcontext) == 0)
00108     {
00109       rc = NFS_REQ_DROP;
00110       goto out;
00111     }
00112 
00113   /* Get the entry in the cache_inode */
00114   if((pentry = cache_inode_get(&fsal_data,
00115                                &attr,
00116                                pcontext,
00117                                NULL,
00118                                &cache_status)) == NULL)
00119     {
00120       /* Stale NFS FH ? */
00121       pres->res_pathconf3.status = NFS3ERR_STALE;
00122       rc = NFS_REQ_OK;
00123       goto out;
00124     }
00125 
00126   /* Build post op file attributes */
00127   nfs_SetPostOpAttr(pexport,
00128                     &attr,
00129                     &(pres->res_pathconf3
00130                       .PATHCONF3res_u.resok.obj_attributes));
00131 
00132   pres->res_pathconf3.PATHCONF3res_u.resok.linkmax = pstaticinfo->maxlink;
00133   pres->res_pathconf3.PATHCONF3res_u.resok.name_max = pstaticinfo->maxnamelen;
00134   pres->res_pathconf3.PATHCONF3res_u.resok.no_trunc = pstaticinfo->no_trunc;
00135   pres->res_pathconf3.PATHCONF3res_u.resok.chown_restricted = pstaticinfo->chown_restricted;
00136   pres->res_pathconf3.PATHCONF3res_u.resok.case_insensitive = pstaticinfo->case_insensitive;
00137   pres->res_pathconf3.PATHCONF3res_u.resok.case_preserving = pstaticinfo->case_preserving;
00138 
00139  out:
00140 
00141   if (pentry)
00142     {
00143       cache_inode_put(pentry);
00144     }
00145 
00146   return rc;
00147 }                               /* nfs3_Pathconf */
00148 
00157 void nfs3_Pathconf_Free(nfs_res_t * pres)
00158 {
00159   /* Nothing to do */
00160   return;
00161 }                               /* nfs3_Pathconf_Free */