summaryrefslogtreecommitdiff
path: root/source3/smbd/fileio.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-01-06 01:22:14 +0000
committerJeremy Allison <jra@samba.org>2004-01-06 01:22:14 +0000
commit0d44747df99f2168a063feedad5039f222746f61 (patch)
tree0ddeca47e4408a6fb7b86357a128caac373f028e /source3/smbd/fileio.c
parent1fa073b55bca9bbc66b86e652e491cc44656071e (diff)
downloadsamba-0d44747df99f2168a063feedad5039f222746f61.tar.gz
samba-0d44747df99f2168a063feedad5039f222746f61.tar.bz2
samba-0d44747df99f2168a063feedad5039f222746f61.zip
Patch based on work from James Peach <jpeach@sgi.com> to convert over to
using pread/pwrite. Modified a little to ensure fsp->pos is correct. Fix for #889. Jeremy. (This used to be commit 019aaaf0df091c3f67048f591e70d4353a02bb9b)
Diffstat (limited to 'source3/smbd/fileio.c')
-rw-r--r--source3/smbd/fileio.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 84339c3a6f..f395954d05 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -95,16 +95,14 @@ ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n)
flush_write_cache(fsp, READ_FLUSH);
- if (seek_file(fsp,pos) == -1) {
- DEBUG(3,("read_file: Failed to seek to %.0f\n",(double)pos));
- return(ret);
- }
-
+ fsp->pos = pos;
+
if (n > 0) {
#ifdef DMF_FIX
int numretries = 3;
tryagain:
- readret = SMB_VFS_READ(fsp,fsp->fd,data,n);
+ readret = SMB_VFS_PREAD(fsp,fsp->fd,data,n,pos);
+
if (readret == -1) {
if ((errno == EAGAIN) && numretries) {
DEBUG(3,("read_file EAGAIN retry in 10 seconds\n"));
@@ -115,7 +113,8 @@ tryagain:
return -1;
}
#else /* NO DMF fix. */
- readret = SMB_VFS_READ(fsp,fsp->fd,data,n);
+ readret = SMB_VFS_PREAD(fsp,fsp->fd,data,n,pos);
+
if (readret == -1)
return -1;
#endif
@@ -143,10 +142,12 @@ static ssize_t real_write_file(files_struct *fsp,char *data,SMB_OFF_T pos, size_
{
ssize_t ret;
- if ((pos != -1) && (seek_file(fsp,pos) == -1))
- return -1;
-
- ret = vfs_write_data(fsp,data,n);
+ if (pos == -1)
+ ret = vfs_write_data(fsp, data, n);
+ else {
+ fsp->pos = pos;
+ ret = vfs_pwrite_data(fsp, data, n, pos);
+ }
DEBUG(10,("real_write_file (%s): pos = %.0f, size = %lu, returned %ld\n",
fsp->fsp_name, (double)pos, (unsigned long)n, (long)ret ));