summaryrefslogtreecommitdiff
path: root/source3/smbd/fileio.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-01-06 01:21:59 +0000
committerJeremy Allison <jra@samba.org>2004-01-06 01:21:59 +0000
commit827c68deb89b5bd14324c57db14274b36a0790d7 (patch)
tree018ea2e604f64a73899744fced6a41086c90e512 /source3/smbd/fileio.c
parent35f843a1be9a703328eee3241bc24416cca945e0 (diff)
downloadsamba-827c68deb89b5bd14324c57db14274b36a0790d7.tar.gz
samba-827c68deb89b5bd14324c57db14274b36a0790d7.tar.bz2
samba-827c68deb89b5bd14324c57db14274b36a0790d7.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 3a24dc868d95c9bcc2ac3a0dbd50e6e226ac0841)
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 ));