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