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_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_fn
)(int fd
, struct gpfs_winattr
*attrs
);
37 static int (*gpfs_ftruncate_fn
)(int fd
, gpfs_off64_t length
);
38 static int (*gpfs_lib_init_fn
)(int flags
);
39 static int (*gpfs_set_times_fn
)(int fd
, int flags
, gpfs_timestruc_t times
[4]);
40 static int (*gpfs_set_times_path_fn
)(char *path
,
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_fgetacl_fn
= dlsym(l
, "gpfs_getacl_fd");
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_fn
= dlsym(l
, "gpfs_get_winattrs");
77 gpfs_ftruncate_fn
= dlsym(l
, "gpfs_ftruncate");
78 gpfs_lib_init_fn
= dlsym(l
, "gpfs_lib_init");
79 gpfs_set_times_fn
= dlsym(l
, "gpfs_set_times");
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_fgetacl(int fd
, int flags
, void *acl
)
114 if (gpfs_fgetacl_fn
== NULL
) {
119 return gpfs_fgetacl_fn(fd
, 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(int fd
, struct gpfs_winattr
*attrs
)
168 if (gpfs_get_winattrs_fn
== NULL
) {
173 return gpfs_get_winattrs_fn(fd
, attrs
);
176 int gpfswrap_ftruncate(int fd
, gpfs_off64_t length
)
178 if (gpfs_ftruncate_fn
== NULL
) {
183 return gpfs_ftruncate_fn(fd
, length
);
186 int gpfswrap_lib_init(int flags
)
188 if (gpfs_lib_init_fn
== NULL
) {
193 return gpfs_lib_init_fn(flags
);
196 int gpfswrap_set_times(int fd
, int flags
, gpfs_timestruc_t times
[4])
198 if (gpfs_set_times_fn
== NULL
) {
203 return gpfs_set_times_fn(fd
, flags
, times
);
206 int gpfswrap_set_times_path(char *path
, int flags
, gpfs_timestruc_t times
[4])
208 if (gpfs_set_times_path_fn
== NULL
) {
213 return gpfs_set_times_path_fn(path
, flags
, times
);
216 int gpfswrap_quotactl(const char *pathname
, int cmd
, int id
, void *bufp
)
218 if (gpfs_quotactl_fn
== NULL
) {
223 return gpfs_quotactl_fn(pathname
, cmd
, id
, bufp
);
226 int gpfswrap_init_trace(void)
228 if (gpfs_init_trace_fn
== NULL
) {
233 return gpfs_init_trace_fn();
236 int gpfswrap_query_trace(void)
238 if (gpfs_query_trace_fn
== NULL
) {
243 return gpfs_query_trace_fn();
246 void gpfswrap_add_trace(int level
, const char *msg
)
248 if (gpfs_add_trace_fn
== NULL
) {
252 gpfs_add_trace_fn(level
, msg
);
255 void gpfswrap_fini_trace(void)
257 if (gpfs_fini_trace_fn
== NULL
) {
261 gpfs_fini_trace_fn();
264 int gpfswrap_fstat_x(int fd
, unsigned int *litemask
,
265 struct gpfs_iattr64
*iattr
, size_t len
)
267 if (gpfs_fstat_x_fn
== NULL
) {
272 return gpfs_fstat_x_fn(fd
, litemask
, iattr
, len
);
275 int gpfswrap_stat_x(const char *pathname
, unsigned int *litemask
,
276 struct gpfs_iattr64
*iattr
, size_t len
)
278 if (gpfs_stat_x_fn
== NULL
) {
283 return gpfs_stat_x_fn(pathname
, litemask
, iattr
, len
);