Replace lseek()/write()/lseek() triple with pwrite call. We already emulate this
authorJeremy Allison <jra@samba.org>
Fri, 3 Dec 2010 01:52:11 +0000 (17:52 -0800)
committerJeremy Allison <jra@samba.org>
Fri, 3 Dec 2010 02:39:42 +0000 (03:39 +0100)
inside pwrite under the covers.

Jeremy.

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Fri Dec  3 03:39:42 CET 2010 on sn-devel-104

source3/modules/vfs_default.c

index 79f66db6d926378fa0143f7dad73abd196d3fe2e..648aa34fcc3f4d7a6fdd442f3b4a7e00c44d8e33 100644 (file)
@@ -886,7 +886,6 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_O
        int result = -1;
        SMB_STRUCT_STAT st;
        char c = 0;
-       SMB_OFF_T currpos;
 
        START_PROFILE(syscall_ftruncate);
 
@@ -909,10 +908,6 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_O
        /* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
           extend a file with ftruncate. Provide alternate implementation
           for this */
-       currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
-       if (currpos == -1) {
-               goto done;
-       }
 
        /* Do an fstat to see if the file is longer than the requested
           size in which case the ftruncate above should have
@@ -939,15 +934,10 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_O
                goto done;
        }
 
-       if (SMB_VFS_LSEEK(fsp, len-1, SEEK_SET) != len -1)
-               goto done;
-
-       if (SMB_VFS_WRITE(fsp, &c, 1)!=1)
+       if (SMB_VFS_PWRITE(fsp, &c, 1, len-1)!=1) {
                goto done;
+       }
 
-       /* Seek to where we were */
-       if (SMB_VFS_LSEEK(fsp, currpos, SEEK_SET) != currpos)
-               goto done;
        result = 0;
 
   done: