fstab-util: introduce fstab_is_extrinsic()

This commit is contained in:
Franck Bui
2020-04-01 10:36:28 +02:00
parent b862c25716
commit bc9e5a4c67
3 changed files with 32 additions and 19 deletions
+24
View File
@@ -35,6 +35,30 @@ int fstab_has_fstype(const char *fstype) {
return false;
}
bool fstab_is_extrinsic(const char *mount, const char *opts) {
/* Don't bother with the OS data itself */
if (PATH_IN_SET(mount,
"/",
"/usr",
"/etc"))
return true;
if (PATH_STARTSWITH_SET(mount,
"/run/initramfs", /* This should stay around from before we boot until after we shutdown */
"/proc", /* All of this is API VFS */
"/sys", /* … dito … */
"/dev")) /* … dito … */
return true;
/* If this is an initrd mount, and we are not in the initrd, then leave
* this around forever, too. */
if (opts && fstab_test_option(opts, "x-initrd.mount\0") && !in_initrd())
return true;
return false;
}
int fstab_is_mount_point(const char *mount) {
_cleanup_endmntent_ FILE *f = NULL;
struct mntent *m;
+1
View File
@@ -6,6 +6,7 @@
#include "macro.h"
bool fstab_is_extrinsic(const char *mount, const char *opts);
int fstab_is_mount_point(const char *mount);
int fstab_has_fstype(const char *fstype);