[go: up one dir, main page]

File: stdout.c

package info (click to toggle)
s390-tools 2.3.0-2~deb10u1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 6,188 kB
  • sloc: ansic: 87,755; sh: 8,398; cpp: 8,384; perl: 3,783; makefile: 1,476; asm: 654
file content (40 lines) | stat: -rw-r--r-- 1,014 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * zgetdump - Tool for copying and converting System z dumps
 *
 * Write dump to standard output (stdout)
 *
 * Copyright IBM Corp. 2001, 2017
 *
 * s390-tools is free software; you can redistribute it and/or modify
 * it under the terms of the MIT license. See LICENSE for details.
 */

#include "zgetdump.h"

int stdout_write_dump(void)
{
	u64 cnt, written = 0;
	char buf[32768];
	ssize_t rc;

	if (!dfi_feat_copy())
		ERR_EXIT("Copying not possible for %s dumps", dfi_name());
	STDERR("Format Info:\n");
	STDERR("  Source: %s\n", dfi_name());
	STDERR("  Target: %s\n", dfo_name());
	STDERR("\n");
	zg_progress_init("Copying dump", dfo_size());
	do {
		cnt = dfo_read(buf, sizeof(buf));
		rc = write(STDOUT_FILENO, buf, cnt);
		if (rc == -1)
			ERR_EXIT_ERRNO("Error: Write failed");
		if (rc != (ssize_t) cnt)
			ERR_EXIT("Error: Could not write full block");
		written += cnt;
		zg_progress(written);
	} while (written != dfo_size());
	STDERR("\n");
	STDERR("Success: Dump has been copied\n");
	return 0;
}