[SCM] Samba Shared Repository - branch v3-6-test updated
Jeremy Allison
jra at samba.org
Thu Feb 24 16:27:03 MST 2011
The branch, v3-6-test has been updated
via 2e19148 Implement the SMB2 close flag SMB2_CLOSE_FLAGS_FULL_INFORMATION (and move definition to correct place).
from 6a7d42f Batch oplocks conflict with exclusive as well as themselves. (cherry picked from commit b3c74eceb0c871e9f782b88ad1678573ca38b3b8)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test
- Log -----------------------------------------------------------------
commit 2e191484b1f6e0c5c59fb321b2599c37a6e320e1
Author: Jeremy Allison <jra at samba.org>
Date: Thu Feb 24 14:52:58 2011 -0800
Implement the SMB2 close flag SMB2_CLOSE_FLAGS_FULL_INFORMATION (and move definition to correct place).
Thanks to Nick Meier @ Microsoft for finding this @ Connectathon.
Jeremy.
(cherry picked from commit c0171feb2c6b912916c780679b1c21f28fab6bb4)
-----------------------------------------------------------------------
Summary of changes:
libcli/smb/smb2_constants.h | 2 +
source3/smbd/smb2_close.c | 95 ++++++++++++++++++++++++++++++--------
source4/libcli/raw/interfaces.h | 1 -
3 files changed, 77 insertions(+), 21 deletions(-)
Changeset truncated at 500 lines:
diff --git a/libcli/smb/smb2_constants.h b/libcli/smb/smb2_constants.h
index 6d29d6e..7ab496d 100644
--- a/libcli/smb/smb2_constants.h
+++ b/libcli/smb/smb2_constants.h
@@ -184,4 +184,6 @@
#define SMB2_GETINFO_SECURITY 0x03
#define SMB2_GETINFO_QUOTA 0x04
+#define SMB2_CLOSE_FLAGS_FULL_INFORMATION (0x01)
+
#endif
diff --git a/source3/smbd/smb2_close.c b/source3/smbd/smb2_close.c
index 56e3167..8ef9dfa 100644
--- a/source3/smbd/smb2_close.c
+++ b/source3/smbd/smb2_close.c
@@ -24,7 +24,8 @@
static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req,
uint16_t in_flags,
- uint64_t in_file_id_volatile);
+ uint64_t in_file_id_volatile,
+ DATA_BLOB *outbody);
NTSTATUS smbd_smb2_request_process_close(struct smbd_smb2_request *req)
{
@@ -52,6 +53,11 @@ NTSTATUS smbd_smb2_request_process_close(struct smbd_smb2_request *req)
return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
}
+ outbody = data_blob_talloc(req->out.vector, NULL, 0x3C);
+ if (outbody.data == NULL) {
+ return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
+ }
+
in_flags = SVAL(inbody, 0x02);
in_file_id_persistent = BVAL(inbody, 0x08);
in_file_id_volatile = BVAL(inbody, 0x10);
@@ -64,40 +70,37 @@ NTSTATUS smbd_smb2_request_process_close(struct smbd_smb2_request *req)
status = smbd_smb2_close(req,
in_flags,
- in_file_id_volatile);
+ in_file_id_volatile,
+ &outbody);
if (!NT_STATUS_IS_OK(status)) {
return smbd_smb2_request_error(req, status);
}
outhdr = (uint8_t *)req->out.vector[i].iov_base;
-
- outbody = data_blob_talloc(req->out.vector, NULL, 0x3C);
- if (outbody.data == NULL) {
- return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
- }
-
- SSVAL(outbody.data, 0x00, 0x3C); /* struct size */
- SSVAL(outbody.data, 0x02, 0); /* flags */
- SIVAL(outbody.data, 0x04, 0); /* reserved */
- SBVAL(outbody.data, 0x08, 0); /* creation time */
- SBVAL(outbody.data, 0x10, 0); /* last access time */
- SBVAL(outbody.data, 0x18, 0); /* last write time */
- SBVAL(outbody.data, 0x20, 0); /* change time */
- SBVAL(outbody.data, 0x28, 0); /* allocation size */
- SBVAL(outbody.data, 0x30, 0); /* end of size */
- SIVAL(outbody.data, 0x38, 0); /* file attributes */
-
return smbd_smb2_request_done(req, outbody, NULL);
}
static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req,
uint16_t in_flags,
- uint64_t in_file_id_volatile)
+ uint64_t in_file_id_volatile,
+ DATA_BLOB *outbody)
{
NTSTATUS status;
struct smb_request *smbreq;
connection_struct *conn = req->tcon->compat_conn;
files_struct *fsp;
+ struct smb_filename *smb_fname = NULL;
+ struct timespec mdate_ts, adate_ts, cdate_ts, create_date_ts;
+ uint64_t allocation_size = 0;
+ uint64_t file_size = 0;
+ uint32_t dos_attrs = 0;
+ uint16_t out_flags = 0;
+ bool posix_open = false;
+
+ ZERO_STRUCT(create_date_ts);
+ ZERO_STRUCT(adate_ts);
+ ZERO_STRUCT(mdate_ts);
+ ZERO_STRUCT(cdate_ts);
DEBUG(10,("smbd_smb2_close: file_id[0x%016llX]\n",
(unsigned long long)in_file_id_volatile));
@@ -118,6 +121,14 @@ static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req,
return NT_STATUS_FILE_CLOSED;
}
+ posix_open = fsp->posix_open;
+ status = copy_smb_filename(talloc_tos(),
+ fsp->fsp_name,
+ &smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
status = close_file(smbreq, fsp, NORMAL_CLOSE);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5,("smbd_smb2_close: close_file[%s]: %s\n",
@@ -125,5 +136,49 @@ static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req,
return status;
}
+ if (in_flags & SMB2_CLOSE_FLAGS_FULL_INFORMATION) {
+ int ret;
+ if (posix_open) {
+ ret = SMB_VFS_LSTAT(conn, smb_fname);
+ } else {
+ ret = SMB_VFS_STAT(conn, smb_fname);
+ }
+ if (ret == 0) {
+ out_flags = SMB2_CLOSE_FLAGS_FULL_INFORMATION;
+ dos_attrs = dos_mode(conn, smb_fname);
+ mdate_ts = smb_fname->st.st_ex_mtime;
+ adate_ts = smb_fname->st.st_ex_atime;
+ create_date_ts = get_create_timespec(conn, NULL, smb_fname);
+ cdate_ts = get_change_timespec(conn, NULL, smb_fname);
+
+ if (lp_dos_filetime_resolution(SNUM(conn))) {
+ dos_filetime_timespec(&create_date_ts);
+ dos_filetime_timespec(&mdate_ts);
+ dos_filetime_timespec(&adate_ts);
+ dos_filetime_timespec(&cdate_ts);
+ }
+ if (!(dos_attrs & FILE_ATTRIBUTE_DIRECTORY)) {
+ file_size = get_file_size_stat(&smb_fname->st);
+ }
+
+ allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn, NULL, &smb_fname->st);
+ }
+ }
+
+ SSVAL(outbody->data, 0x00, 0x3C); /* struct size */
+ SSVAL(outbody->data, 0x02, out_flags); /* flags */
+ SIVAL(outbody->data, 0x04, 0); /* reserved */
+ put_long_date_timespec(conn->ts_res,
+ (char *)&outbody->data[0x8],create_date_ts); /* creation time */
+ put_long_date_timespec(conn->ts_res,
+ (char *)&outbody->data[0x10],adate_ts); /* last access time */
+ put_long_date_timespec(conn->ts_res,
+ (char *)&outbody->data[0x18],mdate_ts); /* last write time */
+ put_long_date_timespec(conn->ts_res,
+ (char *)&outbody->data[0x20],cdate_ts); /* change time */
+ SBVAL(outbody->data, 0x28, allocation_size);/* allocation size */
+ SBVAL(outbody->data, 0x30, file_size); /* end of file */
+ SIVAL(outbody->data, 0x38, dos_attrs); /* file attributes */
+
return NT_STATUS_OK;
}
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index f6d0905..f3ce4e9 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -2090,7 +2090,6 @@ union smb_close {
struct {
union smb_handle file;
time_t write_time;
-#define SMB2_CLOSE_FLAGS_FULL_INFORMATION (1<<0)
uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
} in;
struct {
--
Samba Shared Repository
More information about the samba-cvs
mailing list