[PATCH] block: return EBUSY from drop_partitions on mounted whole disk device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The BLKRRPART ioctl already fails today if any partition under
the device is mounted.  However, if we mkfs a whole disk and mount
it, BLKRRPART happily proceeds down the invalidation path, which
seems like a bad idea.

Check whether the whole device is mounted by checking bd_super,
and return -EBUSY if so.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

I don't know for sure if this is the right approach, but figure
I'll ask in the form of a patch.  ;)

diff --git a/block/partition-generic.c b/block/partition-generic.c
index 0d9e5f9..04f304c 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -397,7 +397,7 @@ static int drop_partitions(struct gendisk *disk, struct block_device *bdev)
 	struct hd_struct *part;
 	int res;
 
-	if (bdev->bd_part_count)
+	if (bdev->bd_super || bdev->bd_part_count)
 		return -EBUSY;
 	res = invalidate_partition(disk, 0);
 	if (res)

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux