1997-04-26 21:21:57 +08:00
|
|
|
/*
|
|
|
|
* flushb.c --- This routine flushes the disk buffers for a disk
|
2000-12-09 22:46:20 +08:00
|
|
|
*
|
|
|
|
* Copyright 1997, 2000, by Theodore Ts'o.
|
|
|
|
*
|
2003-04-15 08:40:49 +08:00
|
|
|
* WARNING: use of flushb on some older 2.2 kernels on a heavily loaded
|
|
|
|
* system will corrupt filesystems. This program is not really useful
|
|
|
|
* beyond for benchmarking scripts.
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
1997-04-26 21:21:57 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/ioctl.h>
|
2001-06-23 09:01:17 +08:00
|
|
|
#include <sys/mount.h>
|
2000-09-13 05:24:36 +08:00
|
|
|
#include "../misc/nls-enable.h"
|
1997-04-26 21:21:57 +08:00
|
|
|
|
2001-06-23 09:01:17 +08:00
|
|
|
/* For Linux, define BLKFLSBUF if necessary */
|
|
|
|
#if (!defined(BLKFLSBUF) && defined(__linux__))
|
|
|
|
#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
|
2000-12-09 22:46:20 +08:00
|
|
|
#endif
|
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
const char *progname;
|
|
|
|
|
2001-01-12 03:15:02 +08:00
|
|
|
static void usage(void)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 11:11:03 +08:00
|
|
|
fprintf(stderr, _("Usage: %s disk\n"), progname);
|
1997-04-26 21:21:57 +08: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 21:58:21 +08:00
|
|
|
#ifdef BLKFLSBUF
|
1997-04-26 21:21:57 +08:00
|
|
|
if (ioctl(fd, BLKFLSBUF, 0) < 0) {
|
1997-04-26 21:58:21 +08:00
|
|
|
perror("ioctl BLKFLSBUF");
|
1997-04-26 21:21:57 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
return 0;
|
1997-04-26 21:58:21 +08:00
|
|
|
#else
|
|
|
|
fprintf(stderr,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 11:11:03 +08:00
|
|
|
_("BLKFLSBUF ioctl not supported! Can't flush buffers.\n"));
|
1997-04-26 21:58:21 +08:00
|
|
|
return 1;
|
|
|
|
#endif
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|