You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
5.1 KiB
166 lines
5.1 KiB
7 years ago
|
From b428a334105a28f55b784d284e865b3c42f1f96d Mon Sep 17 00:00:00 2001
|
||
|
From: Jeremy Allison <jra@samba.org>
|
||
|
Date: Tue, 14 Nov 2017 13:52:03 -0800
|
||
|
Subject: [PATCH] s3: libsmb: smbc_statvfs is missing the supporting SMB2
|
||
|
calls.
|
||
|
|
||
|
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13138
|
||
|
|
||
|
Signed-off-by: Jeremy Allison <jra@samba.org>
|
||
|
Reviewed-by: Andreas Schneider <asn@samba.org>
|
||
|
(cherry picked from commit eefc7a27155b70d027b1193187dd435267d863ea)
|
||
|
---
|
||
|
source3/libsmb/cli_smb2_fnum.c | 97 ++++++++++++++++++++++++++++++++++++++++++
|
||
|
source3/libsmb/cli_smb2_fnum.h | 6 +++
|
||
|
source3/libsmb/clifsinfo.c | 9 ++++
|
||
|
3 files changed, 112 insertions(+)
|
||
|
|
||
|
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
|
||
|
index a478c41f068..89cb1f479d5 100644
|
||
|
--- a/source3/libsmb/cli_smb2_fnum.c
|
||
|
+++ b/source3/libsmb/cli_smb2_fnum.c
|
||
|
@@ -1992,6 +1992,103 @@ NTSTATUS cli_smb2_dskattr(struct cli_state *cli, const char *path,
|
||
|
return status;
|
||
|
}
|
||
|
|
||
|
+/***************************************************************
|
||
|
+ Wrapper that allows SMB2 to query file system sizes.
|
||
|
+ Synchronous only.
|
||
|
+***************************************************************/
|
||
|
+
|
||
|
+NTSTATUS cli_smb2_get_fs_full_size_info(struct cli_state *cli,
|
||
|
+ uint64_t *total_allocation_units,
|
||
|
+ uint64_t *caller_allocation_units,
|
||
|
+ uint64_t *actual_allocation_units,
|
||
|
+ uint64_t *sectors_per_allocation_unit,
|
||
|
+ uint64_t *bytes_per_sector)
|
||
|
+{
|
||
|
+ NTSTATUS status;
|
||
|
+ uint16_t fnum = 0xffff;
|
||
|
+ DATA_BLOB outbuf = data_blob_null;
|
||
|
+ struct smb2_hnd *ph = NULL;
|
||
|
+ TALLOC_CTX *frame = talloc_stackframe();
|
||
|
+
|
||
|
+ if (smbXcli_conn_has_async_calls(cli->conn)) {
|
||
|
+ /*
|
||
|
+ * Can't use sync call while an async call is in flight
|
||
|
+ */
|
||
|
+ status = NT_STATUS_INVALID_PARAMETER;
|
||
|
+ goto fail;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
|
||
|
+ status = NT_STATUS_INVALID_PARAMETER;
|
||
|
+ goto fail;
|
||
|
+ }
|
||
|
+
|
||
|
+ /* First open the top level directory. */
|
||
|
+ status =
|
||
|
+ cli_smb2_create_fnum(cli, "", 0, /* create_flags */
|
||
|
+ FILE_READ_ATTRIBUTES, /* desired_access */
|
||
|
+ FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
|
||
|
+ FILE_SHARE_READ | FILE_SHARE_WRITE |
|
||
|
+ FILE_SHARE_DELETE, /* share_access */
|
||
|
+ FILE_OPEN, /* create_disposition */
|
||
|
+ FILE_DIRECTORY_FILE, /* create_options */
|
||
|
+ &fnum,
|
||
|
+ NULL);
|
||
|
+
|
||
|
+ if (!NT_STATUS_IS_OK(status)) {
|
||
|
+ goto fail;
|
||
|
+ }
|
||
|
+
|
||
|
+ status = map_fnum_to_smb2_handle(cli, fnum, &ph);
|
||
|
+ if (!NT_STATUS_IS_OK(status)) {
|
||
|
+ goto fail;
|
||
|
+ }
|
||
|
+
|
||
|
+ /* getinfo on the returned handle with info_type SMB2_GETINFO_FS (2),
|
||
|
+ level 7 (SMB_FS_FULL_SIZE_INFORMATION). */
|
||
|
+
|
||
|
+ status = smb2cli_query_info(cli->conn,
|
||
|
+ cli->timeout,
|
||
|
+ cli->smb2.session,
|
||
|
+ cli->smb2.tcon,
|
||
|
+ SMB2_GETINFO_FS, /* in_info_type */
|
||
|
+ /* in_file_info_class */
|
||
|
+ SMB_FS_FULL_SIZE_INFORMATION - 1000,
|
||
|
+ 0xFFFF, /* in_max_output_length */
|
||
|
+ NULL, /* in_input_buffer */
|
||
|
+ 0, /* in_additional_info */
|
||
|
+ 0, /* in_flags */
|
||
|
+ ph->fid_persistent,
|
||
|
+ ph->fid_volatile,
|
||
|
+ frame,
|
||
|
+ &outbuf);
|
||
|
+ if (!NT_STATUS_IS_OK(status)) {
|
||
|
+ goto fail;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (outbuf.length < 32) {
|
||
|
+ status = NT_STATUS_INVALID_NETWORK_RESPONSE;
|
||
|
+ goto fail;
|
||
|
+ }
|
||
|
+
|
||
|
+ *total_allocation_units = BIG_UINT(outbuf.data, 0);
|
||
|
+ *caller_allocation_units = BIG_UINT(outbuf.data, 8);
|
||
|
+ *actual_allocation_units = BIG_UINT(outbuf.data, 16);
|
||
|
+ *sectors_per_allocation_unit = (uint64_t)IVAL(outbuf.data, 24);
|
||
|
+ *bytes_per_sector = (uint64_t)IVAL(outbuf.data, 28);
|
||
|
+
|
||
|
+fail:
|
||
|
+
|
||
|
+ if (fnum != 0xffff) {
|
||
|
+ cli_smb2_close_fnum(cli, fnum);
|
||
|
+ }
|
||
|
+
|
||
|
+ cli->raw_status = status;
|
||
|
+
|
||
|
+ TALLOC_FREE(frame);
|
||
|
+ return status;
|
||
|
+}
|
||
|
+
|
||
|
/***************************************************************
|
||
|
Wrapper that allows SMB2 to query file system attributes.
|
||
|
Synchronous only.
|
||
|
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
|
||
|
index 9a709e85d96..c9325b66902 100644
|
||
|
--- a/source3/libsmb/cli_smb2_fnum.h
|
||
|
+++ b/source3/libsmb/cli_smb2_fnum.h
|
||
|
@@ -136,6 +136,12 @@ NTSTATUS cli_smb2_dskattr(struct cli_state *cli,
|
||
|
uint64_t *total,
|
||
|
uint64_t *avail);
|
||
|
NTSTATUS cli_smb2_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr);
|
||
|
+NTSTATUS cli_smb2_get_fs_full_size_info(struct cli_state *cli,
|
||
|
+ uint64_t *total_allocation_units,
|
||
|
+ uint64_t *caller_allocation_units,
|
||
|
+ uint64_t *actual_allocation_units,
|
||
|
+ uint64_t *sectors_per_allocation_unit,
|
||
|
+ uint64_t *bytes_per_sector);
|
||
|
NTSTATUS cli_smb2_query_security_descriptor(struct cli_state *cli,
|
||
|
uint16_t fnum,
|
||
|
uint32_t sec_info,
|
||
|
diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c
|
||
|
index 119b1216fb2..46236390022 100644
|
||
|
--- a/source3/libsmb/clifsinfo.c
|
||
|
+++ b/source3/libsmb/clifsinfo.c
|
||
|
@@ -439,6 +439,15 @@ NTSTATUS cli_get_fs_full_size_info(struct cli_state *cli,
|
||
|
uint32_t rdata_count;
|
||
|
NTSTATUS status;
|
||
|
|
||
|
+ if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
|
||
|
+ return cli_smb2_get_fs_full_size_info(cli,
|
||
|
+ total_allocation_units,
|
||
|
+ caller_allocation_units,
|
||
|
+ actual_allocation_units,
|
||
|
+ sectors_per_allocation_unit,
|
||
|
+ bytes_per_sector);
|
||
|
+ }
|
||
|
+
|
||
|
SSVAL(setup, 0, TRANSACT2_QFSINFO);
|
||
|
SSVAL(param, 0, SMB_FS_FULL_SIZE_INFORMATION);
|
||
|
|
||
|
--
|
||
|
2.15.0.448.gf294e3d99a-goog
|
||
|
|