LCOV - code coverage report
Current view: top level - lib/util - gpfswrap.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 0 126 0.0 %
Date: 2024-04-21 15:09:00 Functions: 0 21 0.0 %

          Line data    Source code
       1             : /*
       2             :  *  Unix SMB/CIFS implementation.
       3             :  *  Wrapper for GPFS library
       4             :  *  Copyright (C) Volker Lendecke 2005
       5             :  *  Copyright (C) Christof Schmitt 2015
       6             :  *
       7             :  *  This program is free software; you can redistribute it and/or modify
       8             :  *  it under the terms of the GNU General Public License as published by
       9             :  *  the Free Software Foundation; either version 3 of the License, or
      10             :  *  (at your option) any later version.
      11             :  *
      12             :  *  This program is distributed in the hope that it will be useful,
      13             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :  *  GNU General Public License for more details.
      16             :  *
      17             :  *  You should have received a copy of the GNU General Public License
      18             :  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
      19             :  */
      20             : 
      21             : #include "replace.h"
      22             : #include "gpfswrap.h"
      23             : 
      24             : static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
      25             : static int (*gpfs_set_lease_fn)(int fd, unsigned int type);
      26             : static int (*gpfs_fgetacl_fn)(int fd, int flags, void *acl);
      27             : static int (*gpfs_putacl_fn)(const char *pathname, int flags, void *acl);
      28             : static int (*gpfs_get_realfilename_path_fn)(const char *pathname,
      29             :                                             char *filenamep,
      30             :                                             int *len);
      31             : static int (*gpfs_register_cifs_export_fn)(void);
      32             : static int (*gpfs_set_winattrs_path_fn)(const char *pathname,
      33             :                                         int flags,
      34             :                                         struct gpfs_winattr *attrs);
      35             : static int (*gpfs_set_winattrs_fn)(int fd, int flags,
      36             :                                    struct gpfs_winattr *attrs);
      37             : static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
      38             : static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
      39             : static int (*gpfs_lib_init_fn)(int flags);
      40             : static int (*gpfs_set_times_fn)(int fd, int flags, gpfs_timestruc_t times[4]);
      41             : static int (*gpfs_set_times_path_fn)(char *path,
      42             :                                      int flags,
      43             :                                      gpfs_timestruc_t times[4]);
      44             : static int (*gpfs_quotactl_fn)(const char *pathname,
      45             :                                int cmd,
      46             :                                int id,
      47             :                                void *bufp);
      48             : static int (*gpfs_init_trace_fn)(void);
      49             : static int (*gpfs_query_trace_fn)(void);
      50             : static void (*gpfs_add_trace_fn)(int level, const char *msg);
      51             : static void (*gpfs_fini_trace_fn)(void);
      52             : static int (*gpfs_fstat_x_fn)(int fd, unsigned int *litemask,
      53             :                               struct gpfs_iattr64 *iattr, size_t len);
      54             : static int (*gpfs_stat_x_fn)(const char *pathname, unsigned int *litemask,
      55             :                              struct gpfs_iattr64 *iattr, size_t len);
      56             : 
      57           0 : int gpfswrap_init(void)
      58             : {
      59           0 :         static void *l;
      60             : 
      61           0 :         if (l != NULL) {
      62           0 :                 return 0;
      63             :         }
      64             : 
      65           0 :         l = dlopen("libgpfs.so", RTLD_LAZY);
      66           0 :         if (l == NULL) {
      67           0 :                 return -1;
      68             :         }
      69             : 
      70           0 :         gpfs_set_share_fn             = dlsym(l, "gpfs_set_share");
      71           0 :         gpfs_set_lease_fn             = dlsym(l, "gpfs_set_lease");
      72           0 :         gpfs_fgetacl_fn               = dlsym(l, "gpfs_getacl_fd");
      73           0 :         gpfs_putacl_fn                = dlsym(l, "gpfs_putacl");
      74           0 :         gpfs_get_realfilename_path_fn = dlsym(l, "gpfs_get_realfilename_path");
      75           0 :         gpfs_register_cifs_export_fn  = dlsym(l, "gpfs_register_cifs_export");
      76           0 :         gpfs_set_winattrs_path_fn     = dlsym(l, "gpfs_set_winattrs_path");
      77           0 :         gpfs_set_winattrs_fn          = dlsym(l, "gpfs_set_winattrs");
      78           0 :         gpfs_get_winattrs_fn          = dlsym(l, "gpfs_get_winattrs");
      79           0 :         gpfs_ftruncate_fn             = dlsym(l, "gpfs_ftruncate");
      80           0 :         gpfs_lib_init_fn              = dlsym(l, "gpfs_lib_init");
      81           0 :         gpfs_set_times_fn             = dlsym(l, "gpfs_set_times");
      82           0 :         gpfs_set_times_path_fn        = dlsym(l, "gpfs_set_times_path");
      83           0 :         gpfs_quotactl_fn              = dlsym(l, "gpfs_quotactl");
      84           0 :         gpfs_init_trace_fn            = dlsym(l, "gpfs_init_trace");
      85           0 :         gpfs_query_trace_fn           = dlsym(l, "gpfs_query_trace");
      86           0 :         gpfs_add_trace_fn             = dlsym(l, "gpfs_add_trace");
      87           0 :         gpfs_fini_trace_fn            = dlsym(l, "gpfs_fini_trace");
      88           0 :         gpfs_fstat_x_fn       = dlsym(l, "gpfs_fstat_x");
      89           0 :         gpfs_stat_x_fn                = dlsym(l, "gpfs_stat_x");
      90             : 
      91           0 :         return 0;
      92             : }
      93             : 
      94           0 : int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
      95             : {
      96           0 :         if (gpfs_set_share_fn == NULL) {
      97           0 :                 errno = ENOSYS;
      98           0 :                 return -1;
      99             :         }
     100             : 
     101           0 :         return gpfs_set_share_fn(fd, allow, deny);
     102             : }
     103             : 
     104           0 : int gpfswrap_set_lease(int fd, unsigned int type)
     105             : {
     106           0 :         if (gpfs_set_lease_fn == NULL) {
     107           0 :                 errno = ENOSYS;
     108           0 :                 return -1;
     109             :         }
     110             : 
     111           0 :         return gpfs_set_lease_fn(fd, type);
     112             : }
     113             : 
     114           0 : int gpfswrap_fgetacl(int fd, int flags, void *acl)
     115             : {
     116           0 :         if (gpfs_fgetacl_fn == NULL) {
     117           0 :                 errno = ENOSYS;
     118           0 :                 return -1;
     119             :         }
     120             : 
     121           0 :         return gpfs_fgetacl_fn(fd, flags, acl);
     122             : }
     123             : 
     124           0 : int gpfswrap_putacl(const char *pathname, int flags, void *acl)
     125             : {
     126           0 :         if (gpfs_putacl_fn == NULL) {
     127           0 :                 errno = ENOSYS;
     128           0 :                 return -1;
     129             :         }
     130             : 
     131           0 :         return gpfs_putacl_fn(pathname, flags, acl);
     132             : }
     133             : 
     134           0 : int gpfswrap_get_realfilename_path(const char *pathname,
     135             :                                    char *filenamep,
     136             :                                    int *len)
     137             : {
     138           0 :         if (gpfs_get_realfilename_path_fn == NULL) {
     139           0 :                 errno = ENOSYS;
     140           0 :                 return -1;
     141             :         }
     142             : 
     143           0 :         return gpfs_get_realfilename_path_fn(pathname, filenamep, len);
     144             : }
     145             : 
     146           0 : int gpfswrap_register_cifs_export(void)
     147             : {
     148           0 :         if (gpfs_register_cifs_export_fn == NULL) {
     149           0 :                 errno = ENOSYS;
     150           0 :                 return -1;
     151             :         }
     152             : 
     153           0 :         return gpfs_register_cifs_export_fn();
     154             : }
     155             : 
     156           0 : int gpfswrap_set_winattrs_path(const char *pathname,
     157             :                                int flags,
     158             :                                struct gpfs_winattr *attrs)
     159             : {
     160           0 :         if (gpfs_set_winattrs_path_fn == NULL) {
     161           0 :                 errno = ENOSYS;
     162           0 :                 return -1;
     163             :         }
     164             : 
     165           0 :         return gpfs_set_winattrs_path_fn(pathname, flags, attrs);
     166             : }
     167             : 
     168           0 : int gpfswrap_set_winattrs(int fd, int flags, struct gpfs_winattr *attrs)
     169             : {
     170           0 :         if (gpfs_set_winattrs_fn == NULL) {
     171           0 :                 errno = ENOSYS;
     172           0 :                 return -1;
     173             :         }
     174             : 
     175           0 :         return gpfs_set_winattrs_fn(fd, flags, attrs);
     176             : }
     177             : 
     178           0 : int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs)
     179             : {
     180           0 :         if (gpfs_get_winattrs_fn == NULL) {
     181           0 :                 errno = ENOSYS;
     182           0 :                 return -1;
     183             :         }
     184             : 
     185           0 :         return gpfs_get_winattrs_fn(fd, attrs);
     186             : }
     187             : 
     188           0 : int gpfswrap_ftruncate(int fd, gpfs_off64_t length)
     189             : {
     190           0 :         if (gpfs_ftruncate_fn == NULL) {
     191           0 :                 errno = ENOSYS;
     192           0 :                 return -1;
     193             :         }
     194             : 
     195           0 :         return gpfs_ftruncate_fn(fd, length);
     196             : }
     197             : 
     198           0 : int gpfswrap_lib_init(int flags)
     199             : {
     200           0 :         if (gpfs_lib_init_fn == NULL) {
     201           0 :                 errno = ENOSYS;
     202           0 :                 return -1;
     203             :         }
     204             : 
     205           0 :         return gpfs_lib_init_fn(flags);
     206             : }
     207             : 
     208           0 : int gpfswrap_set_times(int fd, int flags, gpfs_timestruc_t times[4])
     209             : {
     210           0 :         if (gpfs_set_times_fn == NULL) {
     211           0 :                 errno = ENOSYS;
     212           0 :                 return -1;
     213             :         }
     214             : 
     215           0 :         return gpfs_set_times_fn(fd, flags, times);
     216             : }
     217             : 
     218           0 : int gpfswrap_set_times_path(char *path, int flags, gpfs_timestruc_t times[4])
     219             : {
     220           0 :         if (gpfs_set_times_path_fn == NULL) {
     221           0 :                 errno = ENOSYS;
     222           0 :                 return -1;
     223             :         }
     224             : 
     225           0 :         return gpfs_set_times_path_fn(path, flags, times);
     226             : }
     227             : 
     228           0 : int gpfswrap_quotactl(const char *pathname, int cmd, int id, void *bufp)
     229             : {
     230           0 :         if (gpfs_quotactl_fn == NULL) {
     231           0 :                 errno = ENOSYS;
     232           0 :                 return -1;
     233             :         }
     234             : 
     235           0 :         return gpfs_quotactl_fn(pathname, cmd, id, bufp);
     236             : }
     237             : 
     238           0 : int gpfswrap_init_trace(void)
     239             : {
     240           0 :         if (gpfs_init_trace_fn == NULL) {
     241           0 :                 errno = ENOSYS;
     242           0 :                 return -1;
     243             :         }
     244             : 
     245           0 :         return gpfs_init_trace_fn();
     246             : }
     247             : 
     248           0 : int gpfswrap_query_trace(void)
     249             : {
     250           0 :         if (gpfs_query_trace_fn == NULL) {
     251           0 :                 errno = ENOSYS;
     252           0 :                 return -1;
     253             :         }
     254             : 
     255           0 :         return gpfs_query_trace_fn();
     256             : }
     257             : 
     258           0 : void gpfswrap_add_trace(int level, const char *msg)
     259             : {
     260           0 :         if (gpfs_add_trace_fn == NULL) {
     261           0 :                 return;
     262             :         }
     263             : 
     264           0 :         gpfs_add_trace_fn(level, msg);
     265             : }
     266             : 
     267           0 : void gpfswrap_fini_trace(void)
     268             : {
     269           0 :         if (gpfs_fini_trace_fn == NULL) {
     270           0 :                 return;
     271             :         }
     272             : 
     273           0 :         gpfs_fini_trace_fn();
     274             : }
     275             : 
     276           0 : int gpfswrap_fstat_x(int fd, unsigned int *litemask,
     277             :                      struct gpfs_iattr64 *iattr, size_t len)
     278             : {
     279           0 :         if (gpfs_fstat_x_fn == NULL) {
     280           0 :                 errno = ENOSYS;
     281           0 :                 return -1;
     282             :         }
     283             : 
     284           0 :         return gpfs_fstat_x_fn(fd, litemask, iattr, len);
     285             : }
     286             : 
     287           0 : int gpfswrap_stat_x(const char *pathname, unsigned int *litemask,
     288             :                     struct gpfs_iattr64 *iattr, size_t len)
     289             : {
     290           0 :         if (gpfs_stat_x_fn == NULL) {
     291           0 :                 errno = ENOSYS;
     292           0 :                 return -1;
     293             :         }
     294             : 
     295           0 :         return gpfs_stat_x_fn(pathname, litemask, iattr, len);
     296             : }

Generated by: LCOV version 1.14