mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 00:47:10 +09:00
fstab-util: introduce fstab_has_fstype() helper
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "macro.h"
|
||||
|
||||
int fstab_is_mount_point(const char *mount);
|
||||
int fstab_has_fstype(const char *fstype);
|
||||
|
||||
int fstab_filter_options(const char *opts, const char *names, const char **namefound, char **value, char **filtered);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user