summaryrefslogtreecommitdiff
path: root/source3/smbd/fileio.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-08-14 21:16:06 +0000
committerJeremy Allison <jra@samba.org>2003-08-14 21:16:06 +0000
commit4e8b36a5749f4801022617b8fec1fe5d48529fef (patch)
tree8075e7b7c5ca55b0ae5e82fe9fc9de9b551763fb /source3/smbd/fileio.c
parent11777e6a3085a996ab2c5fa3db34d8834401c24e (diff)
downloadsamba-4e8b36a5749f4801022617b8fec1fe5d48529fef.tar.gz
samba-4e8b36a5749f4801022617b8fec1fe5d48529fef.tar.bz2
samba-4e8b36a5749f4801022617b8fec1fe5d48529fef.zip
Fix SMBseek and get/set position information SMBs. Works against
Samba4 tester. You will need a make clean; make all after this ! Jeremy. (This used to be commit 10d90171ed58bee3e5ab6476341059b585034134)
Diffstat (limited to 'source3/smbd/fileio.c')
-rw-r--r--source3/smbd/fileio.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 6be5f6af7d..6cf7014846 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -87,8 +87,11 @@ ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n)
* Serve from write cache if we can.
*/
- if(read_from_write_cache(fsp, data, pos, n))
+ if(read_from_write_cache(fsp, data, pos, n)) {
+ fsp->pos = pos + n;
+ fsp->position_information = fsp->pos;
return n;
+ }
flush_write_cache(fsp, READ_FLUSH);
@@ -123,6 +126,9 @@ tryagain:
DEBUG(10,("read_file (%s): pos = %.0f, size = %lu, returned %lu\n",
fsp->fsp_name, (double)pos, (unsigned long)n, (long)ret ));
+ fsp->pos += ret;
+ fsp->position_information = fsp->pos;
+
return(ret);
}
@@ -145,6 +151,16 @@ static ssize_t real_write_file(files_struct *fsp,char *data,SMB_OFF_T pos, size_
DEBUG(10,("real_write_file (%s): pos = %.0f, size = %lu, returned %ld\n",
fsp->fsp_name, (double)pos, (unsigned long)n, (long)ret ));
+ if (ret != -1) {
+ fsp->pos += ret;
+
+/* Yes - this is correct - writes don't update this. JRA. */
+/* Found by Samba4 tests. */
+#if 0
+ fsp->position_information = fsp->pos;
+#endif
+ }
+
return ret;
}
@@ -244,7 +260,7 @@ nonop=%u allocated=%u active=%u direct=%u perfect=%u readhits=%u\n",
if(!wcp) {
DO_PROFILE_INC(writecache_direct_writes);
total_written = real_write_file(fsp, data, pos, n);
- if ((total_written != -1) && (pos + total_written > (SMB_OFF_T)fsp->size))
+ if ((total_written != -1) && (pos + total_written > (SMB_OFF_T)fsp->size))
fsp->size = (SMB_BIG_UINT)(pos + total_written);
return total_written;
}
@@ -252,6 +268,8 @@ nonop=%u allocated=%u active=%u direct=%u perfect=%u readhits=%u\n",
DEBUG(9,("write_file (%s)(fd=%d pos=%.0f size=%u) wcp->offset=%.0f wcp->data_size=%u\n",
fsp->fsp_name, fsp->fd, (double)pos, (unsigned int)n, (double)wcp->offset, (unsigned int)wcp->data_size));
+ fsp->pos = pos + n;
+
/*
* If we have active cache and it isn't contiguous then we flush.
* NOTE: There is a small problem with running out of disk ....