Skip to content

Commit a27ce8f

Browse files
iksaifArtem Bityutskiy
authored andcommitted
UBI: add ioctl for is_mapped operation
This patch adds ioctl to check if an LEB is mapped or not (as a debugging option so far). [Re-named ioctl to make it look the same as the other one and made some minor stylistic changes. Artem Bityutskiy.] Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
1 parent c3da23b commit a27ce8f

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎drivers/mtd/ubi/cdev.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,20 @@ static int vol_cdev_ioctl(struct inode *inode, struct file *file,
546546
err = ubi_leb_unmap(desc, lnum);
547547
break;
548548
}
549+
550+
/* Check if logical eraseblock is mapped command */
551+
case UBI_IOCEBISMAP:
552+
{
553+
int32_t lnum;
554+
555+
err = get_user(lnum, (__user int32_t *)argp);
556+
if (err) {
557+
err = -EFAULT;
558+
break;
559+
}
560+
err = ubi_is_mapped(desc, lnum);
561+
break;
562+
}
549563
#endif
550564

551565
default:

‎include/mtd/ubi-user.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137
#define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req)
138138
/* Unmap an eraseblock, used for debugging, disabled by default */
139139
#define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, int32_t)
140+
/* Check if an eraseblock is mapped, used for debugging, disabled by default */
141+
#define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, int32_t)
140142

141143
/* Maximum MTD device name length supported by UBI */
142144
#define MAX_UBI_MTD_NAME_LEN 127

0 commit comments

Comments
 (0)