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>
if (!magic_handle)
return 0;
- dl_magic_open = dlsym(magic_handle, "magic_open");
- dl_magic_file = dlsym(magic_handle, "magic_file");
- dl_magic_load = dlsym(magic_handle, "magic_load");
- dl_magic_close = dlsym(magic_handle, "magic_close");
+ dl_magic_open = (magic_t (*)(int))
+ dlsym(magic_handle, "magic_open");
+ dl_magic_file = (const char *(*)(magic_t, const char *))
+ dlsym(magic_handle, "magic_file");
+ dl_magic_load = (int (*)(magic_t, const char *))
+ dlsym(magic_handle, "magic_load");
+ dl_magic_close = (void (*)(magic_t))
+ dlsym(magic_handle, "magic_close");
}
if (!dl_magic_open || !dl_magic_file ||
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);
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;
* return 1 if there is no partition table, 0 if a partition table is
* detected, and -1 on an error.
*/
+#ifdef HAVE_BLKID_PROBE_ENABLE_PARTITIONS
static int check_partition_table(const char *device)
{
-#ifdef HAVE_BLKID_PROBE_ENABLE_PARTITIONS
blkid_probe pr;
const char *value;
int ret;
errout:
blkid_free_probe(pr);
return ret;
+}
#else
+static int check_partition_table(const char *device EXT2FS_ATTR((unused)))
+{
return -1;
-#endif
}
+#endif
/*
* return 1 if the device looks plausible, creating the file if necessary
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;