Linux block layer
 help / color / mirror / Atom feed
* [PATCH] block: fix ioctl return error with GENHD_FL_NO_PART
@ 2023-10-17  8:09 Li Wang
  2023-10-17  8:58 ` Li Lingfeng
  0 siblings, 1 reply; 4+ messages in thread
From: Li Wang @ 2023-10-17  8:09 UTC (permalink / raw)
  To: axboe, lilingfeng3, linux-block, linux-kernel

GENHD_FL_NO_PART means no device(-ENXIO), not parameter error(-EINVAL).

test case with parted command:
@dd if=/dev/zero of=./blk-file bs=1M count=200
@losetup /dev/loop0 ./blk-file
@parted -s /dev/loop0 mklabel MSDOS
Error: Partition(s) 1, ..., 64 on /dev/loop0 have been written,
but we have been unable to inform the kernel of the change,
probably because it/they are in use. As a result,
the old partition(s) will remain in use. You should reboot now
before making further changes.
@echo $?
1

Fixes: 1a721de8489f ("block: don't add or resize partition on the disk with GENHD_FL_NO_PART")
Signed-off-by: Li Wang <li.wang@windriver.com>
---
 block/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/ioctl.c b/block/ioctl.c
index d5f5cd61efd7..701c64cd67e8 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -21,7 +21,7 @@ static int blkpg_do_ioctl(struct block_device *bdev,
 	long long start, length;
 
 	if (disk->flags & GENHD_FL_NO_PART)
-		return -EINVAL;
+		return -ENXIO;
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 	if (copy_from_user(&p, upart, sizeof(struct blkpg_partition)))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-17 11:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-17  8:09 [PATCH] block: fix ioctl return error with GENHD_FL_NO_PART Li Wang
2023-10-17  8:58 ` Li Lingfeng
2023-10-17  9:26   ` Wang, Li
2023-10-17 11:21     ` Li Lingfeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox