diff options
author | Jeremy Allison <jra@samba.org> | 2005-05-24 04:55:18 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2005-05-24 04:55:18 +0000 |
commit | 36c04d30f2ec740da24f74d02398cd795ffaa5a4 (patch) | |
tree | f0437392e5238daec597e842cc0f42ec61ea18d5 | |
parent | 53d97d9d3efd244965152e4715d893a57c503fa1 (diff) | |
download | samba-36c04d30f2ec740da24f74d02398cd795ffaa5a4.tar.gz samba-36c04d30f2ec740da24f74d02398cd795ffaa5a4.tar.xz samba-36c04d30f2ec740da24f74d02398cd795ffaa5a4.zip |
r6949: Back-port Volker's cache fix, plus my change.
Jeremy.
-rw-r--r-- | source/smbd/fileio.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/smbd/fileio.c b/source/smbd/fileio.c index 9b39bf8fe1e..69b8b576428 100644 --- a/source/smbd/fileio.c +++ b/source/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. |