samba-gpupdate: Test that sysvol paths download in case-insensitive way
[Samba.git] / lib / util / gpfswrap.c
blob14118cbf53c04b7b0d7d828c99c8e60f9853bdcf
1 /*
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/>.
21 #include "replace.h"
22 #include "gpfswrap.h"
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,
29 char *filenamep,
30 int *len);
31 static int (*gpfs_set_winattrs_path_fn)(const char *pathname,
32 int flags,
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,
44 int cmd,
45 int id,
46 void *bufp);
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)
58 static void *l;
60 if (l != NULL) {
61 return 0;
64 l = dlopen("libgpfs.so", RTLD_LAZY);
65 if (l == NULL) {
66 return -1;
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");
89 return 0;
92 int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
94 if (gpfs_set_share_fn == NULL) {
95 errno = ENOSYS;
96 return -1;
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) {
105 errno = ENOSYS;
106 return -1;
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) {
115 errno = ENOSYS;
116 return -1;
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) {
125 errno = ENOSYS;
126 return -1;
129 return gpfs_putacl_fn(pathname, flags, acl);
132 int gpfswrap_get_realfilename_path(const char *pathname,
133 char *filenamep,
134 int *len)
136 if (gpfs_get_realfilename_path_fn == NULL) {
137 errno = ENOSYS;
138 return -1;
141 return gpfs_get_realfilename_path_fn(pathname, filenamep, len);
144 int gpfswrap_set_winattrs_path(const char *pathname,
145 int flags,
146 struct gpfs_winattr *attrs)
148 if (gpfs_set_winattrs_path_fn == NULL) {
149 errno = ENOSYS;
150 return -1;
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) {
159 errno = ENOSYS;
160 return -1;
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) {
170 errno = ENOSYS;
171 return -1;
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) {
180 errno = ENOSYS;
181 return -1;
184 return gpfs_get_winattrs_fn(fd, attrs);
187 int gpfswrap_ftruncate(int fd, gpfs_off64_t length)
189 if (gpfs_ftruncate_fn == NULL) {
190 errno = ENOSYS;
191 return -1;
194 return gpfs_ftruncate_fn(fd, length);
197 int gpfswrap_lib_init(int flags)
199 if (gpfs_lib_init_fn == NULL) {
200 errno = ENOSYS;
201 return -1;
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) {
211 errno = ENOSYS;
212 return -1;
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) {
221 errno = ENOSYS;
222 return -1;
225 return gpfs_quotactl_fn(pathname, cmd, id, bufp);
228 int gpfswrap_init_trace(void)
230 if (gpfs_init_trace_fn == NULL) {
231 errno = ENOSYS;
232 return -1;
235 return gpfs_init_trace_fn();
238 int gpfswrap_query_trace(void)
240 if (gpfs_query_trace_fn == NULL) {
241 errno = ENOSYS;
242 return -1;
245 return gpfs_query_trace_fn();
248 void gpfswrap_add_trace(int level, const char *msg)
250 if (gpfs_add_trace_fn == NULL) {
251 return;
254 gpfs_add_trace_fn(level, msg);
257 void gpfswrap_fini_trace(void)
259 if (gpfs_fini_trace_fn == NULL) {
260 return;
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) {
270 errno = ENOSYS;
271 return -1;
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) {
281 errno = ENOSYS;
282 return -1;
285 return gpfs_stat_x_fn(pathname, litemask, iattr, len);