diff options
| -rw-r--r-- | source3/smbd/reply.c | 31 | ||||
| -rw-r--r-- | source3/smbd/trans2.c | 2 | 
2 files changed, 31 insertions, 2 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index a956261a78..d31c83da9b 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2442,8 +2442,32 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int siz  }  /**************************************************************************** -  reply to a write + Return correct error for space allocation fail.  ****************************************************************************/ + +int allocate_space_error(char *inbuf,char *outbuf, int errno_val) +{ +	errno = errno_val; +	if (!(global_client_caps & CAP_STATUS32)) +		return (UNIXERROR(ERRHRD,ERRdiskfull)); + +	/* Use more specific WNT/W2K error codes. */ +#ifdef EDQUOT +	if (errno_val == ENOSPC || errno_val == EDQUOT) { +#else +	if (errno_val == ENOSPC) { +#endif +		SSVAL(outbuf,smb_flg2,SVAL(outbuf, smb_flg2) | FLAGS2_32_BIT_ERROR_CODES); +		return(ERROR(0,errno == ENOSPC ? NT_STATUS_DISK_FULL : NT_STATUS_QUOTA_EXCEEDED)); +	} + +	return (UNIXERROR(ERRHRD,ERRdiskfull)); +} + +/**************************************************************************** + Reply to a write. +****************************************************************************/ +  int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int size,int dum_buffsize)  {    size_t numtowrite; @@ -2479,6 +2503,11 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int size,int d    if(numtowrite == 0) {        /* This is actually an allocate call, not set EOF. JRA */        nwritten = vfs_allocate_file_space(fsp, (SMB_OFF_T)startpos); +      if (nwritten < 0) { +        int ret = allocate_space_error(inbuf, outbuf, errno); +        END_PROFILE(SMBwrite); +		return ret; +      }    } else      nwritten = write_file(fsp,data,startpos,numtowrite); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index bb7ca6e0f8..26b376ec2d 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -1928,7 +1928,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,        }        if (ret == -1) -        return(UNIXERROR(ERRHRD,ERRdiskfull)); +		return allocate_space_error(inbuf, outbuf, errno);        sbuf.st_size = size;        break;  | 
