summaryrefslogtreecommitdiff
path: root/source/smbd/fileio.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/smbd/fileio.c')
-rw-r--r--source/smbd/fileio.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/source/smbd/fileio.c b/source/smbd/fileio.c
index 1227d12b08e..a5f8242d06e 100644
--- a/source/smbd/fileio.c
+++ b/source/smbd/fileio.c
@@ -509,15 +509,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 |
@@ -525,13 +530,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);