mount-util: beef up bind_remount_recursive() to be able to toggle more than MS_RDONLY
The function is otherwise generic enough to toggle other bind mount flags beyond MS_RDONLY (for example: MS_NOSUID or MS_NODEV), hence let's beef it up slightly to support that too.
This commit is contained in:
@@ -730,7 +730,7 @@ static int mount_bind(const char *dest, CustomMount *m) {
|
||||
return r;
|
||||
|
||||
if (m->read_only) {
|
||||
r = bind_remount_recursive(where, true, NULL);
|
||||
r = bind_remount_recursive(where, MS_RDONLY, MS_RDONLY, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Read-only bind mount failed: %m");
|
||||
}
|
||||
@@ -938,7 +938,7 @@ static int setup_volatile_state(
|
||||
|
||||
/* --volatile=state means we simply overmount /var with a tmpfs, and the rest read-only. */
|
||||
|
||||
r = bind_remount_recursive(directory, true, NULL);
|
||||
r = bind_remount_recursive(directory, MS_RDONLY, MS_RDONLY, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to remount %s read-only: %m", directory);
|
||||
|
||||
@@ -1004,7 +1004,7 @@ static int setup_volatile_yes(
|
||||
|
||||
bind_mounted = true;
|
||||
|
||||
r = bind_remount_recursive(t, true, NULL);
|
||||
r = bind_remount_recursive(t, MS_RDONLY, MS_RDONLY, NULL);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to remount %s read-only: %m", t);
|
||||
goto fail;
|
||||
|
||||
+1
-1
@@ -3323,7 +3323,7 @@ static int outer_child(
|
||||
return r;
|
||||
|
||||
if (arg_read_only && arg_volatile_mode == VOLATILE_NO) {
|
||||
r = bind_remount_recursive(directory, true, NULL);
|
||||
r = bind_remount_recursive(directory, MS_RDONLY, MS_RDONLY, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to make tree read-only: %m");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user