2 * flushb.c --- This routine flushes the disk buffers for a disk
4 * Copyright 1997, 2000, by Theodore Ts'o.
6 * WARNING: use of flushb on some older 2.2 kernels on a heavily loaded
7 * system will corrupt filesystems. This program is not really useful
8 * beyond for benchmarking scripts.
11 * This file may be redistributed under the terms of the GNU Public
21 #include <sys/ioctl.h>
22 #include <sys/mount.h>
23 #include "../misc/nls-enable.h"
25 /* For Linux, define BLKFLSBUF if necessary */
26 #if (!defined(BLKFLSBUF) && defined(__linux__))
27 #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
32 static void usage(void)
34 fprintf(stderr, _("Usage: %s disk\n"), progname);
38 int main(int argc, char **argv)
46 fd = open(argv[1], O_RDONLY, 0);
52 * Note: to reread the partition table, use the ioctl
53 * BLKRRPART instead of BLKFSLBUF.
56 if (ioctl(fd, BLKFLSBUF, 0) < 0) {
57 perror("ioctl BLKFLSBUF");
63 _("BLKFLSBUF ioctl not supported! Can't flush buffers.\n"));