summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-05-15 11:53:07 +0200
committerLennart Poettering <lennart@poettering.net>2023-05-16 10:01:28 +0200
commit04dc2db08a98d309675cabe0eb066c5f4f5ad02f (patch)
tree31fc086120f418e9fb7105c430a1e786119cbc03 /src
parentce6fa09567ca95a25130a4f22f632d09c30330fe (diff)
downloadsystemd-04dc2db08a98d309675cabe0eb066c5f4f5ad02f.tar.gz
mount-setup: minor modernization
Diffstat (limited to 'src')
-rw-r--r--src/shared/mount-setup.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/shared/mount-setup.c b/src/shared/mount-setup.c
index e9cc57901c..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 */
@@ -211,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) {
@@ -277,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