nfs-ganesha 1.4

fsal_types.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 
00037 #ifndef _FSAL_TYPES_SPECIFIC_H
00038 #define _FSAL_TYPES_SPECIFIC_H
00039 
00040 #ifdef HAVE_CONFIG_H
00041 #include "config.h"
00042 #endif
00043 
00044 /*
00045  * FS relative includes
00046  */
00047 
00048 #include "config_parsing.h"
00049 #include "err_fsal.h"
00050 
00051 #ifndef _GNU_SOURCE
00052 #define _GNU_SOURCE
00053 #endif                          /* _GNU_SOURCE */
00054 
00055 #ifndef _ATFILE_SOURCE
00056 #define _ATFILE_SOURCE
00057 #endif                          /* _ATFILE_SOURCE */
00058 
00059 #include <sys/types.h>
00060 #include <sys/stat.h>
00061 #include <sys/syscall.h>
00062 #include <dirent.h>
00063 #include <fcntl.h>
00064 #include <stdio.h>
00065 #include <unistd.h>
00066 #include <string.h>
00067 #include <errno.h>
00068 
00069 /*
00070  * labels in the config file
00071  */
00072 
00073 #define CONF_LABEL_FS_SPECIFIC   "VFS"
00074 
00075 
00076 /* -------------------------------------------
00077  *      POSIX FS dependant definitions
00078  * ------------------------------------------- */
00079 
00080 #define FSAL_VFS_HANDLE_LEN 29
00081 #define FSAL_VFS_FSHANDLE_LEN 64
00082 
00083 #include "fsal_handle_syscalls.h"
00084 #include "fsal_glue_const.h"
00085 
00086 #define fsal_handle_t vfsfsal_handle_t
00087 #define fsal_op_context_t vfsfsal_op_context_t
00088 #define fsal_file_t vfsfsal_file_t
00089 #define fsal_dir_t vfsfsal_dir_t
00090 #define fsal_export_context_t vfsfsal_export_context_t
00091 #define fsal_lockdesc_t vfsfsal_lockdesc_t
00092 #define fsal_cookie_t vfsfsal_cookie_t
00093 #define fs_specific_initinfo_t vfsfs_specific_initinfo_t
00094 #define fsal_cred_t vfsfsal_cred_t
00095 
00096 typedef union {
00097  struct
00098   {
00099      vfs_file_handle_t vfs_handle ;
00100   } data ;
00101   char pad[FSAL_HANDLE_T_SIZE];
00102 } vfsfsal_handle_t;  
00107 typedef struct
00108 {
00109   fsal_staticfsinfo_t * fe_static_fs_info;     /* Must be the first entry in this structure */
00110 
00111   char              fstype[MAXNAMLEN] ;
00112   int               mount_root_fd ;
00113   vfs_file_handle_t root_handle ;
00114 } vfsfsal_export_context_t;
00115 
00116 #define FSAL_EXPORT_CONTEXT_SPECIFIC( _pexport_context ) (uint64_t)((_pexport_context)->dev_id)
00117 
00118 //#define FSAL_GET_EXP_CTX( popctx ) (fsal_export_context_t *)(( (vfsfsal_op_context_t *)popctx)->export_context)
00119 
00125 typedef struct
00126 {
00127   vfsfsal_export_context_t *export_context;     /* Must be the first entry in this structure */
00128   struct user_credentials credential;
00129 } vfsfsal_op_context_t;
00130 
00131 #define FSAL_OP_CONTEXT_TO_UID( pcontext ) ( pcontext->credential.user )
00132 #define FSAL_OP_CONTEXT_TO_GID( pcontext ) ( pcontext->credential.group )
00133 
00134 typedef struct
00135 {
00136   char vfs_mount_point[MAXPATHLEN];
00137 } vfsfs_specific_initinfo_t;
00138 
00140 typedef union {
00141  struct
00142  {
00143   off_t cookie;
00144  } data ;
00145   char pad[FSAL_COOKIE_T_SIZE];
00146 } vfsfsal_cookie_t;
00147 
00148 #define FSAL_SET_PCOOKIE_BY_OFFSET( __pfsal_cookie, __cookie )           \
00149 do                                                                       \
00150 {                                                                        \
00151    ((vfsfsal_cookie_t *)__pfsal_cookie)->data.cookie = (off_t)__cookie ; \
00152 } while( 0 )
00153 
00154 #define FSAL_SET_OFFSET_BY_PCOOKIE( __pfsal_cookie, __cookie )           \
00155 do                                                                       \
00156 {                                                                        \
00157    __cookie =  ((vfsfsal_cookie_t *)__pfsal_cookie)->data.cookie ;       \
00158 } while( 0 )
00159 
00160 
00161 //static const vfsfsal_cookie_t FSAL_READDIR_FROM_BEGINNING = { 0 };
00162 
00163 /* Directory stream descriptor. */
00164 
00165 typedef struct
00166 {
00167   int fd;
00168   vfsfsal_op_context_t context; /* credential for accessing the directory */
00169   fsal_path_t path;
00170   unsigned int dir_offset;
00171   vfsfsal_handle_t handle;
00172 } vfsfsal_dir_t;
00173 
00174 typedef struct
00175 {
00176   int fd;
00177   int ro;                       /* read only file ? */
00178 } vfsfsal_file_t;
00179 
00180 //#define FSAL_GET_EXP_CTX( popctx ) (fsal_export_context_t *)(( (vfsfsal_op_context_t *)popctx)->export_context)
00181 //#define FSAL_FILENO( p_fsal_file )  ((vfsfsal_file_t *)p_fsal_file)->fd 
00182 
00183 #endif                          /* _FSAL_TYPES__SPECIFIC_H */