libndr: Avoid assigning duplicate versions to symbols
[amitay/samba.git] / source3 / modules / vfs_prealloc.c
index 73f1a9322ff634cf3c5c0bb4b65057dd5d54df90..bbb5e55897b19b800ba219bbd942fe880b856c7b 100644 (file)
@@ -20,7 +20,6 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "smbd/smbd.h"
-#include "system/filesys.h"
 
 /* Extent preallocation module.
  *
 #define lock_type struct flock64
 #endif
 
-#ifdef HAVE_GPFS
-#include "gpfs_gpl.h"
-#endif
-
 #define MODULE "prealloc"
 static int module_debug;
 
-static int preallocate_space(int fd, SMB_OFF_T size)
+static int preallocate_space(int fd, off_t size)
 {
        int err;
-#ifndef HAVE_GPFS
        lock_type fl = {0};
 
        if (size <= 0) {
@@ -86,10 +80,6 @@ static int preallocate_space(int fd, SMB_OFF_T size)
        err = -1;
        errno = ENOSYS;
 #endif
-#else /* GPFS uses completely different interface */
-       err = gpfs_prealloc(fd, (gpfs_off64_t)0, (gpfs_off64_t)size);
-#endif
-
        if (err) {
                DEBUG(module_debug,
                        ("%s: preallocate failed on fd=%d size=%lld: %s\n",
@@ -116,15 +106,15 @@ static int prealloc_connect(
        return 0;
 }
 
-static int prealloc_open(vfs_handle_struct* handle,
-                       struct smb_filename *smb_fname,
-                       files_struct *      fsp,
-                       int                 flags,
-                       mode_t              mode)
+static int prealloc_openat(struct vfs_handle_struct* handle,
+                          const struct files_struct *dirfsp,
+                          const struct smb_filename *smb_fname,
+                          files_struct *fsp,
+                          int flags,
+                          mode_t mode)
 {
        int fd;
-       off64_t size = 0;
-
+       off_t size = 0;
        const char * dot;
        char fext[10];
 
@@ -140,7 +130,9 @@ static int prealloc_open(vfs_handle_struct* handle,
        if (dot && *++dot) {
                if (strlen(dot) < sizeof(fext)) {
                        strncpy(fext, dot, sizeof(fext));
-                       strnorm(fext, CASE_LOWER);
+                       if (!strnorm(fext, CASE_LOWER)) {
+                               goto normal_open;
+                       }
                }
        }
 
@@ -161,7 +153,7 @@ static int prealloc_open(vfs_handle_struct* handle,
                goto normal_open;
        }
 
-       fd = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
+       fd = SMB_VFS_NEXT_OPENAT(handle, dirfsp, smb_fname, fsp, flags, mode);
        if (fd < 0) {
                return fd;
        }
@@ -171,9 +163,9 @@ static int prealloc_open(vfs_handle_struct* handle,
         * truncate calls specially.
         */
        if ((flags & O_CREAT) || (flags & O_TRUNC)) {
-               SMB_OFF_T * psize;
+               off_t * psize;
 
-               psize = VFS_ADD_FSP_EXTENSION(handle, fsp, SMB_OFF_T, NULL);
+               psize = VFS_ADD_FSP_EXTENSION(handle, fsp, off_t, NULL);
                if (psize == NULL || *psize == -1) {
                        return fd;
                }
@@ -197,14 +189,14 @@ normal_open:
         */
        DEBUG(module_debug, ("%s: skipping preallocation for %s\n",
                MODULE, smb_fname_str_dbg(smb_fname)));
-       return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
+       return SMB_VFS_NEXT_OPENAT(handle, dirfsp, smb_fname, fsp, flags, mode);
 }
 
 static int prealloc_ftruncate(vfs_handle_struct * handle,
                        files_struct *  fsp,
-                       SMB_OFF_T       offset)
+                       off_t   offset)
 {
-       SMB_OFF_T *psize;
+       off_t *psize;
        int ret = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
 
        /* Maintain the allocated space even in the face of truncates. */
@@ -216,13 +208,13 @@ static int prealloc_ftruncate(vfs_handle_struct * handle,
 }
 
 static struct vfs_fn_pointers prealloc_fns = {
-       .open_fn = prealloc_open,
-       .ftruncate = prealloc_ftruncate,
+       .openat_fn = prealloc_openat,
+       .ftruncate_fn = prealloc_ftruncate,
        .connect_fn = prealloc_connect,
 };
 
-NTSTATUS vfs_prealloc_init(void);
-NTSTATUS vfs_prealloc_init(void)
+static_decl_vfs;
+NTSTATUS vfs_prealloc_init(TALLOC_CTX *ctx)
 {
        return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
                                MODULE, &prealloc_fns);