[BACK]Return to mmapcat.c CVS log [TXT][DIR] Up to [Development] / xfs-cmds / xfstests / src

File: [Development] / xfs-cmds / xfstests / src / mmapcat.c (download)

Revision 1.1, Tue Jun 18 04:37:18 2002 UTC (15 years, 4 months ago) by nathans
Branch: MAIN

add fstest.c and mmapcat.c - keep a copy of these here so they don't get
lost and so that I can write some QA tests which make use of em.  authors
are listed at the head of each file, minor mods made to fix warnings, etc.

/* mmapcat.c - derived from source by misiek@pld.ORG.PL */

#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <stdio.h>

int main(int argc, char **argv)
{
	int fd;
	char *ptr;
	struct stat64 st;

	fd = open(argv[1], O_RDONLY);
	if (fd < 0) {
		perror(argv[1]);
		exit(1);
	}
	fstat64(fd, &st);
	ptr = mmap64(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
	while (*ptr != 0)
		write(1, ptr++, 1);
	exit(0);
}