summaryrefslogtreecommitdiff
path: root/fdflush.c
blob: a15e9b3f7f8fd24098fffcf55db85ef7e92cd844 (plain)
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
#include "internal.h"
#include <sys/ioctl.h>
#include <linux/fd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

const char			fdflush_usage[] = "fdflush device";

int 
fdflush(const char *filename) 
{
	int	status;
	int	fd = open(filename, 0);

	if ( fd < 0 ) {
		name_and_error(filename);
		return 1;
	}

	status = ioctl(fd, FDFLUSH, 0);
	close(fd);

	if ( status != 0 ) {
		name_and_error(filename);
		return 1;
	}
	return 0;
}


int
fdflush_fn(const struct FileInfo * i)
{
  return fdflush(i->source);
}