summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/fileio.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index e797dbda14..76b29ec998 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -508,15 +508,20 @@ nonop=%u allocated=%u active=%u direct=%u perfect=%u readhits=%u\n",
write_path = 3;
- } else if ( (pos >= wcp->file_size) &&
+ } else if ( (pos >= wcp->file_size) &&
(n == 1) &&
- (pos < wcp->offset + 2*wcp->alloc_size) &&
- (wcp->file_size == wcp->offset + wcp->data_size)) {
+ (wcp->file_size == wcp->offset + wcp->data_size) &&
+ (pos < wcp->file_size + wcp->alloc_size)) {
/*
- +---------------+
- | Cached data |
- +---------------+
+
+ End of file ---->|
+
+ +---------------+---------------+
+ | Cached data | Cache buffer |
+ +---------------+---------------+
+
+ |<------- allocated size ---------------->|
+--------+
| 1 Byte |
@@ -524,13 +529,18 @@ nonop=%u allocated=%u active=%u direct=%u perfect=%u readhits=%u\n",
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;
+ Change to :
+
+ End of file ---->|
+ +-----------------------+--------+
+ | Zeroed Cached data | 1 Byte |
+ +-----------------------+--------+
+ */
flush_write_cache(fsp, WRITE_FLUSH);
- wcp->offset = new_start;
- wcp->data_size = pos - new_start + 1;
+ wcp->offset = wcp->file_size;
+ wcp->data_size = pos - wcp->file_size + 1;
memset(wcp->data, '\0', wcp->data_size);
memcpy(wcp->data + wcp->data_size-1, data, 1);