Skip to content

Commit 77032ca

Browse files
Eric Sandeenaxboe
authored andcommitted
Return EBUSY from BLKRRPART for mounted whole-dev fs
Today, blockdev --rereadpt /dev/sda will fail with EBUSY if any partition of sda is mounted (and will fail with EINVAL if pointed at a partition). But it will pass if the entire block device is formatted with a filesystem and mounted. I don't think this makes sense; partitioning should surely not ever change out from under a mounted device. So check for bdev->bd_super, and fail that with -EBUSY as well. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent 78c4a49 commit 77032ca

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎block/partition-generic.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static int drop_partitions(struct gendisk *disk, struct block_device *bdev)
397397
struct hd_struct *part;
398398
int res;
399399

400-
if (bdev->bd_part_count)
400+
if (bdev->bd_part_count || bdev->bd_super)
401401
return -EBUSY;
402402
res = invalidate_partition(disk, 0);
403403
if (res)

0 commit comments

Comments
 (0)