Skip to contentSkip to conversation

mtd: ubi: block: Fix error for write access

PATCH RESEND Applied Romain Izard 2 participants 2 messages Mar 2, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 mtd: ubi: block: Fix error for write access

When opening a device with write access, ubiblock_open returns an error code. Currently, this error code is -EPERM, but this is not the right value.

The open function for other block devices returns -EROFS when opening read-only devices with FMODE_WRITE set. When used with dm-verity, the veritysetup userspace tool is expecting EROFS, and refuses to use the ubiblock device.

Use -EROFS for ubiblock as well. As a result, veritysetup accepts the ubiblock device as valid.

Fixes 9d54c8a33eec (UBI: R/O block driver on top of UBI volumes)
---
 drivers/mtd/ubi/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubi/block.c +1 -1
index b210fdb31c98..4533423cf2aa 100644
@@ -242,7 +242,7 @@ static int ubiblock_open(struct block_device *bdev, fmode_t mode)
 	 * in any case.
 	 */
 	if (mode & FMODE_WRITE) {
-		ret = -EPERM;
+		ret = -EROFS;
 		goto out_unlock;
 	}
 
Signature · 1 line
2.14.1
maintainer Applied
#1 lore raw

Am Freitag, 2. M�rz 2018, 12:16:18 CET schrieb Romain Izard:

Quoted 24 lines

When opening a device with write access, ubiblock_open returns an error code. Currently, this error code is -EPERM, but this is not the right value.

The open function for other block devices returns -EROFS when opening read-only devices with FMODE_WRITE set. When used with dm-verity, the veritysetup userspace tool is expecting EROFS, and refuses to use the ubiblock device.

Use -EROFS for ubiblock as well. As a result, veritysetup accepts the ubiblock device as valid.

Fixes 9d54c8a33eec (UBI: R/O block driver on top of UBI volumes)
---
 drivers/mtd/ubi/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubi/block.c +0 -0
index b210fdb31c98..4533423cf2aa 100644
@@ -242,7 +242,7 @@ static int ubiblock_open(struct block_device *bdev,

fmode_t mode) * in any case.

drivers/mtd/ubi/block.c static int ubiblock_open(struct block_device *bdev, fmode_t mode) · line 245

Quoted 4 lines
drivers/mtd/ubi/block.c +1 -1
 	 */
 	if (mode & FMODE_WRITE) {
-		ret = -EPERM;
+		ret = -EROFS;

Queued for -next.

Thanks,
//richard