*/
static time_t last_rescan = 0;
+static const char *skipped_fs_types[] = {
+#if defined(HAVE_LINUX_OS)
+ "rootfs",
+#endif
+ NULL
+};
+
/**
* Add a new entry to the cache.
* This function should be called with a write lock on the mntent_cache.
mntent_cache_entry_hashtable->insert(mce->dev, mce);
}
+static inline bool skip_fstype(const char *fstype)
+{
+ int i;
+
+ for (i = 0; skipped_fs_types[i]; i++) {
+ if (bstrcmp(fstype, skipped_fs_types[i]))
+ return true;
+ }
+
+ return false;
+}
+
/**
* OS specific function to load the different mntents into the cache.
* This function should be called with a write lock on the mntent_cache.
#endif
while ((mnt = getmntent(fp)) != (struct mntent *)NULL) {
+ if (skip_fstype(mnt->mnt_type)) {
+ continue;
+ }
+
if (stat(mnt->mnt_dir, &st) < 0) {
continue;
}
return;
while (getmntent(fp, &mnt) == 0) {
+ if (skip_fstype(mnt.mnt_fstype)) {
+ continue;
+ }
+
if (stat(mnt.mnt_mountp, &st) < 0) {
continue;
}
if ((cnt = getmntinfo(&mntinfo, flags)) > 0) {
while (cnt > 0) {
- if (stat(mntinfo->f_mntonname, &st) == 0) {
+ if (!skip_fstype(mntinfo->f_fstypename) &&
+ stat(mntinfo->f_mntonname, &st) == 0) {
add_mntent_mapping(st.st_dev,
mntinfo->f_mntfromname,
mntinfo->f_mntonname,
while (cnt < n_entries) {
vmp = (struct vmount *)current;
+ if (skip_fstype(ve->vfsent_name)) {
+ continue;
+ }
+
if (stat(current + vmp->vmt_data[VMT_STUB].vmt_off, &st) < 0) {
continue;
}
cnt = 0;
current = entries;
while (cnt < n_entries) {
+ if (skip_fstype(current->f_fstypename)) {
+ continue;
+ }
+
if (stat(current->f_mntonname, &st) < 0) {
continue;
}
/**
* Flush the current content from the cache.
- * This function should be called with a write lock on the mntent_cache.
*/
-static void flush_mntent_cache(void)
+void flush_mntent_cache(void)
{
/**
- * Make sure the cache is empty (either by flushing it or by initializing it.)
+ * Lock the cache.
*/
- clear_mount_cache();
+ P(mntent_cache_lock);
+
+ if (mntent_cache_entry_hashtable) {
+ previous_cache_hit = NULL;
+ mntent_cache_entry_hashtable->destroy();
+ mntent_cache_entry_hashtable = NULL;
+ }
+
+ V(mntent_cache_lock);
}
/**
* the lookup again.
*/
if (!mce) {
- /**
- * Make sure the cache is empty (either by flushing it or by initializing it.)
- */
- clear_mount_cache();
-
- /**
- * Refresh the cache.
- */
- refresh_mount_cache();
-
+ initialize_mntent_cache();
mce = (mntent_cache_entry_t *)mntent_cache_entry_hashtable->lookup(dev);
}