static int (*dl_magic_load)(magic_t, const char *);
static void (*dl_magic_close)(magic_t);
+/*
+ * NO_CHECK functionality was only added in file 4.20.
+ * Older systems like RHEL 5.x still have file 4.17
+ */
+#ifndef MAGIC_NO_CHECK_COMPRESS
+#define MAGIC_NO_CHECK_COMPRESS 0x0001000
+#endif
+#ifndef MAGIC_NO_CHECK_ELF
+#define MAGIC_NO_CHECK_ELF 0x0010000
+#endif
+
#ifdef HAVE_DLOPEN
#include <dlfcn.h>
ext2_filsys fs;
errcode_t retval;
time_t tm;
- char buf[80];
retval = ext2fs_open2(device, 0, EXT2_FLAG_64BITS, 0, 0,
- unix_io_manager, &fs);
+#ifdef _WIN64
+ windows_io_manager,
+#else
+ unix_io_manager,
+#endif
+ &fs);
if (retval)
return;
sb = fs->super;
if (sb->s_mtime) {
tm = sb->s_mtime;
- if (sb->s_last_mounted[0]) {
- memset(buf, 0, sizeof(buf));
- strncpy(buf, sb->s_last_mounted,
- sizeof(sb->s_last_mounted));
- printf(_("\tlast mounted on %s on %s"), buf,
- ctime(&tm));
- } else
+ if (sb->s_last_mounted[0])
+ printf(_("\tlast mounted on %.*s on %s"),
+ EXT2_LEN_STR(sb->s_last_mounted), ctime(&tm));
+ else
printf(_("\tlast mounted on %s"), ctime(&tm));
} else if (sb->s_mkfs_time) {
tm = sb->s_mkfs_time;
if (fs_type) {
if (fs_label)
- printf(_("%s contains a %s file system "
- "labelled '%s'\n"), device, fs_type, fs_label);
+ printf(_("%s contains a %s file system labelled '%s'\n"),
+ device, fs_type, fs_label);
else
printf(_("%s contains a %s file system\n"), device,
fs_type);
}
#ifdef HAVE_MAGIC_H
- if ((flags & CHECK_FS_EXIST) && magic_library_available()) {
+ if ((flags & CHECK_FS_EXIST) &&
+ !getenv("E2FSPROGS_LIBMAGIC_SUPPRESS") &&
+ magic_library_available()) {
const char *msg;
magic_t mag;
int has_magic = 0;
return !has_magic;
}
#endif
-
- ret = check_partition_table(device);
- if (ret >= 0)
- return ret;
-
+ if (flags & CHECK_FS_EXIST) {
+ ret = check_partition_table(device);
+ if (ret >= 0)
+ return ret;
+ }
return 1;
}