modules/vfs_default.c

説明を見る。
00001 /*
00002    Unix SMB/CIFS implementation.
00003    Wrap disk only vfs functions to sidestep dodgy compilers.
00004    Copyright (C) Tim Potter 1998
00005    Copyright (C) Jeremy Allison 2007
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 
00022 #include "includes.h"
00023 
00024 #undef DBGC_CLASS
00025 #define DBGC_CLASS DBGC_VFS
00026 
00027 /* Check for NULL pointer parameters in vfswrap_* functions */
00028 
00029 /* We don't want to have NULL function pointers lying around.  Someone
00030    is sure to try and execute them.  These stubs are used to prevent
00031    this possibility. */
00032 
00033 static int vfswrap_connect(vfs_handle_struct *handle,  const char *service, const char *user)
00034 {
00035     return 0;    /* Return >= 0 for success */
00036 }
00037 
00038 static void vfswrap_disconnect(vfs_handle_struct *handle)
00039 {
00040 }
00041 
00042 /* Disk operations */
00043 
00044 static SMB_BIG_UINT vfswrap_disk_free(vfs_handle_struct *handle,  const char *path, BOOL small_query, SMB_BIG_UINT *bsize,
00045                                SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
00046 {
00047         SMB_BIG_UINT result;
00048 
00049         result = sys_disk_free(handle->conn, path, small_query, bsize, dfree, dsize);
00050         return result;
00051 }
00052 
00053 static int vfswrap_get_quota(struct vfs_handle_struct *handle,  enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
00054 {
00055 #ifdef HAVE_SYS_QUOTAS
00056         int result;
00057 
00058         START_PROFILE(syscall_get_quota);
00059         result = sys_get_quota(handle->conn->connectpath, qtype, id, qt);
00060         END_PROFILE(syscall_get_quota);
00061         return result;
00062 #else
00063         errno = ENOSYS;
00064         return -1;
00065 #endif
00066 }
00067 
00068 static int vfswrap_set_quota(struct vfs_handle_struct *handle,  enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
00069 {
00070 #ifdef HAVE_SYS_QUOTAS
00071         int result;
00072 
00073         START_PROFILE(syscall_set_quota);
00074         result = sys_set_quota(handle->conn->connectpath, qtype, id, qt);
00075         END_PROFILE(syscall_set_quota);
00076         return result;
00077 #else
00078         errno = ENOSYS;
00079         return -1;
00080 #endif
00081 }
00082 
00083 static int vfswrap_get_shadow_copy_data(struct vfs_handle_struct *handle, struct files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, BOOL labels)
00084 {
00085         errno = ENOSYS;
00086         return -1;  /* Not implemented. */
00087 }
00088 
00089 static int vfswrap_statvfs(struct vfs_handle_struct *handle,  const char *path, vfs_statvfs_struct *statbuf)
00090 {
00091         return sys_statvfs(path, statbuf);
00092 }
00093 
00094 /* Directory operations */
00095 
00096 static SMB_STRUCT_DIR *vfswrap_opendir(vfs_handle_struct *handle,  const char *fname, const char *mask, uint32 attr)
00097 {
00098         SMB_STRUCT_DIR *result;
00099 
00100         START_PROFILE(syscall_opendir);
00101         result = sys_opendir(fname);
00102         END_PROFILE(syscall_opendir);
00103         return result;
00104 }
00105 
00106 static SMB_STRUCT_DIRENT *vfswrap_readdir(vfs_handle_struct *handle,  SMB_STRUCT_DIR *dirp)
00107 {
00108         SMB_STRUCT_DIRENT *result;
00109 
00110         START_PROFILE(syscall_readdir);
00111         result = sys_readdir(dirp);
00112         END_PROFILE(syscall_readdir);
00113         return result;
00114 }
00115 
00116 static void vfswrap_seekdir(vfs_handle_struct *handle,  SMB_STRUCT_DIR *dirp, long offset)
00117 {
00118         START_PROFILE(syscall_seekdir);
00119         sys_seekdir(dirp, offset);
00120         END_PROFILE(syscall_seekdir);
00121 }
00122 
00123 static long vfswrap_telldir(vfs_handle_struct *handle,  SMB_STRUCT_DIR *dirp)
00124 {
00125         long result;
00126         START_PROFILE(syscall_telldir);
00127         result = sys_telldir(dirp);
00128         END_PROFILE(syscall_telldir);
00129         return result;
00130 }
00131 
00132 static void vfswrap_rewinddir(vfs_handle_struct *handle,  SMB_STRUCT_DIR *dirp)
00133 {
00134         START_PROFILE(syscall_rewinddir);
00135         sys_rewinddir(dirp);
00136         END_PROFILE(syscall_rewinddir);
00137 }
00138 
00139 static int vfswrap_mkdir(vfs_handle_struct *handle,  const char *path, mode_t mode)
00140 {
00141         int result;
00142         BOOL has_dacl = False;
00143 
00144         START_PROFILE(syscall_mkdir);
00145 
00146         if (lp_inherit_acls(SNUM(handle->conn)) && (has_dacl = directory_has_default_acl(handle->conn, parent_dirname(path))))
00147                 mode = 0777;
00148 
00149         result = mkdir(path, mode);
00150 
00151         if (result == 0 && !has_dacl) {
00152                 /*
00153                  * We need to do this as the default behavior of POSIX ACLs
00154                  * is to set the mask to be the requested group permission
00155                  * bits, not the group permission bits to be the requested
00156                  * group permission bits. This is not what we want, as it will
00157                  * mess up any inherited ACL bits that were set. JRA.
00158                  */
00159                 int saved_errno = errno; /* We may get ENOSYS */
00160                 if ((SMB_VFS_CHMOD_ACL(handle->conn, path, mode) == -1) && (errno == ENOSYS))
00161                         errno = saved_errno;
00162         }
00163 
00164         END_PROFILE(syscall_mkdir);
00165         return result;
00166 }
00167 
00168 static int vfswrap_rmdir(vfs_handle_struct *handle,  const char *path)
00169 {
00170         int result;
00171 
00172         START_PROFILE(syscall_rmdir);
00173         result = rmdir(path);
00174         END_PROFILE(syscall_rmdir);
00175         return result;
00176 }
00177 
00178 static int vfswrap_closedir(vfs_handle_struct *handle,  SMB_STRUCT_DIR *dirp)
00179 {
00180         int result;
00181 
00182         START_PROFILE(syscall_closedir);
00183         result = sys_closedir(dirp);
00184         END_PROFILE(syscall_closedir);
00185         return result;
00186 }
00187 
00188 /* File operations */
00189 
00190 static int vfswrap_open(vfs_handle_struct *handle,  const char *fname,
00191         files_struct *fsp, int flags, mode_t mode)
00192 {
00193         int result;
00194 
00195         START_PROFILE(syscall_open);
00196         result = sys_open(fname, flags, mode);
00197         END_PROFILE(syscall_open);
00198         return result;
00199 }
00200 
00201 static int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
00202 {
00203         int result;
00204 
00205         START_PROFILE(syscall_close);
00206 
00207         result = close(fd);
00208         END_PROFILE(syscall_close);
00209         return result;
00210 }
00211 
00212 static ssize_t vfswrap_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n)
00213 {
00214         ssize_t result;
00215 
00216         START_PROFILE_BYTES(syscall_read, n);
00217         result = sys_read(fd, data, n);
00218         END_PROFILE(syscall_read);
00219         return result;
00220 }
00221 
00222 static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data,
00223                         size_t n, SMB_OFF_T offset)
00224 {
00225         ssize_t result;
00226 
00227 #if defined(HAVE_PREAD) || defined(HAVE_PREAD64)
00228         START_PROFILE_BYTES(syscall_pread, n);
00229         result = sys_pread(fd, data, n, offset);
00230         END_PROFILE(syscall_pread);
00231 
00232         if (result == -1 && errno == ESPIPE) {
00233                 /* Maintain the fiction that pipes can be seeked (sought?) on. */
00234                 result = SMB_VFS_READ(fsp, fd, data, n);
00235                 fsp->fh->pos = 0;
00236         }
00237 
00238 #else /* HAVE_PREAD */
00239         SMB_OFF_T   curr;
00240         int lerrno;
00241 
00242         curr = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
00243         if (curr == -1 && errno == ESPIPE) {
00244                 /* Maintain the fiction that pipes can be seeked (sought?) on. */
00245                 result = SMB_VFS_READ(fsp, fd, data, n);
00246                 fsp->fh->pos = 0;
00247                 return result;
00248         }
00249 
00250         if (SMB_VFS_LSEEK(fsp, fd, offset, SEEK_SET) == -1) {
00251                 return -1;
00252         }
00253 
00254         errno = 0;
00255         result = SMB_VFS_READ(fsp, fd, data, n);
00256         lerrno = errno;
00257 
00258         SMB_VFS_LSEEK(fsp, fd, curr, SEEK_SET);
00259         errno = lerrno;
00260 
00261 #endif /* HAVE_PREAD */
00262 
00263         return result;
00264 }
00265 
00266 static ssize_t vfswrap_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n)
00267 {
00268         ssize_t result;
00269 
00270         START_PROFILE_BYTES(syscall_write, n);
00271         result = sys_write(fd, data, n);
00272         END_PROFILE(syscall_write);
00273         return result;
00274 }
00275 
00276 static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data,
00277                         size_t n, SMB_OFF_T offset)
00278 {
00279         ssize_t result;
00280 
00281 #if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64)
00282         START_PROFILE_BYTES(syscall_pwrite, n);
00283         result = sys_pwrite(fd, data, n, offset);
00284         END_PROFILE(syscall_pwrite);
00285 
00286         if (result == -1 && errno == ESPIPE) {
00287                 /* Maintain the fiction that pipes can be sought on. */
00288                 result = SMB_VFS_WRITE(fsp, fd, data, n);
00289         }
00290 
00291 #else /* HAVE_PWRITE */
00292         SMB_OFF_T   curr;
00293         int         lerrno;
00294 
00295         curr = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
00296         if (curr == -1) {
00297                 return -1;
00298         }
00299 
00300         if (SMB_VFS_LSEEK(fsp, fd, offset, SEEK_SET) == -1) {
00301                 return -1;
00302         }
00303 
00304         result = SMB_VFS_WRITE(fsp, fd, data, n);
00305         lerrno = errno;
00306 
00307         SMB_VFS_LSEEK(fsp, fd, curr, SEEK_SET);
00308         errno = lerrno;
00309 
00310 #endif /* HAVE_PWRITE */
00311 
00312         return result;
00313 }
00314 
00315 static SMB_OFF_T vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, int filedes, SMB_OFF_T offset, int whence)
00316 {
00317         SMB_OFF_T result = 0;
00318 
00319         START_PROFILE(syscall_lseek);
00320 
00321         /* Cope with 'stat' file opens. */
00322         if (filedes != -1)
00323                 result = sys_lseek(filedes, offset, whence);
00324 
00325         /*
00326          * We want to maintain the fiction that we can seek
00327          * on a fifo for file system purposes. This allows
00328          * people to set up UNIX fifo's that feed data to Windows
00329          * applications. JRA.
00330          */
00331 
00332         if((result == -1) && (errno == ESPIPE)) {
00333                 result = 0;
00334                 errno = 0;
00335         }
00336 
00337         END_PROFILE(syscall_lseek);
00338         return result;
00339 }
00340 
00341 static ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *hdr,
00342                         SMB_OFF_T offset, size_t n)
00343 {
00344         ssize_t result;
00345 
00346         START_PROFILE_BYTES(syscall_sendfile, n);
00347         result = sys_sendfile(tofd, fromfd, hdr, offset, n);
00348         END_PROFILE(syscall_sendfile);
00349         return result;
00350 }
00351 
00352 /*********************************************************
00353  For rename across filesystems Patch from Warren Birnbaum
00354  <warrenb@hpcvscdp.cv.hp.com>
00355 **********************************************************/
00356 
00357 static int copy_reg(const char *source, const char *dest)
00358 {
00359         SMB_STRUCT_STAT source_stats;
00360         int saved_errno;
00361         int ifd = -1;
00362         int ofd = -1;
00363 
00364         if (sys_lstat (source, &source_stats) == -1)
00365                 return -1;
00366 
00367         if (!S_ISREG (source_stats.st_mode))
00368                 return -1;
00369 
00370         if((ifd = sys_open (source, O_RDONLY, 0)) < 0)
00371                 return -1;
00372 
00373         if (unlink (dest) && errno != ENOENT)
00374                 return -1;
00375 
00376 #ifdef O_NOFOLLOW
00377         if((ofd = sys_open (dest, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW, 0600)) < 0 )
00378 #else
00379         if((ofd = sys_open (dest, O_WRONLY | O_CREAT | O_TRUNC , 0600)) < 0 )
00380 #endif
00381                 goto err;
00382 
00383         if (transfer_file(ifd, ofd, (size_t)-1) == -1)
00384                 goto err;
00385 
00386         /*
00387          * Try to preserve ownership.  For non-root it might fail, but that's ok.
00388          * But root probably wants to know, e.g. if NFS disallows it.
00389          */
00390 
00391 #ifdef HAVE_FCHOWN
00392         if ((fchown(ofd, source_stats.st_uid, source_stats.st_gid) == -1) && (errno != EPERM))
00393 #else
00394         if ((chown(dest, source_stats.st_uid, source_stats.st_gid) == -1) && (errno != EPERM))
00395 #endif
00396                 goto err;
00397 
00398         /*
00399          * fchown turns off set[ug]id bits for non-root,
00400          * so do the chmod last.
00401          */
00402 
00403 #if defined(HAVE_FCHMOD)
00404         if (fchmod (ofd, source_stats.st_mode & 07777))
00405 #else
00406         if (chmod (dest, source_stats.st_mode & 07777))
00407 #endif
00408                 goto err;
00409 
00410         if (close (ifd) == -1)
00411                 goto err;
00412 
00413         if (close (ofd) == -1)
00414                 return -1;
00415 
00416         /* Try to copy the old file's modtime and access time.  */
00417         {
00418                 struct utimbuf tv;
00419 
00420                 tv.actime = source_stats.st_atime;
00421                 tv.modtime = source_stats.st_mtime;
00422                 utime(dest, &tv);
00423         }
00424 
00425         if (unlink (source) == -1)
00426                 return -1;
00427 
00428         return 0;
00429 
00430   err:
00431 
00432         saved_errno = errno;
00433         if (ifd != -1)
00434                 close(ifd);
00435         if (ofd != -1)
00436                 close(ofd);
00437         errno = saved_errno;
00438         return -1;
00439 }
00440 
00441 static int vfswrap_rename(vfs_handle_struct *handle,  const char *oldname, const char *newname)
00442 {
00443         int result;
00444 
00445         START_PROFILE(syscall_rename);
00446         result = rename(oldname, newname);
00447         if ((result == -1) && (errno == EXDEV)) {
00448                 /* Rename across filesystems needed. */
00449                 result = copy_reg(oldname, newname);
00450         }
00451 
00452         END_PROFILE(syscall_rename);
00453         return result;
00454 }
00455 
00456 static int vfswrap_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd)
00457 {
00458 #ifdef HAVE_FSYNC
00459         int result;
00460 
00461         START_PROFILE(syscall_fsync);
00462         result = fsync(fd);
00463         END_PROFILE(syscall_fsync);
00464         return result;
00465 #else
00466         return 0;
00467 #endif
00468 }
00469 
00470 static int vfswrap_stat(vfs_handle_struct *handle,  const char *fname, SMB_STRUCT_STAT *sbuf)
00471 {
00472         int result;
00473 
00474         START_PROFILE(syscall_stat);
00475         result = sys_stat(fname, sbuf);
00476         END_PROFILE(syscall_stat);
00477         return result;
00478 }
00479 
00480 static int vfswrap_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
00481 {
00482         int result;
00483 
00484         START_PROFILE(syscall_fstat);
00485         result = sys_fstat(fd, sbuf);
00486         END_PROFILE(syscall_fstat);
00487         return result;
00488 }
00489 
00490 int vfswrap_lstat(vfs_handle_struct *handle,  const char *path, SMB_STRUCT_STAT *sbuf)
00491 {
00492         int result;
00493 
00494         START_PROFILE(syscall_lstat);
00495         result = sys_lstat(path, sbuf);
00496         END_PROFILE(syscall_lstat);
00497         return result;
00498 }
00499 
00500 static int vfswrap_unlink(vfs_handle_struct *handle,  const char *path)
00501 {
00502         int result;
00503 
00504         START_PROFILE(syscall_unlink);
00505         result = unlink(path);
00506         END_PROFILE(syscall_unlink);
00507         return result;
00508 }
00509 
00510 static int vfswrap_chmod(vfs_handle_struct *handle,  const char *path, mode_t mode)
00511 {
00512         int result;
00513 
00514         START_PROFILE(syscall_chmod);
00515 
00516         /*
00517          * We need to do this due to the fact that the default POSIX ACL
00518          * chmod modifies the ACL *mask* for the group owner, not the
00519          * group owner bits directly. JRA.
00520          */
00521 
00522 
00523         {
00524                 int saved_errno = errno; /* We might get ENOSYS */
00525                 if ((result = SMB_VFS_CHMOD_ACL(handle->conn, path, mode)) == 0) {
00526                         END_PROFILE(syscall_chmod);
00527                         return result;
00528                 }
00529                 /* Error - return the old errno. */
00530                 errno = saved_errno;
00531         }
00532 
00533         result = chmod(path, mode);
00534         END_PROFILE(syscall_chmod);
00535         return result;
00536 }
00537 
00538 static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode)
00539 {
00540         int result;
00541 
00542         START_PROFILE(syscall_fchmod);
00543 
00544         /*
00545          * We need to do this due to the fact that the default POSIX ACL
00546          * chmod modifies the ACL *mask* for the group owner, not the
00547          * group owner bits directly. JRA.
00548          */
00549 
00550         {
00551                 int saved_errno = errno; /* We might get ENOSYS */
00552                 if ((result = SMB_VFS_FCHMOD_ACL(fsp, fd, mode)) == 0) {
00553                         END_PROFILE(syscall_fchmod);
00554                         return result;
00555                 }
00556                 /* Error - return the old errno. */
00557                 errno = saved_errno;
00558         }
00559 
00560 #if defined(HAVE_FCHMOD)
00561         result = fchmod(fd, mode);
00562 #else
00563         result = -1;
00564         errno = ENOSYS;
00565 #endif
00566 
00567         END_PROFILE(syscall_fchmod);
00568         return result;
00569 }
00570 
00571 static int vfswrap_chown(vfs_handle_struct *handle,  const char *path, uid_t uid, gid_t gid)
00572 {
00573         int result;
00574 
00575         START_PROFILE(syscall_chown);
00576         result = sys_chown(path, uid, gid);
00577         END_PROFILE(syscall_chown);
00578         return result;
00579 }
00580 
00581 static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, uid_t uid, gid_t gid)
00582 {
00583 #ifdef HAVE_FCHOWN
00584         int result;
00585 
00586         START_PROFILE(syscall_fchown);
00587         result = fchown(fd, uid, gid);
00588         END_PROFILE(syscall_fchown);
00589         return result;
00590 #else
00591         errno = ENOSYS;
00592         return -1;
00593 #endif
00594 }
00595 
00596 static int vfswrap_chdir(vfs_handle_struct *handle,  const char *path)
00597 {
00598         int result;
00599 
00600         START_PROFILE(syscall_chdir);
00601         result = chdir(path);
00602         END_PROFILE(syscall_chdir);
00603         return result;
00604 }
00605 
00606 static char *vfswrap_getwd(vfs_handle_struct *handle,  char *path)
00607 {
00608         char *result;
00609 
00610         START_PROFILE(syscall_getwd);
00611         result = sys_getwd(path);
00612         END_PROFILE(syscall_getwd);
00613         return result;
00614 }
00615 
00616 /*********************************************************************
00617  nsec timestamp resolution call. Convert down to whatever the underlying
00618  system will support.
00619 **********************************************************************/
00620 
00621 static int vfswrap_ntimes(vfs_handle_struct *handle, const char *path, const struct timespec ts[2])
00622 {
00623         int result;
00624 
00625         START_PROFILE(syscall_ntimes);
00626 #if defined(HAVE_UTIMES)
00627         {
00628                 struct timeval tv[2];
00629                 tv[0] = convert_timespec_to_timeval(ts[0]);
00630                 tv[1] = convert_timespec_to_timeval(ts[1]);
00631                 result = utimes(path, tv);
00632         }
00633 #elif defined(HAVE_UTIME)
00634         {
00635                 struct utimbuf times;
00636                 times.actime = convert_timespec_to_time_t(ts[0]);
00637                 times.modtime = convert_timespec_to_time_t(ts[1]);
00638                 result = utime(path, times);
00639         }
00640 #else
00641         errno = ENOSYS;
00642         result = -1;
00643 #endif
00644         END_PROFILE(syscall_ntimes);
00645         return result;
00646 }
00647 
00648 /*********************************************************************
00649  A version of ftruncate that will write the space on disk if strict
00650  allocate is set.
00651 **********************************************************************/
00652 
00653 static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len)
00654 {
00655         SMB_STRUCT_STAT st;
00656         SMB_OFF_T currpos = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
00657         unsigned char zero_space[4096];
00658         SMB_OFF_T space_to_write;
00659 
00660         if (currpos == -1)
00661                 return -1;
00662 
00663         if (SMB_VFS_FSTAT(fsp, fd, &st) == -1)
00664                 return -1;
00665 
00666         space_to_write = len - st.st_size;
00667 
00668 #ifdef S_ISFIFO
00669         if (S_ISFIFO(st.st_mode))
00670                 return 0;
00671 #endif
00672 
00673         if (st.st_size == len)
00674                 return 0;
00675 
00676         /* Shrink - just ftruncate. */
00677         if (st.st_size > len)
00678                 return sys_ftruncate(fd, len);
00679 
00680         /* Write out the real space on disk. */
00681         if (SMB_VFS_LSEEK(fsp, fd, st.st_size, SEEK_SET) != st.st_size)
00682                 return -1;
00683 
00684         space_to_write = len - st.st_size;
00685 
00686         memset(zero_space, '\0', sizeof(zero_space));
00687         while ( space_to_write > 0) {
00688                 SMB_OFF_T retlen;
00689                 SMB_OFF_T current_len_to_write = MIN(sizeof(zero_space),space_to_write);
00690 
00691                 retlen = SMB_VFS_WRITE(fsp,fsp->fh->fd,(char *)zero_space,current_len_to_write);
00692                 if (retlen <= 0)
00693                         return -1;
00694 
00695                 space_to_write -= retlen;
00696         }
00697 
00698         /* Seek to where we were */
00699         if (SMB_VFS_LSEEK(fsp, fd, currpos, SEEK_SET) != currpos)
00700                 return -1;
00701 
00702         return 0;
00703 }
00704 
00705 static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len)
00706 {
00707         int result = -1;
00708         SMB_STRUCT_STAT st;
00709         char c = 0;
00710         SMB_OFF_T currpos;
00711 
00712         START_PROFILE(syscall_ftruncate);
00713 
00714         if (lp_strict_allocate(SNUM(fsp->conn))) {
00715                 result = strict_allocate_ftruncate(handle, fsp, fd, len);
00716                 END_PROFILE(syscall_ftruncate);
00717                 return result;
00718         }
00719 
00720         /* we used to just check HAVE_FTRUNCATE_EXTEND and only use
00721            sys_ftruncate if the system supports it. Then I discovered that
00722            you can have some filesystems that support ftruncate
00723            expansion and some that don't! On Linux fat can't do
00724            ftruncate extend but ext2 can. */
00725 
00726         result = sys_ftruncate(fd, len);
00727         if (result == 0)
00728                 goto done;
00729 
00730         /* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
00731            extend a file with ftruncate. Provide alternate implementation
00732            for this */
00733         currpos = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
00734         if (currpos == -1) {
00735                 goto done;
00736         }
00737 
00738         /* Do an fstat to see if the file is longer than the requested
00739            size in which case the ftruncate above should have
00740            succeeded or shorter, in which case seek to len - 1 and
00741            write 1 byte of zero */
00742         if (SMB_VFS_FSTAT(fsp, fd, &st) == -1) {
00743                 goto done;
00744         }
00745 
00746 #ifdef S_ISFIFO
00747         if (S_ISFIFO(st.st_mode)) {
00748                 result = 0;
00749                 goto done;
00750         }
00751 #endif
00752 
00753         if (st.st_size == len) {
00754                 result = 0;
00755                 goto done;
00756         }
00757 
00758         if (st.st_size > len) {
00759                 /* the sys_ftruncate should have worked */
00760                 goto done;
00761         }
00762 
00763         if (SMB_VFS_LSEEK(fsp, fd, len-1, SEEK_SET) != len -1)
00764                 goto done;
00765 
00766         if (SMB_VFS_WRITE(fsp, fd, &c, 1)!=1)
00767                 goto done;
00768 
00769         /* Seek to where we were */
00770         if (SMB_VFS_LSEEK(fsp, fd, currpos, SEEK_SET) != currpos)
00771                 goto done;
00772         result = 0;
00773 
00774   done:
00775 
00776         END_PROFILE(syscall_ftruncate);
00777         return result;
00778 }
00779 
00780 static BOOL vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
00781 {
00782         BOOL result;
00783 
00784         START_PROFILE(syscall_fcntl_lock);
00785         result =  fcntl_lock(fd, op, offset, count, type);
00786         END_PROFILE(syscall_fcntl_lock);
00787         return result;
00788 }
00789 
00790 static int vfswrap_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, int fd,
00791                                 uint32 share_mode)
00792 {
00793         START_PROFILE(syscall_kernel_flock);
00794         kernel_flock(fd, share_mode);
00795         END_PROFILE(syscall_kernel_flock);
00796         return 0;
00797 }
00798 
00799 static BOOL vfswrap_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
00800 {
00801         BOOL result;
00802 
00803         START_PROFILE(syscall_fcntl_getlock);
00804         result =  fcntl_getlock(fd, poffset, pcount, ptype, ppid);
00805         END_PROFILE(syscall_fcntl_getlock);
00806         return result;
00807 }
00808 
00809 static int vfswrap_linux_setlease(vfs_handle_struct *handle, files_struct *fsp, int fd,
00810                                 int leasetype)
00811 {
00812         int result = -1;
00813 
00814         START_PROFILE(syscall_linux_setlease);
00815 
00816 #ifdef LINUX
00817         /* first set the signal handler */
00818         if(linux_set_lease_sighandler(fd) == -1)
00819                 return -1;
00820 
00821         result = linux_setlease(fd, leasetype);
00822 #else
00823         errno = ENOSYS;
00824 #endif
00825         END_PROFILE(syscall_linux_setlease);
00826         return result;
00827 }
00828 
00829 static int vfswrap_symlink(vfs_handle_struct *handle,  const char *oldpath, const char *newpath)
00830 {
00831         int result;
00832 
00833         START_PROFILE(syscall_symlink);
00834         result = sys_symlink(oldpath, newpath);
00835         END_PROFILE(syscall_symlink);
00836         return result;
00837 }
00838 
00839 static int vfswrap_readlink(vfs_handle_struct *handle,  const char *path, char *buf, size_t bufsiz)
00840 {
00841         int result;
00842 
00843         START_PROFILE(syscall_readlink);
00844         result = sys_readlink(path, buf, bufsiz);
00845         END_PROFILE(syscall_readlink);
00846         return result;
00847 }
00848 
00849 static int vfswrap_link(vfs_handle_struct *handle,  const char *oldpath, const char *newpath)
00850 {
00851         int result;
00852 
00853         START_PROFILE(syscall_link);
00854         result = sys_link(oldpath, newpath);
00855         END_PROFILE(syscall_link);
00856         return result;
00857 }
00858 
00859 static int vfswrap_mknod(vfs_handle_struct *handle,  const char *pathname, mode_t mode, SMB_DEV_T dev)
00860 {
00861         int result;
00862 
00863         START_PROFILE(syscall_mknod);
00864         result = sys_mknod(pathname, mode, dev);
00865         END_PROFILE(syscall_mknod);
00866         return result;
00867 }
00868 
00869 static char *vfswrap_realpath(vfs_handle_struct *handle,  const char *path, char *resolved_path)
00870 {
00871         char *result;
00872 
00873         START_PROFILE(syscall_realpath);
00874         result = sys_realpath(path, resolved_path);
00875         END_PROFILE(syscall_realpath);
00876         return result;
00877 }
00878 
00879 static NTSTATUS vfswrap_notify_watch(vfs_handle_struct *vfs_handle,
00880                                      struct sys_notify_context *ctx,
00881                                      struct notify_entry *e,
00882                                      void (*callback)(struct sys_notify_context *ctx, 
00883                                                       void *private_data,
00884                                                       struct notify_event *ev),
00885                                      void *private_data, void *handle)
00886 {
00887         /*
00888          * So far inotify is the only supported default notify mechanism. If
00889          * another platform like the the BSD's or a proprietary Unix comes
00890          * along and wants another default, we can play the same trick we
00891          * played with Posix ACLs.
00892          *
00893          * Until that is the case, hard-code inotify here.
00894          */
00895 #ifdef HAVE_INOTIFY
00896         if (lp_kernel_change_notify(ctx->conn->params)) {
00897                 return inotify_watch(ctx, e, callback, private_data, handle);
00898         }
00899 #endif
00900         /*
00901          * Do nothing, leave everything to notify_internal.c
00902          */
00903         return NT_STATUS_OK;
00904 }
00905 
00906 static int vfswrap_chflags(vfs_handle_struct *handle, const char *path, int flags)
00907 {
00908 #ifdef HAVE_CHFLAGS
00909         return chflags(path, flags);
00910 #else
00911         errno = ENOSYS;
00912         return -1;
00913 #endif
00914 }
00915 
00916 static size_t vfswrap_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info, SEC_DESC **ppdesc)
00917 {
00918         size_t result;
00919 
00920         START_PROFILE(fget_nt_acl);
00921         result = get_nt_acl(fsp, security_info, ppdesc);
00922         END_PROFILE(fget_nt_acl);
00923         return result;
00924 }
00925 
00926 static size_t vfswrap_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info, SEC_DESC **ppdesc)
00927 {
00928         size_t result;
00929 
00930         START_PROFILE(get_nt_acl);
00931         result = get_nt_acl(fsp, security_info, ppdesc);
00932         END_PROFILE(get_nt_acl);
00933         return result;
00934 }
00935 
00936 static BOOL vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd)
00937 {
00938         BOOL result;
00939 
00940         START_PROFILE(fset_nt_acl);
00941         result = set_nt_acl(fsp, security_info_sent, psd);
00942         END_PROFILE(fset_nt_acl);
00943         return result;
00944 }
00945 
00946 static BOOL vfswrap_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info_sent, SEC_DESC *psd)
00947 {
00948         BOOL result;
00949 
00950         START_PROFILE(set_nt_acl);
00951         result = set_nt_acl(fsp, security_info_sent, psd);
00952         END_PROFILE(set_nt_acl);
00953         return result;
00954 }
00955 
00956 static int vfswrap_chmod_acl(vfs_handle_struct *handle,  const char *name, mode_t mode)
00957 {
00958 #ifdef HAVE_NO_ACL
00959         errno = ENOSYS;
00960         return -1;
00961 #else
00962         int result;
00963 
00964         START_PROFILE(chmod_acl);
00965         result = chmod_acl(handle->conn, name, mode);
00966         END_PROFILE(chmod_acl);
00967         return result;
00968 #endif
00969 }
00970 
00971 static int vfswrap_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode)
00972 {
00973 #ifdef HAVE_NO_ACL
00974         errno = ENOSYS;
00975         return -1;
00976 #else
00977         int result;
00978 
00979         START_PROFILE(fchmod_acl);
00980         result = fchmod_acl(fsp, fd, mode);
00981         END_PROFILE(fchmod_acl);
00982         return result;
00983 #endif
00984 }
00985 
00986 static int vfswrap_sys_acl_get_entry(vfs_handle_struct *handle,  SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p)
00987 {
00988         return sys_acl_get_entry(theacl, entry_id, entry_p);
00989 }
00990 
00991 static int vfswrap_sys_acl_get_tag_type(vfs_handle_struct *handle,  SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p)
00992 {
00993         return sys_acl_get_tag_type(entry_d, tag_type_p);
00994 }
00995 
00996 static int vfswrap_sys_acl_get_permset(vfs_handle_struct *handle,  SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p)
00997 {
00998         return sys_acl_get_permset(entry_d, permset_p);
00999 }
01000 
01001 static void * vfswrap_sys_acl_get_qualifier(vfs_handle_struct *handle,  SMB_ACL_ENTRY_T entry_d)
01002 {
01003         return sys_acl_get_qualifier(entry_d);
01004 }
01005 
01006 static SMB_ACL_T vfswrap_sys_acl_get_file(vfs_handle_struct *handle,  const char *path_p, SMB_ACL_TYPE_T type)
01007 {
01008         return sys_acl_get_file(handle, path_p, type);
01009 }
01010 
01011 static SMB_ACL_T vfswrap_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
01012 {
01013         return sys_acl_get_fd(handle, fsp, fd);
01014 }
01015 
01016 static int vfswrap_sys_acl_clear_perms(vfs_handle_struct *handle,  SMB_ACL_PERMSET_T permset)
01017 {
01018         return sys_acl_clear_perms(permset);
01019 }
01020 
01021 static int vfswrap_sys_acl_add_perm(vfs_handle_struct *handle,  SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm)
01022 {
01023         return sys_acl_add_perm(permset, perm);
01024 }
01025 
01026 static char * vfswrap_sys_acl_to_text(vfs_handle_struct *handle,  SMB_ACL_T theacl, ssize_t *plen)
01027 {
01028         return sys_acl_to_text(theacl, plen);
01029 }
01030 
01031 static SMB_ACL_T vfswrap_sys_acl_init(vfs_handle_struct *handle,  int count)
01032 {
01033         return sys_acl_init(count);
01034 }
01035 
01036 static int vfswrap_sys_acl_create_entry(vfs_handle_struct *handle,  SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry)
01037 {
01038         return sys_acl_create_entry(pacl, pentry);
01039 }
01040 
01041 static int vfswrap_sys_acl_set_tag_type(vfs_handle_struct *handle,  SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype)
01042 {
01043         return sys_acl_set_tag_type(entry, tagtype);
01044 }
01045 
01046 static int vfswrap_sys_acl_set_qualifier(vfs_handle_struct *handle,  SMB_ACL_ENTRY_T entry, void *qual)
01047 {
01048         return sys_acl_set_qualifier(entry, qual);
01049 }
01050 
01051 static int vfswrap_sys_acl_set_permset(vfs_handle_struct *handle,  SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset)
01052 {
01053         return sys_acl_set_permset(entry, permset);
01054 }
01055 
01056 static int vfswrap_sys_acl_valid(vfs_handle_struct *handle,  SMB_ACL_T theacl )
01057 {
01058         return sys_acl_valid(theacl );
01059 }
01060 
01061 static int vfswrap_sys_acl_set_file(vfs_handle_struct *handle,  const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
01062 {
01063         return sys_acl_set_file(handle, name, acltype, theacl);
01064 }
01065 
01066 static int vfswrap_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_ACL_T theacl)
01067 {
01068         return sys_acl_set_fd(handle, fsp, fd, theacl);
01069 }
01070 
01071 static int vfswrap_sys_acl_delete_def_file(vfs_handle_struct *handle,  const char *path)
01072 {
01073         return sys_acl_delete_def_file(handle, path);
01074 }
01075 
01076 static int vfswrap_sys_acl_get_perm(vfs_handle_struct *handle,  SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm)
01077 {
01078         return sys_acl_get_perm(permset, perm);
01079 }
01080 
01081 static int vfswrap_sys_acl_free_text(vfs_handle_struct *handle,  char *text)
01082 {
01083         return sys_acl_free_text(text);
01084 }
01085 
01086 static int vfswrap_sys_acl_free_acl(vfs_handle_struct *handle,  SMB_ACL_T posix_acl)
01087 {
01088         return sys_acl_free_acl(posix_acl);
01089 }
01090 
01091 static int vfswrap_sys_acl_free_qualifier(vfs_handle_struct *handle,  void *qualifier, SMB_ACL_TAG_T tagtype)
01092 {
01093         return sys_acl_free_qualifier(qualifier, tagtype);
01094 }
01095 
01096 /****************************************************************
01097  Extended attribute operations.
01098 *****************************************************************/
01099 
01100 static ssize_t vfswrap_getxattr(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size)
01101 {
01102         return sys_getxattr(path, name, value, size);
01103 }
01104 
01105 static ssize_t vfswrap_lgetxattr(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size)
01106 {
01107         return sys_lgetxattr(path, name, value, size);
01108 }
01109 
01110 static ssize_t vfswrap_fgetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, void *value, size_t size)
01111 {
01112         return sys_fgetxattr(fd, name, value, size);
01113 }
01114 
01115 static ssize_t vfswrap_listxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)
01116 {
01117         return sys_listxattr(path, list, size);
01118 }
01119 
01120 ssize_t vfswrap_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)
01121 {
01122         return sys_llistxattr(path, list, size);
01123 }
01124 
01125 ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp,int fd, char *list, size_t size)
01126 {
01127         return sys_flistxattr(fd, list, size);
01128 }
01129 
01130 static int vfswrap_removexattr(struct vfs_handle_struct *handle, const char *path, const char *name)
01131 {
01132         return sys_removexattr(path, name);
01133 }
01134 
01135 static int vfswrap_lremovexattr(struct vfs_handle_struct *handle, const char *path, const char *name)
01136 {
01137         return sys_lremovexattr(path, name);
01138 }
01139 
01140 static int vfswrap_fremovexattr(struct vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name)
01141 {
01142         return sys_fremovexattr(fd, name);
01143 }
01144 
01145 static int vfswrap_setxattr(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
01146 {
01147         return sys_setxattr(path, name, value, size, flags);
01148 }
01149 
01150 static int vfswrap_lsetxattr(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
01151 {
01152         return sys_lsetxattr(path, name, value, size, flags);
01153 }
01154 
01155 static 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)
01156 {
01157         return sys_fsetxattr(fd, name, value, size, flags);
01158 }
01159 
01160 static int vfswrap_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
01161 {
01162         return sys_aio_read(aiocb);
01163 }
01164 
01165 static int vfswrap_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
01166 {
01167         return sys_aio_write(aiocb);
01168 }
01169 
01170 static ssize_t vfswrap_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
01171 {
01172         return sys_aio_return(aiocb);
01173 }
01174 
01175 static int vfswrap_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb)
01176 {
01177         return sys_aio_cancel(fd, aiocb);
01178 }
01179 
01180 static int vfswrap_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
01181 {
01182         return sys_aio_error(aiocb);
01183 }
01184 
01185 static int vfswrap_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
01186 {
01187         return sys_aio_fsync(op, aiocb);
01188 }
01189 
01190 static int vfswrap_aio_suspend(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_AIOCB * const aiocb[], int n, const struct timespec *timeout)
01191 {
01192         return sys_aio_suspend(aiocb, n, timeout);
01193 }
01194 
01195 static vfs_op_tuple vfs_default_ops[] = {
01196 
01197         /* Disk operations */
01198 
01199         {SMB_VFS_OP(vfswrap_connect),   SMB_VFS_OP_CONNECT,
01200          SMB_VFS_LAYER_OPAQUE},
01201         {SMB_VFS_OP(vfswrap_disconnect),        SMB_VFS_OP_DISCONNECT,
01202          SMB_VFS_LAYER_OPAQUE},
01203         {SMB_VFS_OP(vfswrap_disk_free), SMB_VFS_OP_DISK_FREE,
01204          SMB_VFS_LAYER_OPAQUE},
01205         {SMB_VFS_OP(vfswrap_get_quota), SMB_VFS_OP_GET_QUOTA,
01206          SMB_VFS_LAYER_OPAQUE},
01207         {SMB_VFS_OP(vfswrap_set_quota), SMB_VFS_OP_SET_QUOTA,
01208          SMB_VFS_LAYER_OPAQUE},
01209         {SMB_VFS_OP(vfswrap_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
01210          SMB_VFS_LAYER_OPAQUE},
01211         {SMB_VFS_OP(vfswrap_statvfs),   SMB_VFS_OP_STATVFS,
01212          SMB_VFS_LAYER_OPAQUE},
01213 
01214         /* Directory operations */
01215 
01216         {SMB_VFS_OP(vfswrap_opendir),   SMB_VFS_OP_OPENDIR,
01217          SMB_VFS_LAYER_OPAQUE},
01218         {SMB_VFS_OP(vfswrap_readdir),   SMB_VFS_OP_READDIR,
01219          SMB_VFS_LAYER_OPAQUE},
01220         {SMB_VFS_OP(vfswrap_seekdir),   SMB_VFS_OP_SEEKDIR,
01221          SMB_VFS_LAYER_OPAQUE},
01222         {SMB_VFS_OP(vfswrap_telldir),   SMB_VFS_OP_TELLDIR,
01223          SMB_VFS_LAYER_OPAQUE},
01224         {SMB_VFS_OP(vfswrap_rewinddir), SMB_VFS_OP_REWINDDIR,
01225          SMB_VFS_LAYER_OPAQUE},
01226         {SMB_VFS_OP(vfswrap_mkdir),     SMB_VFS_OP_MKDIR,
01227          SMB_VFS_LAYER_OPAQUE},
01228         {SMB_VFS_OP(vfswrap_rmdir),     SMB_VFS_OP_RMDIR,
01229          SMB_VFS_LAYER_OPAQUE},
01230         {SMB_VFS_OP(vfswrap_closedir),  SMB_VFS_OP_CLOSEDIR,
01231          SMB_VFS_LAYER_OPAQUE},
01232 
01233         /* File operations */
01234 
01235         {SMB_VFS_OP(vfswrap_open),      SMB_VFS_OP_OPEN,
01236          SMB_VFS_LAYER_OPAQUE},
01237         {SMB_VFS_OP(vfswrap_close),     SMB_VFS_OP_CLOSE,
01238          SMB_VFS_LAYER_OPAQUE},
01239         {SMB_VFS_OP(vfswrap_read),      SMB_VFS_OP_READ,
01240          SMB_VFS_LAYER_OPAQUE},
01241         {SMB_VFS_OP(vfswrap_pread),     SMB_VFS_OP_PREAD,
01242          SMB_VFS_LAYER_OPAQUE},
01243         {SMB_VFS_OP(vfswrap_write),     SMB_VFS_OP_WRITE,
01244          SMB_VFS_LAYER_OPAQUE},
01245         {SMB_VFS_OP(vfswrap_pwrite),    SMB_VFS_OP_PWRITE,
01246          SMB_VFS_LAYER_OPAQUE},
01247         {SMB_VFS_OP(vfswrap_lseek),     SMB_VFS_OP_LSEEK,
01248          SMB_VFS_LAYER_OPAQUE},
01249         {SMB_VFS_OP(vfswrap_sendfile),  SMB_VFS_OP_SENDFILE,
01250          SMB_VFS_LAYER_OPAQUE},
01251         {SMB_VFS_OP(vfswrap_rename),    SMB_VFS_OP_RENAME,
01252          SMB_VFS_LAYER_OPAQUE},
01253         {SMB_VFS_OP(vfswrap_fsync),     SMB_VFS_OP_FSYNC,
01254          SMB_VFS_LAYER_OPAQUE},
01255         {SMB_VFS_OP(vfswrap_stat),      SMB_VFS_OP_STAT,
01256          SMB_VFS_LAYER_OPAQUE},
01257         {SMB_VFS_OP(vfswrap_fstat),     SMB_VFS_OP_FSTAT,
01258          SMB_VFS_LAYER_OPAQUE},
01259         {SMB_VFS_OP(vfswrap_lstat),     SMB_VFS_OP_LSTAT,
01260          SMB_VFS_LAYER_OPAQUE},
01261         {SMB_VFS_OP(vfswrap_unlink),    SMB_VFS_OP_UNLINK,
01262          SMB_VFS_LAYER_OPAQUE},
01263         {SMB_VFS_OP(vfswrap_chmod),     SMB_VFS_OP_CHMOD,
01264          SMB_VFS_LAYER_OPAQUE},
01265         {SMB_VFS_OP(vfswrap_fchmod),    SMB_VFS_OP_FCHMOD,
01266          SMB_VFS_LAYER_OPAQUE},
01267         {SMB_VFS_OP(vfswrap_chown),     SMB_VFS_OP_CHOWN,
01268          SMB_VFS_LAYER_OPAQUE},
01269         {SMB_VFS_OP(vfswrap_fchown),    SMB_VFS_OP_FCHOWN,
01270          SMB_VFS_LAYER_OPAQUE},
01271         {SMB_VFS_OP(vfswrap_chdir),     SMB_VFS_OP_CHDIR,
01272          SMB_VFS_LAYER_OPAQUE},
01273         {SMB_VFS_OP(vfswrap_getwd),     SMB_VFS_OP_GETWD,
01274          SMB_VFS_LAYER_OPAQUE},
01275         {SMB_VFS_OP(vfswrap_ntimes),    SMB_VFS_OP_NTIMES,
01276          SMB_VFS_LAYER_OPAQUE},
01277         {SMB_VFS_OP(vfswrap_ftruncate), SMB_VFS_OP_FTRUNCATE,
01278          SMB_VFS_LAYER_OPAQUE},
01279         {SMB_VFS_OP(vfswrap_lock),      SMB_VFS_OP_LOCK,
01280          SMB_VFS_LAYER_OPAQUE},
01281         {SMB_VFS_OP(vfswrap_kernel_flock),      SMB_VFS_OP_KERNEL_FLOCK,
01282          SMB_VFS_LAYER_OPAQUE},
01283         {SMB_VFS_OP(vfswrap_linux_setlease),    SMB_VFS_OP_LINUX_SETLEASE,
01284          SMB_VFS_LAYER_OPAQUE},
01285         {SMB_VFS_OP(vfswrap_getlock),   SMB_VFS_OP_GETLOCK,
01286          SMB_VFS_LAYER_OPAQUE},
01287         {SMB_VFS_OP(vfswrap_symlink),   SMB_VFS_OP_SYMLINK,
01288          SMB_VFS_LAYER_OPAQUE},
01289         {SMB_VFS_OP(vfswrap_readlink),  SMB_VFS_OP_READLINK,
01290          SMB_VFS_LAYER_OPAQUE},
01291         {SMB_VFS_OP(vfswrap_link),      SMB_VFS_OP_LINK,
01292          SMB_VFS_LAYER_OPAQUE},
01293         {SMB_VFS_OP(vfswrap_mknod),     SMB_VFS_OP_MKNOD,
01294          SMB_VFS_LAYER_OPAQUE},
01295         {SMB_VFS_OP(vfswrap_realpath),  SMB_VFS_OP_REALPATH,
01296          SMB_VFS_LAYER_OPAQUE},
01297         {SMB_VFS_OP(vfswrap_notify_watch),      SMB_VFS_OP_NOTIFY_WATCH,
01298          SMB_VFS_LAYER_OPAQUE},
01299         {SMB_VFS_OP(vfswrap_chflags),   SMB_VFS_OP_CHFLAGS,
01300          SMB_VFS_LAYER_OPAQUE},
01301 
01302         /* NT ACL operations. */
01303 
01304         {SMB_VFS_OP(vfswrap_fget_nt_acl),       SMB_VFS_OP_FGET_NT_ACL,
01305          SMB_VFS_LAYER_OPAQUE},
01306         {SMB_VFS_OP(vfswrap_get_nt_acl),        SMB_VFS_OP_GET_NT_ACL,
01307          SMB_VFS_LAYER_OPAQUE},
01308         {SMB_VFS_OP(vfswrap_fset_nt_acl),       SMB_VFS_OP_FSET_NT_ACL,
01309          SMB_VFS_LAYER_OPAQUE},
01310         {SMB_VFS_OP(vfswrap_set_nt_acl),        SMB_VFS_OP_SET_NT_ACL,
01311          SMB_VFS_LAYER_OPAQUE},
01312 
01313         /* POSIX ACL operations. */
01314 
01315         {SMB_VFS_OP(vfswrap_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
01316          SMB_VFS_LAYER_OPAQUE},
01317         {SMB_VFS_OP(vfswrap_fchmod_acl),        SMB_VFS_OP_FCHMOD_ACL,
01318          SMB_VFS_LAYER_OPAQUE},
01319         {SMB_VFS_OP(vfswrap_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
01320          SMB_VFS_LAYER_OPAQUE},
01321         {SMB_VFS_OP(vfswrap_sys_acl_get_tag_type),      SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
01322          SMB_VFS_LAYER_OPAQUE},
01323         {SMB_VFS_OP(vfswrap_sys_acl_get_permset),       SMB_VFS_OP_SYS_ACL_GET_PERMSET,
01324          SMB_VFS_LAYER_OPAQUE},
01325         {SMB_VFS_OP(vfswrap_sys_acl_get_qualifier),     SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
01326          SMB_VFS_LAYER_OPAQUE},
01327         {SMB_VFS_OP(vfswrap_sys_acl_get_file),  SMB_VFS_OP_SYS_ACL_GET_FILE,
01328          SMB_VFS_LAYER_OPAQUE},
01329         {SMB_VFS_OP(vfswrap_sys_acl_get_fd),    SMB_VFS_OP_SYS_ACL_GET_FD,
01330          SMB_VFS_LAYER_OPAQUE},
01331         {SMB_VFS_OP(vfswrap_sys_acl_clear_perms),       SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
01332          SMB_VFS_LAYER_OPAQUE},
01333         {SMB_VFS_OP(vfswrap_sys_acl_add_perm),  SMB_VFS_OP_SYS_ACL_ADD_PERM,
01334          SMB_VFS_LAYER_OPAQUE},
01335         {SMB_VFS_OP(vfswrap_sys_acl_to_text),   SMB_VFS_OP_SYS_ACL_TO_TEXT,
01336          SMB_VFS_LAYER_OPAQUE},
01337         {SMB_VFS_OP(vfswrap_sys_acl_init),      SMB_VFS_OP_SYS_ACL_INIT,
01338          SMB_VFS_LAYER_OPAQUE},
01339         {SMB_VFS_OP(vfswrap_sys_acl_create_entry),      SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
01340          SMB_VFS_LAYER_OPAQUE},
01341         {SMB_VFS_OP(vfswrap_sys_acl_set_tag_type),      SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
01342          SMB_VFS_LAYER_OPAQUE},
01343         {SMB_VFS_OP(vfswrap_sys_acl_set_qualifier),     SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
01344          SMB_VFS_LAYER_OPAQUE},
01345         {SMB_VFS_OP(vfswrap_sys_acl_set_permset),       SMB_VFS_OP_SYS_ACL_SET_PERMSET,
01346          SMB_VFS_LAYER_OPAQUE},
01347         {SMB_VFS_OP(vfswrap_sys_acl_valid),     SMB_VFS_OP_SYS_ACL_VALID,
01348          SMB_VFS_LAYER_OPAQUE},
01349         {SMB_VFS_OP(vfswrap_sys_acl_set_file),  SMB_VFS_OP_SYS_ACL_SET_FILE,
01350          SMB_VFS_LAYER_OPAQUE},
01351         {SMB_VFS_OP(vfswrap_sys_acl_set_fd),    SMB_VFS_OP_SYS_ACL_SET_FD,
01352          SMB_VFS_LAYER_OPAQUE},
01353         {SMB_VFS_OP(vfswrap_sys_acl_delete_def_file),   SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
01354          SMB_VFS_LAYER_OPAQUE},
01355         {SMB_VFS_OP(vfswrap_sys_acl_get_perm),  SMB_VFS_OP_SYS_ACL_GET_PERM,
01356          SMB_VFS_LAYER_OPAQUE},
01357         {SMB_VFS_OP(vfswrap_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
01358          SMB_VFS_LAYER_OPAQUE},
01359         {SMB_VFS_OP(vfswrap_sys_acl_free_acl),  SMB_VFS_OP_SYS_ACL_FREE_ACL,
01360          SMB_VFS_LAYER_OPAQUE},
01361         {SMB_VFS_OP(vfswrap_sys_acl_free_qualifier),    SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
01362          SMB_VFS_LAYER_OPAQUE},
01363 
01364         /* EA operations. */
01365 
01366         {SMB_VFS_OP(vfswrap_getxattr),  SMB_VFS_OP_GETXATTR,
01367          SMB_VFS_LAYER_OPAQUE},
01368         {SMB_VFS_OP(vfswrap_lgetxattr), SMB_VFS_OP_LGETXATTR,
01369          SMB_VFS_LAYER_OPAQUE},
01370         {SMB_VFS_OP(vfswrap_fgetxattr), SMB_VFS_OP_FGETXATTR,
01371          SMB_VFS_LAYER_OPAQUE},
01372         {SMB_VFS_OP(vfswrap_listxattr), SMB_VFS_OP_LISTXATTR,
01373          SMB_VFS_LAYER_OPAQUE},
01374         {SMB_VFS_OP(vfswrap_llistxattr),        SMB_VFS_OP_LLISTXATTR,
01375          SMB_VFS_LAYER_OPAQUE},
01376         {SMB_VFS_OP(vfswrap_flistxattr),        SMB_VFS_OP_FLISTXATTR,
01377          SMB_VFS_LAYER_OPAQUE},
01378         {SMB_VFS_OP(vfswrap_removexattr),       SMB_VFS_OP_REMOVEXATTR,
01379          SMB_VFS_LAYER_OPAQUE},
01380         {SMB_VFS_OP(vfswrap_lremovexattr),      SMB_VFS_OP_LREMOVEXATTR,
01381          SMB_VFS_LAYER_OPAQUE},
01382         {SMB_VFS_OP(vfswrap_fremovexattr),      SMB_VFS_OP_FREMOVEXATTR,
01383          SMB_VFS_LAYER_OPAQUE},
01384         {SMB_VFS_OP(vfswrap_setxattr),  SMB_VFS_OP_SETXATTR,
01385          SMB_VFS_LAYER_OPAQUE},
01386         {SMB_VFS_OP(vfswrap_lsetxattr), SMB_VFS_OP_LSETXATTR,
01387          SMB_VFS_LAYER_OPAQUE},
01388         {SMB_VFS_OP(vfswrap_fsetxattr), SMB_VFS_OP_FSETXATTR,
01389          SMB_VFS_LAYER_OPAQUE},
01390 
01391         {SMB_VFS_OP(vfswrap_aio_read),  SMB_VFS_OP_AIO_READ,
01392          SMB_VFS_LAYER_OPAQUE},
01393         {SMB_VFS_OP(vfswrap_aio_write), SMB_VFS_OP_AIO_WRITE,
01394          SMB_VFS_LAYER_OPAQUE},
01395         {SMB_VFS_OP(vfswrap_aio_return),        SMB_VFS_OP_AIO_RETURN,
01396          SMB_VFS_LAYER_OPAQUE},
01397         {SMB_VFS_OP(vfswrap_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
01398          SMB_VFS_LAYER_OPAQUE},
01399         {SMB_VFS_OP(vfswrap_aio_error), SMB_VFS_OP_AIO_ERROR,
01400          SMB_VFS_LAYER_OPAQUE},
01401         {SMB_VFS_OP(vfswrap_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
01402          SMB_VFS_LAYER_OPAQUE},
01403         {SMB_VFS_OP(vfswrap_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
01404          SMB_VFS_LAYER_OPAQUE},
01405 
01406         /* Finish VFS operations definition */
01407 
01408         {SMB_VFS_OP(NULL),              SMB_VFS_OP_NOOP,
01409          SMB_VFS_LAYER_NOOP}
01410 };
01411 
01412 NTSTATUS vfs_default_init(void);
01413 NTSTATUS vfs_default_init(void)
01414 {
01415         unsigned int needed = SMB_VFS_OP_LAST + 1; /* convert from index to count */
01416 
01417         if (ARRAY_SIZE(vfs_default_ops) != needed) {
01418                 DEBUG(0, ("%s: %u ops registered, but %u ops are required\n",
01419                         DEFAULT_VFS_MODULE_NAME, (unsigned int)ARRAY_SIZE(vfs_default_ops), needed));
01420                 smb_panic("operation(s) missing from default VFS module");
01421         }
01422 
01423         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
01424                                 DEFAULT_VFS_MODULE_NAME, vfs_default_ops);
01425 }

Sambaに対してSat Aug 29 21:23:07 2009に生成されました。  doxygen 1.4.7