Provide TestCase.assertIsInstance for python < 2.7.
[Samba.git] / source3 / modules / gpfswrap.c
blobaac2f44405d0679364b2dc469b4f33c75a1e94e0
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)(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,
29 int *len);
30 static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags,
31 struct gpfs_winattr *attrs);
32 static int (*gpfs_get_winattrs_path_fn)(char *pathname,
33 struct gpfs_winattr *attrs);
34 static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
35 static int (*gpfs_prealloc_fn)(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
36 static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
37 static int (*gpfs_lib_init_fn)(int flags);
38 static int (*gpfs_set_times_path_fn)(char *pathname, int flags,
39 gpfs_timestruc_t times[4]);
40 static int (*gpfs_quotactl_fn)(char *pathname, int cmd, int id, void *bufp);
41 static int (*gpfs_fcntl_fn)(int fd, void *argp);
42 static int (*gpfs_getfilesetid_fn)(char *pathname, char *name, int *idp);
44 int gpfswrap_init(void)
46 static void *l;
48 if (l != NULL) {
49 return 0;
52 l = dlopen("libgpfs.so", RTLD_LAZY);
53 if (l == NULL) {
54 return -1;
57 gpfs_set_share_fn = dlsym(l, "gpfs_set_share");
58 gpfs_set_lease_fn = dlsym(l, "gpfs_set_lease");
59 gpfs_getacl_fn = dlsym(l, "gpfs_getacl");
60 gpfs_putacl_fn = dlsym(l, "gpfs_putacl");
61 gpfs_get_realfilename_path_fn = dlsym(l, "gpfs_get_realfilename_path");
62 gpfs_set_winattrs_path_fn = dlsym(l, "gpfs_set_winattrs_path");
63 gpfs_get_winattrs_path_fn = dlsym(l, "gpfs_get_winattrs_path");
64 gpfs_get_winattrs_fn = dlsym(l, "gpfs_get_winattrs");
65 gpfs_prealloc_fn = dlsym(l, "gpfs_prealloc");
66 gpfs_ftruncate_fn = dlsym(l, "gpfs_ftruncate");
67 gpfs_lib_init_fn = dlsym(l, "gpfs_lib_init");
68 gpfs_set_times_path_fn = dlsym(l, "gpfs_set_times_path");
69 gpfs_quotactl_fn = dlsym(l, "gpfs_quotactl");
70 gpfs_fcntl_fn = dlsym(l, "gpfs_fcntl");
71 gpfs_getfilesetid_fn = dlsym(l, "gpfs_getfilesetid");
73 return 0;
76 int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
78 if (gpfs_set_share_fn == NULL) {
79 errno = ENOSYS;
80 return -1;
83 return gpfs_set_share_fn(fd, allow, deny);
86 int gpfswrap_set_lease(int fd, unsigned int type)
88 if (gpfs_set_lease_fn == NULL) {
89 errno = ENOSYS;
90 return -1;
93 return gpfs_set_lease_fn(fd, type);
96 int gpfswrap_getacl(char *pathname, int flags, void *acl)
98 if (gpfs_getacl_fn == NULL) {
99 errno = ENOSYS;
100 return -1;
103 return gpfs_getacl_fn(pathname, flags, acl);
106 int gpfswrap_putacl(char *pathname, int flags, void *acl)
108 if (gpfs_putacl_fn == NULL) {
109 errno = ENOSYS;
110 return -1;
113 return gpfs_putacl_fn(pathname, flags, acl);
116 int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len)
118 if (gpfs_get_realfilename_path_fn == NULL) {
119 errno = ENOSYS;
120 return -1;
123 return gpfs_get_realfilename_path_fn(pathname, filenamep, len);
126 int gpfswrap_set_winattrs_path(char *pathname, int flags,
127 struct gpfs_winattr *attrs)
129 if (gpfs_set_winattrs_path_fn == NULL) {
130 errno = ENOSYS;
131 return -1;
134 return gpfs_set_winattrs_path_fn(pathname, flags, attrs);
137 int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs)
139 if (gpfs_get_winattrs_path_fn == NULL) {
140 errno = ENOSYS;
141 return -1;
144 return gpfs_get_winattrs_path_fn(pathname, attrs);
147 int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs)
149 if (gpfs_get_winattrs_fn == NULL) {
150 errno = ENOSYS;
151 return -1;
154 return gpfs_get_winattrs_fn(fd, attrs);
157 int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes)
159 if (gpfs_prealloc_fn == NULL) {
160 errno = ENOSYS;
161 return -1;
164 return gpfs_prealloc_fn(fd, start, bytes);
167 int gpfswrap_ftruncate(int fd, gpfs_off64_t length)
169 if (gpfs_ftruncate_fn == NULL) {
170 errno = ENOSYS;
171 return -1;
174 return gpfs_ftruncate_fn(fd, length);
177 int gpfswrap_lib_init(int flags)
179 if (gpfs_lib_init_fn == NULL) {
180 errno = ENOSYS;
181 return -1;
184 return gpfs_lib_init_fn(flags);
187 int gpfswrap_set_times_path(char *pathname, int flags,
188 gpfs_timestruc_t times[4])
190 if (gpfs_set_times_path_fn == NULL) {
191 errno = ENOSYS;
192 return -1;
195 return gpfs_set_times_path_fn(pathname, flags, times);
198 int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp)
200 if (gpfs_quotactl_fn == NULL) {
201 errno = ENOSYS;
202 return -1;
205 return gpfs_quotactl_fn(pathname, cmd, id, bufp);
208 int gpfswrap_fcntl(int fd, void *argp)
210 if (gpfs_fcntl_fn == NULL) {
211 errno = ENOSYS;
212 return -1;
215 return gpfs_fcntl_fn(fd, argp);
218 int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
220 if (gpfs_getfilesetid_fn == NULL) {
221 errno = ENOSYS;
222 return -1;
225 return gpfs_getfilesetid_fn(pathname, name, idp);