nfs-ganesha 1.4

fsal_context.c

Go to the documentation of this file.
00001 /*
00002  * vim:expandtab:shiftwidth=8:tabstop=8:
00003  */
00004 
00014 #ifdef HAVE_CONFIG_H
00015 #include "config.h"
00016 #endif
00017 
00018 #include "fsal.h"
00019 #include "fsal_internal.h"
00020 #include "fsal_common.h"
00021 #include <pwd.h>
00022 #include <errno.h>
00023 #include <stdlib.h>
00024 #include <string.h>
00025 #include <sys/types.h>
00026 #include <unistd.h>
00027 
00040 fsal_status_t FUSEFSAL_BuildExportContext(fsal_export_context_t * p_export_context, /* OUT */
00041                                           fsal_path_t * p_export_path,  /* IN */
00042                                           char *fs_specific_options     /* IN */
00043     )
00044 {
00045   /* sanity check */
00046   if(!p_export_context)
00047     Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_BuildExportContext);
00048 
00049   /* TODO */
00050   /* no FS specific option string supported for now */
00051   /* retrieves the root handle */
00052   /* store root full path */
00053 
00054   /* unused */
00055   memset(p_export_context, 0, sizeof(fusefsal_export_context_t));
00056 
00057   /* Save pointer to fsal_staticfsinfo_t in export context */
00058   p_export_context->fe_static_fs_info = &global_fs_info;
00059 
00060   Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_BuildExportContext);
00061 
00062 }
00063 
00064 fsal_status_t FUSEFSAL_InitClientContext(fsal_op_context_t *context)
00065 {
00066   fusefsal_op_context_t * p_thr_context = (fusefsal_op_context_t *)context;
00067 
00068   /* sanity check */
00069   if(!p_thr_context)
00070     Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_InitClientContext);
00071 
00072   /* initialy set the export entry to none */
00073   p_thr_context->export_context = NULL;
00074 
00075   /* set credential info */
00076   p_thr_context->credential.user = 0;
00077   p_thr_context->credential.group = 0;
00078   p_thr_context->credential.nbgroups = 0;
00079 
00080   /* build fuse context */
00081   p_thr_context->ganefuse_context.ganefuse = NULL;
00082   p_thr_context->ganefuse_context.uid = 0;
00083   p_thr_context->ganefuse_context.gid = 0;
00084   p_thr_context->ganefuse_context.pid = getpid();
00085   p_thr_context->ganefuse_context.private_data = fs_private_data;
00086 
00087   Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_InitClientContext);
00088 
00089 }
00090 
00114 fsal_status_t FUSEFSAL_GetClientContext(fsal_op_context_t *context,  /* IN/OUT  */
00115                                         fsal_export_context_t * p_export_context,   /* IN */
00116                                         fsal_uid_t uid, /* IN */
00117                                         fsal_gid_t gid, /* IN */
00118                                         fsal_gid_t * alt_groups,        /* IN */
00119                                         fsal_count_t nb_alt_groups      /* IN */
00120     )
00121 {
00122 
00123   fusefsal_op_context_t * p_thr_context = (fusefsal_op_context_t *)context;
00124 
00125   /* sanity check */
00126   if(!p_thr_context || !p_export_context)
00127     Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_GetClientContext);
00128 
00129   /* set the specific export context */
00130   p_thr_context->export_context = (fusefsal_export_context_t *) p_export_context;
00131 
00132   /* set credential info */
00133   p_thr_context->credential.user = uid;
00134   p_thr_context->credential.group = gid;
00135   p_thr_context->credential.nbgroups = 0; /* no alt groups at present */
00136 
00137   /* build fuse context */
00138   p_thr_context->ganefuse_context.ganefuse = NULL;
00139   p_thr_context->ganefuse_context.uid = uid;
00140   p_thr_context->ganefuse_context.gid = gid;
00141   p_thr_context->ganefuse_context.pid = getpid();
00142   p_thr_context->ganefuse_context.private_data = fs_private_data;
00143 
00144   Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_GetClientContext);
00145 
00146 }
00147 
00148 /* @} */