- mount me;
- while (read_mount_entry(f, &me)) {
- if (conf_debug_pruning) {
- fprintf(stderr,
- " `%s' (%d on %d) is `%s' of `%s' (%u:%u), type `%s'\n",
- me.mount_point.c_str(), me.id, me.parent_id, me.root.c_str(), me.source.c_str(),
- me.dev_major, me.dev_minor, me.fs_type.c_str());
+ {
+ mount me;
+ while (read_mount_entry(f, &me)) {
+ string fs_type_upper = me.fs_type;
+ for (char &c : fs_type_upper) {
+ c = toupper(c);
+ }
+ me.pruned_due_to_fs_type =
+ (find(conf_prunefs.begin(), conf_prunefs.end(), fs_type_upper) != conf_prunefs.end());
+ mount_entries.emplace(make_pair(me.dev_major, me.dev_minor), me);
+ if (conf_debug_pruning) {
+ fprintf(stderr,
+ " `%s' (%d on %d) is `%s' of `%s' (%u:%u), type `%s' (pruned_fs=%d)\n",
+ me.mount_point.c_str(), me.id, me.parent_id, me.root.c_str(), me.source.c_str(),
+ me.dev_major, me.dev_minor, me.fs_type.c_str(), me.pruned_due_to_fs_type);
+ }
+ }
+ fclose(f);
+ }
+
+ // Now propagate pruned status recursively through parent links
+ // (e.g. if /run is tmpfs, then /run/foo should also be pruned).
+ unordered_map<int, mount *> id_to_mount;
+ for (auto &[key, me] : mount_entries) {
+ id_to_mount[me.id] = &me;
+ }
+ unordered_map<int, bool> id_to_pruned_cache;
+ for (auto &[key, me] : mount_entries) {
+ me.to_remove =
+ find_whether_under_pruned(me.id, id_to_mount, &id_to_pruned_cache);
+ if (conf_debug_pruning && me.to_remove) {
+ fprintf(stderr, " `%s' is, or is under, a pruned file system; removing\n",
+ me.mount_point.c_str());