Skip to content

Commit

Permalink
Return EBUSY from BLKRRPART for mounted whole-dev fs
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Eric Sandeen authored and axboe committed Nov 26, 2015
1 parent 78c4a49 commit 77032ca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/partition-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_part_count || bdev->bd_super)
return -EBUSY;
res = invalidate_partition(disk, 0);
if (res)
Expand Down

0 comments on commit 77032ca

Please sign in to comment.