/*
 * flushb.c --- This routine flushes the disk buffers for a disk
 */

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>

#include <linux/fs.h>

char *progname;

void usage()
{
	fprintf(stderr, "Usage: %s disk\n", progname);
	exit(1);
}	
	
int main(int argc, char **argv)
{
	int	fd;
	
	progname = argv[0];
	if (argc != 2)
		usage();

	fd = open(argv[1], O_RDONLY, 0);
	if (fd < 0) {
		perror("open");
		exit(1);
	}
	/*
	 * Note: to reread the partition table, use the ioctl
	 * BLKRRPART instead of BLKFSLBUF.
	 */
	if (ioctl(fd, BLKFLSBUF, 0) < 0) {
		perror("ioctl");
		exit(1);
	}
	return 0;
}
