1 From 9d54c8a33eec78289b1b3f6e10874719c27ce0a7 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Tue, 25 Feb 2014 13:25:22 -0300
4 Subject: [PATCH] UBI: R/O block driver on top of UBI volumes
6 This commit introduces read-only block device emulation on top of UBI volumes.
8 Given UBI takes care of wear leveling and bad block management it's possible
9 to add a thin layer to enable block device access to UBI volumes.
10 This allows to use a block-oriented filesystem on a flash device.
12 The UBI block devices are meant to be used in conjunction with any
13 regular, block-oriented file system (e.g. ext4), although it's primarily
14 targeted at read-only file systems, such as squashfs.
16 Block devices are created upon user request through new ioctls:
17 UBI_IOCVOLATTBLK to attach and UBI_IOCVOLDETBLK to detach.
18 Also, a new UBI module parameter is added 'ubi.block'. This parameter is
19 needed in order to attach a block device on boot-up time, allowing to
20 mount the rootfs on a ubiblock device.
21 For instance, you could have these kernel parameters:
23 ubi.mtd=5 ubi.block=0,0 root=/dev/ubiblock0_0
25 Or, if you compile ubi as a module:
27 $ modprobe ubi mtd=/dev/mtd5 block=/dev/ubi0_0
29 Artem: amend commentaries and massage the patch a little bit.
31 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
32 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
34 drivers/mtd/ubi/Kconfig | 15 +
35 drivers/mtd/ubi/Makefile | 1 +
36 drivers/mtd/ubi/block.c | 646 ++++++++++++++++++++++++++++++++++++++++++++
37 drivers/mtd/ubi/build.c | 11 +
38 drivers/mtd/ubi/cdev.c | 20 ++
39 drivers/mtd/ubi/ubi.h | 14 +
40 include/uapi/mtd/ubi-user.h | 11 +
41 7 files changed, 718 insertions(+)
42 create mode 100644 drivers/mtd/ubi/block.c
44 diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig
45 index 36663af..783fb18 100644
46 --- a/drivers/mtd/ubi/Kconfig
47 +++ b/drivers/mtd/ubi/Kconfig
48 @@ -87,4 +87,19 @@ config MTD_UBI_GLUEBI
49 work on top of UBI. Do not enable this unless you use legacy
53 + bool "Read-only block devices on top of UBI volumes"
56 + This option enables read-only UBI block devices support. UBI block
57 + devices will be layered on top of UBI volumes, which means that the
58 + UBI driver will transparently handle things like bad eraseblocks and
59 + bit-flips. You can put any block-oriented file system on top of UBI
60 + volumes in read-only mode (e.g., ext4), but it is probably most
61 + practical for read-only file systems, like squashfs.
63 + When selected, this feature will be built in the UBI driver.
65 + If in doubt, say "N".
68 diff --git a/drivers/mtd/ubi/Makefile b/drivers/mtd/ubi/Makefile
69 index b46b0c97..4e3c3d7 100644
70 --- a/drivers/mtd/ubi/Makefile
71 +++ b/drivers/mtd/ubi/Makefile
72 @@ -3,5 +3,6 @@ obj-$(CONFIG_MTD_UBI) += ubi.o
73 ubi-y += vtbl.o vmt.o upd.o build.o cdev.o kapi.o eba.o io.o wl.o attach.o
74 ubi-y += misc.o debug.o
75 ubi-$(CONFIG_MTD_UBI_FASTMAP) += fastmap.o
76 +ubi-$(CONFIG_MTD_UBI_BLOCK) += block.o
78 obj-$(CONFIG_MTD_UBI_GLUEBI) += gluebi.o
79 diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
81 index 0000000..cea7d1c
83 +++ b/drivers/mtd/ubi/block.c
86 + * Copyright (c) 2014 Ezequiel Garcia
87 + * Copyright (c) 2011 Free Electrons
89 + * Driver parameter handling strongly based on drivers/mtd/ubi/build.c
90 + * Copyright (c) International Business Machines Corp., 2006
91 + * Copyright (c) Nokia Corporation, 2007
92 + * Authors: Artem Bityutskiy, Frank Haverkamp
94 + * This program is free software; you can redistribute it and/or modify
95 + * it under the terms of the GNU General Public License as published by
96 + * the Free Software Foundation, version 2.
98 + * This program is distributed in the hope that it will be useful,
99 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
100 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
101 + * the GNU General Public License for more details.
105 + * Read-only block devices on top of UBI volumes
107 + * A simple implementation to allow a block device to be layered on top of a
108 + * UBI volume. The implementation is provided by creating a static 1-to-1
109 + * mapping between the block device and the UBI volume.
111 + * The addressed byte is obtained from the addressed block sector, which is
112 + * mapped linearly into the corresponding LEB:
114 + * LEB number = addressed byte / LEB size
116 + * This feature is compiled in the UBI core, and adds a new 'block' parameter
117 + * to allow early block device attaching. Runtime block attach/detach for UBI
118 + * volumes is provided through two new UBI ioctls: UBI_IOCVOLATTBLK and
119 + * UBI_IOCVOLDETBLK.
122 +#include <linux/module.h>
123 +#include <linux/init.h>
124 +#include <linux/err.h>
125 +#include <linux/kernel.h>
126 +#include <linux/list.h>
127 +#include <linux/mutex.h>
128 +#include <linux/slab.h>
129 +#include <linux/vmalloc.h>
130 +#include <linux/mtd/ubi.h>
131 +#include <linux/workqueue.h>
132 +#include <linux/blkdev.h>
133 +#include <linux/hdreg.h>
134 +#include <asm/div64.h>
136 +#include "ubi-media.h"
139 +/* Maximum number of supported devices */
140 +#define UBIBLOCK_MAX_DEVICES 32
142 +/* Maximum length of the 'block=' parameter */
143 +#define UBIBLOCK_PARAM_LEN 63
145 +/* Maximum number of comma-separated items in the 'block=' parameter */
146 +#define UBIBLOCK_PARAM_COUNT 2
148 +struct ubiblock_param {
151 + char name[UBIBLOCK_PARAM_LEN+1];
154 +/* Numbers of elements set in the @ubiblock_param array */
155 +static int ubiblock_devs __initdata;
157 +/* MTD devices specification parameters */
158 +static struct ubiblock_param ubiblock_param[UBIBLOCK_MAX_DEVICES] __initdata;
161 + struct ubi_volume_desc *desc;
167 + struct gendisk *gd;
168 + struct request_queue *rq;
170 + struct workqueue_struct *wq;
171 + struct work_struct work;
173 + struct mutex dev_mutex;
174 + spinlock_t queue_lock;
175 + struct list_head list;
178 +/* Linked list of all ubiblock instances */
179 +static LIST_HEAD(ubiblock_devices);
180 +static DEFINE_MUTEX(devices_mutex);
181 +static int ubiblock_major;
183 +static int __init ubiblock_set_param(const char *val,
184 + const struct kernel_param *kp)
188 + struct ubiblock_param *param;
189 + char buf[UBIBLOCK_PARAM_LEN];
190 + char *pbuf = &buf[0];
191 + char *tokens[UBIBLOCK_PARAM_COUNT];
196 + len = strnlen(val, UBIBLOCK_PARAM_LEN);
198 + ubi_warn("block: empty 'block=' parameter - ignored\n");
202 + if (len == UBIBLOCK_PARAM_LEN) {
203 + ubi_err("block: parameter \"%s\" is too long, max. is %d\n",
204 + val, UBIBLOCK_PARAM_LEN);
210 + /* Get rid of the final newline */
211 + if (buf[len - 1] == '\n')
212 + buf[len - 1] = '\0';
214 + for (i = 0; i < UBIBLOCK_PARAM_COUNT; i++)
215 + tokens[i] = strsep(&pbuf, ",");
217 + param = &ubiblock_param[ubiblock_devs];
219 + /* Two parameters: can be 'ubi, vol_id' or 'ubi, vol_name' */
220 + ret = kstrtoint(tokens[0], 10, ¶m->ubi_num);
224 + /* Second param can be a number or a name */
225 + ret = kstrtoint(tokens[1], 10, ¶m->vol_id);
227 + param->vol_id = -1;
228 + strcpy(param->name, tokens[1]);
232 + /* One parameter: must be device path */
233 + strcpy(param->name, tokens[0]);
234 + param->ubi_num = -1;
235 + param->vol_id = -1;
243 +static const struct kernel_param_ops ubiblock_param_ops = {
244 + .set = ubiblock_set_param,
246 +module_param_cb(block, &ubiblock_param_ops, NULL, 0);
247 +MODULE_PARM_DESC(block, "Attach block devices to UBI volumes. Parameter format: block=<path|dev,num|dev,name>.\n"
248 + "Multiple \"block\" parameters may be specified.\n"
249 + "UBI volumes may be specified by their number, name, or path to the device node.\n"
251 + "Using the UBI volume path:\n"
252 + "ubi.block=/dev/ubi0_0\n"
253 + "Using the UBI device, and the volume name:\n"
254 + "ubi.block=0,rootfs\n"
255 + "Using both UBI device number and UBI volume number:\n"
256 + "ubi.block=0,0\n");
258 +static struct ubiblock *find_dev_nolock(int ubi_num, int vol_id)
260 + struct ubiblock *dev;
262 + list_for_each_entry(dev, &ubiblock_devices, list)
263 + if (dev->ubi_num == ubi_num && dev->vol_id == vol_id)
268 +static int ubiblock_read_to_buf(struct ubiblock *dev, char *buffer,
269 + int leb, int offset, int len)
273 + ret = ubi_read(dev->desc, leb, buffer, offset, len);
275 + ubi_err("%s ubi_read error %d",
276 + dev->gd->disk_name, ret);
282 +static int ubiblock_read(struct ubiblock *dev, char *buffer,
283 + sector_t sec, int len)
285 + int ret, leb, offset;
286 + int bytes_left = len;
288 + loff_t pos = sec << 9;
290 + /* Get LEB:offset address to read from */
291 + offset = do_div(pos, dev->leb_size);
294 + while (bytes_left) {
296 + * We can only read one LEB at a time. Therefore if the read
297 + * length is larger than one LEB size, we split the operation.
299 + if (offset + to_read > dev->leb_size)
300 + to_read = dev->leb_size - offset;
302 + ret = ubiblock_read_to_buf(dev, buffer, leb, offset, to_read);
307 + bytes_left -= to_read;
308 + to_read = bytes_left;
315 +static int do_ubiblock_request(struct ubiblock *dev, struct request *req)
320 + if (req->cmd_type != REQ_TYPE_FS)
323 + if (blk_rq_pos(req) + blk_rq_cur_sectors(req) >
324 + get_capacity(req->rq_disk))
327 + if (rq_data_dir(req) != READ)
328 + return -ENOSYS; /* Write not implemented */
330 + sec = blk_rq_pos(req);
331 + len = blk_rq_cur_bytes(req);
334 + * Let's prevent the device from being removed while we're doing I/O
335 + * work. Notice that this means we serialize all the I/O operations,
336 + * but it's probably of no impact given the NAND core serializes
337 + * flash access anyway.
339 + mutex_lock(&dev->dev_mutex);
340 + ret = ubiblock_read(dev, req->buffer, sec, len);
341 + mutex_unlock(&dev->dev_mutex);
346 +static void ubiblock_do_work(struct work_struct *work)
348 + struct ubiblock *dev =
349 + container_of(work, struct ubiblock, work);
350 + struct request_queue *rq = dev->rq;
351 + struct request *req;
354 + spin_lock_irq(rq->queue_lock);
356 + req = blk_fetch_request(rq);
359 + spin_unlock_irq(rq->queue_lock);
360 + res = do_ubiblock_request(dev, req);
361 + spin_lock_irq(rq->queue_lock);
364 + * If we're done with this request,
365 + * we need to fetch a new one
367 + if (!__blk_end_request_cur(req, res))
368 + req = blk_fetch_request(rq);
371 + spin_unlock_irq(rq->queue_lock);
374 +static void ubiblock_request(struct request_queue *rq)
376 + struct ubiblock *dev;
377 + struct request *req;
379 + dev = rq->queuedata;
382 + while ((req = blk_fetch_request(rq)) != NULL)
383 + __blk_end_request_all(req, -ENODEV);
385 + queue_work(dev->wq, &dev->work);
388 +static int ubiblock_open(struct block_device *bdev, fmode_t mode)
390 + struct ubiblock *dev = bdev->bd_disk->private_data;
393 + mutex_lock(&dev->dev_mutex);
394 + if (dev->refcnt > 0) {
396 + * The volume is already open, just increase the reference
403 + * We want users to be aware they should only mount us as read-only.
404 + * It's just a paranoid check, as write requests will get rejected
407 + if (mode & FMODE_WRITE) {
412 + dev->desc = ubi_open_volume(dev->ubi_num, dev->vol_id, UBI_READONLY);
413 + if (IS_ERR(dev->desc)) {
414 + ubi_err("%s failed to open ubi volume %d_%d",
415 + dev->gd->disk_name, dev->ubi_num, dev->vol_id);
416 + ret = PTR_ERR(dev->desc);
423 + mutex_unlock(&dev->dev_mutex);
427 + mutex_unlock(&dev->dev_mutex);
431 +static void ubiblock_release(struct gendisk *gd, fmode_t mode)
433 + struct ubiblock *dev = gd->private_data;
435 + mutex_lock(&dev->dev_mutex);
437 + if (dev->refcnt == 0) {
438 + ubi_close_volume(dev->desc);
441 + mutex_unlock(&dev->dev_mutex);
444 +static int ubiblock_getgeo(struct block_device *bdev, struct hd_geometry *geo)
446 + /* Some tools might require this information */
448 + geo->cylinders = 1;
449 + geo->sectors = get_capacity(bdev->bd_disk);
454 +static const struct block_device_operations ubiblock_ops = {
455 + .owner = THIS_MODULE,
456 + .open = ubiblock_open,
457 + .release = ubiblock_release,
458 + .getgeo = ubiblock_getgeo,
461 +int ubiblock_add(struct ubi_volume_info *vi)
463 + struct ubiblock *dev;
464 + struct gendisk *gd;
468 + /* Check that the volume isn't already handled */
469 + mutex_lock(&devices_mutex);
470 + if (find_dev_nolock(vi->ubi_num, vi->vol_id)) {
471 + mutex_unlock(&devices_mutex);
474 + mutex_unlock(&devices_mutex);
476 + dev = kzalloc(sizeof(struct ubiblock), GFP_KERNEL);
480 + mutex_init(&dev->dev_mutex);
482 + dev->ubi_num = vi->ubi_num;
483 + dev->vol_id = vi->vol_id;
484 + dev->leb_size = vi->usable_leb_size;
486 + /* Initialize the gendisk of this ubiblock device */
487 + gd = alloc_disk(1);
489 + ubi_err("block: alloc_disk failed");
494 + gd->fops = &ubiblock_ops;
495 + gd->major = ubiblock_major;
496 + gd->first_minor = dev->ubi_num * UBI_MAX_VOLUMES + dev->vol_id;
497 + gd->private_data = dev;
498 + sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
499 + disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
500 + set_capacity(gd, disk_capacity);
503 + spin_lock_init(&dev->queue_lock);
504 + dev->rq = blk_init_queue(ubiblock_request, &dev->queue_lock);
506 + ubi_err("block: blk_init_queue failed");
511 + dev->rq->queuedata = dev;
512 + dev->gd->queue = dev->rq;
515 + * Create one workqueue per volume (per registered block device).
516 + * Rembember workqueues are cheap, they're not threads.
518 + dev->wq = alloc_workqueue(gd->disk_name, 0, 0);
520 + goto out_free_queue;
521 + INIT_WORK(&dev->work, ubiblock_do_work);
523 + mutex_lock(&devices_mutex);
524 + list_add_tail(&dev->list, &ubiblock_devices);
525 + mutex_unlock(&devices_mutex);
527 + /* Must be the last step: anyone can call file ops from now on */
529 + ubi_msg("%s created from ubi%d:%d(%s)",
530 + dev->gd->disk_name, dev->ubi_num, dev->vol_id, vi->name);
534 + blk_cleanup_queue(dev->rq);
543 +static void ubiblock_cleanup(struct ubiblock *dev)
545 + del_gendisk(dev->gd);
546 + blk_cleanup_queue(dev->rq);
547 + ubi_msg("%s released", dev->gd->disk_name);
551 +int ubiblock_del(struct ubi_volume_info *vi)
553 + struct ubiblock *dev;
555 + mutex_lock(&devices_mutex);
556 + dev = find_dev_nolock(vi->ubi_num, vi->vol_id);
558 + mutex_unlock(&devices_mutex);
562 + /* Found a device, let's lock it so we can check if it's busy */
563 + mutex_lock(&dev->dev_mutex);
564 + if (dev->refcnt > 0) {
565 + mutex_unlock(&dev->dev_mutex);
566 + mutex_unlock(&devices_mutex);
570 + /* Remove from device list */
571 + list_del(&dev->list);
572 + mutex_unlock(&devices_mutex);
574 + /* Flush pending work and stop this workqueue */
575 + destroy_workqueue(dev->wq);
577 + ubiblock_cleanup(dev);
578 + mutex_unlock(&dev->dev_mutex);
583 +static void ubiblock_resize(struct ubi_volume_info *vi)
585 + struct ubiblock *dev;
589 + * Need to lock the device list until we stop using the device,
590 + * otherwise the device struct might get released in 'ubiblock_del()'.
592 + mutex_lock(&devices_mutex);
593 + dev = find_dev_nolock(vi->ubi_num, vi->vol_id);
595 + mutex_unlock(&devices_mutex);
599 + mutex_lock(&dev->dev_mutex);
600 + disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
601 + set_capacity(dev->gd, disk_capacity);
602 + ubi_msg("%s resized to %d LEBs", dev->gd->disk_name, vi->size);
603 + mutex_unlock(&dev->dev_mutex);
604 + mutex_unlock(&devices_mutex);
607 +static int ubiblock_notify(struct notifier_block *nb,
608 + unsigned long notification_type, void *ns_ptr)
610 + struct ubi_notification *nt = ns_ptr;
612 + switch (notification_type) {
613 + case UBI_VOLUME_ADDED:
615 + * We want to enforce explicit block device attaching for
616 + * volumes, so when a volume is added we do nothing.
619 + case UBI_VOLUME_REMOVED:
620 + ubiblock_del(&nt->vi);
622 + case UBI_VOLUME_RESIZED:
623 + ubiblock_resize(&nt->vi);
631 +static struct notifier_block ubiblock_notifier = {
632 + .notifier_call = ubiblock_notify,
635 +static struct ubi_volume_desc * __init
636 +open_volume_desc(const char *name, int ubi_num, int vol_id)
639 + /* No ubi num, name must be a vol device path */
640 + return ubi_open_volume_path(name, UBI_READONLY);
641 + else if (vol_id == -1)
642 + /* No vol_id, must be vol_name */
643 + return ubi_open_volume_nm(ubi_num, name, UBI_READONLY);
645 + return ubi_open_volume(ubi_num, vol_id, UBI_READONLY);
648 +static int __init ubiblock_attach_from_param(void)
651 + struct ubiblock_param *p;
652 + struct ubi_volume_desc *desc;
653 + struct ubi_volume_info vi;
655 + for (i = 0; i < ubiblock_devs; i++) {
656 + p = &ubiblock_param[i];
658 + desc = open_volume_desc(p->name, p->ubi_num, p->vol_id);
659 + if (IS_ERR(desc)) {
660 + ubi_err("block: can't open volume, err=%ld\n",
662 + ret = PTR_ERR(desc);
666 + ubi_get_volume_info(desc, &vi);
667 + ubi_close_volume(desc);
669 + ret = ubiblock_add(&vi);
671 + ubi_err("block: can't add '%s' volume, err=%d\n",
679 +static void ubiblock_detach_all(void)
681 + struct ubiblock *next;
682 + struct ubiblock *dev;
684 + list_for_each_entry_safe(dev, next, &ubiblock_devices, list) {
685 + /* Flush pending work and stop workqueue */
686 + destroy_workqueue(dev->wq);
687 + /* The module is being forcefully removed */
688 + WARN_ON(dev->desc);
689 + /* Remove from device list */
690 + list_del(&dev->list);
691 + ubiblock_cleanup(dev);
696 +int __init ubiblock_init(void)
700 + ubiblock_major = register_blkdev(0, "ubiblock");
701 + if (ubiblock_major < 0)
702 + return ubiblock_major;
704 + /* Attach block devices from 'block=' module param */
705 + ret = ubiblock_attach_from_param();
710 + * Block devices needs to be attached to volumes explicitly
711 + * upon user request. So we ignore existing volumes.
713 + ret = ubi_register_volume_notifier(&ubiblock_notifier, 1);
719 + unregister_blkdev(ubiblock_major, "ubiblock");
721 + ubiblock_detach_all();
725 +void __exit ubiblock_exit(void)
727 + ubi_unregister_volume_notifier(&ubiblock_notifier);
728 + ubiblock_detach_all();
729 + unregister_blkdev(ubiblock_major, "ubiblock");
731 diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
732 index 57deae9..6e30a3c 100644
733 --- a/drivers/mtd/ubi/build.c
734 +++ b/drivers/mtd/ubi/build.c
735 @@ -1298,6 +1298,15 @@ static int __init ubi_init(void)
739 + err = ubiblock_init();
741 + ubi_err("block: cannot initialize, error %d", err);
743 + /* See comment above re-ubi_is_module(). */
744 + if (ubi_is_module())
751 @@ -1326,6 +1335,8 @@ static void __exit ubi_exit(void)
757 for (i = 0; i < UBI_MAX_DEVICES; i++)
758 if (ubi_devices[i]) {
759 mutex_lock(&ubi_devices_mutex);
760 diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
761 index 8ca49f2..39d3774 100644
762 --- a/drivers/mtd/ubi/cdev.c
763 +++ b/drivers/mtd/ubi/cdev.c
764 @@ -561,6 +561,26 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
768 + /* Attach a block device to an UBI volume */
769 + case UBI_IOCVOLATTBLK:
771 + struct ubi_volume_info vi;
773 + ubi_get_volume_info(desc, &vi);
774 + err = ubiblock_add(&vi);
778 + /* Dettach a block device from an UBI volume */
779 + case UBI_IOCVOLDETBLK:
781 + struct ubi_volume_info vi;
783 + ubi_get_volume_info(desc, &vi);
784 + err = ubiblock_del(&vi);
791 diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
792 index 8ea6297..e76ff98 100644
793 --- a/drivers/mtd/ubi/ubi.h
794 +++ b/drivers/mtd/ubi/ubi.h
795 @@ -864,6 +864,20 @@ int ubi_update_fastmap(struct ubi_device *ubi);
796 int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
800 +#ifdef CONFIG_MTD_UBI_BLOCK
801 +int ubiblock_init(void);
802 +void ubiblock_exit(void);
803 +int ubiblock_add(struct ubi_volume_info *vi);
804 +int ubiblock_del(struct ubi_volume_info *vi);
806 +static inline int ubiblock_init(void) { return 0; }
807 +static inline void ubiblock_exit(void) {}
808 +static inline int ubiblock_add(struct ubi_volume_info *vi) { return -ENOTTY; }
809 +static inline int ubiblock_del(struct ubi_volume_info *vi) { return -ENOTTY; }
814 * ubi_rb_for_each_entry - walk an RB-tree.
815 * @rb: a pointer to type 'struct rb_node' to use as a loop counter
816 diff --git a/include/uapi/mtd/ubi-user.h b/include/uapi/mtd/ubi-user.h
817 index 723c324..b98585a 100644
818 --- a/include/uapi/mtd/ubi-user.h
819 +++ b/include/uapi/mtd/ubi-user.h
821 * used. A pointer to a &struct ubi_set_vol_prop_req object is expected to be
822 * passed. The object describes which property should be set, and to which value
825 + * Block devices on UBI volumes
826 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
828 + * To attach or detach a block device from an UBI volume the %UBI_IOCVOLATTBLK
829 + * and %UBI_IOCVOLDETBLK ioctl commands should be used, respectively.
830 + * These commands take no arguments.
835 /* Set an UBI volume property */
836 #define UBI_IOCSETVOLPROP _IOW(UBI_VOL_IOC_MAGIC, 6, \
837 struct ubi_set_vol_prop_req)
838 +/* Attach a block device to an UBI volume */
839 +#define UBI_IOCVOLATTBLK _IO(UBI_VOL_IOC_MAGIC, 7)
840 +/* Detach a block device from an UBI volume */
841 +#define UBI_IOCVOLDETBLK _IO(UBI_VOL_IOC_MAGIC, 8)
843 /* Maximum MTD device name length supported by UBI */
844 #define MAX_UBI_MTD_NAME_LEN 127