Merge branch 'debian/master' into debian/backports
[e2fsprogs.git] / misc / check_fuzzer.c
blobcee21bfe62bd0b6fd7dc15626ea9c154e9e9b012
1 /*
2 * Play with a file system image quickly to find UBSAN problems
4 * Run a file system through some of the libext2fs functions used by
5 * some fuzzer reports.
6 */
8 #include <stdio.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <stdlib.h>
12 #include <time.h>
13 #include <sys/types.h>
14 #include <sys/time.h>
16 #include <ext2fs/ext2_fs.h>
17 #include <ext2fs/ext2fs.h>
19 int main (int argc, char *argv[])
21 errcode_t retval = 0;
22 ext2_filsys fs;
23 int exit_status = 1;
25 initialize_ext2_error_table();
27 if (argc != 2) {
28 fprintf(stderr, "%s: Usage <device|filesystem>\n", argv[0]);
29 exit(1);
32 retval = ext2fs_open(argv[1], 0, 0, 0,
33 unix_io_manager, &fs);
34 if (retval) {
35 com_err(argv[0], retval, "while trying to open '%s'",
36 argv[1]);
37 exit(1);
40 retval = ext2fs_read_inode_bitmap(fs);
41 if (retval) {
42 com_err(argv[0], retval, "while trying to read inode bitmaps");
43 goto errout;
46 retval = ext2fs_read_block_bitmap(fs);
47 if (retval) {
48 com_err(argv[0], retval, "while trying to read inode bitmaps");
49 goto errout;
52 retval = ext2fs_check_directory(fs, EXT2_ROOT_INO);
53 if (retval) {
54 com_err(argv[0], retval, "while trying to read inode bitmaps");
55 goto errout;
57 exit_status = 0;
58 errout:
59 ext2fs_close(fs);
60 return exit_status;