#include <fcntl.h>
#include <stdio.h>

char buf[8192] = {0};

int main()
{
	int i;
	int written;
	int fda = open("/tmp/afile", O_CREAT | O_EXCL | O_WRONLY, 0600);
	int fdb = open("/tmp/bfile", O_CREAT | O_EXCL | O_WRONLY, 0600);
	if (fda < 0 || fdb < 0)
	{
		printf("Opening files failed\n");
		return(1);
	}
	for(i = 0; i < 2048; i++)
		{
			written=write(fda, buf, 8192);
			if (written < 8192)
			{
				printf("Write to file failed");
				return(2);
			}
		}

	posix_fallocate(fdb, 0, 16*1024*1024);

	close(fda);
	close(fdb);

	return 0;
}
