1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-12 13:18:14 +03:00

Merge pull request #27647 from poettering/mount-setup-tweaklets

mount-setup: minor tweaks
This commit is contained in:
Lennart Poettering 2023-05-16 05:26:09 -07:00 committed by GitHub
commit b10c4acfa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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