diff options
author | robi <robi> | 2010-10-21 00:26:25 +0000 |
---|---|---|
committer | robi <robi> | 2010-10-21 00:26:25 +0000 |
commit | 0c1eea1cdef832dd75ee8d020f3258ba8eadfdb4 (patch) | |
tree | 94f3fb34a41a3626005c2ec067a9c3814bdb6f9a /src/ext4magic.c | |
parent | 89cc6be0e26452bfb2f456bc0d6ee6cfbd101479 (diff) |
segfault if filesystem can not open
Diffstat (limited to 'src/ext4magic.c')
-rw-r--r-- | src/ext4magic.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/ext4magic.c b/src/ext4magic.c index b747941..7a07eda 100644 --- a/src/ext4magic.c +++ b/src/ext4magic.c @@ -191,7 +191,7 @@ static void open_filesystem(char *device, int open_flags, blk_t superblock, retval = ext2fs_open(device, open_flags, superblock, blocksize, unix_io_manager, ¤t_fs); if (retval) { - fprintf(stderr,"%s %d while opening filesystem \n", device, retval); + fprintf(stderr,"%s Error %d while opening filesystem \n", device, retval); current_fs = NULL; return; } @@ -199,12 +199,12 @@ static void open_filesystem(char *device, int open_flags, blk_t superblock, retval = ext2fs_read_inode_bitmap(current_fs); if (retval) { - fprintf(stderr,"%s %d while reading inode bitmap\n", device, retval); + fprintf(stderr,"%s Error %d while reading inode bitmap\n", device, retval); goto errout; } retval = ext2fs_read_block_bitmap(current_fs); if (retval) { - fprintf(stderr,"%s %d while reading block bitmap\n",device, retval); + fprintf(stderr,"%s Error %d while reading block bitmap\n",device, retval); goto errout; } @@ -226,7 +226,7 @@ static void open_filesystem(char *device, int open_flags, blk_t superblock, if (data_io) { retval = ext2fs_set_data_io(current_fs, data_io); if (retval) { - fprintf(stderr,"%s %d while setting data source\n", device, retval); + fprintf(stderr,"%s Error %d while setting data source\n", device, retval); goto errout; } } @@ -240,7 +240,7 @@ errout: #endif retval = ext2fs_close(current_fs); if (retval) - fprintf(stderr, "%s %d while trying to close filesystem\n", device, retval); + fprintf(stderr, "%s Error %d while trying to close filesystem\n", device, retval); current_fs = NULL; } @@ -594,6 +594,8 @@ while ((c = getopt (argc, argv, "TJRMLlmrQSxi:t:j:f:Vd:B:b:a:I:H")) != EOF) { if (getuid()) mode = 0; if (optind < argc) open_filesystem(argv[optind], open_flags,superblock, blocksize, magicscan, data_filename); + + if (! current_fs) mode = 0; #ifdef DEBUG printf("Operation-mode = %d\n", mode); #endif |