Changeset 745 for trunk/server/source3/smbd/fileio.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/smbd/fileio.c
r590 r745 21 21 22 22 #include "includes.h" 23 #include "printing.h" 24 #include "smbd/smbd.h" 23 25 #include "smbd/globals.h" 26 #include "smbprofile.h" 24 27 25 28 static bool setup_write_cache(files_struct *, SMB_OFF_T); … … 128 131 } else { 129 132 fsp->fh->pos = pos; 130 if (pos && lp_strict_allocate(SNUM(fsp->conn))) { 133 if (pos && lp_strict_allocate(SNUM(fsp->conn) && 134 !fsp->is_sparse)) { 131 135 if (vfs_fill_sparse(fsp, pos) == -1) { 132 136 return -1; … … 292 296 293 297 if (fsp->print_file) { 294 uint32 jobid;295 296 if (!rap_to_pjobid(fsp->rap_print_jobid, NULL, &jobid)) { 297 DEBUG(3,("write_file: Unable to map RAP jobid %u to jobid.\n",298 (unsigned int)fsp->rap_print_jobid ));299 errno = EBADF;298 uint32_t t; 299 int ret; 300 301 ret = print_spool_write(fsp, data, n, pos, &t); 302 if (ret) { 303 errno = ret; 300 304 return -1; 301 305 } 302 303 return print_job_write(SNUM(fsp->conn), jobid, data, pos, n); 306 return t; 304 307 } 305 308 … … 320 323 if (!IS_DOS_ARCHIVE(dosmode)) { 321 324 file_set_dosmode(fsp->conn, fsp->fsp_name, 322 dosmode | aARCH, NULL, false);325 dosmode | FILE_ATTRIBUTE_ARCHIVE, NULL, false); 323 326 } 324 327 } … … 403 406 fsp->fh->pos = pos + n; 404 407 408 if ((n == 1) && (data[0] == '\0') && (pos > wcp->file_size)) { 409 int ret; 410 411 /* 412 * This is a 1-byte write of a 0 beyond the EOF and 413 * thus implicitly also beyond the current active 414 * write cache, the typical file-extending (and 415 * allocating, but we're using the write cache here) 416 * write done by Windows. We just have to ftruncate 417 * the file and rely on posix semantics to return 418 * zeros for non-written file data that is within the 419 * file length. 420 * 421 * We can not use wcp_file_size_change here because we 422 * might have an existing write cache, and 423 * wcp_file_size_change assumes a change to just the 424 * end of the current write cache. 425 */ 426 427 wcp->file_size = pos + 1; 428 ret = SMB_VFS_FTRUNCATE(fsp, wcp->file_size); 429 if (ret == -1) { 430 DEBUG(0,("wcp_file_size_change (%s): ftruncate of size %.0f" 431 "error %s\n", fsp_str_dbg(fsp), 432 (double)wcp->file_size, strerror(errno))); 433 return -1; 434 } 435 return 1; 436 } 437 438 405 439 /* 406 440 * If we have active cache and it isn't contiguous then we flush. … … 794 828 } 795 829 #endif 830 831 if ((wcp->data_size == 0) 832 && (pos > wcp->file_size) 833 && (pos + n <= wcp->file_size + wcp->alloc_size)) { 834 /* 835 * This is a write completely beyond the 836 * current EOF, but within reach of the write 837 * cache. We expect fill-up writes pretty 838 * soon, so it does not make sense to start 839 * the write cache at the current 840 * offset. These fill-up writes would trigger 841 * separate pwrites or even unnecessary cache 842 * flushes because they overlap if this is a 843 * one-byte allocating write. 844 */ 845 wcp->offset = wcp->file_size; 846 wcp->data_size = pos - wcp->file_size; 847 memset(wcp->data, 0, wcp->data_size); 848 } 849 796 850 memcpy(wcp->data+wcp->data_size, data, n); 797 851 if (wcp->data_size == 0) {
Note:
See TracChangeset
for help on using the changeset viewer.