nfs-ganesha 1.4

mfsl_async.c

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 
00036 #ifdef HAVE_CONFIG_H
00037 #include "config.h"
00038 #endif
00039 
00040 /* fsal_types contains constants and type definitions for FSAL */
00041 #include "log.h"
00042 #include "fsal_types.h"
00043 #include "fsal.h"
00044 #include "mfsl_types.h"
00045 #include "mfsl.h"
00046 #include "common_utils.h"
00047 
00048 #include <pthread.h>
00049 #include <errno.h>
00050 
00051 #ifndef _USE_SWIG
00052 
00053 extern mfsl_parameter_t mfsl_param;
00054 
00055 fsal_handle_t dir_handle_precreate;
00056 unsigned int dir_handle_set = 0;
00057 unsigned int end_of_mfsl = FALSE;
00058 
00059 void constructor_preacreated_entries(void *ptr, void *parameters)
00060 {
00061   fsal_status_t fsal_status;
00062   fsal_path_t fsal_path;
00063   mfsl_precreated_object_t *pobject = (mfsl_precreated_object_t *) ptr;
00064 
00065   pobject->inited = 0;
00066 }                               /* constructor_preacreated_entries */
00067 
00079 fsal_handle_t tmp_symlink_dirhandle;  
00081 fsal_status_t mfsl_async_init_symlinkdir(fsal_op_context_t * pcontext)
00082 {
00083   fsal_attrib_list_t dir_attr;
00084   fsal_status_t fsal_status;
00085   fsal_path_t fsal_path;
00086 
00087   fsal_status = FSAL_str2path(mfsl_param.tmp_symlink_dir, MAXPATHLEN, &fsal_path);
00088   if(FSAL_IS_ERROR(fsal_status))
00089     {
00090       LogMajor(COMPONENT_MFSL, "Impossible to convert path %s", mfsl_param.tmp_symlink_dir);
00091       exit(1);
00092     }
00093 
00094   fsal_status = FSAL_lookupPath(&fsal_path, pcontext, &tmp_symlink_dirhandle, &dir_attr);
00095   if(FSAL_IS_ERROR(fsal_status))
00096     {
00097       LogMajor(COMPONENT_MFSL,
00098           "Impossible to lookup directory %s to be used to store precreated objects: status=(%u,%u)",
00099            mfsl_param.tmp_symlink_dir, fsal_status.major, fsal_status.minor);
00100       exit(1);
00101     }
00102 }                               /* mfsl_async_init_symlinkdir */
00103 
00115 #define NB_DIRENT_CLEAN 100
00116 
00117 fsal_status_t mfsl_async_init_clean_precreated_objects(fsal_op_context_t * pcontext)
00118 {
00119   fsal_status_t fsal_status;
00120   fsal_path_t fsal_path;
00121   fsal_handle_t dir_handle;
00122   fsal_attrib_list_t dir_attr;
00123   fsal_dir_t dir_descriptor;
00124   fsal_dir_t subdir_descriptor;
00125   fsal_dirent_t dirent[NB_DIRENT_CLEAN];
00126   fsal_dirent_t subdirent[NB_DIRENT_CLEAN];
00127   fsal_cookie_t end_cookie;
00128   fsal_cookie_t subend_cookie;
00129   fsal_count_t nb_entries;
00130   fsal_count_t subnb_entries;
00131   fsal_count_t nb_count;
00132   fsal_count_t subnb_count;
00133   fsal_boolean_t eod = FALSE;
00134   fsal_boolean_t subeod = FALSE;
00135   fsal_status.major = ERR_FSAL_NO_ERROR;
00136   fsal_status.minor = 0;
00137   fsal_cookie_t fsal_cookie_beginning ;
00138 
00139   fsal_status = FSAL_str2path(mfsl_param.pre_create_obj_dir, MAXPATHLEN, &fsal_path);
00140   if(FSAL_IS_ERROR(fsal_status))
00141     {
00142       LogMajor(COMPONENT_MFSL, "Impossible to convert path %s", mfsl_param.pre_create_obj_dir);
00143       exit(1);
00144     }
00145 
00146   fsal_status = FSAL_lookupPath(&fsal_path, pcontext, &dir_handle, &dir_attr);
00147   if(FSAL_IS_ERROR(fsal_status))
00148     {
00149       LogMajor(COMPONENT_MFSL,
00150           "Impossible to lookup directory %s to be used to store precreated objects: status=(%u,%u)",
00151            mfsl_param.pre_create_obj_dir, fsal_status.major, fsal_status.minor);
00152       exit(1);
00153     }
00154 
00155   while(eod == FALSE)
00156     {
00157       fsal_status = FSAL_opendir(&dir_handle, pcontext, &dir_descriptor, &dir_attr);
00158       if(FSAL_IS_ERROR(fsal_status))
00159         {
00160       LogMajor(COMPONENT_MFSL,
00161               "Impossible to opendir directory %s to be used to store precreated objects: status=(%u,%u)",
00162                mfsl_param.pre_create_obj_dir, fsal_status.major, fsal_status.minor);
00163           exit(1);
00164         }
00165 
00166       FSAL_SET_COOKIE_BEGINNING(fsal_cookie_beginning);
00167       fsal_status = FSAL_readdir(&dir_descriptor,
00168                                  fsal_cookie_beginning,
00169                                  FSAL_ATTRS_MANDATORY,
00170                                  NB_DIRENT_CLEAN * sizeof(fsal_dirent_t),
00171                                  dirent, &end_cookie, &nb_entries, &eod);
00172       if(FSAL_IS_ERROR(fsal_status))
00173         {
00174       LogMajor(COMPONENT_MFSL,
00175               "Impossible to readdir directory %s to be used to store precreated objects: status=(%u,%u)",
00176                mfsl_param.pre_create_obj_dir, fsal_status.major, fsal_status.minor);
00177           exit(1);
00178         }
00179 
00180       fsal_status = FSAL_closedir(&dir_descriptor);
00181       if(FSAL_IS_ERROR(fsal_status))
00182         {
00183           LogMajor(COMPONENT_MFSL,
00184               "Impossible to closedir directory %s to be used to store precreated objects: status=(%u,%u)",
00185                mfsl_param.pre_create_obj_dir, fsal_status.major, fsal_status.minor);
00186           exit(1);
00187         }
00188 
00189       for(nb_count = 0; nb_count < nb_entries; nb_count++)
00190         {
00191           fsal_status = FSAL_unlink(&dir_handle,
00192                                     &dirent[nb_count].name, pcontext, &dir_attr);
00193           if(FSAL_IS_ERROR(fsal_status))
00194             {
00195               if(fsal_status.major != ERR_FSAL_NOTEMPTY)
00196                 {
00197 #ifdef _USE_PROXY
00198                   if(fsal_status.minor == NFS4ERR_GRACE)
00199                     LogCrit(COMPONENT_MFSL,
00200                         "The remote server is within grace period. Wait for grace period to end and retry");
00201                   else
00202 #endif
00203                     LogMajor(COMPONENT_MFSL, "Impossible to unlink %s/%s status=(%u,%u)",
00204                                mfsl_param.pre_create_obj_dir, dirent[nb_count].name.name,
00205                                fsal_status.major, fsal_status.minor);
00206                   exit(1);
00207                 }
00208               else
00209                 {
00210                   while(subeod == FALSE)
00211                     {
00212                       /* non empty directory, cleanup it too.. */
00213                       fsal_status = FSAL_opendir(&dirent[nb_count].handle,
00214                                                  pcontext, &subdir_descriptor, &dir_attr);
00215                       if(FSAL_IS_ERROR(fsal_status))
00216                         {
00217                           LogMajor(COMPONENT_MFSL,
00218                               "Impossible to opendir directory %s/%s to be used to store precreated objects: status=(%u,%u)",
00219                                mfsl_param.pre_create_obj_dir, dirent[nb_count].name.name,
00220                                fsal_status.major, fsal_status.minor);
00221                           exit(1);
00222                         }
00223 
00224                       fsal_status = FSAL_readdir(&subdir_descriptor,
00225                                                  fsal_cookie_beginning,
00226                                                  FSAL_ATTRS_MANDATORY,
00227                                                  NB_DIRENT_CLEAN * sizeof(fsal_dirent_t),
00228                                                  subdirent,
00229                                                  &subend_cookie, &subnb_entries, &subeod);
00230                       if(FSAL_IS_ERROR(fsal_status))
00231                         {
00232                           LogMajor(COMPONENT_MFSL,
00233                               "Impossible to readdir directory %s/%s to be used to store precreated objects: status=(%u,%u)",
00234                                mfsl_param.pre_create_obj_dir, dirent[nb_count].name.name,
00235                                fsal_status.major, fsal_status.minor);
00236                           exit(1);
00237                         }
00238 
00239                       fsal_status = FSAL_closedir(&subdir_descriptor);
00240                       if(FSAL_IS_ERROR(fsal_status))
00241                         {
00242                           LogMajor(COMPONENT_MFSL,
00243                               "Impossible to closedir directory %s to be used to store precreated objects: status=(%u,%u)",
00244                                mfsl_param.pre_create_obj_dir, dirent[nb_count].name.name,
00245                                fsal_status.major, fsal_status.minor);
00246                           exit(1);
00247                         }
00248 
00249                       for(subnb_count = 0; subnb_count < subnb_entries; subnb_count++)
00250                         {
00251                           fsal_status = FSAL_unlink(&dirent[nb_count].handle,
00252                                                     &subdirent[subnb_count].name,
00253                                                     pcontext, &dir_attr);
00254                           if(FSAL_IS_ERROR(fsal_status))
00255                             {
00256                               if(fsal_status.major != ERR_FSAL_NOTEMPTY)
00257                                 {
00258 #ifdef _USE_PROXY
00259                                   if(fsal_status.minor == NFS4ERR_GRACE)
00260                                     LogCrit(COMPONENT_MFSL,
00261                                         "The remote server is within grace period. Wait for grace period to end and retry");
00262                                   else
00263 #endif
00264                                     LogMajor(COMPONENT_MFSL,
00265                                         "Impossible to unlink %s/%s/%s status=(%u,%u)",
00266                                          mfsl_param.pre_create_obj_dir,
00267                                          dirent[nb_count].name.name,
00268                                          subdirent[subnb_count], fsal_status.major,
00269                                          fsal_status.minor);
00270                                   exit(1);
00271                                 }
00272                             }
00273                         }       /* for */
00274                     }           /* while (subeod ) */
00275                   subeod = FALSE;
00276                 }               /* else */
00277             }                   /* if */
00278         }                       /* for */
00279 
00280     }                           /* while( eod ) */
00281 
00282   return fsal_status;
00283 }                               /* mfsl_async_init_clean_precreated_object */
00284 
00297 fsal_status_t mfsl_async_init_precreated_directories(fsal_op_context_t    *pcontext,
00298                                                      pool_t *pool_dirs)
00299 {
00300   unsigned int i = 0;
00301   char newdirpath[MAXNAMLEN];
00302   pthread_t me = pthread_self();
00303   unsigned int pid = (unsigned int)getpid();
00304   fsal_status_t fsal_status;
00305   fsal_path_t fsal_path;
00306   fsal_name_t fsal_name;
00307   mfsl_precreated_object_t *pprecreated;
00308   fsal_attrib_list_t dir_attr;
00309   static unsigned int counter = 0;
00310   struct prealloc_header *piter;
00311 
00312   fsal_status.major = ERR_FSAL_NO_ERROR;
00313   fsal_status.minor = 0;
00314 
00315   fsal_status = FSAL_str2path(mfsl_param.pre_create_obj_dir, MAXPATHLEN, &fsal_path);
00316   if(FSAL_IS_ERROR(fsal_status))
00317     {
00318       LogMajor(COMPONENT_MFSL, "Impossible to convert path %s", mfsl_param.pre_create_obj_dir);
00319       exit(1);
00320     }
00321 
00322   dir_attr.asked_attributes = FSAL_ATTRS_POSIX;
00323   dir_attr.supported_attributes = FSAL_ATTRS_POSIX;
00324 
00325   if(dir_handle_set == 0)
00326     {
00327       fsal_status =
00328           FSAL_lookupPath(&fsal_path, pcontext, &dir_handle_precreate, &dir_attr);
00329       if(FSAL_IS_ERROR(fsal_status))
00330         {
00331           LogMajor(COMPONENT_MFSL,
00332               "Impossible to lookup directory %s to be used to store precreated objects: status=(%u,%u)",
00333                mfsl_param.pre_create_obj_dir, fsal_status.major, fsal_status.minor);
00334           exit(1);
00335         }
00336 
00337       dir_handle_set = 1;
00338     }
00339 
00340   return fsal_status;
00341 }                               /* mfsl_async_init_precreated_directories */
00342 
00355 fsal_status_t mfsl_async_init_precreated_files(fsal_op_context_t    *pcontext,
00356                                                pool_t *pool_files)
00357 {
00358   unsigned int i = 0;
00359   char newdirpath[MAXNAMLEN];
00360   pthread_t me = pthread_self();
00361   unsigned int pid = (unsigned int)getpid();
00362   fsal_status_t fsal_status;
00363   fsal_path_t fsal_path;
00364   fsal_name_t fsal_name;
00365   mfsl_precreated_object_t *pprecreated;
00366   fsal_attrib_list_t dir_attr;
00367   fsal_attrib_list_t obj_attr;
00368   struct prealloc_header *piter;
00369   static unsigned int counter = 0;
00370 
00371   fsal_status.major = ERR_FSAL_NO_ERROR;
00372   fsal_status.minor = 0;
00373 
00374   fsal_status = FSAL_str2path(mfsl_param.pre_create_obj_dir, MAXPATHLEN, &fsal_path);
00375   if(FSAL_IS_ERROR(fsal_status))
00376     {
00377       LogMajor(COMPONENT_MFSL, "Impossible to convert path %s", mfsl_param.pre_create_obj_dir);
00378       exit(1);
00379     }
00380 
00381   dir_attr.asked_attributes = FSAL_ATTRS_POSIX;
00382   dir_attr.supported_attributes = FSAL_ATTRS_POSIX;
00383   if(dir_handle_set == 0)
00384     {
00385       fsal_status =
00386           FSAL_lookupPath(&fsal_path, pcontext, &dir_handle_precreate, &dir_attr);
00387       if(FSAL_IS_ERROR(fsal_status))
00388         {
00389           LogMajor(COMPONENT_MFSL,
00390               "Impossible to lookup directory %s to be used to store precreated objects: status=(%u,%u)",
00391                mfsl_param.pre_create_obj_dir, fsal_status.major, fsal_status.minor);
00392           exit(1);
00393         }
00394 
00395       dir_handle_set = 1;
00396     }
00397 
00398   return fsal_status;
00399 }                               /* mfsl_async_init_precreated_files */
00400 
00412 fsal_status_t MFSL_PrepareContext(fsal_op_context_t * pcontext)
00413 {
00414   return mfsl_async_init_clean_precreated_objects(pcontext);
00415 }                               /* MFSL_PrepareContext */
00416 
00429 fsal_status_t MFSL_GetContext(mfsl_context_t * pcontext,
00430                               fsal_op_context_t * pfsal_context)
00431 {
00432   fsal_status_t status;
00433 
00434   status.major = ERR_FSAL_NO_ERROR;
00435   status.minor = 0;
00436 
00437   if(pthread_mutex_init(&pcontext->lock, NULL) != 0)
00438     MFSL_return(ERR_FSAL_SERVERFAULT, errno);
00439 
00440   pcontext->synclet_index = 0;  /* only one synclet for now */
00441 
00442   pcontext->pool_async_op = pool_init(NULL,
00443                                       sizeof(mfsl_async_op_desc_t),
00444                                       pool_basic_substrate,
00445                                       NULL, NULL, NULL);
00446 
00447   pcontext->pool_spec_data =
00448     pool_init(NULL, sizeof(mfsl_object_specific_data_t),
00449               pool_basic_substrate,
00450               NULL, NULL, NULL);
00451 
00452   /* Preallocate files and dirs for this thread */
00453   P(pcontext->lock);
00454   status = MFSL_RefreshContext(pcontext, pfsal_context);
00455   V(pcontext->lock);
00456 
00457   return status;
00458 }                               /* MFSL_GetContext */
00459 
00472 fsal_status_t MFSL_ASYNC_GetSyncletContext(mfsl_synclet_context_t * pcontext,
00473                                            fsal_op_context_t * pfsal_context)
00474 {
00475   fsal_status_t status;
00476 
00477   status.major = ERR_FSAL_NO_ERROR;
00478   status.minor = 0;
00479 
00480   if(pthread_mutex_init(&pcontext->lock, NULL) != 0)
00481     MFSL_return(ERR_FSAL_SERVERFAULT, errno);
00482 
00483   return status;
00484 }
00485 
00498 fsal_status_t MFSL_ASYNC_RefreshContextDirs(mfsl_context_t * pcontext,
00499                                             fsal_op_context_t * pfsal_context)
00500 {
00501   fsal_status_t status;
00502 
00503   status.major = ERR_FSAL_NO_ERROR;
00504   status.minor = 0;
00505 
00506   if(pcontext->pool_dirs.pa_constructor == NULL)
00507     {
00508       pcontext->pool_dirs = pool_init(NULL,
00509                                       sizeof(mfsl_precreated_object_t),
00510                                       pool_basic_substrate,
00511                                       NULL,
00512                                       constructor_preacreated_entries, NULL);
00513 
00514       status = mfsl_async_init_precreated_directories(pfsal_context, &pcontext->pool_dirs);
00515       if(FSAL_IS_ERROR(status))
00516         return status;
00517     }
00518 
00519   return status;
00520 }                               /* MFSL_ASYNC_RefreshContextDirs */
00521 
00536 fsal_status_t MFSL_ASYNC_RefreshContextFiles(mfsl_context_t * pcontext,
00537                                              fsal_op_context_t * pfsal_context)
00538 {
00539   fsal_status_t status;
00540 
00541   status.major = ERR_FSAL_NO_ERROR;
00542   status.minor = 0;
00543 
00544   if(pcontext->pool_files.pa_constructor == NULL)
00545     {
00546       pcontext->pool_files
00547         = pool_init(NULL
00548                     sizeof(mfsl_precreated_object_t),
00549                     pool_basic_substrate, NULL
00550                     constructor_preacreated_entries, NULL);
00551 
00552       status = mfsl_async_init_precreated_files(pfsal_context, &pcontext->pool_files);
00553       if(FSAL_IS_ERROR(status))
00554         return status;
00555     }
00556 
00557   return status;
00558 }                               /* MFSL_ASYNC_RefreshtContextFiles */
00559 
00572 fsal_status_t MFSL_RefreshContext(mfsl_context_t * pcontext,
00573                                   fsal_op_context_t * pfsal_context)
00574 {
00575   fsal_status_t status;
00576   fsal_export_context_t fsal_export_context;
00577   fsal_op_context_t fsal_context;
00578 
00579   status.major = ERR_FSAL_NO_ERROR;
00580   status.minor = 0;
00581 
00582   if(pcontext->pool_dirs.pa_constructor == NULL || pcontext->pool_files.pa_constructor == NULL)
00583     {
00584       status = FSAL_BuildExportContext(&fsal_export_context, NULL, NULL);
00585       if(FSAL_IS_ERROR(status))
00586         return status;
00587 
00588       status = FSAL_GetClientContext(pfsal_context, &fsal_export_context, 0, 0, NULL, 0);
00589       if(FSAL_IS_ERROR(status))
00590         return status;
00591     }
00592 
00593   status = MFSL_ASYNC_RefreshContextDirs(pcontext, pfsal_context);
00594   if(FSAL_IS_ERROR(status))
00595     return status;
00596  
00597   status = MFSL_ASYNC_RefreshContextFiles(pcontext, pfsal_context);
00598   if(FSAL_IS_ERROR(status))
00599     return status;
00600  
00601   return status;
00602 }                               /* MFSL_ASYNC_RefreshContext */
00603 
00616 fsal_status_t MFSL_ASYNC_RefreshSyncletContext(mfsl_synclet_context_t * pcontext,
00617                                                fsal_op_context_t * pfsal_context)
00618 {
00619   fsal_status_t status;
00620 
00621   status.major = ERR_FSAL_NO_ERROR;
00622   status.minor = 0;
00623 
00624   return status;
00625 }                               /* MFSL_ASYNC_RefreshSyncletContext */
00626 
00638 int MFSL_ASYNC_is_synced(mfsl_object_t * mobject)
00639 {
00640   if(mobject == NULL)
00641     return FALSE;
00642 
00643   if(mobject->health == MFSL_ASYNC_SYNCHRONOUS)
00644     return TRUE;
00645 
00646   /* in all other case, returns FALSE */
00647   return FALSE;
00648 }                               /*  MFSL_ASYNC_is_synced */
00649 
00650 #endif                          /* ! _USE_SWIG */
00651 
00652 /******************************************************
00653  *              Common Filesystem calls.
00654  ******************************************************/
00655 
00656 fsal_status_t MFSL_lookupPath(fsal_path_t * p_path,     /* IN */
00657                               fsal_op_context_t * p_context,    /* IN */
00658                               mfsl_context_t * p_mfsl_context,  /* IN */
00659                               mfsl_object_t * object_handle,    /* OUT */
00660                               fsal_attrib_list_t * object_attributes    /* [ IN/OUT ] */
00661     )
00662 {
00663   fsal_status_t fsal_status;
00664 
00665   fsal_status = FSAL_lookupPath(p_path,
00666                                 p_context, &object_handle->handle, object_attributes);
00667   return fsal_status;
00668 }                               /* MFSL_lookupPath */
00669 
00670 fsal_status_t MFSL_lookupJunction(mfsl_object_t * p_junction_handle,    /* IN */
00671                                   fsal_op_context_t * p_context,        /* IN */
00672                                   mfsl_context_t * p_mfsl_context,      /* IN */
00673                                   mfsl_object_t * p_fsoot_handle,       /* OUT */
00674                                   fsal_attrib_list_t * p_fsroot_attributes      /* [ IN/OUT ] */
00675     )
00676 {
00677   return FSAL_lookupJunction(&p_junction_handle->handle,
00678                              p_context, &p_fsoot_handle->handle, p_fsroot_attributes);
00679 }                               /* MFSL_lookupJunction */
00680 
00681 fsal_status_t MFSL_access(mfsl_object_t * object_handle,        /* IN */
00682                           fsal_op_context_t * p_context,        /* IN */
00683                           mfsl_context_t * p_mfsl_context,      /* IN */
00684                           fsal_accessflags_t access_type,       /* IN */
00685                           fsal_attrib_list_t * object_attributes        /* [ IN/OUT ] */
00686     )
00687 {
00688   fsal_status_t fsal_status;
00689 
00690   P(object_handle->lock);
00691   fsal_status = FSAL_access(&object_handle->handle,
00692                             p_context, access_type, object_attributes);
00693   V(object_handle->lock);
00694 
00695   return fsal_status;
00696 }                               /* MFSL_access */
00697 
00698 fsal_status_t MFSL_opendir(mfsl_object_t * dir_handle,  /* IN */
00699                            fsal_op_context_t * p_context,       /* IN */
00700                            mfsl_context_t * p_mfsl_context,     /* IN */
00701                            fsal_dir_t * dir_descriptor, /* OUT */
00702                            fsal_attrib_list_t * dir_attributes  /* [ IN/OUT ] */
00703     )
00704 {
00705   fsal_status_t fsal_status;
00706 
00707   P(dir_handle->lock);
00708   fsal_status = FSAL_opendir(&dir_handle->handle,
00709                              p_context, dir_descriptor, dir_attributes);
00710   V(dir_handle->lock);
00711 
00712   return fsal_status;
00713 }                               /* MFSL_opendir */
00714 
00715 fsal_status_t MFSL_readdir(fsal_dir_t * dir_descriptor, /* IN */
00716                            fsal_cookie_t start_position,        /* IN */
00717                            fsal_attrib_mask_t get_attr_mask,    /* IN */
00718                            fsal_mdsize_t buffersize,    /* IN */
00719                            fsal_dirent_t * pdirent,     /* OUT */
00720                            fsal_cookie_t * end_position,        /* OUT */
00721                            fsal_count_t * nb_entries,   /* OUT */
00722                            fsal_boolean_t * end_of_dir, /* OUT */
00723                            mfsl_context_t * p_mfsl_context      /* IN */
00724     )
00725 {
00726   fsal_status_t fsal_status;
00727 
00728   return FSAL_readdir(dir_descriptor,
00729                       start_position,
00730                       get_attr_mask,
00731                       buffersize, pdirent, end_position, nb_entries, end_of_dir);
00732 
00733 }                               /* MFSL_readdir */
00734 
00735 fsal_status_t MFSL_closedir(fsal_dir_t * dir_descriptor,        /* IN */
00736                             mfsl_context_t * p_mfsl_context     /* IN */
00737     )
00738 {
00739   fsal_status_t fsal_status;
00740 
00741   return FSAL_closedir(dir_descriptor);
00742 }                               /* FSAL_closedir */
00743 
00744 fsal_status_t MFSL_open(mfsl_object_t * filehandle,     /* IN */
00745                         fsal_op_context_t * p_context,  /* IN */
00746                         mfsl_context_t * p_mfsl_context,        /* IN */
00747                         fsal_openflags_t openflags,     /* IN */
00748                         fsal_file_t * file_descriptor,  /* OUT */
00749                         fsal_attrib_list_t * file_attributes    /* [ IN/OUT ] */
00750     )
00751 {
00752   fsal_status_t fsal_status;
00753 
00754   fsal_status = FSAL_open(&filehandle->handle,
00755                           p_context, openflags, file_descriptor, file_attributes);
00756   return fsal_status;
00757 }                               /* MFSL_open */
00758 
00759 fsal_status_t MFSL_open_by_fileid(mfsl_object_t * filehandle,   /* IN */
00760                                   fsal_u64_t fileid,    /* IN */
00761                                   fsal_op_context_t * p_context,        /* IN */
00762                                   mfsl_context_t * p_mfsl_context,      /* IN */
00763                                   fsal_openflags_t openflags,   /* IN */
00764                                   fsal_file_t * file_descriptor,        /* OUT */
00765                                   fsal_attrib_list_t * file_attributes /* [ IN/OUT ] */ )
00766 {
00767   return FSAL_open_by_fileid(&filehandle->handle,
00768                              fileid,
00769                              p_context, openflags, file_descriptor, file_attributes);
00770 }                               /* MFSL_open_by_fileid */
00771 
00772 fsal_status_t MFSL_read(fsal_file_t * file_descriptor,  /*  IN  */
00773                         fsal_seek_t * seek_descriptor,  /* [IN] */
00774                         fsal_size_t buffer_size,        /*  IN  */
00775                         caddr_t buffer, /* OUT  */
00776                         fsal_size_t * read_amount,      /* OUT  */
00777                         fsal_boolean_t * end_of_file,   /* OUT  */
00778                         mfsl_context_t * p_mfsl_context /* IN */
00779     )
00780 {
00781   return FSAL_read(file_descriptor,
00782                    seek_descriptor, buffer_size, buffer, read_amount, end_of_file);
00783 }                               /* MFSL_read */
00784 
00785 fsal_status_t MFSL_write(fsal_file_t * file_descriptor, /* IN */
00786                          fsal_seek_t * seek_descriptor, /* IN */
00787                          fsal_size_t buffer_size,       /* IN */
00788                          caddr_t buffer,        /* IN */
00789                          fsal_size_t * write_amount,    /* OUT */
00790                          mfsl_context_t * p_mfsl_context        /* IN */
00791     )
00792 {
00793   return FSAL_write(file_descriptor, seek_descriptor, buffer_size, buffer, write_amount);
00794 }                               /* MFSL_write */
00795 
00796 fsal_status_t MFSL_close(fsal_file_t * file_descriptor, /* IN */
00797                          mfsl_context_t * p_mfsl_context        /* IN */
00798     )
00799 {
00800   return FSAL_close(file_descriptor);
00801 }                               /* MFSL_close */
00802 
00803 fsal_status_t MFSL_commit(mfsl_file_t * file_descriptor /* IN */,
00804                          void * pextra)
00805 {
00806    return FSAL_commit( &file_descriptor->fsal_file ) ;
00807 }
00808 
00809 fsal_status_t MFSL_close_by_fileid(fsal_file_t * file_descriptor /* IN */ ,
00810                                    fsal_u64_t fileid, mfsl_context_t * p_mfsl_context)  /* IN */
00811 {
00812   return FSAL_close_by_fileid(file_descriptor, fileid);
00813 }                               /* MFSL_close_by_fileid */
00814 
00815 fsal_status_t MFSL_readlink(mfsl_object_t * linkhandle, /* IN */
00816                             fsal_op_context_t * p_context,      /* IN */
00817                             mfsl_context_t * p_mfsl_context,    /* IN */
00818                             fsal_path_t * p_link_content,       /* OUT */
00819                             fsal_attrib_list_t * link_attributes        /* [ IN/OUT ] */
00820     )
00821 {
00822   fsal_status_t fsal_status;
00823 
00824   P(linkhandle->lock);
00825   fsal_status = FSAL_readlink(&linkhandle->handle,
00826                               p_context, p_link_content, link_attributes);
00827   V(linkhandle->lock);
00828 
00829   return fsal_status;
00830 }                               /* MFSL_readlink */
00831 
00832 fsal_status_t MFSL_mknode(mfsl_object_t * parentdir_handle,     /* IN */
00833                           fsal_name_t * p_node_name,    /* IN */
00834                           fsal_op_context_t * p_context,        /* IN */
00835                           mfsl_context_t * p_mfsl_context,      /* IN */
00836                           fsal_accessmode_t accessmode, /* IN */
00837                           fsal_nodetype_t nodetype,     /* IN */
00838                           fsal_dev_t * dev,     /* IN */
00839                           mfsl_object_t * p_object_handle,      /* OUT */
00840                           fsal_attrib_list_t * node_attributes  /* [ IN/OUT ] */
00841     )
00842 {
00843   return FSAL_mknode(&parentdir_handle->handle,
00844                      p_node_name,
00845                      p_context,
00846                      accessmode,
00847                      nodetype, dev, &p_object_handle->handle, node_attributes);
00848 }                               /* MFSL_mknode */
00849 
00850 fsal_status_t MFSL_rcp(mfsl_object_t * filehandle,      /* IN */
00851                        fsal_op_context_t * p_context,   /* IN */
00852                        mfsl_context_t * p_mfsl_context, /* IN */
00853                        fsal_path_t * p_local_path,      /* IN */
00854                        fsal_rcpflag_t transfer_opt      /* IN */
00855     )
00856 {
00857   fsal_status_t fsal_status;
00858 
00859   P(filehandle->lock);
00860   fsal_status = FSAL_rcp(&filehandle->handle, p_context, p_local_path, transfer_opt);
00861   V(filehandle->lock);
00862 
00863   return fsal_status;
00864 }                               /* MFSL_rcp */
00865 
00866 /* To be called before exiting */
00867 fsal_status_t MFSL_terminate(void)
00868 {
00869   fsal_status_t status;
00870 
00871   end_of_mfsl = TRUE;
00872 
00873   status.major = ERR_FSAL_NO_ERROR;
00874   status.minor = 0;
00875 
00876   return status;
00877 
00878 }                               /* MFSL_terminate */