gboolean gsd_should_ignore_unix_mount (GUnixMountEntry *mount) { const char *fs, *device; guint i; /* This is borrowed from GLib and used as a way to determine * which mounts we should ignore by default. GLib doesn't * expose this in a way that allows it to be used for this * purpose */ /* We also ignore network filesystems */ const gchar *ignore_fs[] = { "adfs", "afs", "auto", "autofs", "autofs4", "cgroup", "cifs", "configfs", "cxfs", "debugfs", "devfs", "devpts", "devtmpfs", "ecryptfs", "fdescfs", "fusectl", "gfs", "gfs2", "gpfs", "hugetlbfs", "kernfs", "linprocfs", "linsysfs", "lustre", "lustre_lite", "mfs", "mqueue", "ncpfs", "nfs", "nfs4", "nfsd", "nullfs", "ocfs2", "overlay", "proc", "procfs", "pstore", "ptyfs", "rootfs", "rpc_pipefs", "securityfs", "selinuxfs", "smbfs", "sysfs", "tmpfs", "usbfs", "zfs", NULL }; const gchar *ignore_devices[] = { "none", "sunrpc", "devpts", "nfsd", "/dev/loop", "/dev/vn", NULL }; fs = g_unix_mount_get_fs_type (mount); device = g_unix_mount_get_device_path (mount); for (i = 0; ignore_fs[i] != NULL; i++) if (g_str_equal (ignore_fs[i], fs)) return TRUE; for (i = 0; ignore_devices[i] != NULL; i++) if (g_str_equal (ignore_devices[i], device)) return TRUE; return FALSE; }
static VALUE unixmount_get_device_path(VALUE self) { return CSTR2RVAL(g_unix_mount_get_device_path(_SELF(self))); }
static gboolean ldsm_mount_should_ignore (GUnixMountEntry *mount) { const gchar *fs, *device, *path; path = g_unix_mount_get_mount_path (mount); if (ldsm_mount_is_user_ignore (path)) return TRUE; /* This is borrowed from GLib and used as a way to determine * which mounts we should ignore by default. GLib doesn't * expose this in a way that allows it to be used for this * purpose */ /* We also ignore network filesystems */ const gchar *ignore_fs[] = { "adfs", "afs", "auto", "autofs", "autofs4", "cifs", "cxfs", "devfs", "devpts", "ecryptfs", "fdescfs", "gfs", "gfs2", "kernfs", "linprocfs", "linsysfs", "lustre", "lustre_lite", "ncpfs", "nfs", "nfs4", "nfsd", "ocfs2", "proc", "procfs", "ptyfs", "rpc_pipefs", "selinuxfs", "smbfs", "sysfs", "tmpfs", "usbfs", "zfs", NULL }; const gchar *ignore_devices[] = { "none", "sunrpc", "devpts", "nfsd", "/dev/loop", "/dev/vn", NULL }; fs = g_unix_mount_get_fs_type (mount); device = g_unix_mount_get_device_path (mount); if (is_in (fs, ignore_fs)) return TRUE; if (is_in (device, ignore_devices)) return TRUE; return FALSE; }
static RmMountEntries *rm_mount_list_open(RmMountTable *table) { RmMountEntries *self = g_slice_new(RmMountEntries); self->mnt_entries = g_unix_mounts_get(NULL); self->entries = NULL; self->current = NULL; for(GList *iter = self->mnt_entries; iter; iter = iter->next) { RmMountEntry *wrap_entry = g_slice_new(RmMountEntry); GUnixMountEntry *entry = iter->data; wrap_entry->fsname = g_strdup(g_unix_mount_get_device_path(entry)); wrap_entry->dir = g_strdup(g_unix_mount_get_mount_path(entry)); wrap_entry->type = g_strdup(g_unix_mount_get_fs_type(entry)); self->entries = g_list_prepend(self->entries, wrap_entry); } RmMountEntry *wrap_entry = NULL; while((wrap_entry = rm_mount_list_next(self))) { /* bindfs mounts mirror directory trees. * This cannot be detected properly by rmlint since * files in it have the same inode as their unmirrored file, but * a different dev_t. * * Also ignore kernel filesystems. * * So better go and ignore it. */ static struct RmEvilFs { /* fsname as show by `mount` */ const char *name; /* Wether to warn about the exclusion on this */ bool unusual; } evilfs_types[] = {{"bindfs", 1}, {"nullfs", 1}, /* Ignore the usual linux file system spam */ {"proc", 0}, {"cgroup", 0}, {"configfs", 0}, {"sys", 0}, {"devtmpfs", 0}, {"debugfs", 0}, {NULL, 0}}; /* btrfs and ocfs2 filesystems support reflinks for deduplication */ static const char *reflinkfs_types[] = {"btrfs", "ocfs2", NULL}; const struct RmEvilFs *evilfs_found = NULL; for(int i = 0; evilfs_types[i].name && !evilfs_found; ++i) { if(strcmp(evilfs_types[i].name, wrap_entry->type) == 0) { evilfs_found = &evilfs_types[i]; } } const char *reflinkfs_found = NULL; for(int i = 0; reflinkfs_types[i] && !reflinkfs_found; ++i) { if(strcmp(reflinkfs_types[i], wrap_entry->type) == 0) { reflinkfs_found = reflinkfs_types[i]; break; } } if(evilfs_found != NULL) { RmStat dir_stat; rm_sys_stat(wrap_entry->dir, &dir_stat); g_hash_table_insert(table->evilfs_table, GUINT_TO_POINTER(dir_stat.st_dev), GUINT_TO_POINTER(1)); GLogLevelFlags log_level = G_LOG_LEVEL_DEBUG; if(evilfs_found->unusual) { log_level = G_LOG_LEVEL_WARNING; rm_log_warning_prefix(); } else { rm_log_debug_prefix(); } g_log("rmlint", log_level, _("`%s` mount detected at %s (#%u); Ignoring all files in it.\n"), evilfs_found->name, wrap_entry->dir, (unsigned)dir_stat.st_dev); } rm_log_debug_line("Filesystem %s: %s", wrap_entry->dir, (reflinkfs_found) ? "reflink" : "normal"); if(reflinkfs_found != NULL) { RmStat dir_stat; rm_sys_stat(wrap_entry->dir, &dir_stat); g_hash_table_insert(table->reflinkfs_table, GUINT_TO_POINTER(dir_stat.st_dev), (gpointer)reflinkfs_found); } } return self; }