This commit was manufactured by cvs2svn to create branch 'SAMBA_TNG'.
[Samba.git] / source / smbd / vfs-wrap.c
bloba3dd7520236aadc2c7d09ace17a41ce73e3e8678
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
4 s Wrap disk only vfs functions to sidestep dodgy compilers.
5 Copyright (C) Tim Potter 1998
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 2 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, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
24 /* Check for NULL pointer parameters in vfswrap_* functions */
26 #define VFS_CHECK_NULL
28 /* We don't want to have NULL function pointers lying around. Someone
29 is sure to try and execute them. These stubs are used to prevent
30 this possibility. */
32 int vfswrap_dummy_connect(struct vfs_connection_struct *conn, char *service,
33 char *user)
35 return 0; /* Return >= 0 for success */
38 void vfswrap_dummy_disconnect(void)
42 /* Disk operations */
44 SMB_BIG_UINT vfswrap_disk_free(char *path, BOOL small_query, SMB_BIG_UINT *bsize,
45 SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
47 SMB_BIG_UINT result;
49 #ifdef VFS_CHECK_NULL
50 if ((path == NULL) || (bsize == NULL) || (dfree == NULL) ||
51 (dsize == NULL)) {
53 smb_panic("NULL pointer passed to vfswrap_disk_free() function\n");
55 #endif
57 result = sys_disk_free(path, small_query, bsize, dfree, dsize);
58 return result;
61 /* Directory operations */
63 DIR *vfswrap_opendir(char *fname)
65 DIR *result;
67 #ifdef VFS_CHECK_NULL
68 if (fname == NULL) {
69 smb_panic("NULL pointer passed to vfswrap_opendir()\n");
71 #endif
73 result = opendir(fname);
74 return result;
77 struct dirent *vfswrap_readdir(DIR *dirp)
79 struct dirent *result;
81 #ifdef VFS_CHECK_NULL
82 if (dirp == NULL) {
83 smb_panic("NULL pointer passed to vfswrap_readdir()\n");
85 #endif
87 result = readdir(dirp);
88 return result;
91 int vfswrap_mkdir(char *path, mode_t mode)
93 int result;
95 #ifdef VFS_CHECK_NULL
96 if (path == NULL) {
97 smb_panic("NULL pointer passed to vfswrap_mkdir()\n");
99 #endif
101 result = mkdir(path, mode);
102 return result;
105 int vfswrap_rmdir(char *path)
107 int result;
109 #ifdef VFS_CHECK_NULL
110 if (path == NULL) {
111 smb_panic("NULL pointer passed to vfswrap_rmdir()\n");
113 #endif
115 result = rmdir(path);
116 return result;
119 int vfswrap_closedir(DIR *dirp)
121 int result;
123 #ifdef VFS_CHECK_NULL
124 if (dirp == NULL) {
125 smb_panic("NULL pointer passed to vfswrap_closedir()\n");
127 #endif
129 result = closedir(dirp);
130 return result;
133 /* File operations */
135 int vfswrap_open(char *fname, int flags, mode_t mode)
137 int result;
139 #ifdef VFS_CHECK_NULL
140 if (fname == NULL) {
141 smb_panic("NULL pointer passed to vfswrap_open()\n");
143 #endif
145 result = sys_open(fname, flags, mode);
146 return result;
149 int vfswrap_close(int fd)
151 int result;
153 result = close(fd);
154 return result;
157 ssize_t vfswrap_read(int fd, char *data, size_t n)
159 ssize_t result;
161 #ifdef VFS_CHECK_NULL
162 if (data == NULL) {
163 smb_panic("NULL pointer passed to vfswrap_read()\n");
165 #endif
167 result = read(fd, data, n);
168 return result;
171 ssize_t vfswrap_write(int fd, char *data, size_t n)
173 ssize_t result;
175 #ifdef VFS_CHECK_NULL
176 if (data == NULL) {
177 smb_panic("NULL pointer passed to vfswrap_write()\n");
179 #endif
181 result = write(fd, data, n);
182 return result;
185 SMB_OFF_T vfswrap_lseek(int filedes, SMB_OFF_T offset, int whence)
187 SMB_OFF_T result;
189 result = sys_lseek(filedes, offset, whence);
190 return result;
193 int vfswrap_rename(char *old, char *new)
195 int result;
197 #ifdef VFS_CHECK_NULL
198 if ((old == NULL) || (new == NULL)) {
199 smb_panic("NULL pointer passed to vfswrap_rename()\n");
201 #endif
203 result = rename(old, new);
204 return result;
207 int vfswrap_fsync(int fd)
209 #ifdef HAVE_FSYNC
210 return fsync(fd);
211 #else
212 return 0;
213 #endif
216 int vfswrap_stat(char *fname, SMB_STRUCT_STAT *sbuf)
218 int result;
220 #ifdef VFS_CHECK_NULL
221 if ((fname == NULL) || (sbuf == NULL)) {
222 smb_panic("NULL pointer passed to vfswrap_stat()\n");
224 #endif
226 result = sys_stat(fname, sbuf);
227 return result;
230 int vfswrap_fstat(int fd, SMB_STRUCT_STAT *sbuf)
232 int result;
234 #ifdef VFS_CHECK_NULL
235 if (sbuf == NULL) {
236 smb_panic("NULL pointer passed to vfswrap_fstat()\n");
238 #endif
240 result = sys_fstat(fd, sbuf);
241 return result;
244 int vfswrap_lstat(char *path,
245 SMB_STRUCT_STAT *sbuf)
247 int result;
249 #ifdef VFS_CHECK_NULL
250 if ((path == NULL) || (sbuf == NULL)) {
251 smb_panic("NULL pointer passed to vfswrap_lstat()\n");
253 #endif
255 result = sys_lstat(path, sbuf);
256 return result;
259 int vfswrap_unlink(char *path)
261 int result;
263 #ifdef VFS_CHECK_NULL
264 if (path == NULL) {
265 smb_panic("NULL pointer passed to vfswrap_unlink()\n");
267 #endif
269 result = unlink(path);
270 return result;
273 int vfswrap_chmod(char *path, mode_t mode)
275 int result;
277 #ifdef VFS_CHECK_NULL
278 if (path == NULL) {
279 smb_panic("NULL pointer passed to vfswrap_chmod()\n");
281 #endif
283 result = chmod(path, mode);
284 return result;
287 int vfswrap_utime(char *path, struct utimbuf *times)
289 int result;
291 #ifdef VFS_CHECK_NULL
292 if ((path == NULL) || (times == NULL)) {
293 smb_panic("NULL pointer passed to vfswrap_utime()\n");
295 #endif
297 result = utime(path, times);
298 return result;
301 int vfswrap_ftruncate(int fd, SMB_OFF_T offset)
303 int result;
305 result = sys_ftruncate(fd, offset);
306 return result;