Skip to content

Commit 6946703

Browse files
authored
Merge pull request #1749 from kolyshkin/mount-nits
linux: nits to mounting code
2 parents 7143e24 + 37dacae commit 6946703

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/libcrun/linux.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,17 +1243,11 @@ do_mount (libcrun_container_t *container, const char *source, int targetfd,
12431243
}
12441244
}
12451245

1246-
if (mountflags & ALL_PROPAGATIONS)
1246+
if (mountflags & ALL_PROPAGATIONS_NO_REC)
12471247
{
1248-
unsigned long rec = mountflags & MS_REC;
1249-
unsigned long propagation = mountflags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE);
1250-
1251-
if (propagation)
1252-
{
1253-
ret = mount (NULL, real_target, NULL, rec | propagation, NULL);
1254-
if (UNLIKELY (ret < 0))
1255-
return crun_make_error (err, errno, "set propagation for `%s`", target);
1256-
}
1248+
ret = mount (NULL, real_target, NULL, mountflags & ALL_PROPAGATIONS, NULL);
1249+
if (UNLIKELY (ret < 0))
1250+
return crun_make_error (err, errno, "set propagation for `%s`", target);
12571251
}
12581252

12591253
if (mountflags & (MS_BIND | MS_RDONLY))
@@ -2595,7 +2589,7 @@ libcrun_set_mounts (struct container_entrypoint_s *entrypoint_args, libcrun_cont
25952589
if (def->linux->rootfs_propagation)
25962590
rootfs_propagation = get_mount_flags (def->linux->rootfs_propagation, 0, NULL, NULL, NULL, NULL);
25972591

2598-
if ((rootfs_propagation & (MS_SHARED | MS_SLAVE | MS_PRIVATE | MS_UNBINDABLE)) == 0)
2592+
if ((rootfs_propagation & ALL_PROPAGATIONS_NO_REC) == 0)
25992593
rootfs_propagation = MS_REC | MS_PRIVATE;
26002594

26012595
get_private_data (container)->rootfs_propagation = rootfs_propagation;

0 commit comments

Comments
 (0)