Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/smbd/fileio.c

    r590 r745  
    2121
    2222#include "includes.h"
     23#include "printing.h"
     24#include "smbd/smbd.h"
    2325#include "smbd/globals.h"
     26#include "smbprofile.h"
    2427
    2528static bool setup_write_cache(files_struct *, SMB_OFF_T);
     
    128131        } else {
    129132                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)) {
    131135                        if (vfs_fill_sparse(fsp, pos) == -1) {
    132136                                return -1;
     
    292296
    293297        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;
    300304                        return -1;
    301305                }
    302 
    303                 return print_job_write(SNUM(fsp->conn), jobid, data, pos, n);
     306                return t;
    304307        }
    305308
     
    320323                                if (!IS_DOS_ARCHIVE(dosmode)) {
    321324                                        file_set_dosmode(fsp->conn, fsp->fsp_name,
    322                                                  dosmode | aARCH, NULL, false);
     325                                                 dosmode | FILE_ATTRIBUTE_ARCHIVE, NULL, false);
    323326                                }
    324327                        }
     
    403406        fsp->fh->pos = pos + n;
    404407
     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
    405439        /*
    406440         * If we have active cache and it isn't contiguous then we flush.
     
    794828                }
    795829#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
    796850                memcpy(wcp->data+wcp->data_size, data, n);
    797851                if (wcp->data_size == 0) {
Note: See TracChangeset for help on using the changeset viewer.