#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/fsuid.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>

#define SIZE 10240
#define ME 500

int main(int argc, char * argv[])
{
	char * buff = NULL;
	int fd = 0 ;

	buff = malloc(SIZE);

	setfsuid(ME);
	fd = open(argv[1], O_CREAT|O_RDWR, 0644);
	printf("buff=%p, errno=%u\n", buff, errno);

	printf("fd = %d\n", fd) ;
	printf("bytes written = %d, errno=%u\n",
		write( fd, buff, SIZE), errno);

	printf("fsync:%d errno=%u\n", fsync(fd), errno);
	printf("close:%d errno=%u\n", close(fd), errno);
}
