2 * Unix SMB/CIFS implementation.
3 * Provide a connection to GPFS specific features
4 * Copyright (C) Volker Lendecke 2005
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "system/filesys.h"
22 #include "smbd/smbd.h"
25 #include <gpfs_fcntl.h>
28 static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
29 static int (*gpfs_set_lease_fn)(int fd, unsigned int type);
30 static int (*gpfs_getacl_fn)(char *pathname, int flags, void *acl);
31 static int (*gpfs_putacl_fn)(char *pathname, int flags, void *acl);
32 static int (*gpfs_get_realfilename_path_fn)(char *pathname, char *filenamep,
34 static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags,
35 struct gpfs_winattr *attrs);
36 static int (*gpfs_get_winattrs_path_fn)(char *pathname,
37 struct gpfs_winattr *attrs);
38 static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
39 static int (*gpfs_prealloc_fn)(int fd, gpfs_off64_t start, gpfs_off64_t bytes);
40 static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
41 static int (*gpfs_lib_init_fn)(int flags);
42 static int (*gpfs_set_times_path_fn)(char *pathname, int flags,
43 gpfs_timestruc_t times[4]);
44 static int (*gpfs_quotactl_fn)(char *pathname, int cmd, int id, void *bufp);
45 static int (*gpfs_fcntl_fn)(int fd, void *argp);
46 static int (*gpfs_getfilesetid_fn)(char *pathname, char *name, int *idp);
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_get_winattrs_path_fn = dlsym(l, "gpfs_get_winattrs_path");
68 gpfs_get_winattrs_fn = dlsym(l, "gpfs_get_winattrs");
69 gpfs_prealloc_fn = dlsym(l, "gpfs_prealloc");
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_fcntl_fn = dlsym(l, "gpfs_fcntl");
75 gpfs_getfilesetid_fn = dlsym(l, "gpfs_getfilesetid");
80 int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny)
82 if (gpfs_set_share_fn == NULL) {
87 return gpfs_set_share_fn(fd, allow, deny);
90 int gpfswrap_set_lease(int fd, unsigned int type)
92 if (gpfs_set_lease_fn == NULL) {
97 return gpfs_set_lease_fn(fd, type);
100 int gpfswrap_getacl(char *pathname, int flags, void *acl)
102 if (gpfs_getacl_fn == NULL) {
107 return gpfs_getacl_fn(pathname, flags, acl);
110 int gpfswrap_putacl(char *pathname, int flags, void *acl)
112 if (gpfs_putacl_fn == NULL) {
117 return gpfs_putacl_fn(pathname, flags, acl);
120 int gpfswrap_get_realfilename_path(char *pathname, char *filenamep, int *len)
122 if (gpfs_get_realfilename_path_fn == NULL) {
127 return gpfs_get_realfilename_path_fn(pathname, filenamep, len);
130 int gpfswrap_set_winattrs_path(char *pathname, int flags,
131 struct gpfs_winattr *attrs)
133 if (gpfs_set_winattrs_path_fn == NULL) {
138 return gpfs_set_winattrs_path_fn(pathname, flags, attrs);
141 int gpfswrap_get_winattrs_path(char *pathname, struct gpfs_winattr *attrs)
143 if (gpfs_get_winattrs_path_fn == NULL) {
148 return gpfs_get_winattrs_path_fn(pathname, attrs);
151 int gpfswrap_get_winattrs(int fd, struct gpfs_winattr *attrs)
153 if (gpfs_get_winattrs_fn == NULL) {
158 return gpfs_get_winattrs_fn(fd, attrs);
161 int gpfswrap_prealloc(int fd, gpfs_off64_t start, gpfs_off64_t bytes)
163 if (gpfs_prealloc_fn == NULL) {
168 return gpfs_prealloc_fn(fd, start, bytes);
171 int gpfswrap_ftruncate(int fd, gpfs_off64_t length)
173 if (gpfs_ftruncate_fn == NULL) {
178 return gpfs_ftruncate_fn(fd, length);
181 int gpfswrap_lib_init(int flags)
183 if (gpfs_lib_init_fn == NULL) {
188 return gpfs_lib_init_fn(flags);
191 int gpfswrap_set_times_path(char *pathname, int flags,
192 gpfs_timestruc_t times[4])
194 if (gpfs_set_times_path_fn == NULL) {
199 return gpfs_set_times_path_fn(pathname, flags, times);
202 int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp)
204 if (gpfs_quotactl_fn == NULL) {
209 return gpfs_quotactl_fn(pathname, cmd, id, bufp);
212 int gpfswrap_fcntl(int fd, void *argp)
214 if (gpfs_fcntl_fn == NULL) {
219 return gpfs_fcntl_fn(fd, argp);
222 int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
224 if (gpfs_getfilesetid_fn == NULL) {
229 return gpfs_getfilesetid_fn(pathname, name, idp);