summaryrefslogtreecommitdiff
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
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)
-rw-r--r--source3/smbd/reply.c31
-rw-r--r--source3/smbd/trans2.c2
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;