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
)(char *pathname
, int flags
, void *acl
);
27 static int (*gpfs_putacl_fn
)(char *pathname
, int flags
, void *acl
);
28 static int (*gpfs_get_realfilename_path_fn
)(char *pathname
, char *filenamep
,
30 static int (*gpfs_set_winattrs_path_fn
)(char *pathname
, int flags
,
31 struct gpfs_winattr
*attrs
);
32 static int (*gpfs_set_winattrs_fn
)(int fd
, int flags
,
33 struct gpfs_winattr
*attrs
);
34 static int (*gpfs_get_winattrs_path_fn
)(char *pathname
,
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_path_fn
)(char *pathname
, int flags
,
40 gpfs_timestruc_t times
[4]);
41 static int (*gpfs_quotactl_fn
)(char *pathname
, int cmd
, int id
, void *bufp
);
42 static int (*gpfs_getfilesetid_fn
)(char *pathname
, char *name
, int *idp
);
43 static int (*gpfs_init_trace_fn
)(void);
44 static int (*gpfs_query_trace_fn
)(void);
45 static void (*gpfs_add_trace_fn
)(int level
, const char *msg
);
46 static void (*gpfs_fini_trace_fn
)(void);
48 int gpfswrap_init(void)
56 l
= dlopen("libgpfs.so", RTLD_LAZY
);
61 gpfs_set_share_fn
= dlsym(l
, "gpfs_set_share");
62 gpfs_set_lease_fn
= dlsym(l
, "gpfs_set_lease");
63 gpfs_getacl_fn
= dlsym(l
, "gpfs_getacl");
64 gpfs_putacl_fn
= dlsym(l
, "gpfs_putacl");
65 gpfs_get_realfilename_path_fn
= dlsym(l
, "gpfs_get_realfilename_path");
66 gpfs_set_winattrs_path_fn
= dlsym(l
, "gpfs_set_winattrs_path");
67 gpfs_set_winattrs_fn
= dlsym(l
, "gpfs_set_winattrs");
68 gpfs_get_winattrs_path_fn
= dlsym(l
, "gpfs_get_winattrs_path");
69 gpfs_get_winattrs_fn
= dlsym(l
, "gpfs_get_winattrs");
70 gpfs_ftruncate_fn
= dlsym(l
, "gpfs_ftruncate");
71 gpfs_lib_init_fn
= dlsym(l
, "gpfs_lib_init");
72 gpfs_set_times_path_fn
= dlsym(l
, "gpfs_set_times_path");
73 gpfs_quotactl_fn
= dlsym(l
, "gpfs_quotactl");
74 gpfs_getfilesetid_fn
= dlsym(l
, "gpfs_getfilesetid");
75 gpfs_init_trace_fn
= dlsym(l
, "gpfs_init_trace");
76 gpfs_query_trace_fn
= dlsym(l
, "gpfs_query_trace");
77 gpfs_add_trace_fn
= dlsym(l
, "gpfs_add_trace");
78 gpfs_fini_trace_fn
= dlsym(l
, "gpfs_fini_trace");
83 int gpfswrap_set_share(int fd
, unsigned int allow
, unsigned int deny
)
85 if (gpfs_set_share_fn
== NULL
) {
90 return gpfs_set_share_fn(fd
, allow
, deny
);
93 int gpfswrap_set_lease(int fd
, unsigned int type
)
95 if (gpfs_set_lease_fn
== NULL
) {
100 return gpfs_set_lease_fn(fd
, type
);
103 int gpfswrap_getacl(char *pathname
, int flags
, void *acl
)
105 if (gpfs_getacl_fn
== NULL
) {
110 return gpfs_getacl_fn(pathname
, flags
, acl
);
113 int gpfswrap_putacl(char *pathname
, int flags
, void *acl
)
115 if (gpfs_putacl_fn
== NULL
) {
120 return gpfs_putacl_fn(pathname
, flags
, acl
);
123 int gpfswrap_get_realfilename_path(char *pathname
, char *filenamep
, int *len
)
125 if (gpfs_get_realfilename_path_fn
== NULL
) {
130 return gpfs_get_realfilename_path_fn(pathname
, filenamep
, len
);
133 int gpfswrap_set_winattrs_path(char *pathname
, int flags
,
134 struct gpfs_winattr
*attrs
)
136 if (gpfs_set_winattrs_path_fn
== NULL
) {
141 return gpfs_set_winattrs_path_fn(pathname
, flags
, attrs
);
144 int gpfswrap_set_winattrs(int fd
, int flags
, struct gpfs_winattr
*attrs
)
146 if (gpfs_set_winattrs_fn
== NULL
) {
151 return gpfs_set_winattrs_fn(fd
, flags
, attrs
);
154 int gpfswrap_get_winattrs_path(char *pathname
, struct gpfs_winattr
*attrs
)
156 if (gpfs_get_winattrs_path_fn
== NULL
) {
161 return gpfs_get_winattrs_path_fn(pathname
, attrs
);
164 int gpfswrap_get_winattrs(int fd
, struct gpfs_winattr
*attrs
)
166 if (gpfs_get_winattrs_fn
== NULL
) {
171 return gpfs_get_winattrs_fn(fd
, attrs
);
174 int gpfswrap_ftruncate(int fd
, gpfs_off64_t length
)
176 if (gpfs_ftruncate_fn
== NULL
) {
181 return gpfs_ftruncate_fn(fd
, length
);
184 int gpfswrap_lib_init(int flags
)
186 if (gpfs_lib_init_fn
== NULL
) {
191 return gpfs_lib_init_fn(flags
);
194 int gpfswrap_set_times_path(char *pathname
, int flags
,
195 gpfs_timestruc_t times
[4])
197 if (gpfs_set_times_path_fn
== NULL
) {
202 return gpfs_set_times_path_fn(pathname
, flags
, times
);
205 int gpfswrap_quotactl(char *pathname
, int cmd
, int id
, void *bufp
)
207 if (gpfs_quotactl_fn
== NULL
) {
212 return gpfs_quotactl_fn(pathname
, cmd
, id
, bufp
);
215 int gpfswrap_getfilesetid(char *pathname
, char *name
, int *idp
)
217 if (gpfs_getfilesetid_fn
== NULL
) {
222 return gpfs_getfilesetid_fn(pathname
, name
, idp
);
225 int gpfswrap_init_trace(void)
227 if (gpfs_init_trace_fn
== NULL
) {
232 return gpfs_init_trace_fn();
235 int gpfswrap_query_trace(void)
237 if (gpfs_query_trace_fn
== NULL
) {
242 return gpfs_query_trace_fn();
245 void gpfswrap_add_trace(int level
, const char *msg
)
247 if (gpfs_add_trace_fn
== NULL
) {
251 gpfs_add_trace_fn(level
, msg
);
254 void gpfswrap_fini_trace(void)
256 if (gpfs_fini_trace_fn
== NULL
) {
260 gpfs_fini_trace_fn();