summaryrefslogtreecommitdiffstats
path: root/src/shared/fstab-util.c
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2017-06-26 15:22:10 +0200
committerFranck Bui <fbui@suse.com>2017-06-27 10:04:46 +0200
commit6c1921e9f39ce450bbd066341afc6a677ef122cb (patch)
tree32e40a81559ecea510cf27456138642b6ae957a9 /src/shared/fstab-util.c
parentfstab-util: don't eat up errors in fstab_is_mount_point() (diff)
downloadsystemd-6c1921e9f39ce450bbd066341afc6a677ef122cb.tar.xz
systemd-6c1921e9f39ce450bbd066341afc6a677ef122cb.zip
fstab-util: introduce fstab_has_fstype() helper
Diffstat (limited to 'src/shared/fstab-util.c')
-rw-r--r--src/shared/fstab-util.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c
index 5675b0beac..ec2e868ca8 100644
--- a/src/shared/fstab-util.c
+++ b/src/shared/fstab-util.c
@@ -34,6 +34,26 @@
#include "strv.h"
#include "util.h"
+int fstab_has_fstype(const char *fstype) {
+ _cleanup_endmntent_ FILE *f = NULL;
+ struct mntent *m;
+
+ f = setmntent("/etc/fstab", "re");
+ if (!f)
+ return errno == ENOENT ? false : -errno;
+
+ for (;;) {
+ errno = 0;
+ m = getmntent(f);
+ if (!m)
+ return errno != 0 ? -errno : false;
+
+ if (streq(m->mnt_type, fstype))
+ return true;
+ }
+ return false;
+}
+
int fstab_is_mount_point(const char *mount) {
_cleanup_endmntent_ FILE *f = NULL;
struct mntent *m;