2011-06-28 16:59:18 +04:00
/*
2006-11-09 23:29:31 +03:00
* Unix SMB / CIFS implementation .
2015-02-19 01:25:02 +03:00
* Wrapper for GPFS library
2006-11-09 23:29:31 +03:00
* Copyright ( C ) Volker Lendecke 2005
2015-02-19 01:25:02 +03:00
* Copyright ( C ) Christof Schmitt 2015
2006-11-09 23:29:31 +03:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
* the Free Software Foundation ; either version 3 of the License , or
2006-11-09 23:29:31 +03:00
* ( at your option ) any later version .
2011-06-28 16:59:18 +04:00
*
2006-11-09 23:29:31 +03:00
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
2011-06-28 16:59:18 +04:00
*
2006-11-09 23:29:31 +03:00
* You should have received a copy of the GNU General Public License
2007-07-10 09:23:25 +04:00
* along with this program ; if not , see < http : //www.gnu.org/licenses/>.
2006-11-09 23:29:31 +03:00
*/
2015-02-19 01:24:56 +03:00
# include "replace.h"
2014-12-11 02:05:16 +03:00
# include "gpfswrap.h"
2006-11-09 23:29:31 +03:00
static int ( * gpfs_set_share_fn ) ( int fd , unsigned int allow , unsigned int deny ) ;
2014-12-11 01:06:02 +03:00
static int ( * gpfs_set_lease_fn ) ( int fd , unsigned int type ) ;
2020-01-28 16:34:55 +03:00
static int ( * gpfs_getacl_fn ) ( const char * pathname , int flags , void * acl ) ;
2020-01-28 16:39:51 +03:00
static int ( * gpfs_putacl_fn ) ( const char * pathname , int flags , void * acl ) ;
2020-01-28 16:42:01 +03:00
static int ( * gpfs_get_realfilename_path_fn ) ( const char * pathname ,
char * filenamep ,
2014-12-11 01:15:53 +03:00
int * len ) ;
2020-01-28 16:44:24 +03:00
static int ( * gpfs_set_winattrs_path_fn ) ( const char * pathname ,
int flags ,
2014-12-11 01:22:27 +03:00
struct gpfs_winattr * attrs ) ;
2016-03-23 08:38:11 +03:00
static int ( * gpfs_set_winattrs_fn ) ( int fd , int flags ,
struct gpfs_winattr * attrs ) ;
2020-01-28 16:46:43 +03:00
static int ( * gpfs_get_winattrs_path_fn ) ( const char * pathname ,
2014-12-11 01:27:05 +03:00
struct gpfs_winattr * attrs ) ;
2009-05-29 02:20:10 +04:00
static int ( * gpfs_get_winattrs_fn ) ( int fd , struct gpfs_winattr * attrs ) ;
2010-10-08 15:43:17 +04:00
static int ( * gpfs_ftruncate_fn ) ( int fd , gpfs_off64_t length ) ;
2011-02-21 20:25:36 +03:00
static int ( * gpfs_lib_init_fn ) ( int flags ) ;
2014-01-07 22:55:46 +04:00
static int ( * gpfs_set_times_path_fn ) ( char * pathname , int flags ,
gpfs_timestruc_t times [ 4 ] ) ;
2020-01-28 16:50:19 +03:00
static int ( * gpfs_quotactl_fn ) ( const char * pathname ,
int cmd ,
int id ,
void * bufp ) ;
2015-02-25 02:18:59 +03:00
static int ( * gpfs_init_trace_fn ) ( void ) ;
static int ( * gpfs_query_trace_fn ) ( void ) ;
static void ( * gpfs_add_trace_fn ) ( int level , const char * msg ) ;
static void ( * gpfs_fini_trace_fn ) ( void ) ;
2019-08-20 01:35:18 +03:00
static int ( * gpfs_fstat_x_fn ) ( int fd , unsigned int * litemask ,
struct gpfs_iattr64 * iattr , size_t len ) ;
static int ( * gpfs_stat_x_fn ) ( const char * pathname , unsigned int * litemask ,
struct gpfs_iattr64 * iattr , size_t len ) ;
2006-11-09 23:29:31 +03:00
2015-02-18 20:14:22 +03:00
int gpfswrap_init ( void )
{
static void * l ;
if ( l ! = NULL ) {
return 0 ;
}
l = dlopen ( " libgpfs.so " , RTLD_LAZY ) ;
if ( l = = NULL ) {
return - 1 ;
}
gpfs_set_share_fn = dlsym ( l , " gpfs_set_share " ) ;
gpfs_set_lease_fn = dlsym ( l , " gpfs_set_lease " ) ;
gpfs_getacl_fn = dlsym ( l , " gpfs_getacl " ) ;
gpfs_putacl_fn = dlsym ( l , " gpfs_putacl " ) ;
gpfs_get_realfilename_path_fn = dlsym ( l , " gpfs_get_realfilename_path " ) ;
gpfs_set_winattrs_path_fn = dlsym ( l , " gpfs_set_winattrs_path " ) ;
2016-03-23 08:38:11 +03:00
gpfs_set_winattrs_fn = dlsym ( l , " gpfs_set_winattrs " ) ;
2015-02-18 20:14:22 +03:00
gpfs_get_winattrs_path_fn = dlsym ( l , " gpfs_get_winattrs_path " ) ;
gpfs_get_winattrs_fn = dlsym ( l , " gpfs_get_winattrs " ) ;
gpfs_ftruncate_fn = dlsym ( l , " gpfs_ftruncate " ) ;
gpfs_lib_init_fn = dlsym ( l , " gpfs_lib_init " ) ;
gpfs_set_times_path_fn = dlsym ( l , " gpfs_set_times_path " ) ;
gpfs_quotactl_fn = dlsym ( l , " gpfs_quotactl " ) ;
2015-02-25 02:18:59 +03:00
gpfs_init_trace_fn = dlsym ( l , " gpfs_init_trace " ) ;
gpfs_query_trace_fn = dlsym ( l , " gpfs_query_trace " ) ;
gpfs_add_trace_fn = dlsym ( l , " gpfs_add_trace " ) ;
gpfs_fini_trace_fn = dlsym ( l , " gpfs_fini_trace " ) ;
2019-08-20 01:35:18 +03:00
gpfs_fstat_x_fn = dlsym ( l , " gpfs_fstat_x " ) ;
gpfs_stat_x_fn = dlsym ( l , " gpfs_stat_x " ) ;
2015-02-18 20:14:22 +03:00
return 0 ;
}
2015-02-19 00:22:55 +03:00
int gpfswrap_set_share ( int fd , unsigned int allow , unsigned int deny )
{
if ( gpfs_set_share_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_set_share_fn ( fd , allow , deny ) ;
}
2014-12-11 01:06:02 +03:00
int gpfswrap_set_lease ( int fd , unsigned int type )
{
if ( gpfs_set_lease_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_set_lease_fn ( fd , type ) ;
}
2020-01-28 16:34:55 +03:00
int gpfswrap_getacl ( const char * pathname , int flags , void * acl )
2014-12-11 01:09:07 +03:00
{
if ( gpfs_getacl_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_getacl_fn ( pathname , flags , acl ) ;
}
2020-01-28 16:39:51 +03:00
int gpfswrap_putacl ( const char * pathname , int flags , void * acl )
2014-12-11 01:11:18 +03:00
{
if ( gpfs_putacl_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_putacl_fn ( pathname , flags , acl ) ;
}
2020-01-28 16:42:01 +03:00
int gpfswrap_get_realfilename_path ( const char * pathname ,
char * filenamep ,
int * len )
2014-12-11 01:15:53 +03:00
{
if ( gpfs_get_realfilename_path_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_get_realfilename_path_fn ( pathname , filenamep , len ) ;
}
2020-01-28 16:44:24 +03:00
int gpfswrap_set_winattrs_path ( const char * pathname ,
int flags ,
2014-12-11 01:22:27 +03:00
struct gpfs_winattr * attrs )
{
if ( gpfs_set_winattrs_path_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_set_winattrs_path_fn ( pathname , flags , attrs ) ;
}
2016-03-23 08:38:11 +03:00
int gpfswrap_set_winattrs ( int fd , int flags , struct gpfs_winattr * attrs )
{
if ( gpfs_set_winattrs_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_set_winattrs_fn ( fd , flags , attrs ) ;
}
2020-01-28 16:46:43 +03:00
int gpfswrap_get_winattrs_path ( const char * pathname ,
struct gpfs_winattr * attrs )
2014-12-11 01:27:05 +03:00
{
if ( gpfs_get_winattrs_path_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_get_winattrs_path_fn ( pathname , attrs ) ;
}
2014-12-11 01:29:19 +03:00
int gpfswrap_get_winattrs ( int fd , struct gpfs_winattr * attrs )
{
if ( gpfs_get_winattrs_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_get_winattrs_fn ( fd , attrs ) ;
}
2014-12-11 01:33:23 +03:00
int gpfswrap_ftruncate ( int fd , gpfs_off64_t length )
{
if ( gpfs_ftruncate_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_ftruncate_fn ( fd , length ) ;
}
2014-12-11 01:34:59 +03:00
int gpfswrap_lib_init ( int flags )
{
if ( gpfs_lib_init_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_lib_init_fn ( flags ) ;
}
2014-12-11 01:40:16 +03:00
int gpfswrap_set_times_path ( char * pathname , int flags ,
gpfs_timestruc_t times [ 4 ] )
{
if ( gpfs_set_times_path_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_set_times_path_fn ( pathname , flags , times ) ;
}
2020-01-28 16:50:19 +03:00
int gpfswrap_quotactl ( const char * pathname , int cmd , int id , void * bufp )
2014-12-11 01:42:32 +03:00
{
if ( gpfs_quotactl_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_quotactl_fn ( pathname , cmd , id , bufp ) ;
}
2015-02-25 02:18:59 +03:00
int gpfswrap_init_trace ( void )
{
if ( gpfs_init_trace_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_init_trace_fn ( ) ;
}
int gpfswrap_query_trace ( void )
{
if ( gpfs_query_trace_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_query_trace_fn ( ) ;
}
void gpfswrap_add_trace ( int level , const char * msg )
{
if ( gpfs_add_trace_fn = = NULL ) {
return ;
}
gpfs_add_trace_fn ( level , msg ) ;
}
void gpfswrap_fini_trace ( void )
{
if ( gpfs_fini_trace_fn = = NULL ) {
return ;
}
gpfs_fini_trace_fn ( ) ;
}
2019-08-20 01:35:18 +03:00
int gpfswrap_fstat_x ( int fd , unsigned int * litemask ,
struct gpfs_iattr64 * iattr , size_t len )
{
if ( gpfs_fstat_x_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_fstat_x_fn ( fd , litemask , iattr , len ) ;
}
int gpfswrap_stat_x ( const char * pathname , unsigned int * litemask ,
struct gpfs_iattr64 * iattr , size_t len )
{
if ( gpfs_stat_x_fn = = NULL ) {
errno = ENOSYS ;
return - 1 ;
}
return gpfs_stat_x_fn ( pathname , litemask , iattr , len ) ;
}