if (fnum != 0xffff) {
cli_smb2_close_fnum(cli, fnum);
}
+
+ cli->raw_status = status;
+
TALLOC_FREE(subframe);
TALLOC_FREE(frame);
return status;
return status;
}
- cli_smb2_close_fnum(cli, fnum);
+ status = cli_smb2_close_fnum(cli, fnum);
ZERO_STRUCTP(sbuf);
sbuf->st_ex_size = cr.end_of_file;
*attributes = cr.file_attributes;
- return NT_STATUS_OK;
+ return status;
}
/***************************************************************
if (fnum != 0xffff) {
cli_smb2_close_fnum(cli, fnum);
}
+
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
fail:
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
&change_time_ts,
NULL);
+ cli->raw_status = status;
+
if (!NT_STATUS_IS_OK(status)) {
return status;
}
cli_smb2_close_fnum(cli, fnum);
}
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
cli_smb2_close_fnum(cli, fnum);
}
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
cli_smb2_close_fnum(cli, fnum);
}
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
cli_smb2_close_fnum(cli, fnum);
}
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
put_long_date((char *)inbuf.data + 16, write_time);
}
- return smb2cli_set_info(cli->conn,
+ cli->raw_status = smb2cli_set_info(cli->conn,
cli->timeout,
cli->smb2.session,
cli->smb2.tcon,
0, /* in_additional_info */
ph->fid_persistent,
ph->fid_volatile);
+
+ return cli->raw_status;
}
/***************************************************************
cli_smb2_close_fnum(cli, fnum);
}
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
cli_smb2_close_fnum(cli, fnum);
}
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
fail:
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
fail:
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
***************************************************************/
NTSTATUS cli_smb2_rename(struct cli_state *cli,
- const char *fname_src,
- const char *fname_dst)
+ const char *fname_src,
+ const char *fname_dst,
+ bool replace)
{
NTSTATUS status;
DATA_BLOB inbuf = data_blob_null;
goto fail;
}
+ if (replace) {
+ SCVAL(inbuf.data, 0, 1);
+ }
+
SIVAL(inbuf.data, 16, converted_size_bytes);
memcpy(inbuf.data + 20, converted_str, converted_size_bytes);
cli_smb2_close_fnum(cli, fnum);
}
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
fail:
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
cli_smb2_close_fnum(cli, fnum);
}
+ cli->raw_status = status;
+
return status;
}
cli_smb2_close_fnum(cli, fnum);
}
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
}
fail:
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
pqt_list);
cleanup:
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
status = parse_fs_quota_buffer(outbuf.data, outbuf.length, pqt);
cleanup:
+ cli->raw_status = status;
+
+ TALLOC_FREE(frame);
+ return status;
+}
+
+/***************************************************************
+ Wrapper that allows SMB2 to set user quota.
+ Synchronous only.
+***************************************************************/
+
+NTSTATUS cli_smb2_set_user_quota(struct cli_state *cli,
+ int quota_fnum,
+ SMB_NTQUOTA_LIST *qtl)
+{
+ 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 cleanup;
+ }
+
+ if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto cleanup;
+ }
+
+ status = map_fnum_to_smb2_handle(cli, quota_fnum, &ph);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto cleanup;
+ }
+
+ status = build_user_quota_buffer(qtl, 0, talloc_tos(), &inbuf, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto cleanup;
+ }
+
+ status = smb2cli_set_info(cli->conn, cli->timeout, cli->smb2.session,
+ cli->smb2.tcon, 4, /* in_info_type */
+ 0, /* in_file_info_class */
+ &inbuf, /* in_input_buffer */
+ 0, /* in_additional_info */
+ ph->fid_persistent, ph->fid_volatile);
+cleanup:
+
+ cli->raw_status = status;
+
+ TALLOC_FREE(frame);
+
+ return status;
+}
+
+NTSTATUS cli_smb2_set_fs_quota_info(struct cli_state *cli,
+ int quota_fnum,
+ SMB_NTQUOTA_STRUCT *pqt)
+{
+ 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 cleanup;
+ }
+
+ if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto cleanup;
+ }
+
+ status = map_fnum_to_smb2_handle(cli, quota_fnum, &ph);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto cleanup;
+ }
+
+ status = build_fs_quota_buffer(talloc_tos(), pqt, &inbuf, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto cleanup;
+ }
+
+ status = smb2cli_set_info(
+ cli->conn, cli->timeout, cli->smb2.session, cli->smb2.tcon,
+ 2, /* in_info_type */
+ SMB_FS_QUOTA_INFORMATION - 1000, /* in_file_info_class */
+ &inbuf, /* in_input_buffer */
+ 0, /* in_additional_info */
+ ph->fid_persistent, ph->fid_volatile);
+cleanup:
+ cli->raw_status = status;
+
TALLOC_FREE(frame);
return status;
}
bool get_names)
{
struct tevent_req *req, *subreq;
- struct cli_smb2_close_fnum_state *state;
+ struct cli_smb2_shadow_copy_data_fnum_state *state;
NTSTATUS status;
req = tevent_req_create(mem_ctx, &state,
pnames,
pnum_names);
fail:
+ cli->raw_status = status;
+
+ 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,
+ uint64_t newsize)
+{
+ 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;
+ }
+
+ SBVAL(inbuf.data, 0, newsize);
+
+ /* 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;
}