summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-03-11 02:33:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:33 -0500
commit5214cb6782b1ac01b4b23d53478fa11ad00915fe (patch)
tree4a3e63eef3c24cf5c938c1800c3a38bf9964b09d
parent8a05fe78c966bed4c1f18561bf03f9f190b36434 (diff)
downloadsamba-5214cb6782b1ac01b4b23d53478fa11ad00915fe.tar.gz
samba-5214cb6782b1ac01b4b23d53478fa11ad00915fe.tar.bz2
samba-5214cb6782b1ac01b4b23d53478fa11ad00915fe.zip
r21783: Add in the "create info" field to the reply
from POSIX_OPEN and POSIX_MKDIR as specified by Stevef in the wikki (extra 4 byte field). Also fix horrible bug in James's code (James you should review this for your Apple patch tree) where he failed to allocate the correct return memory size when returning a INFO2 struct. Added #define for the size of the INFO2 struct and made sure we allocate the correct size for return. Jeremy. (This used to be commit d88bc59cb4d5e8851b0856c67ed878ba8bd84552)
-rw-r--r--source3/include/trans2.h8
-rw-r--r--source3/smbd/trans2.c54
2 files changed, 39 insertions, 23 deletions
diff --git a/source3/include/trans2.h b/source3/include/trans2.h
index be635462e1..67a0e0fc52 100644
--- a/source3/include/trans2.h
+++ b/source3/include/trans2.h
@@ -498,6 +498,8 @@ findfirst/findnext is SMB_FIND_FILE_UNIX_INFO2.
#define SMB_FIND_FILE_UNIX 0x202
#define SMB_FIND_FILE_UNIX_INFO2 0x20B /* UNIX File Info2 */
+#define SMB_FILE_UNIX_INFO2_SIZE 116
+
/*
Info level for TRANS2_QFSINFO - returns version of CIFS UNIX extensions, plus
64-bits worth of capability fun :-).
@@ -727,7 +729,11 @@ enum smb_whoami_flags {
#define SMB_NO_INFO_LEVEL_RETURNED 0xFFFF
/*
- [2 bytes] reply info level - as requested or 0xFFFF if not available.
+ [2 bytes] - flags field. Identical to flags reply for oplock response field in SMBNTCreateX)
+ [2 bytes] - FID returned.
+ [4 bytes] - CreateAction (same as in NTCreateX response).
+ [2 bytes] - reply info level - as requested or 0xFFFF if not available.
+ [2 bytes] - padding (must be zero)
[n bytes] - info level reply - if available.
*/
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 5401aac15d..01956d8119 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -5227,6 +5227,7 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
mode_t unixmode = (mode_t)0;
files_struct *fsp = NULL;
uint16 info_level_return = 0;
+ int info;
char *pdata = *ppdata;
if (total_data < 18) {
@@ -5254,7 +5255,7 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
FILE_CREATE,
0,
mod_unixmode,
- NULL,
+ &info,
&fsp);
if (NT_STATUS_IS_OK(status)) {
@@ -5264,9 +5265,11 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
info_level_return = SVAL(pdata,16);
if (info_level_return == SMB_QUERY_FILE_UNIX_BASIC) {
- *pdata_return_size = 8 + SMB_FILE_UNIX_BASIC_SIZE;
+ *pdata_return_size = 12 + SMB_FILE_UNIX_BASIC_SIZE;
+ } else if (info_level_return == SMB_QUERY_FILE_UNIX_INFO2) {
+ *pdata_return_size = 12 + SMB_FILE_UNIX_INFO2_SIZE;
} else {
- *pdata_return_size = 8;
+ *pdata_return_size = 12;
}
/* Realloc the data size */
@@ -5277,20 +5280,21 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
}
SSVAL(pdata,0,NO_OPLOCK_RETURN);
- SSVAL(pdata,2,0);
+ SSVAL(pdata,2,0); /* No fnum. */
+ SIVAL(pdata,4,info); /* Was directory created. */
switch (info_level_return) {
case SMB_QUERY_FILE_UNIX_BASIC:
- SSVAL(pdata,4,SMB_QUERY_FILE_UNIX_BASIC);
- SSVAL(pdata,6,0); /* Padding. */
- store_file_unix_basic(conn, pdata + 8, fsp, psbuf);
+ SSVAL(pdata,8,SMB_QUERY_FILE_UNIX_BASIC);
+ SSVAL(pdata,10,0); /* Padding. */
+ store_file_unix_basic(conn, pdata + 12, fsp, psbuf);
case SMB_QUERY_FILE_UNIX_INFO2:
- SSVAL(pdata,4,SMB_QUERY_FILE_UNIX_INFO2);
- SSVAL(pdata,6,0); /* Padding. */
- store_file_unix_basic_info2(conn, pdata + 8, fsp, psbuf);
+ SSVAL(pdata,8,SMB_QUERY_FILE_UNIX_INFO2);
+ SSVAL(pdata,10,0); /* Padding. */
+ store_file_unix_basic_info2(conn, pdata + 12, fsp, psbuf);
default:
- SSVAL(pdata,4,SMB_NO_INFO_LEVEL_RETURNED);
- SSVAL(pdata,6,0); /* Padding. */
+ SSVAL(pdata,8,SMB_NO_INFO_LEVEL_RETURNED);
+ SSVAL(pdata,10,0); /* Padding. */
}
return status;
@@ -5430,10 +5434,14 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
info_level_return = SVAL(pdata,16);
+ /* Allocate the correct return size. */
+
if (info_level_return == SMB_QUERY_FILE_UNIX_BASIC) {
- *pdata_return_size = 8 + SMB_FILE_UNIX_BASIC_SIZE;
+ *pdata_return_size = 12 + SMB_FILE_UNIX_BASIC_SIZE;
+ } else if (info_level_return == SMB_QUERY_FILE_UNIX_INFO2) {
+ *pdata_return_size = 12 + SMB_FILE_UNIX_INFO2_SIZE;
} else {
- *pdata_return_size = 8;
+ *pdata_return_size = 12;
}
/* Realloc the data size */
@@ -5457,18 +5465,20 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
}
SSVAL(pdata,2,fsp->fnum);
+ SIVAL(pdata,4,info); /* Was file created etc. */
+
switch (info_level_return) {
case SMB_QUERY_FILE_UNIX_BASIC:
- SSVAL(pdata,4,SMB_QUERY_FILE_UNIX_BASIC);
- SSVAL(pdata,6,0); /* padding. */
- store_file_unix_basic(conn, pdata + 8, fsp, psbuf);
+ SSVAL(pdata,8,SMB_QUERY_FILE_UNIX_BASIC);
+ SSVAL(pdata,10,0); /* padding. */
+ store_file_unix_basic(conn, pdata + 12, fsp, psbuf);
case SMB_QUERY_FILE_UNIX_INFO2:
- SSVAL(pdata,4,SMB_QUERY_FILE_UNIX_INFO2);
- SSVAL(pdata,6,0); /* padding. */
- store_file_unix_basic_info2(conn, pdata + 8, fsp, psbuf);
+ SSVAL(pdata,8,SMB_QUERY_FILE_UNIX_INFO2);
+ SSVAL(pdata,10,0); /* padding. */
+ store_file_unix_basic_info2(conn, pdata + 12, fsp, psbuf);
default:
- SSVAL(pdata,4,SMB_NO_INFO_LEVEL_RETURNED);
- SSVAL(pdata,6,0); /* padding. */
+ SSVAL(pdata,8,SMB_NO_INFO_LEVEL_RETURNED);
+ SSVAL(pdata,10,0); /* padding. */
}
return NT_STATUS_OK;
}