summaryrefslogtreecommitdiff
path: root/source3/smbd/reply.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-08-07 01:19:32 +0000
committerJeremy Allison <jra@samba.org>2001-08-07 01:19:32 +0000
commit0c218e1abe237e23014332b014ec06f2e9d27e5e (patch)
treee55ce75a893bd46417ee055896e9f807f34ec613 /source3/smbd/reply.c
parentd851036d8205a13f64f3a14db8a60e72fbeee7d6 (diff)
downloadsamba-0c218e1abe237e23014332b014ec06f2e9d27e5e.tar.gz
samba-0c218e1abe237e23014332b014ec06f2e9d27e5e.tar.bz2
samba-0c218e1abe237e23014332b014ec06f2e9d27e5e.zip
Added fixes to return correct error codes on space allocation fail.
Jeremy. (This used to be commit 3bf2419f4b7a9d46a1d48062212a6a6579c22b92)
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r--source3/smbd/reply.c31
1 files changed, 30 insertions, 1 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);