/* * buffer_dump.c --- This routine triggers a debugging ioctl which * dumps all buffer heads which have a non-zero bh_count. * * Copyright 1997, 2000, by Theodore Ts'o. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% */ #include #include #include #include #include #include #include /* For Linux, define BLKDUMPUSEDBUFFERS if necessary */ #if (!defined(BLKDUMPUSEDBUFFERS) && defined(__linux__)) #define BLKDUMPUSEDBUFFERS _IO(0x12,119) #endif const char *progname; static void usage(void) { fprintf(stderr, "Usage: %s disk\n", progname); 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. */ if (ioctl(fd, BLKDUMPUSEDBUFFERS, 0) < 0) { perror("ioctl BLKDUMPUSEDBUFFERS"); exit(1); } return 0; }