e2fsprogs/e2fsck/flushb.c

56 lines
880 B
C
Raw Normal View History

1997-04-26 17:21:57 +04:00
/*
* 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>
#ifdef __STDC__
#define NOARGS void
#else
#define NOARGS
#define const
#endif
const char *progname;
static void usage(NOARGS)
{
fprintf(stderr, _("Usage: %s disk\n"), progname);
1997-04-26 17:21:57 +04:00
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.
*/
1997-04-26 17:58:21 +04:00
#ifdef BLKFLSBUF
1997-04-26 17:21:57 +04:00
if (ioctl(fd, BLKFLSBUF, 0) < 0) {
1997-04-26 17:58:21 +04:00
perror("ioctl BLKFLSBUF");
1997-04-26 17:21:57 +04:00
exit(1);
}
return 0;
1997-04-26 17:58:21 +04:00
#else
fprintf(stderr,
_("BLKFLSBUF ioctl not supported! Can't flush buffers.\n"));
1997-04-26 17:58:21 +04:00
return 1;
#endif
1997-04-26 17:21:57 +04:00
}