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 
00035 #ifndef _FSAL_TYPES_SPECIFIC_H
00036 #define _FSAL_TYPES_SPECIFIC_H
00037 
00038 /* >> write here the includes your need for your filesystem << */
00039 
00040   /* Change bellow the label of your filesystem configuration
00041    * section in the GANESHA's configuration file.
00042    */
00043 # define CONF_LABEL_FS_SPECIFIC   "ZFS"
00044 
00045 #include <sys/types.h>
00046 #include <sys/stat.h>
00047 #include <fcntl.h>
00048 #include <sys/param.h>
00049 #include <inttypes.h>
00050 #include "config_parsing.h"
00051 #include "err_fsal.h"
00052 
00053 #include <libzfswrap.h>
00054 
00055 
00056 
00057   /* In this section, you must define your own FSAL internal types.
00058    * Here are some template types :
00059    */
00060 
00061 #include "fsal_glue_const.h"
00062 
00063 #define fsal_handle_t zfsfsal_handle_t
00064 #define fsal_op_context_t zfsfsal_op_context_t
00065 #define fsal_file_t zfsfsal_file_t
00066 #define fsal_dir_t zfsfsal_dir_t
00067 #define fsal_export_context_t zfsfsal_export_context_t
00068 #define fsal_lockdesc_t zfsfsal_lockdesc_t
00069 #define fsal_cookie_t zfsfsal_cookie_t
00070 #define fs_specific_initinfo_t zfsfs_specific_initinfo_t
00071 #define fsal_cred_t zfsfsal_cred_t
00072 
00073 typedef union
00074 {
00075   struct
00076   {
00077     inogen_t zfs_handle;
00078     fsal_nodetype_t type;
00079     char i_snap;
00080   } data;
00081   char pad[FSAL_HANDLE_T_SIZE];
00082 } zfsfsal_handle_t;
00083 
00084 typedef struct
00085 {
00086   fsal_staticfsinfo_t * fe_static_fs_info;     /* Must be the first entry in this structure */
00087 
00088   zfsfsal_handle_t root_handle;
00089   libzfswrap_vfs_t *p_vfs;
00090 
00091 } zfsfsal_export_context_t;
00092 
00093 #define FSAL_EXPORT_CONTEXT_SPECIFIC( pexport_context ) (uint64_t)(FSAL_Handle_to_RBTIndex( &(pexport_context->root_handle), 0 ) )
00094 
00095 typedef struct
00096 {
00097   zfsfsal_export_context_t *export_context; /* Must be the first member of this structure */
00098   struct user_credentials credential;
00099   int thread_connect_array[32];
00100 
00101 } zfsfsal_op_context_t;
00102 
00103 #define FSAL_OP_CONTEXT_TO_UID( pcontext ) ( pcontext->credential.user )
00104 #define FSAL_OP_CONTEXT_TO_GID( pcontext ) ( pcontext->credential.group )
00105 
00106 typedef struct
00107 {
00108   creden_t cred;
00109   libzfswrap_vnode_t *p_vnode;
00110   zfsfsal_handle_t handle;
00111 
00112 } zfsfsal_dir_t;
00113 
00114 typedef struct
00115 {
00116   creden_t cred;
00117   zfsfsal_handle_t handle;
00118   off_t current_offset;
00119   int flags;
00120   libzfswrap_vnode_t *p_vnode;
00121   int is_closed;
00122 
00123 } zfsfsal_file_t;
00124 
00125 typedef union
00126 {
00127   struct
00128   {
00129     off_t cookie;
00130   } data;
00131   char pad[FSAL_COOKIE_T_SIZE];
00132 } zfsfsal_cookie_t;
00133 
00134 #define FSAL_SET_PCOOKIE_BY_OFFSET( __pfsal_cookie, __cookie )           \
00135 do                                                                       \
00136 {                                                                        \
00137    ((zfsfsal_cookie_t *)__pfsal_cookie)->data.cookie = (off_t)__cookie ; \
00138 } while( 0 )
00139 
00140 #define FSAL_SET_OFFSET_BY_PCOOKIE( __pfsal_cookie, __cookie )           \
00141 do                                                                       \
00142 {                                                                        \
00143    __cookie =  ((zfsfsal_cookie_t *)__pfsal_cookie)->data.cookie ;       \
00144 } while( 0 )
00145 
00146 //#define FSAL_READDIR_FROM_BEGINNING 0
00147 
00148 typedef struct
00149 {
00150   char psz_zpool[FSAL_MAX_NAME_LEN];
00151 
00152   int auto_snapshots;
00153 
00154   char psz_snap_hourly_prefix[FSAL_MAX_NAME_LEN];
00155   int snap_hourly_time;
00156   int snap_hourly_number;
00157 
00158   char psz_snap_daily_prefix[FSAL_MAX_NAME_LEN];
00159   int snap_daily_time;
00160   int snap_daily_number;
00161 
00162 } zfsfs_specific_initinfo_t;
00163 
00164 #endif                          /* _FSAL_TYPES_SPECIFIC_H */