2 * Unix SMB/CIFS implementation.
3 * Wrapper for GPFS library
4 * Copyright (C) Volker Lendecke 2005
5 * Copyright (C) Christof Schmitt 2015
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.
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.
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/>.
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_getacl_fn
)(const char *pathname
, 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
,
31 static int (*gpfs_set_winattrs_path_fn
)(const char *pathname
,
33 struct gpfs_winattr
*attrs
);
34 static int (*gpfs_set_winattrs_fn
)(int fd
, int flags
,
35 struct gpfs_winattr
*attrs
);
36 static int (*gpfs_get_winattrs_path_fn
)(const char *pathname
,
37 struct gpfs_winattr
*attrs
);
38 static int (*gpfs_get_winattrs_fn
)(int fd
, struct gpfs_winattr
*attrs
);
39 static int (*gpfs_ftruncate_fn
)(int fd
, gpfs_off64_t length
);
40 static int (*gpfs_lib_init_fn
)(int flags
);
41 static int (*gpfs_set_times_path_fn
)(char *pathname
, int flags
,
42 gpfs_timestruc_t times
[4]);
43 static int (*gpfs_quotactl_fn
)(const char *pathname
,
47 static int (*gpfs_init_trace_fn
)(void);
48 static int (*gpfs_query_trace_fn
)(void);
49 static void (*gpfs_add_trace_fn
)(int level
, const char *msg
);
50 static void (*gpfs_fini_trace_fn
)(void);
51 static int (*gpfs_fstat_x_fn
)(int fd
, unsigned int *litemask
,
52 struct gpfs_iattr64
*iattr
, size_t len
);
53 static int (*gpfs_stat_x_fn
)(const char *pathname
, unsigned int *litemask
,
54 struct gpfs_iattr64
*iattr
, size_t len
);
56 int gpfswrap_init(void)
64 l
= dlopen("libgpfs.so", RTLD_LAZY
);
69 gpfs_set_share_fn
= dlsym(l
, "gpfs_set_share");
70 gpfs_set_lease_fn
= dlsym(l
, "gpfs_set_lease");
71 gpfs_getacl_fn
= dlsym(l
, "gpfs_getacl");
72 gpfs_putacl_fn
= dlsym(l
, "gpfs_putacl");
73 gpfs_get_realfilename_path_fn
= dlsym(l
, "gpfs_get_realfilename_path");
74 gpfs_set_winattrs_path_fn
= dlsym(l
, "gpfs_set_winattrs_path");
75 gpfs_set_winattrs_fn
= dlsym(l
, "gpfs_set_winattrs");
76 gpfs_get_winattrs_path_fn
= dlsym(l
, "gpfs_get_winattrs_path");
77 gpfs_get_winattrs_fn
= dlsym(l
, "gpfs_get_winattrs");
78 gpfs_ftruncate_fn
= dlsym(l
, "gpfs_ftruncate");
79 gpfs_lib_init_fn
= dlsym(l
, "gpfs_lib_init");
80 gpfs_set_times_path_fn
= dlsym(l
, "gpfs_set_times_path");
81 gpfs_quotactl_fn
= dlsym(l
, "gpfs_quotactl");
82 gpfs_init_trace_fn
= dlsym(l
, "gpfs_init_trace");
83 gpfs_query_trace_fn
= dlsym(l
, "gpfs_query_trace");
84 gpfs_add_trace_fn
= dlsym(l
, "gpfs_add_trace");
85 gpfs_fini_trace_fn
= dlsym(l
, "gpfs_fini_trace");
86 gpfs_fstat_x_fn
= dlsym(l
, "gpfs_fstat_x");
87 gpfs_stat_x_fn
= dlsym(l
, "gpfs_stat_x");
92 int gpfswrap_set_share(int fd
, unsigned int allow
, unsigned int deny
)
94 if (gpfs_set_share_fn
== NULL
) {
99 return gpfs_set_share_fn(fd
, allow
, deny
);
102 int gpfswrap_set_lease(int fd
, unsigned int type
)
104 if (gpfs_set_lease_fn
== NULL
) {
109 return gpfs_set_lease_fn(fd
, type
);
112 int gpfswrap_getacl(const char *pathname
, int flags
, void *acl
)
114 if (gpfs_getacl_fn
== NULL
) {
119 return gpfs_getacl_fn(pathname
, flags
, acl
);
122 int gpfswrap_putacl(const char *pathname
, int flags
, void *acl
)
124 if (gpfs_putacl_fn
== NULL
) {
129 return gpfs_putacl_fn(pathname
, flags
, acl
);
132 int gpfswrap_get_realfilename_path(const char *pathname
,
136 if (gpfs_get_realfilename_path_fn
== NULL
) {
141 return gpfs_get_realfilename_path_fn(pathname
, filenamep
, len
);
144 int gpfswrap_set_winattrs_path(const char *pathname
,
146 struct gpfs_winattr
*attrs
)
148 if (gpfs_set_winattrs_path_fn
== NULL
) {
153 return gpfs_set_winattrs_path_fn(pathname
, flags
, attrs
);
156 int gpfswrap_set_winattrs(int fd
, int flags
, struct gpfs_winattr
*attrs
)
158 if (gpfs_set_winattrs_fn
== NULL
) {
163 return gpfs_set_winattrs_fn(fd
, flags
, attrs
);
166 int gpfswrap_get_winattrs_path(const char *pathname
,
167 struct gpfs_winattr
*attrs
)
169 if (gpfs_get_winattrs_path_fn
== NULL
) {
174 return gpfs_get_winattrs_path_fn(pathname
, attrs
);
177 int gpfswrap_get_winattrs(int fd
, struct gpfs_winattr
*attrs
)
179 if (gpfs_get_winattrs_fn
== NULL
) {
184 return gpfs_get_winattrs_fn(fd
, attrs
);
187 int gpfswrap_ftruncate(int fd
, gpfs_off64_t length
)
189 if (gpfs_ftruncate_fn
== NULL
) {
194 return gpfs_ftruncate_fn(fd
, length
);
197 int gpfswrap_lib_init(int flags
)
199 if (gpfs_lib_init_fn
== NULL
) {
204 return gpfs_lib_init_fn(flags
);
207 int gpfswrap_set_times_path(char *pathname
, int flags
,
208 gpfs_timestruc_t times
[4])
210 if (gpfs_set_times_path_fn
== NULL
) {
215 return gpfs_set_times_path_fn(pathname
, flags
, times
);
218 int gpfswrap_quotactl(const char *pathname
, int cmd
, int id
, void *bufp
)
220 if (gpfs_quotactl_fn
== NULL
) {
225 return gpfs_quotactl_fn(pathname
, cmd
, id
, bufp
);
228 int gpfswrap_init_trace(void)
230 if (gpfs_init_trace_fn
== NULL
) {
235 return gpfs_init_trace_fn();
238 int gpfswrap_query_trace(void)
240 if (gpfs_query_trace_fn
== NULL
) {
245 return gpfs_query_trace_fn();
248 void gpfswrap_add_trace(int level
, const char *msg
)
250 if (gpfs_add_trace_fn
== NULL
) {
254 gpfs_add_trace_fn(level
, msg
);
257 void gpfswrap_fini_trace(void)
259 if (gpfs_fini_trace_fn
== NULL
) {
263 gpfs_fini_trace_fn();
266 int gpfswrap_fstat_x(int fd
, unsigned int *litemask
,
267 struct gpfs_iattr64
*iattr
, size_t len
)
269 if (gpfs_fstat_x_fn
== NULL
) {
274 return gpfs_fstat_x_fn(fd
, litemask
, iattr
, len
);
277 int gpfswrap_stat_x(const char *pathname
, unsigned int *litemask
,
278 struct gpfs_iattr64
*iattr
, size_t len
)
280 if (gpfs_stat_x_fn
== NULL
) {
285 return gpfs_stat_x_fn(pathname
, litemask
, iattr
, len
);