8d44a1a0fa12ac44a45af07152986f89caa7d7f5
[jra/samba/.git] / source3 / smbd / vfs-wrap.c
1 /* 
2    Unix SMB/CIFS implementation.
3    Wrap disk only vfs functions to sidestep dodgy compilers.
4    Copyright (C) Tim Potter 1998
5    
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 2 of the License, or
9    (at your option) any later version.
10    
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.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "includes.h"
22
23 #undef DBGC_CLASS
24 #define DBGC_CLASS DBGC_VFS
25
26
27 /* Check for NULL pointer parameters in vfswrap_* functions */
28
29 /* We don't want to have NULL function pointers lying around.  Someone
30    is sure to try and execute them.  These stubs are used to prevent
31    this possibility. */
32
33 int vfswrap_dummy_connect(vfs_handle_struct *handle, connection_struct *conn, const char *service, const char *user)
34 {
35     return 0;    /* Return >= 0 for success */
36 }
37
38 void vfswrap_dummy_disconnect(vfs_handle_struct *handle, connection_struct *conn)
39 {
40 }
41
42 /* Disk operations */
43
44 SMB_BIG_UINT vfswrap_disk_free(vfs_handle_struct *handle, connection_struct *conn, const char *path, BOOL small_query, SMB_BIG_UINT *bsize, 
45                                SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
46 {
47     SMB_BIG_UINT result;
48
49     result = sys_disk_free(path, small_query, bsize, dfree, dsize);
50     return result;
51 }
52     
53 /* Directory operations */
54
55 DIR *vfswrap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname)
56 {
57     DIR *result;
58
59     START_PROFILE(syscall_opendir);
60     result = opendir(fname);
61     END_PROFILE(syscall_opendir);
62     return result;
63 }
64
65 struct dirent *vfswrap_readdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp)
66 {
67     struct dirent *result;
68
69     START_PROFILE(syscall_readdir);
70     result = readdir(dirp);
71     END_PROFILE(syscall_readdir);
72     return result;
73 }
74
75 int vfswrap_mkdir(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode)
76 {
77         int result;
78         BOOL has_dacl = False;
79
80         START_PROFILE(syscall_mkdir);
81
82         if (lp_inherit_acls(SNUM(conn)) && (has_dacl = directory_has_default_acl(conn, parent_dirname(path))))
83                 mode = 0777;
84
85         result = mkdir(path, mode);
86
87         if (result == 0 && !has_dacl) {
88                 /*
89                  * We need to do this as the default behavior of POSIX ACLs     
90                  * is to set the mask to be the requested group permission
91                  * bits, not the group permission bits to be the requested
92                  * group permission bits. This is not what we want, as it will
93                  * mess up any inherited ACL bits that were set. JRA.
94                  */
95                 int saved_errno = errno; /* We may get ENOSYS */
96                 if ((SMB_VFS_CHMOD_ACL(conn, path, mode) == -1) && (errno == ENOSYS))
97                         errno = saved_errno;
98         }
99
100     END_PROFILE(syscall_mkdir);
101     return result;
102 }
103
104 int vfswrap_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char *path)
105 {
106     int result;
107
108     START_PROFILE(syscall_rmdir);
109     result = rmdir(path);
110     END_PROFILE(syscall_rmdir);
111     return result;
112 }
113
114 int vfswrap_closedir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp)
115 {
116     int result;
117
118     START_PROFILE(syscall_closedir);
119     result = closedir(dirp);
120     END_PROFILE(syscall_closedir);
121     return result;
122 }
123
124 /* File operations */
125     
126 int vfswrap_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode)
127 {
128     int result;
129
130     START_PROFILE(syscall_open);
131     result = sys_open(fname, flags, mode);
132     END_PROFILE(syscall_open);
133     return result;
134 }
135
136 int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
137 {
138     int result;
139
140     START_PROFILE(syscall_close);
141
142     result = close(fd);
143     END_PROFILE(syscall_close);
144     return result;
145 }
146
147 ssize_t vfswrap_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n)
148 {
149     ssize_t result;
150
151     START_PROFILE_BYTES(syscall_read, n);
152     result = sys_read(fd, data, n);
153     END_PROFILE(syscall_read);
154     return result;
155 }
156
157 ssize_t vfswrap_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n)
158 {
159     ssize_t result;
160
161     START_PROFILE_BYTES(syscall_write, n);
162     result = sys_write(fd, data, n);
163     END_PROFILE(syscall_write);
164     return result;
165 }
166
167 SMB_OFF_T vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, int filedes, SMB_OFF_T offset, int whence)
168 {
169         SMB_OFF_T result = 0;
170
171         START_PROFILE(syscall_lseek);
172
173         /* Cope with 'stat' file opens. */
174         if (filedes != -1)
175                 result = sys_lseek(filedes, offset, whence);
176
177         /*
178          * We want to maintain the fiction that we can seek
179          * on a fifo for file system purposes. This allows
180          * people to set up UNIX fifo's that feed data to Windows
181          * applications. JRA.
182          */
183
184         if((result == -1) && (errno == ESPIPE)) {
185                 result = 0;
186                 errno = 0;
187         }
188
189         END_PROFILE(syscall_lseek);
190         return result;
191 }
192
193 ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *hdr,
194                         SMB_OFF_T offset, size_t n)
195 {
196         ssize_t result;
197
198         START_PROFILE_BYTES(syscall_sendfile, n);
199         result = sys_sendfile(tofd, fromfd, hdr, offset, n);
200         END_PROFILE(syscall_sendfile);
201         return result;
202 }
203
204 int vfswrap_rename(vfs_handle_struct *handle, connection_struct *conn, const char *old, const char *new)
205 {
206     int result;
207
208     START_PROFILE(syscall_rename);
209     result = rename(old, new);
210     END_PROFILE(syscall_rename);
211     return result;
212 }
213
214 int vfswrap_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd)
215 {
216 #ifdef HAVE_FSYNC
217     int result;
218
219     START_PROFILE(syscall_fsync);
220
221     result = fsync(fd);
222     END_PROFILE(syscall_fsync);
223     return result;
224 #else
225         return 0;
226 #endif
227 }
228
229 int vfswrap_stat(vfs_handle_struct *handle, connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sbuf)
230 {
231     int result;
232
233     START_PROFILE(syscall_stat);
234     result = sys_stat(fname, sbuf);
235     END_PROFILE(syscall_stat);
236     return result;
237 }
238
239 int vfswrap_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
240 {
241     int result;
242
243     START_PROFILE(syscall_fstat);
244     result = sys_fstat(fd, sbuf);
245     END_PROFILE(syscall_fstat);
246     return result;
247 }
248
249 int vfswrap_lstat(vfs_handle_struct *handle, connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf)
250 {
251     int result;
252
253     START_PROFILE(syscall_lstat);
254     result = sys_lstat(path, sbuf);
255     END_PROFILE(syscall_lstat);
256     return result;
257 }
258
259 int vfswrap_unlink(vfs_handle_struct *handle, connection_struct *conn, const char *path)
260 {
261     int result;
262
263     START_PROFILE(syscall_unlink);
264     result = unlink(path);
265     END_PROFILE(syscall_unlink);
266     return result;
267 }
268
269 int vfswrap_chmod(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode)
270 {
271     int result;
272
273     START_PROFILE(syscall_chmod);
274
275         /*
276          * We need to do this due to the fact that the default POSIX ACL
277          * chmod modifies the ACL *mask* for the group owner, not the
278          * group owner bits directly. JRA.
279          */
280
281         
282         {
283                 int saved_errno = errno; /* We might get ENOSYS */
284                 if ((result = SMB_VFS_CHMOD_ACL(conn, path, mode)) == 0) {
285                         END_PROFILE(syscall_chmod);
286                         return result;
287                 }
288                 /* Error - return the old errno. */
289                 errno = saved_errno;
290         }
291
292     result = chmod(path, mode);
293     END_PROFILE(syscall_chmod);
294     return result;
295 }
296
297 int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode)
298 {
299         int result;
300         
301         START_PROFILE(syscall_fchmod);
302
303         /*
304          * We need to do this due to the fact that the default POSIX ACL
305          * chmod modifies the ACL *mask* for the group owner, not the
306          * group owner bits directly. JRA.
307          */
308         
309         {
310                 int saved_errno = errno; /* We might get ENOSYS */
311                 if ((result = SMB_VFS_FCHMOD_ACL(fsp, fd, mode)) == 0) {
312                         END_PROFILE(syscall_chmod);
313                         return result;
314                 }
315                 /* Error - return the old errno. */
316                 errno = saved_errno;
317         }
318
319 #if defined(HAVE_FCHMOD)
320         result = fchmod(fd, mode);
321 #else
322         result = -1;
323         errno = ENOSYS;
324 #endif
325
326         END_PROFILE(syscall_fchmod);
327         return result;
328 }
329
330 int vfswrap_chown(vfs_handle_struct *handle, connection_struct *conn, const char *path, uid_t uid, gid_t gid)
331 {
332     int result;
333
334     START_PROFILE(syscall_chown);
335     result = sys_chown(path, uid, gid);
336     END_PROFILE(syscall_chown);
337     return result;
338 }
339
340 int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, uid_t uid, gid_t gid)
341 {
342 #ifdef HAVE_FCHOWN
343     int result;
344
345     START_PROFILE(syscall_fchown);
346
347     result = fchown(fd, uid, gid);
348     END_PROFILE(syscall_fchown);
349     return result;
350 #else
351     errno = ENOSYS;
352     return -1;
353 #endif
354 }
355
356 int vfswrap_chdir(vfs_handle_struct *handle, connection_struct *conn, const char *path)
357 {
358     int result;
359
360     START_PROFILE(syscall_chdir);
361     result = chdir(path);
362     END_PROFILE(syscall_chdir);
363     return result;
364 }
365
366 char *vfswrap_getwd(vfs_handle_struct *handle, connection_struct *conn, char *path)
367 {
368     char *result;
369
370     START_PROFILE(syscall_getwd);
371     result = sys_getwd(path);
372     END_PROFILE(syscall_getwd);
373     return result;
374 }
375
376 int vfswrap_utime(vfs_handle_struct *handle, connection_struct *conn, const char *path, struct utimbuf *times)
377 {
378     int result;
379
380     START_PROFILE(syscall_utime);
381     result = utime(path, times);
382     END_PROFILE(syscall_utime);
383     return result;
384 }
385
386 /*********************************************************************
387  A version of ftruncate that will write the space on disk if strict
388  allocate is set.
389 **********************************************************************/
390
391 static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len)
392 {
393         SMB_STRUCT_STAT st;
394         SMB_OFF_T currpos = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
395         unsigned char zero_space[4096];
396         SMB_OFF_T space_to_write;
397
398         if (currpos == -1)
399                 return -1;
400
401         if (SMB_VFS_FSTAT(fsp, fd, &st) == -1)
402                 return -1;
403
404         space_to_write = len - st.st_size;
405
406 #ifdef S_ISFIFO
407         if (S_ISFIFO(st.st_mode))
408                 return 0;
409 #endif
410
411         if (st.st_size == len)
412                 return 0;
413
414         /* Shrink - just ftruncate. */
415         if (st.st_size > len)
416                 return sys_ftruncate(fd, len);
417
418         /* Write out the real space on disk. */
419         if (SMB_VFS_LSEEK(fsp, fd, st.st_size, SEEK_SET) != st.st_size)
420                 return -1;
421
422         space_to_write = len - st.st_size;
423
424         memset(zero_space, '\0', sizeof(zero_space));
425         while ( space_to_write > 0) {
426                 SMB_OFF_T retlen;
427                 SMB_OFF_T current_len_to_write = MIN(sizeof(zero_space),space_to_write);
428
429                 retlen = SMB_VFS_WRITE(fsp,fsp->fd,(char *)zero_space,current_len_to_write);
430                 if (retlen <= 0)
431                         return -1;
432
433                 space_to_write -= retlen;
434         }
435
436         /* Seek to where we were */
437         if (SMB_VFS_LSEEK(fsp, fd, currpos, SEEK_SET) != currpos)
438                 return -1;
439
440         return 0;
441 }
442
443 int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len)
444 {
445         int result = -1;
446         SMB_STRUCT_STAT st;
447         char c = 0;
448         SMB_OFF_T currpos;
449
450         START_PROFILE(syscall_ftruncate);
451
452         if (lp_strict_allocate(SNUM(fsp->conn))) {
453                 result = strict_allocate_ftruncate(handle, fsp, fd, len);
454                 END_PROFILE(syscall_ftruncate);
455                 return result;
456         }
457
458         /* we used to just check HAVE_FTRUNCATE_EXTEND and only use
459            sys_ftruncate if the system supports it. Then I discovered that
460            you can have some filesystems that support ftruncate
461            expansion and some that don't! On Linux fat can't do
462            ftruncate extend but ext2 can. */
463
464         result = sys_ftruncate(fd, len);
465         if (result == 0)
466                 goto done;
467
468         /* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
469            extend a file with ftruncate. Provide alternate implementation
470            for this */
471         currpos = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
472         if (currpos == -1) {
473                 goto done;
474         }
475
476         /* Do an fstat to see if the file is longer than the requested
477            size in which case the ftruncate above should have
478            succeeded or shorter, in which case seek to len - 1 and
479            write 1 byte of zero */
480         if (SMB_VFS_FSTAT(fsp, fd, &st) == -1) {
481                 goto done;
482         }
483
484 #ifdef S_ISFIFO
485         if (S_ISFIFO(st.st_mode)) {
486                 result = 0;
487                 goto done;
488         }
489 #endif
490
491         if (st.st_size == len) {
492                 result = 0;
493                 goto done;
494         }
495
496         if (st.st_size > len) {
497                 /* the sys_ftruncate should have worked */
498                 goto done;
499         }
500
501         if (SMB_VFS_LSEEK(fsp, fd, len-1, SEEK_SET) != len -1)
502                 goto done;
503
504         if (SMB_VFS_WRITE(fsp, fd, &c, 1)!=1)
505                 goto done;
506
507         /* Seek to where we were */
508         if (SMB_VFS_LSEEK(fsp, fd, currpos, SEEK_SET) != currpos)
509                 goto done;
510         result = 0;
511
512   done:
513
514         END_PROFILE(syscall_ftruncate);
515         return result;
516 }
517
518 BOOL vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
519 {
520     BOOL result;
521
522     START_PROFILE(syscall_fcntl_lock);
523
524     result =  fcntl_lock(fd, op, offset, count,type);
525     END_PROFILE(syscall_fcntl_lock);
526     return result;
527 }
528
529 int vfswrap_symlink(vfs_handle_struct *handle, connection_struct *conn, const char *oldpath, const char *newpath)
530 {
531     int result;
532
533     START_PROFILE(syscall_symlink);
534     result = sys_symlink(oldpath, newpath);
535     END_PROFILE(syscall_symlink);
536     return result;
537 }
538
539 int vfswrap_readlink(vfs_handle_struct *handle, connection_struct *conn, const char *path, char *buf, size_t bufsiz)
540 {
541     int result;
542
543     START_PROFILE(syscall_readlink);
544     result = sys_readlink(path, buf, bufsiz);
545     END_PROFILE(syscall_readlink);
546     return result;
547 }
548
549 int vfswrap_link(vfs_handle_struct *handle, connection_struct *conn, const char *oldpath, const char *newpath)
550 {
551         int result;
552
553         START_PROFILE(syscall_link);
554         result = sys_link(oldpath, newpath);
555         END_PROFILE(syscall_link);
556         return result;
557 }
558
559 int vfswrap_mknod(vfs_handle_struct *handle, connection_struct *conn, const char *pathname, mode_t mode, SMB_DEV_T dev)
560 {
561         int result;
562
563         START_PROFILE(syscall_mknod);
564         result = sys_mknod(pathname, mode, dev);
565         END_PROFILE(syscall_mknod);
566         return result;
567 }
568
569 char *vfswrap_realpath(vfs_handle_struct *handle, connection_struct *conn, const char *path, char *resolved_path)
570 {
571         char *result;
572
573         START_PROFILE(syscall_realpath);
574         result = sys_realpath(path, resolved_path);
575         END_PROFILE(syscall_realpath);
576         return result;
577 }
578
579 size_t vfswrap_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info, SEC_DESC **ppdesc)
580 {
581         size_t result;
582
583         START_PROFILE(fget_nt_acl);
584         result = get_nt_acl(fsp, security_info, ppdesc);
585         END_PROFILE(fget_nt_acl);
586         return result;
587 }
588
589 size_t vfswrap_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info, SEC_DESC **ppdesc)
590 {
591         size_t result;
592
593         START_PROFILE(get_nt_acl);
594         result = get_nt_acl(fsp, security_info, ppdesc);
595         END_PROFILE(get_nt_acl);
596         return result;
597 }
598
599 BOOL vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd)
600 {
601         BOOL result;
602
603         START_PROFILE(fset_nt_acl);
604         result = set_nt_acl(fsp, security_info_sent, psd);
605         END_PROFILE(fset_nt_acl);
606         return result;
607 }
608
609 BOOL vfswrap_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info_sent, SEC_DESC *psd)
610 {
611         BOOL result;
612
613         START_PROFILE(set_nt_acl);
614         result = set_nt_acl(fsp, security_info_sent, psd);
615         END_PROFILE(set_nt_acl);
616         return result;
617 }
618
619 int vfswrap_chmod_acl(vfs_handle_struct *handle, connection_struct *conn, const char *name, mode_t mode)
620 {
621 #ifdef HAVE_NO_ACL
622         errno = ENOSYS;
623         return -1;
624 #else
625         int result;
626
627         START_PROFILE(chmod_acl);
628         result = chmod_acl(conn, name, mode);
629         END_PROFILE(chmod_acl);
630         return result;
631 #endif
632 }
633
634 int vfswrap_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode)
635 {
636 #ifdef HAVE_NO_ACL
637         errno = ENOSYS;
638         return -1;
639 #else
640         int result;
641
642         START_PROFILE(fchmod_acl);
643         result = fchmod_acl(fsp, fd, mode);
644         END_PROFILE(fchmod_acl);
645         return result;
646 #endif
647 }
648
649 int vfswrap_sys_acl_get_entry(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p)
650 {
651         return sys_acl_get_entry(theacl, entry_id, entry_p);
652 }
653
654 int vfswrap_sys_acl_get_tag_type(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p)
655 {
656         return sys_acl_get_tag_type(entry_d, tag_type_p);
657 }
658
659 int vfswrap_sys_acl_get_permset(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p)
660 {
661         return sys_acl_get_permset(entry_d, permset_p);
662 }
663
664 void * vfswrap_sys_acl_get_qualifier(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry_d)
665 {
666         return sys_acl_get_qualifier(entry_d);
667 }
668
669 SMB_ACL_T vfswrap_sys_acl_get_file(vfs_handle_struct *handle, connection_struct *conn, const char *path_p, SMB_ACL_TYPE_T type)
670 {
671         return sys_acl_get_file(path_p, type);
672 }
673
674 SMB_ACL_T vfswrap_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
675 {
676         return sys_acl_get_fd(fd);
677 }
678
679 int vfswrap_sys_acl_clear_perms(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_PERMSET_T permset)
680 {
681         return sys_acl_clear_perms(permset);
682 }
683
684 int vfswrap_sys_acl_add_perm(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm)
685 {
686         return sys_acl_add_perm(permset, perm);
687 }
688
689 char * vfswrap_sys_acl_to_text(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_T theacl, ssize_t *plen)
690 {
691         return sys_acl_to_text(theacl, plen);
692 }
693
694 SMB_ACL_T vfswrap_sys_acl_init(vfs_handle_struct *handle, connection_struct *conn, int count)
695 {
696         return sys_acl_init(count);
697 }
698
699 int vfswrap_sys_acl_create_entry(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry)
700 {
701         return sys_acl_create_entry(pacl, pentry);
702 }
703
704 int vfswrap_sys_acl_set_tag_type(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype)
705 {
706         return sys_acl_set_tag_type(entry, tagtype);
707 }
708
709 int vfswrap_sys_acl_set_qualifier(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry, void *qual)
710 {
711         return sys_acl_set_qualifier(entry, qual);
712 }
713
714 int vfswrap_sys_acl_set_permset(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset)
715 {
716         return sys_acl_set_permset(entry, permset);
717 }
718
719 int vfswrap_sys_acl_valid(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_T theacl )
720 {
721         return sys_acl_valid(theacl );
722 }
723
724 int vfswrap_sys_acl_set_file(vfs_handle_struct *handle, connection_struct *conn, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
725 {
726         return sys_acl_set_file(name, acltype, theacl);
727 }
728
729 int vfswrap_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_ACL_T theacl)
730 {
731         return sys_acl_set_fd(fd, theacl);
732 }
733
734 int vfswrap_sys_acl_delete_def_file(vfs_handle_struct *handle, connection_struct *conn, const char *path)
735 {
736         return sys_acl_delete_def_file(path);
737 }
738
739 int vfswrap_sys_acl_get_perm(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm)
740 {
741         return sys_acl_get_perm(permset, perm);
742 }
743
744 int vfswrap_sys_acl_free_text(vfs_handle_struct *handle, connection_struct *conn, char *text)
745 {
746         return sys_acl_free_text(text);
747 }
748
749 int vfswrap_sys_acl_free_acl(vfs_handle_struct *handle, connection_struct *conn, SMB_ACL_T posix_acl)
750 {
751         return sys_acl_free_acl(posix_acl);
752 }
753
754 int vfswrap_sys_acl_free_qualifier(vfs_handle_struct *handle, connection_struct *conn, void *qualifier, SMB_ACL_TAG_T tagtype)
755 {
756         return sys_acl_free_qualifier(qualifier, tagtype);
757 }
758
759 int vfswrap_get_quota(struct vfs_handle_struct *handle, struct connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
760 {
761 #ifdef HAVE_SYS_QUOTAS
762         int result;
763
764         START_PROFILE(syscall_get_quota);
765         result = sys_get_quota(conn->connectpath, qtype, id, qt);
766         END_PROFILE(syscall_get_quota);
767         return result;
768 #else
769         errno = ENOSYS;
770         return -1;
771 #endif  
772 }
773
774 int vfswrap_set_quota(struct vfs_handle_struct *handle, struct connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
775 {
776 #ifdef HAVE_SYS_QUOTAS
777         int result;
778
779         START_PROFILE(syscall_set_quota);
780         result = sys_set_quota(conn->connectpath, qtype, id, qt);
781         END_PROFILE(syscall_set_quota);
782         return result;
783 #else
784         errno = ENOSYS;
785         return -1;
786 #endif  
787 }
788
789 /****************************************************************
790  Extended attribute operations.
791 *****************************************************************/
792
793 ssize_t vfswrap_getxattr(struct vfs_handle_struct *handle,struct connection_struct *conn,const char *path, const char *name, void *value, size_t size)
794 {
795         return sys_getxattr(path, name, value, size);
796 }
797
798 ssize_t vfswrap_lgetxattr(struct vfs_handle_struct *handle,struct connection_struct *conn,const char *path, const char *name, void *value, size_t size)
799 {
800         return sys_lgetxattr(path, name, value, size);
801 }
802
803 ssize_t vfswrap_fgetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, void *value, size_t size)
804 {
805         return sys_fgetxattr(fd, name, value, size);
806 }
807
808 ssize_t vfswrap_listxattr(struct vfs_handle_struct *handle, struct connection_struct *conn,const char *path, char *list, size_t size)
809 {
810         return sys_listxattr(path, list, size);
811 }
812
813 ssize_t vfswrap_llistxattr(struct vfs_handle_struct *handle, struct connection_struct *conn,const char *path, char *list, size_t size)
814 {
815         return sys_llistxattr(path, list, size);
816 }
817
818 ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp,int fd, char *list, size_t size)
819 {
820         return sys_flistxattr(fd, list, size);
821 }
822
823 int vfswrap_removexattr(struct vfs_handle_struct *handle, struct connection_struct *conn,const char *path, const char *name)
824 {
825         return sys_removexattr(path, name);
826 }
827
828 int vfswrap_lremovexattr(struct vfs_handle_struct *handle, struct connection_struct *conn,const char *path, const char *name)
829 {
830         return sys_lremovexattr(path, name);
831 }
832
833 int vfswrap_fremovexattr(struct vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name)
834 {
835         return sys_fremovexattr(fd, name);
836 }
837
838 int vfswrap_setxattr(struct vfs_handle_struct *handle, struct connection_struct *conn,const char *path, const char *name, const void *value, size_t size, int flags)
839 {
840         return sys_setxattr(path, name, value, size, flags);
841 }
842
843 int vfswrap_lsetxattr(struct vfs_handle_struct *handle, struct connection_struct *conn,const char *path, const char *name, const void *value, size_t size, int flags)
844 {
845         return sys_lsetxattr(path, name, value, size, flags);
846 }
847
848 int vfswrap_fsetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, const void *value, size_t size, int flags)
849 {
850         return sys_fsetxattr(fd, name, value, size, flags);
851 }