tools/testing/selftests/splice/splice_read.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/splice/splice_read.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/splice/splice_read.c
Extension
.c
Size
998 bytes
Lines
58
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (fstat(fd, &statbuf) < 0) {
			perror(argv[1]);
			return EXIT_FAILURE;
		}

		if (statbuf.st_size > INT_MAX) {
			fprintf(stderr, "%s: Too big\n", argv[1]);
			return EXIT_FAILURE;
		}

		size = statbuf.st_size;
	}

	/* splice(2) file to stdout. */
	spliced = splice(fd, NULL, STDOUT_FILENO, NULL,
		      size, SPLICE_F_MOVE);
	if (spliced < 0) {
		perror("splice");
		return EXIT_FAILURE;
	}

	close(fd);
	return EXIT_SUCCESS;
}

Annotation

Implementation Notes