Skip to main content

mount_esp_writable

Function mount_esp_writable 

Source
pub fn mount_esp_writable(device: &str) -> Result<TempMount>
Expand description

Get a read-write view of the ESP for the provided device, gracefully handling the case where the ESP is already mounted (possibly read-only) in the current mount namespace.

If the ESP’s device is already mounted, that mount is unconditionally remounted read-write in place first – the same approach already used for /sysroot in open_dir_remount_rw, which likewise doesn’t bother checking whether it’s already writable before remounting. This matters because our own fresh mount(2) below would otherwise get EBUSY from the kernel’s get_tree_bdev_flags() if the existing mount’s MS_RDONLY state doesn’t match what we’re requesting (e.g. via a systemd.mount-extra=UUID=...:/boot:auto:ro cmdline karg written by bootc install to-filesystem). Note remounting a private clone of the existing mount would not be sufficient here: that only clears the clone’s own mount-level read-only flag, not the shared superblock’s, so writes through it would still fail with EROFS. Remounting the existing mount directly is safe because bootc always runs in its own unshared mount namespace (see cli::ensure_self_unshared_mount_namespace).