summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-05-16 05:26:09 -0700
committerGitHub <noreply@github.com>2023-05-16 05:26:09 -0700
commitb10c4acfa38e0b00df4209edfb62ad726ae51084 (patch)
tree1e89a0b720e53f67611e1fcf871beb7f8b2d4db3 /src
parent8a1b59059162793b537801e777b73aadd8087f9e (diff)
parent04dc2db08a98d309675cabe0eb066c5f4f5ad02f (diff)
downloadsystemd-b10c4acfa38e0b00df4209edfb62ad726ae51084.tar.gz
Merge pull request #27647 from poettering/mount-setup-tweaklets
mount-setup: minor tweaks
Diffstat (limited to 'src')
-rw-r--r--src/shared/mount-setup.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/shared/mount-setup.c b/src/shared/mount-setup.c
index a920e8a92a..edd37c193a 100644
--- a/src/shared/mount-setup.c
+++ b/src/shared/mount-setup.c
@@ -114,6 +114,8 @@ static const MountPoint mount_table[] = {
NULL, MNT_NONE, },
};
+assert_cc(N_EARLY_MOUNT <= ELEMENTSOF(mount_table));
+
bool mount_point_is_api(const char *path) {
/* Checks if this mount point is considered "API", and hence
* should be ignored */
@@ -186,13 +188,11 @@ static int mount_one(const MountPoint *p, bool relabel) {
strna(p->options));
if (FLAGS_SET(p->mode, MNT_FOLLOW_SYMLINK))
- r = RET_NERRNO(mount(p->what, p->where, p->type, p->flags, p->options));
+ r = mount_follow_verbose(priority, p->what, p->where, p->type, p->flags, p->options);
else
- r = mount_nofollow(p->what, p->where, p->type, p->flags, p->options);
- if (r < 0) {
- log_full_errno(priority, r, "Failed to mount %s at %s: %m", p->type, p->where);
+ r = mount_nofollow_verbose(priority, p->what, p->where, p->type, p->flags, p->options);
+ if (r < 0)
return (p->mode & MNT_FATAL) ? r : 0;
- }
/* Relabel again, since we now mounted something fresh here */
if (relabel)
@@ -205,7 +205,7 @@ static int mount_one(const MountPoint *p, bool relabel) {
(void) umount2(p->where, UMOUNT_NOFOLLOW);
(void) rmdir(p->where);
- log_full_errno(priority, r, "Mount point %s not writable after mounting: %m", p->where);
+ log_full_errno(priority, r, "Mount point %s not writable after mounting, undoing: %m", p->where);
return (p->mode & MNT_FATAL) ? r : 0;
}
}
@@ -213,27 +213,23 @@ static int mount_one(const MountPoint *p, bool relabel) {
return 1;
}
-static int mount_points_setup(unsigned n, bool loaded_policy) {
- unsigned i;
- int r = 0;
+static int mount_points_setup(size_t n, bool loaded_policy) {
+ int ret = 0, r;
- for (i = 0; i < n; i ++) {
- int j;
+ assert(n <= ELEMENTSOF(mount_table));
- j = mount_one(mount_table + i, loaded_policy);
- if (j != 0 && r >= 0)
- r = j;
+ FOREACH_ARRAY(mp, mount_table, n) {
+ r = mount_one(mp, loaded_policy);
+ if (r != 0 && ret >= 0)
+ ret = r;
}
- return r;
+ return ret;
}
int mount_setup_early(void) {
- assert_cc(N_EARLY_MOUNT <= ELEMENTSOF(mount_table));
-
- /* Do a minimal mount of /proc and friends to enable the most
- * basic stuff, such as SELinux */
- return mount_points_setup(N_EARLY_MOUNT, false);
+ /* Do a minimal mount of /proc and friends to enable the most basic stuff, such as SELinux */
+ return mount_points_setup(N_EARLY_MOUNT, /* loaded_policy= */ false);
}
static const char *join_with(const char *controller) {
@@ -279,7 +275,7 @@ static int symlink_controller(const char *target, const char *alias) {
p = strjoina("/sys/fs/cgroup/", target);
r = mac_smack_copy(a, p);
- if (r < 0 && r != -EOPNOTSUPP)
+ if (r < 0 && !ERRNO_IS_NOT_SUPPORTED(r))
return log_error_errno(r, "Failed to copy smack label from %s to %s: %m", p, a);
#endif