diff -uNrp samba-3.2.6.org/source/smbd/vfs.c samba-3.2.6/source/smbd/vfs.c --- samba-3.2.6.org/source/smbd/vfs.c 2008-12-10 20:12:23.000000000 +0900 +++ samba-3.2.6/source/smbd/vfs.c 2008-12-22 13:54:54.000000000 +0900 @@ -575,6 +575,20 @@ int vfs_allocate_file_space(files_struct int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len) { int ret; + connection_struct *conn = fsp->conn; + SMB_BIG_UINT space_avail; + SMB_BIG_UINT bsize,dfree,dsize; + + /* available disk space is enough or not? */ + if (lp_strict_allocate(SNUM(fsp->conn))){ + space_avail = get_dfree_info(conn,fsp->fsp_name,False,&bsize,&dfree,&dsize); + /* space_avail is 1k blocks */ + if (space_avail == (SMB_BIG_UINT)-1 || + ((SMB_BIG_UINT)len/1024 > space_avail) ) { + errno = ENOSPC; + return -1; + } + } release_level_2_oplocks_on_change(fsp); DEBUG(10,("vfs_set_filelen: ftruncate %s to len %.0f\n", fsp->fsp_name, (double)len));