print_job_end(SNUM(fsp->conn),jobid, close_type);
}
+
+/****************************************************************************
+ Discovered by Sebastian Kloska <oncaphillis@snafu.de>. When print files
+ go beyond 4GB, the 32-bit offset sent in old SMBwrite calls is relative
+ to the current 4GB chunk we're writing to.
+****************************************************************************/
+
+SMB_OFF_T printfile_offset(files_struct *fsp, SMB_OFF_T offset)
+{
+ SMB_STRUCT_STAT st;
+
+ if (sys_fstat(fsp->fh->fd, &st, false) == -1) {
+ DEBUG(3,("printfile_offset: sys_fstat failed on %s (%s)\n",
+ fsp_str_dbg(fsp),
+ strerror(errno) ));
+ return offset;
+ }
+
+ return (st.st_ex_size & 0xffffffff00000000LL) + offset;
+}
return;
}
- if (!fsp->print_file) {
+ if (fsp->print_file) {
+ startpos = printfile_offset(fsp, startpos);
+ } else {
init_strict_lock_struct(fsp, (uint32)req->smbpid,
(uint64_t)startpos, (uint64_t)tcount, WRITE_LOCK,
&lock);
startpos = IVAL_TO_SMB_OFF_T(req->vwv+2, 0);
data = (const char *)req->buf + 3;
- if (numtowrite && !fsp->print_file) {
+ if (fsp->print_file) {
+ startpos = printfile_offset(fsp, startpos);
+ } else if (numtowrite) {
init_strict_lock_struct(fsp, (uint32)req->smbpid,
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&lock);
startpos = IVAL_TO_SMB_OFF_T(req->vwv+2, 0);
data = (const char *)req->buf + 3;
- if (!fsp->print_file) {
+ if (fsp->print_file) {
+ startpos = printfile_offset(fsp, startpos);
+ } else {
init_strict_lock_struct(fsp, (uint32)req->smbpid,
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&lock);
mtime = convert_time_t_to_timespec(srv_make_unix_date3(req->vwv+4));
data = (const char *)req->buf + 1;
- if (numtowrite && !fsp->print_file) {
+ if (fsp->print_file) {
+ startpos = printfile_offset(fsp, startpos);
+ } else if (numtowrite) {
init_strict_lock_struct(fsp, (uint32)req->smbpid,
(uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
&lock);