浏览代码

UBI: add ioctl for map operation

This patch adds ioctl for the LEB map operation (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>
Corentin Chary 16 年之前
父节点
当前提交
141e6ebd1b
共有 2 个文件被更改,包括 29 次插入0 次删除
  1. 14 0
      drivers/mtd/ubi/cdev.c
  2. 15 0
      include/mtd/ubi-user.h

+ 14 - 0
drivers/mtd/ubi/cdev.c

@@ -518,6 +518,20 @@ static int vol_cdev_ioctl(struct inode *inode, struct file *file,
 		err = ubi_wl_flush(ubi);
 		break;
 	}
+
+	/* Logical eraseblock map command */
+	case UBI_IOCEBMAP:
+	{
+		struct ubi_map_req req;
+
+		err = copy_from_user(&req, argp, sizeof(struct ubi_map_req));
+		if (err) {
+			err = -EFAULT;
+			break;
+		}
+		err = ubi_leb_map(desc, req.lnum, req.dtype);
+		break;
+	}
 #endif
 
 	default:

+ 15 - 0
include/mtd/ubi-user.h

@@ -133,6 +133,9 @@
 #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t)
 /* An atomic eraseblock change command */
 #define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t)
+/* Map an eraseblock, used for debugging, disabled by default */
+#define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req)
+
 
 /* Maximum MTD device name length supported by UBI */
 #define MAX_UBI_MTD_NAME_LEN 127
@@ -319,4 +322,16 @@ struct ubi_leb_change_req {
 	int8_t  padding[7];
 } __attribute__ ((packed));
 
+/**
+ * struct ubi_map_req - a data structure used in map eraseblock requests.
+ * @lnum: logical eraseblock number to unmap
+ * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
+ * @padding: reserved for future, not used, has to be zeroed
+ */
+struct ubi_map_req {
+	int32_t lnum;
+	int8_t  dtype;
+	int8_t  padding[3];
+} __attribute__ ((packed));
+
 #endif /* __UBI_USER_H__ */