Preallocated file size...

Luis Claudio R. Goncalves lclaudio at conectiva.com.br
Tue Feb 8 17:01:37 GMT 2000


Hi!

    Following this message there's a little patch that "corrects" a weird
behavior (or feature) of reply.c - at least in Linux and Solaris boxes.
    If you're writing a file in the disk and you reach the quota roof, the
file will be truncated and zero filled 'till its nominal size - it isn't
a Samba problem, it's a filesystem feature. This simple and ugly patch corrects
the truncated file size every time the above scene happens to any user.
    This patch was released last year and it works fine on 1.9.19 and
2.x . I haven't tested it aginst TNG...

					Hope this helps.

							Luis Claudio

[ Luis Claudio R. Goncalves                  lclaudio at conectiva.com.br ]
[ BSc in Computer Science -- MSc coming soon -- Gospel User -- Linuxer ]
[ Fault Tolerance - Real-Time - Distributed Systems - IECLB - IS 40:31 ]
[ LateNite Programmer --  Jesus Is The Solid Rock On Which I Stand  -- ]


# -----------------cut here--------------------
--- source/smbd/reply.c.orig	Thu Feb 25 16:22:59 1999
+++ source/smbd/reply.c	Thu Feb 25 16:24:56 1999
@@ -2399,14 +2399,21 @@
   if (lp_syncalways(SNUM(conn)))
     sync_file(conn,fsp);
 
-  if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0))
+  if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0))  { 
+    nwritten = set_filelen(fsp->fd_ptr->fd, (SMB_OFF_T)startpos);
+    DEBUG(0,("REPLY.C: File [%s] truncated to %d bytes\n",
+	fsp->fsp_name, (SMB_OFF_T)startpos));
     return(UNIXERROR(ERRDOS,ERRnoaccess));
+  }
 
   outsize = set_message(outbuf,1,0,True);
   
   SSVAL(outbuf,smb_vwv0,nwritten);
 
   if (nwritten < (ssize_t)numtowrite) {
+    nwritten = set_filelen(fsp->fd_ptr->fd, (SMB_OFF_T)startpos + nwritten);
+    DEBUG(0,("REPLY.C: File [%s] truncated to %d bytes\n",
+	fsp->fsp_name, (SMB_OFF_T)startpos));
     CVAL(outbuf,smb_rcls) = ERRHRD;
     SSVAL(outbuf,smb_err,ERRdiskfull);      
   }






More information about the samba-technical mailing list