Ejemplo n.º 1
0
/*
 * check whether a file or directory is flagged as compressed.
 */
static NTSTATUS dos_mode_check_compressed(connection_struct *conn,
					  struct smb_filename *smb_fname,
					  bool *is_compressed)
{
	NTSTATUS status;
	uint16_t compression_fmt;
	TALLOC_CTX *tmp_ctx = talloc_new(NULL);
	if (tmp_ctx == NULL) {
		status = NT_STATUS_NO_MEMORY;
		goto err_out;
	}

	status = SMB_VFS_GET_COMPRESSION(conn, tmp_ctx, NULL, smb_fname,
					 &compression_fmt);
	if (!NT_STATUS_IS_OK(status)) {
		goto err_ctx_free;
	}

	if (compression_fmt == COMPRESSION_FORMAT_LZNT1) {
		*is_compressed = true;
	} else {
		*is_compressed = false;
	}
	status = NT_STATUS_OK;

err_ctx_free:
	talloc_free(tmp_ctx);
err_out:
	return status;
}
Ejemplo n.º 2
0
static NTSTATUS fsctl_get_cmprn(TALLOC_CTX *mem_ctx,
				struct tevent_context *ev,
				struct files_struct *fsp,
				size_t in_max_output,
				DATA_BLOB *out_output)
{
	struct compression_state cmpr_state;
	enum ndr_err_code ndr_ret;
	DATA_BLOB output;
	NTSTATUS status;

	if (fsp == NULL) {
		return NT_STATUS_FILE_CLOSED;
	}

	/* Windows doesn't check for SEC_FILE_READ_ATTRIBUTE permission here */

	if ((fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) == 0) {
		DEBUG(4, ("FS does not advertise compression support\n"));
		return NT_STATUS_NOT_SUPPORTED;
	}

	ZERO_STRUCT(cmpr_state);
	status = SMB_VFS_GET_COMPRESSION(fsp->conn,
					 mem_ctx,
					 fsp,
					 NULL,
					 &cmpr_state.format);
	if (!NT_STATUS_IS_OK(status)) {
		return status;
	}

	ndr_ret = ndr_push_struct_blob(&output, mem_ctx,
				       &cmpr_state,
			(ndr_push_flags_fn_t)ndr_push_compression_state);
	if (ndr_ret != NDR_ERR_SUCCESS) {
		return NT_STATUS_INTERNAL_ERROR;
	}

	if (in_max_output < output.length) {
		DEBUG(1, ("max output %u too small for compression state %ld\n",
		      (unsigned int)in_max_output, (long int)output.length));
		return NT_STATUS_INVALID_USER_BUFFER;
	}
	*out_output = output;

	return NT_STATUS_OK;
}