summaryrefslogtreecommitdiff
path: root/source3/smbd/fileio.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-05-24 04:55:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:58 -0500
commit0ef417d9583154a261ae8c4b01f23c29a9110ca1 (patch)
tree9bca1701a3b251c7264a0d7666839173bc080830 /source3/smbd/fileio.c
parent85abe083670fb059644da80a4d518d90a6fd23f9 (diff)
downloadsamba-0ef417d9583154a261ae8c4b01f23c29a9110ca1.tar.gz
samba-0ef417d9583154a261ae8c4b01f23c29a9110ca1.tar.bz2
samba-0ef417d9583154a261ae8c4b01f23c29a9110ca1.zip
r6949: Back-port Volker's cache fix, plus my change.
Jeremy. (This used to be commit 27d43f6d36b3f6abc368ec6a00ef9803cb27c324)
Diffstat (limited to 'source3/smbd/fileio.c')
-rw-r--r--source3/smbd/fileio.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 9b39bf8fe1..69b8b57642 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -509,6 +509,44 @@ nonop=%u allocated=%u active=%u direct=%u perfect=%u readhits=%u\n",
write_path = 3;
+ } else if ( (pos >= wcp->file_size) &&
+ (n == 1) &&
+ (pos < wcp->offset + 2*wcp->alloc_size) &&
+ (wcp->file_size == wcp->offset + wcp->data_size)) {
+
+ /*
+ +---------------+
+ | Cached data |
+ +---------------+
+
+ +--------+
+ | 1 Byte |
+ +--------+
+
+ MS-Office seems to do this a lot to determine if there's enough
+ space on the filesystem to write a new file.
+ */
+
+ SMB_BIG_UINT new_start = wcp->offset + wcp->data_size;
+
+ flush_write_cache(fsp, WRITE_FLUSH);
+ wcp->offset = new_start;
+ wcp->data_size = pos - new_start + 1;
+ memset(wcp->data, '\0', wcp->data_size);
+ memcpy(wcp->data + wcp->data_size-1, data, 1);
+
+ /*
+ * Update the file size if changed.
+ */
+
+ if (wcp->offset + wcp->data_size > wcp->file_size) {
+ if (wcp_file_size_change(fsp) == -1) {
+ return -1;
+ }
+ }
+
+ return n;
+
} else {
/* ASCII art..... JRA.