diff --git a/pkg/storaged/format-dialog.jsx b/pkg/storaged/format-dialog.jsx index 5b8802a0e086..2da510c65df7 100644 --- a/pkg/storaged/format-dialog.jsx +++ b/pkg/storaged/format-dialog.jsx @@ -274,8 +274,7 @@ function format_dialog_internal(client, path, start, size, enable_dos_extended, visible: is_filesystem, value: old_dir || "", validate: (val, values, variant) => { - if (variant !== "nomount") - return is_valid_mount_point(client, block, val); + return is_valid_mount_point(client, block, val, variant == "nomount"); } }), SelectOne("type", _("Type"), diff --git a/pkg/storaged/fsys-tab.jsx b/pkg/storaged/fsys-tab.jsx index bca681d78c8e..a6465500b488 100644 --- a/pkg/storaged/fsys-tab.jsx +++ b/pkg/storaged/fsys-tab.jsx @@ -96,16 +96,19 @@ function nice_block_name(block) { return utils.block_name(client.blocks[block.CryptoBackingDevice] || block); } -export async function is_valid_mount_point(client, block, val, ignore_overmounting) { - if (val === "") - return _("Mount point cannot be empty"); +export function is_valid_mount_point(client, block, val, format_only, for_fstab) { + if (val === "") { + if (!format_only || for_fstab) + return _("Mount point cannot be empty"); + return null; + } const other_blocks = find_blocks_for_mount_point(client, val, block); if (other_blocks.length > 0) return cockpit.format(_("Mount point is already used for $0"), other_blocks.map(nice_block_name).join(", ")); - if (!ignore_overmounting) { + if (!format_only) { const children = utils.find_children_for_mount_point(client, val, block); if (Object.keys(children).length > 0) return <> @@ -329,8 +332,7 @@ export function mounting_dialog(client, block, mode, forced_options) { TextInput("mount_point", _("Mount point"), { value: old_dir, - validate: val => is_valid_mount_point(client, block, val, - mode == "update" && !is_filesystem_mounted) + validate: val => is_valid_mount_point(client, block, val, mode == "update" && !is_filesystem_mounted, true) }), CheckBoxes("mount_options", _("Mount options"), { diff --git a/pkg/storaged/stratis-details.jsx b/pkg/storaged/stratis-details.jsx index 52acdf137241..25a3d0289f93 100644 --- a/pkg/storaged/stratis-details.jsx +++ b/pkg/storaged/stratis-details.jsx @@ -328,8 +328,7 @@ export function stratis_content_rows(client, pool, options) { TextInput("mount_point", _("Mount point"), { validate: (val, values, variant) => { - if (variant !== "nomount") - return is_valid_mount_point(client, null, val); + return is_valid_mount_point(client, null, val, variant == "nomount"); } }), CheckBoxes("mount_options", _("Mount options"), @@ -514,8 +513,7 @@ function create_fs(client, pool) { TextInput("mount_point", _("Mount point"), { validate: (val, values, variant) => { - if (variant !== "nomount") - return is_valid_mount_point(client, null, val); + return is_valid_mount_point(client, null, val, variant == "nomount"); } }), CheckBoxes("mount_options", _("Mount options"), diff --git a/test/verify/check-storage-mounting b/test/verify/check-storage-mounting index 131b4020f198..0ceb3de4dc68 100755 --- a/test/verify/check-storage-mounting +++ b/test/verify/check-storage-mounting @@ -459,6 +459,9 @@ class TestStorageMountingLUKS(storagelib.StorageCase): self.dialog_set_val("mount_point", "/run/data") self.dialog_apply() self.dialog_wait_error("mount_point", "Mount point is already used for /dev/test/one") + self.dialog_set_val("mount_point", "/run/data") # to clear the error + self.dialog_apply_secondary() + self.dialog_wait_error("mount_point", "Mount point is already used for /dev/test/one") self.dialog_cancel() self.dialog_wait_close()