Subject: [PATCH] gpt, dos: reject new partitions on mounted disks Before allocating a new partition, ask the existing engine offline check whether volumes on the disk are mounted. Return EBUSY without creating a segment when the disk is not offline. diff --git a/plugins/dos/defsegmgr.c b/plugins/dos/defsegmgr.c index 33fea00..5f68747 100644 --- a/plugins/dos/defsegmgr.c +++ b/plugins/dos/defsegmgr.c @@ -855,6 +855,13 @@ static int CreateDiskSegment( DISKSEG * free_space, /* a free } } + if (ld->object_type == DISK && + strncmp(ld->name, "mpath", 5) != 0 && + !EngFncs->is_offline(ld, NULL)) { + LOG_EXIT_INT(EBUSY); + return EBUSY; + } + /* * Dump debug info to engine log */ diff --git a/plugins/gpt/gptsegmgr.c b/plugins/gpt/gptsegmgr.c index 7659735..4898024 100644 --- a/plugins/gpt/gptsegmgr.c +++ b/plugins/gpt/gptsegmgr.c @@ -1134,6 +1134,13 @@ static int CreateDiskSegment( storage_object_t * freespace, /* a return rc; } + if (ld->object_type == DISK && + strncmp(ld->name, "mpath", 5) != 0 && + !EngFncs->is_offline(ld, NULL)) { + LOG_EXIT_INT(EBUSY); + return EBUSY; + } + /* * Dump debug info to engine log */