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_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
,
31 static int (*gpfs_register_cifs_export_fn
)(void);
32 static int (*gpfs_set_winattrs_path_fn
)(const char *pathname
,
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
,
43 gpfs_timestruc_t times
[4]);
44 static int (*gpfs_quotactl_fn
)(const char *pathname
,
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
);
57 int gpfswrap_init(void)
65 l
= dlopen("libgpfs.so", RTLD_LAZY
);
70 gpfs_set_share_fn
= dlsym(l
, "gpfs_set_share");
71 gpfs_set_lease_fn
= dlsym(l
, "gpfs_set_lease");
72 gpfs_fgetacl_fn
= dlsym(l
, "gpfs_getacl_fd");
73 gpfs_putacl_fn
= dlsym(l
, "gpfs_putacl");
74 gpfs_get_realfilename_path_fn
= dlsym(l
, "gpfs_get_realfilename_path");
75 gpfs_register_cifs_export_fn
= dlsym(l
, "gpfs_register_cifs_export");
76 gpfs_set_winattrs_path_fn
= dlsym(l
, "gpfs_set_winattrs_path");
77 gpfs_set_winattrs_fn
= dlsym(l
, "gpfs_set_winattrs");
78 gpfs_get_winattrs_fn
= dlsym(l
, "gpfs_get_winattrs");
79 gpfs_ftruncate_fn
= dlsym(l
, "gpfs_ftruncate");
80 gpfs_lib_init_fn
= dlsym(l
, "gpfs_lib_init");
81 gpfs_set_times_fn
= dlsym(l
, "gpfs_set_times");
82 gpfs_set_times_path_fn
= dlsym(l
, "gpfs_set_times_path");
83 gpfs_quotactl_fn
= dlsym(l
, "gpfs_quotactl");
84 gpfs_init_trace_fn
= dlsym(l
, "gpfs_init_trace");
85 gpfs_query_trace_fn
= dlsym(l
, "gpfs_query_trace");
86 gpfs_add_trace_fn
= dlsym(l
, "gpfs_add_trace");
87 gpfs_fini_trace_fn
= dlsym(l
, "gpfs_fini_trace");
88 gpfs_fstat_x_fn
= dlsym(l
, "gpfs_fstat_x");
89 gpfs_stat_x_fn
= dlsym(l
, "gpfs_stat_x");
94 int gpfswrap_set_share(int fd
, unsigned int allow
, unsigned int deny
)
96 if (gpfs_set_share_fn
== NULL
) {
101 return gpfs_set_share_fn(fd
, allow
, deny
);
104 int gpfswrap_set_lease(int fd
, unsigned int type
)
106 if (gpfs_set_lease_fn
== NULL
) {
111 return gpfs_set_lease_fn(fd
, type
);
114 int gpfswrap_fgetacl(int fd
, int flags
, void *acl
)
116 if (gpfs_fgetacl_fn
== NULL
) {
121 return gpfs_fgetacl_fn(fd
, flags
, acl
);
124 int gpfswrap_putacl(const char *pathname
, int flags
, void *acl
)
126 if (gpfs_putacl_fn
== NULL
) {
131 return gpfs_putacl_fn(pathname
, flags
, acl
);
134 int gpfswrap_get_realfilename_path(const char *pathname
,
138 if (gpfs_get_realfilename_path_fn
== NULL
) {
143 return gpfs_get_realfilename_path_fn(pathname
, filenamep
, len
);
146 int gpfswrap_register_cifs_export(void)
148 if (gpfs_register_cifs_export_fn
== NULL
) {
153 return gpfs_register_cifs_export_fn();
156 int gpfswrap_set_winattrs_path(const char *pathname
,
158 struct gpfs_winattr
*attrs
)
160 if (gpfs_set_winattrs_path_fn
== NULL
) {
165 return gpfs_set_winattrs_path_fn(pathname
, flags
, attrs
);
168 int gpfswrap_set_winattrs(int fd
, int flags
, struct gpfs_winattr
*attrs
)
170 if (gpfs_set_winattrs_fn
== NULL
) {
175 return gpfs_set_winattrs_fn(fd
, flags
, attrs
);
178 int gpfswrap_get_winattrs(int fd
, struct gpfs_winattr
*attrs
)
180 if (gpfs_get_winattrs_fn
== NULL
) {
185 return gpfs_get_winattrs_fn(fd
, attrs
);
188 int gpfswrap_ftruncate(int fd
, gpfs_off64_t length
)
190 if (gpfs_ftruncate_fn
== NULL
) {
195 return gpfs_ftruncate_fn(fd
, length
);
198 int gpfswrap_lib_init(int flags
)
200 if (gpfs_lib_init_fn
== NULL
) {
205 return gpfs_lib_init_fn(flags
);
208 int gpfswrap_set_times(int fd
, int flags
, gpfs_timestruc_t times
[4])
210 if (gpfs_set_times_fn
== NULL
) {
215 return gpfs_set_times_fn(fd
, flags
, times
);
218 int gpfswrap_set_times_path(char *path
, int flags
, gpfs_timestruc_t times
[4])
220 if (gpfs_set_times_path_fn
== NULL
) {
225 return gpfs_set_times_path_fn(path
, flags
, times
);
228 int gpfswrap_quotactl(const char *pathname
, int cmd
, int id
, void *bufp
)
230 if (gpfs_quotactl_fn
== NULL
) {
235 return gpfs_quotactl_fn(pathname
, cmd
, id
, bufp
);
238 int gpfswrap_init_trace(void)
240 if (gpfs_init_trace_fn
== NULL
) {
245 return gpfs_init_trace_fn();
248 int gpfswrap_query_trace(void)
250 if (gpfs_query_trace_fn
== NULL
) {
255 return gpfs_query_trace_fn();
258 void gpfswrap_add_trace(int level
, const char *msg
)
260 if (gpfs_add_trace_fn
== NULL
) {
264 gpfs_add_trace_fn(level
, msg
);
267 void gpfswrap_fini_trace(void)
269 if (gpfs_fini_trace_fn
== NULL
) {
273 gpfs_fini_trace_fn();
276 int gpfswrap_fstat_x(int fd
, unsigned int *litemask
,
277 struct gpfs_iattr64
*iattr
, size_t len
)
279 if (gpfs_fstat_x_fn
== NULL
) {
284 return gpfs_fstat_x_fn(fd
, litemask
, iattr
, len
);
287 int gpfswrap_stat_x(const char *pathname
, unsigned int *litemask
,
288 struct gpfs_iattr64
*iattr
, size_t len
)
290 if (gpfs_stat_x_fn
== NULL
) {
295 return gpfs_stat_x_fn(pathname
, litemask
, iattr
, len
);