mirror of
https://github.com/systemd/systemd.git
synced 2025-03-19 22:50:17 +03:00
fstab-util: don't eat up errors in fstab_is_mount_point()
That way the caller can decide what to do with failures, whether to consider them or ignore them.
This commit is contained in:
parent
d31ae54818
commit
b9088048b1
@ -435,7 +435,10 @@ static int add_esp(DissectedPartition *p) {
|
|||||||
esp = access("/efi/", F_OK) >= 0 ? "/efi" : "/boot";
|
esp = access("/efi/", F_OK) >= 0 ? "/efi" : "/boot";
|
||||||
|
|
||||||
/* We create an .automount which is not overridden by the .mount from the fstab generator. */
|
/* We create an .automount which is not overridden by the .mount from the fstab generator. */
|
||||||
if (fstab_is_mount_point(esp)) {
|
r = fstab_is_mount_point(esp);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to parse fstab: %m");
|
||||||
|
if (r == 0) {
|
||||||
log_debug("%s specified in fstab, ignoring.", esp);
|
log_debug("%s specified in fstab, ignoring.", esp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -34,18 +34,23 @@
|
|||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
bool fstab_is_mount_point(const char *mount) {
|
int fstab_is_mount_point(const char *mount) {
|
||||||
_cleanup_endmntent_ FILE *f = NULL;
|
_cleanup_endmntent_ FILE *f = NULL;
|
||||||
struct mntent *m;
|
struct mntent *m;
|
||||||
|
|
||||||
f = setmntent("/etc/fstab", "re");
|
f = setmntent("/etc/fstab", "re");
|
||||||
if (!f)
|
if (!f)
|
||||||
return false;
|
return errno == ENOENT ? false : -errno;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
errno = 0;
|
||||||
|
m = getmntent(f);
|
||||||
|
if (!m)
|
||||||
|
return errno != 0 ? -errno : false;
|
||||||
|
|
||||||
while ((m = getmntent(f)))
|
|
||||||
if (path_equal(m->mnt_dir, mount))
|
if (path_equal(m->mnt_dir, mount))
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
|
|
||||||
bool fstab_is_mount_point(const char *mount);
|
int fstab_is_mount_point(const char *mount);
|
||||||
|
|
||||||
int fstab_filter_options(const char *opts, const char *names, const char **namefound, char **value, char **filtered);
|
int fstab_filter_options(const char *opts, const char *names, const char **namefound, char **value, char **filtered);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user