if ((flags & CHECK_FS_EXIST) && magic_library_available()) {
const char *msg;
magic_t mag;
+ int has_magic = 0;
mag = dl_magic_open(MAGIC_RAW | MAGIC_SYMLINK | MAGIC_DEVICES |
MAGIC_ERROR | MAGIC_NO_CHECK_ELF |
dl_magic_load(mag, NULL);
msg = dl_magic_file(mag, device);
- if (msg && strcmp(msg, "data") && strcmp(msg, "empty"))
- printf(_("%s contains a `%s'\n"), device, msg);
+ if (msg && strcmp(msg, "data") && strcmp(msg, "empty")) {
+ printf(_("%s contains `%s' data\n"), device, msg);
+ has_magic = 1;
+ }
dl_magic_close(mag);
- return 0;
+ return !has_magic;
}
#endif
or
e2fsck -b 32768 <device>
-test.img contains a `PNG image data, 148 x 31, 8-bit/color RGBA, non-interlaced'
+test.img contains `PNG image data, 148 x 31, 8-bit/color RGBA, non-interlaced' data
*** debugfs
test.img: Bad magic number in super-block while opening filesystem
-test.img contains a `PNG image data, 148 x 31, 8-bit/color RGBA, non-interlaced'
+test.img contains `PNG image data, 148 x 31, 8-bit/color RGBA, non-interlaced' data
*** tune2fs
../misc/tune2fs: Bad magic number in super-block while trying to open test.img
-test.img contains a `PNG image data, 148 x 31, 8-bit/color RGBA, non-interlaced'
+test.img contains `PNG image data, 148 x 31, 8-bit/color RGBA, non-interlaced' data
*** mke2fs
Creating filesystem with 16384 1k blocks and 4096 inodes
Superblock backups stored on blocks:
or
e2fsck -b 32768 <device>
-test.img contains a `PNG image data, 148 x 31, 8-bit/color RGBA, non-interlaced'
+test.img contains `PNG image data, 148 x 31, 8-bit/color RGBA, non-interlaced' data
*** debugfs
*** tune2fs
../misc/tune2fs: Bad magic number in super-block while trying to open test.img
-test.img contains a `PNG image data, 148 x 31, 8-bit/color RGBA, non-interlaced'
+test.img contains `PNG image data, 148 x 31, 8-bit/color RGBA, non-interlaced' data
*** mke2fs
Creating filesystem with 16384 1k blocks and 4096 inodes
Superblock backups stored on blocks:
#!/bin/bash
-if [ "$(grep -c 'define HAVE_MAGIC_H' $test_dir/../../lib/config.h)" -gt 0 ]; then
+if [ "$(grep -c 'define HAVE_MAGIC_H' ../lib/config.h)" -gt 0 ]; then
FSCK_OPT=-fn
IMAGE=$test_dir/image.bz2