The Samba-Bugzilla – Attachment 12775 Details for
Bug 12479
cli_ftruncate fails with an SMB2+ connection
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
test patch for master
0001-s3-libsmb-Add-cli_smb2_ftruncate-plumb-into-cli_ftru.patch (text/plain), 3.44 KB, created by
Jeremy Allison
on 2016-12-21 22:14:34 UTC
(
hide
)
Description:
test patch for master
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2016-12-21 22:14:34 UTC
Size:
3.44 KB
patch
obsolete
>From 157a45d92c611ab1aced00844c9e46494a6e9510 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Wed, 21 Dec 2016 13:55:50 -0800 >Subject: [PATCH] s3: libsmb: Add cli_smb2_ftruncate(), plumb into > cli_ftruncate(). > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12479 > >Signed-off-by: Jeremy Allison <jra@samba.org> >--- > source3/libsmb/cli_smb2_fnum.c | 62 ++++++++++++++++++++++++++++++++++++++++++ > source3/libsmb/cli_smb2_fnum.h | 2 ++ > source3/libsmb/clifile.c | 8 +++++- > 3 files changed, 71 insertions(+), 1 deletion(-) > >diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c >index 266f2d3..72fcc5d 100644 >--- a/source3/libsmb/cli_smb2_fnum.c >+++ b/source3/libsmb/cli_smb2_fnum.c >@@ -3574,3 +3574,65 @@ NTSTATUS cli_smb2_shadow_copy_data(TALLOC_CTX *mem_ctx, > TALLOC_FREE(frame); > return status; > } >+ >+/*************************************************************** >+ Wrapper that allows SMB2 to truncate a file. >+ Synchronous only. >+***************************************************************/ >+ >+NTSTATUS cli_smb2_ftruncate(struct cli_state *cli, >+ uint16_t fnum) >+{ >+ NTSTATUS status; >+ DATA_BLOB inbuf = 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; >+ } >+ >+ status = map_fnum_to_smb2_handle(cli, >+ fnum, >+ &ph); >+ if (!NT_STATUS_IS_OK(status)) { >+ goto fail; >+ } >+ >+ inbuf = data_blob_talloc_zero(frame, 8); >+ if (inbuf.data == NULL) { >+ status = NT_STATUS_NO_MEMORY; >+ goto fail; >+ } >+ >+ /* setinfo on the handle with info_type SMB2_SETINFO_FILE (1), >+ level 20 (SMB_FILE_END_OF_FILE_INFORMATION - 1000). */ >+ >+ status = smb2cli_set_info(cli->conn, >+ cli->timeout, >+ cli->smb2.session, >+ cli->smb2.tcon, >+ 1, /* in_info_type */ >+ /* in_file_info_class */ >+ SMB_FILE_END_OF_FILE_INFORMATION - 1000, >+ &inbuf, /* in_input_buffer */ >+ 0, /* in_additional_info */ >+ ph->fid_persistent, >+ ph->fid_volatile); >+ >+ fail: >+ >+ cli->raw_status = status; >+ >+ TALLOC_FREE(frame); >+ return status; >+} >diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h >index 3289f7e..2b9f0b9 100644 >--- a/source3/libsmb/cli_smb2_fnum.h >+++ b/source3/libsmb/cli_smb2_fnum.h >@@ -208,4 +208,6 @@ NTSTATUS cli_smb2_shadow_copy_data(TALLOC_CTX *mem_ctx, > bool get_names, > char ***pnames, > int *pnum_names); >+NTSTATUS cli_smb2_ftruncate(struct cli_state *cli, >+ uint16_t fnum); > #endif /* __SMB2CLI_FNUM_H__ */ >diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c >index 5e667bd..5a45147 100644 >--- a/source3/libsmb/clifile.c >+++ b/source3/libsmb/clifile.c >@@ -2819,11 +2819,17 @@ NTSTATUS cli_ftruncate_recv(struct tevent_req *req) > > NTSTATUS cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size) > { >- TALLOC_CTX *frame = talloc_stackframe(); >+ TALLOC_CTX *frame = NULL; > struct tevent_context *ev = NULL; > struct tevent_req *req = NULL; > NTSTATUS status = NT_STATUS_OK; > >+ if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { >+ return cli_smb2_ftruncate(cli, fnum); >+ } >+ >+ frame = talloc_stackframe(); >+ > if (smbXcli_conn_has_async_calls(cli->conn)) { > /* > * Can't use sync call while an async call is in flight >-- >2.7.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 12479
:
12775
|
12776
|
12792
|
12800
|
12801