File: fdflush.c

package info (click to toggle)
fdflush 1.0.0-12
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 32 kB
  • ctags: 6
  • sloc: makefile: 42; ansic: 25; sh: 2
file content (36 lines) | stat: -rw-r--r-- 675 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Floppy-disk buffer flush program.
 * Copyright (C) 1995 Bruce Perens
 * This program is free software under the GNU General Public License
 */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/fd.h>

static const char	fd0[] = "/dev/fd0";

int
main(int argc, char * * argv)
{
	const char *	floppy = fd0;
	int		fd;

	if ( argc > 1 )
		floppy = argv[1];

	fd = open(floppy, O_RDONLY);

	if ( fd < 0 ) {
		fprintf(stderr, "%s: %s.\n", floppy, strerror(errno));
		return -1;
	}

	if ( ioctl(fd, FDFLUSH, 0) != 0 ) {
		fprintf(stderr, "%s: fdflush: %s.\n", floppy, strerror(errno));
		return -1;
	}
	return 0;
}