preallocated file size

David Collier-Brown davecb at
Mon Feb 7 16:00:00 GMT 2000

Andreas Abach wrote:
> There is still another bug in Samba. When writing a file to share that
> is larger than the free space on the disk the file is allocated with
> its full length. During the copy process you'll get an error, but the
> file will be left on the samba-share and it will be reported with it's
> original size. A full report can be read at
> The same happens when quotas are
> used. I send this problem to this list some weeks ago, but it seams to
> unimportant to the mass.

	It's being discussed, but Jeremy is away and many of the
	other chaps are buried in work.

	Thanks for the complete writeup: would you be kind 
	enough to put a log of the connection
	up on the web site, so we can compare it with the
	log from win95?  I'm willing to try to fix it, with
	a little help from real experts like Richard.

	My initial thoughts go like this:

typedef struct file_fd_struct { 
   BOOL check_for_write_at_end;
} file_fd_struct;

in smbd/open.c open_file()
        fds->check_for_write_at_end = True;

in <the initial write>
        if ( fds->check_for_write_at_end == True 
            && requested_position != 0) {
                /* Then application was writing the last block */
                /* of the file first to see if we have enough space.

                fds->check_for_write_at_end == False;

                length = requested_position + len;
                (void) fstatvfs(fds->fd, buf);
                if (length >= (buf.f_bavail*buf.f_frsize)) {
                        /* Then the copy will fail eventually, so */
                        /* report it now. This will avoid NT (Win2K)
                        /* assuming it can't fail, and then */
                        /* running out of space. The latter leaves */
                        /* files full of nulls as the result of a */
                        /* "successful" copy. */

David Collier-Brown,  | Always do right. This will gratify some people
185 Ellerslie Ave.,   | and astonish the rest.        -- Mark Twain
Willowdale, Ontario   | //
Work: (905) 415-2849 Home: (416) 223-8968 Email: davecb at

More information about the samba-technical mailing list