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 /*
00041  * FS relative includes
00042  */
00043 
00044 #include "config_parsing.h"
00045 #include "err_fsal.h"
00046 
00047 #ifndef _GNU_SOURCE
00048 #define _GNU_SOURCE
00049 #endif                          /* _GNU_SOURCE */
00050 
00051 #ifndef _ATFILE_SOURCE
00052 #define _ATFILE_SOURCE
00053 #endif                          /* _ATFILE_SOURCE */
00054 
00055 #include <sys/types.h>
00056 #include <sys/stat.h>
00057 #include <sys/syscall.h>
00058 #include <dirent.h>
00059 #include <fcntl.h>
00060 #include <stdio.h>
00061 #include <unistd.h>
00062 #include <string.h>
00063 #include <errno.h>
00064 #include <gpfs_nfs.h>
00065 #include <stddef.h> /* For offsetof */
00066 
00067 
00068 #include "fsal_glue_const.h"
00069 
00070 #define fsal_handle_t gpfsfsal_handle_t
00071 #define fsal_op_context_t gpfsfsal_op_context_t
00072 #define fsal_file_t gpfsfsal_file_t
00073 #define fsal_dir_t gpfsfsal_dir_t
00074 #define fsal_export_context_t gpfsfsal_export_context_t
00075 #define fsal_lockdesc_t gpfsfsal_lockdesc_t
00076 #define fsal_cookie_t gpfsfsal_cookie_t
00077 #define fs_specific_initinfo_t gpfsfs_specific_initinfo_t
00078 #define fsal_cred_t gpfsfsal_cred_t
00079 
00080 /*
00081  * labels in the config file
00082  */
00083 
00084 #define CONF_LABEL_FS_SPECIFIC   "GPFS"
00085 
00086 /* -------------------------------------------
00087  *      POSIX FS dependant definitions
00088  * ------------------------------------------- */
00089 
00090 #define FSAL_GPFS_HANDLE_LEN 64
00091 #define FSAL_GPFS_FSHANDLE_LEN 64
00092 
00095 #define AT_FDCWD   -100
00096 
00097 #define OPENHANDLE_HANDLE_LEN 40
00098 #define OPENHANDLE_KEY_LEN 28
00099 #define OPENHANDLE_VERSION 1
00100 #define OPENHANDLE_DRIVER_MAGIC     'O'
00101 #define OPENHANDLE_OFFSET_OF_FILEID (2 * sizeof(int))
00102 
00111 /* some versions of GPFS don't have this in their headers */
00112 #ifndef H_GPFS_NFS
00113 struct gpfs_file_handle
00114 {
00115    u_int32_t handle_size;
00116    u_int32_t handle_type;
00117    u_int16_t handle_version;
00118    u_int16_t handle_key_size;
00119   /* file identifier */
00120   unsigned char f_handle[OPENHANDLE_HANDLE_LEN];
00121 };
00122 #endif
00123 
00124 static inline size_t gpfs_sizeof_handle(struct gpfs_file_handle *hdl)
00125 {
00126   return offsetof(struct gpfs_file_handle, f_handle) + hdl->handle_size;
00127 }
00130 /* Allow aliasing of fsal_handle_t since FSALs will be
00131  * casting between pointer types
00132  */
00133 typedef struct
00134 {
00135   struct
00136   {
00137     //  unsigned int fsid[2];
00138     struct gpfs_file_handle handle;
00139   } data ;
00140 } __attribute__((__may_alias__)) gpfsfsal_handle_t;  
00144 typedef struct
00145 {
00146   fsal_staticfsinfo_t * fe_static_fs_info;     /* Must be the first entry in this structure */
00147 
00148   /* Warning: This string is not currently filled in or used. */
00149   char mount_point[FSAL_MAX_PATH_LEN];
00150 
00151   int mount_root_fd;
00152   gpfsfsal_handle_t mount_root_handle;
00153   unsigned int fsid[2];
00154 } gpfsfsal_export_context_t;
00155 
00156 #define FSAL_EXPORT_CONTEXT_SPECIFIC( _pexport_context ) (uint64_t)((_pexport_context)->dev_id)
00157 
00158 typedef struct
00159 {
00160   gpfsfsal_export_context_t *export_context;        /* Must be the first entry in this structure */
00161   struct user_credentials credential;
00162 } gpfsfsal_op_context_t;
00163 
00164 #define FSAL_OP_CONTEXT_TO_UID( pcontext ) ( pcontext->credential.user )
00165 #define FSAL_OP_CONTEXT_TO_GID( pcontext ) ( pcontext->credential.group )
00166 
00167 typedef struct
00168 {
00169   int  use_kernel_module_interface;
00170   char open_by_handle_dev_file[MAXPATHLEN];
00171 } gpfsfs_specific_initinfo_t;
00172 
00174 typedef union {
00175  struct
00176  {
00177   off_t cookie;
00178  } data ;
00179   char pad[FSAL_COOKIE_T_SIZE];
00180 } gpfsfsal_cookie_t;
00181 
00182 // static const fsal_cookie_t FSAL_READDIR_FROM_BEGINNING = { 0 };
00183 
00184 /* Directory stream descriptor. */
00185 
00186 typedef struct
00187 {
00188   int fd;
00189   gpfsfsal_op_context_t context;    /* credential for accessing the directory */
00190   fsal_path_t path;
00191   unsigned int dir_offset;
00192   gpfsfsal_handle_t handle;
00193 } gpfsfsal_dir_t;
00194 
00195 typedef struct
00196 {
00197   int fd;
00198   int ro;                       /* read only file ? */
00199 } gpfsfsal_file_t;
00200 
00201 //#define FSAL_FILENO( p_fsal_file )  ( (p_fsal_file)->fd )
00202 
00203 /* Define the buffer size for GPFS NFS4 ACL. */
00204 #define GPFS_ACL_BUF_SIZE 0x1000
00205 
00206 /* A set of buffers to retrieve multiple attributes at the same time. */
00207 typedef struct fsal_xstat__
00208 {
00209   int attr_valid;
00210   struct stat buffstat;
00211   char buffacl[GPFS_ACL_BUF_SIZE];
00212 } gpfsfsal_xstat_t;
00213 
00214 #endif                          /* _FSAL_TYPES__SPECIFIC_H */