2 * flushb.c --- This routine flushes the disk buffers for a disk
4 * Copyright 1997, 2000, by Theodore Ts'o.
6 * This program may be used under the provisions of the GNU Public
7 * License, *EXCEPT* that a binary copy of the executable may not be
8 * packaged as a part of binary package which is distributed as part
9 * of a Linux distribution. (Yes, this violates the Debian Free
10 * Software Guidelines of restricting its field of use. That's the
11 * point. I don't want this program being distributed in Debian,
12 * because I don't care to support it, and the maintainer, Yann
13 * Dirson, doesn't seem to pay attention to my wishes on this matter.
14 * So I'm deliberately adding this clause so it violates the Debian
15 * Free Software Guidelines to force him to take it out. (What part
16 * of THIS IS FOR MY OWN USE don't you understand? And no, I'm going
17 * to write a man page for it either. And don't file a bug about it
18 * or bug me about it.) If this doesn't work, I'll have to remove it
19 * from the upstream source distribution at the next release. End of
22 * (BTW, use of flushb on some older 2.2 kernels on a heavily loaded
23 * system will corrupt filesystems.)
31 #include <sys/ioctl.h>
32 #include "../misc/nls-enable.h"
34 /* For Linux/i386, define BLKFLSBUF */
35 #if (!defined(BLKFLSBUF) && defined(__i386__))
36 #define BLKFLSBUF 0x1261 /* flush buffer cache */
41 static void usage(void)
43 fprintf(stderr, _("Usage: %s disk\n"), progname);
47 int main(int argc, char **argv)
55 fd = open(argv[1], O_RDONLY, 0);
61 * Note: to reread the partition table, use the ioctl
62 * BLKRRPART instead of BLKFSLBUF.
65 if (ioctl(fd, BLKFLSBUF, 0) < 0) {
66 perror("ioctl BLKFLSBUF");
72 _("BLKFLSBUF ioctl not supported! Can't flush buffers.\n"));