ubi-user.h revision 766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2
1801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy/*
2801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * Copyright (c) International Business Machines Corp., 2006
3801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
4801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * This program is free software; you can redistribute it and/or modify
5801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * it under the terms of the GNU General Public License as published by
6801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * the Free Software Foundation; either version 2 of the License, or
7801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * (at your option) any later version.
8801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
9801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * This program is distributed in the hope that it will be useful,
10801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * but WITHOUT ANY WARRANTY; without even the implied warranty of
11801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * the GNU General Public License for more details.
13801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
14801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * You should have received a copy of the GNU General Public License
15801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * along with this program; if not, write to the Free Software
16801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
18801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * Author: Artem Bityutskiy (Битюцкий Артём)
19801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy */
20801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
21801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#ifndef __UBI_USER_H__
22801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#define __UBI_USER_H__
23801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
24801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy/*
259b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * UBI device creation (the same as MTD device attachment)
269b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
279b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy *
289b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * MTD devices may be attached using %UBI_IOCATT ioctl command of the UBI
299b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * control device. The caller has to properly fill and pass
309b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * &struct ubi_attach_req object - UBI will attach the MTD device specified in
319b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * the request and return the newly created UBI device number as the ioctl
329b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * return value.
339b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy *
349b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * UBI device deletion (the same as MTD device detachment)
359b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
369b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy *
379b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * An UBI device maybe deleted with %UBI_IOCDET ioctl command of the UBI
389b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * control device.
399b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy *
40801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * UBI volume creation
41801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * ~~~~~~~~~~~~~~~~~~~
42801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
43f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * UBI volumes are created via the %UBI_IOCMKVOL ioctl command of UBI character
44801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * device. A &struct ubi_mkvol_req object has to be properly filled and a
45f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * pointer to it has to be passed to the ioctl.
46801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
47801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * UBI volume deletion
48801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * ~~~~~~~~~~~~~~~~~~~
49801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
50f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * To delete a volume, the %UBI_IOCRMVOL ioctl command of the UBI character
51801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * device should be used. A pointer to the 32-bit volume ID hast to be passed
52f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * to the ioctl.
53801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
54801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * UBI volume re-size
55801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * ~~~~~~~~~~~~~~~~~~
56801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
57f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * To re-size a volume, the %UBI_IOCRSVOL ioctl command of the UBI character
58801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * device should be used. A &struct ubi_rsvol_req object has to be properly
59f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * filled and a pointer to it has to be passed to the ioctl.
60801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
61f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * UBI volumes re-name
62f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * ~~~~~~~~~~~~~~~~~~~
63f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy *
64f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * To re-name several volumes atomically at one go, the %UBI_IOCRNVOL command
65f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * of the UBI character device should be used. A &struct ubi_rnvol_req object
66f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * has to be properly filled and a pointer to it has to be passed to the ioctl.
67f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy *
68801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * UBI volume update
69801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * ~~~~~~~~~~~~~~~~~
70801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
71f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * Volume update should be done via the %UBI_IOCVOLUP ioctl command of the
72801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * corresponding UBI volume character device. A pointer to a 64-bit update
73f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * size should be passed to the ioctl. After this, UBI expects user to write
74801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * this number of bytes to the volume character device. The update is finished
75801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * when the claimed number of bytes is passed. So, the volume update sequence
76801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * is something like:
77801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
78801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * fd = open("/dev/my_volume");
79801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * ioctl(fd, UBI_IOCVOLUP, &image_size);
80801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * write(fd, buf, image_size);
81801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * close(fd);
82866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy *
83f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * Logical eraseblock erase
84866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * ~~~~~~~~~~~~~~~~~~~~~~~~
85866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy *
86f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * To erase a logical eraseblock, the %UBI_IOCEBER ioctl command of the
87f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * corresponding UBI volume character device should be used. This command
88f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * unmaps the requested logical eraseblock, makes sure the corresponding
89f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * physical eraseblock is successfully erased, and returns.
90f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy *
91f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * Atomic logical eraseblock change
92f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy *
94f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * Atomic logical eraseblock change operation is called using the %UBI_IOCEBCH
95f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * ioctl command of the corresponding UBI volume character device. A pointer to
96f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * a &struct ubi_leb_change_req object has to be passed to the ioctl. Then the
97f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * user is expected to write the requested amount of bytes (similarly to what
98f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * should be done in case of the "volume update" ioctl).
99f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy *
100f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * Logical eraseblock map
101f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * ~~~~~~~~~~~~~~~~~~~~~
102f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy *
103f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * To map a logical eraseblock to a physical eraseblock, the %UBI_IOCEBMAP
104f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * ioctl command should be used. A pointer to a &struct ubi_map_req object is
105f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * expected to be passed. The ioctl maps the requested logical eraseblock to
106f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * a physical eraseblock and returns.  Only non-mapped logical eraseblocks can
107f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * be mapped. If the logical eraseblock specified in the request is already
108f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * mapped to a physical eraseblock, the ioctl fails and returns error.
109f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy *
110f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * Logical eraseblock unmap
111f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * ~~~~~~~~~~~~~~~~~~~~~~~~
112f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy *
113f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * To unmap a logical eraseblock to a physical eraseblock, the %UBI_IOCEBUNMAP
114f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * ioctl command should be used. The ioctl unmaps the logical eraseblocks,
115f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * schedules corresponding physical eraseblock for erasure, and returns. Unlike
116f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * the "LEB erase" command, it does not wait for the physical eraseblock being
117f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * erased. Note, the side effect of this is that if an unclean reboot happens
118f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * after the unmap ioctl returns, you may find the LEB mapped again to the same
119f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * physical eraseblock after the UBI is run again.
120f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy *
121f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * Check if logical eraseblock is mapped
122f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy *
124f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * To check if a logical eraseblock is mapped to a physical eraseblock, the
125f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * %UBI_IOCEBISMAP ioctl command should be used. It returns %0 if the LEB is
126f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * not mapped, and %1 if it is mapped.
127766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani *
128766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * Set an UBI volume property
129766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * ~~~~~~~~~~~~~~~~~~~~~~~~~
130766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani *
131766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * To set an UBI volume property the %UBI_IOCSETPROP ioctl command should be
132766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * used. A pointer to a &struct ubi_set_prop_req object is expected to be
133766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * passed. The object describes which property should be set, and to which value
134766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * it should be set.
135801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy */
136801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
137801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy/*
1389b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * When a new UBI volume or UBI device is created, users may either specify the
1399b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * volume/device number they want to create or to let UBI automatically assign
1409b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * the number using these constants.
141801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy */
142801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#define UBI_VOL_NUM_AUTO (-1)
1439b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy#define UBI_DEV_NUM_AUTO (-1)
144801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
145801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy/* Maximum volume name length */
146801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#define UBI_MAX_VOLUME_NAME 127
147801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
148f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy/* ioctl commands of UBI character devices */
149801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
150801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#define UBI_IOC_MAGIC 'o'
151801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
152801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy/* Create an UBI volume */
153801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#define UBI_IOCMKVOL _IOW(UBI_IOC_MAGIC, 0, struct ubi_mkvol_req)
154801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy/* Remove an UBI volume */
155801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#define UBI_IOCRMVOL _IOW(UBI_IOC_MAGIC, 1, int32_t)
156801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy/* Re-size an UBI volume */
157801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req)
158f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy/* Re-name volumes */
159f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy#define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req)
160801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
161f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy/* ioctl commands of the UBI control character device */
1629b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy
1639b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy#define UBI_CTRL_IOC_MAGIC 'o'
1649b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy
1659b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy/* Attach an MTD device */
1669b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy#define UBI_IOCATT _IOW(UBI_CTRL_IOC_MAGIC, 64, struct ubi_attach_req)
1679b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy/* Detach an MTD device */
1689b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy#define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, int32_t)
1699b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy
170f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy/* ioctl commands of UBI volume character devices */
171801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
172801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#define UBI_VOL_IOC_MAGIC 'O'
173801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
174801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy/* Start UBI volume update */
175801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t)
176f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy/* LEB erasure command, used for debugging, disabled by default */
177801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t)
178f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy/* Atomic LEB change command */
179866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy#define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t)
180f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy/* Map LEB command */
181141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Chary#define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req)
182f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy/* Unmap LEB command */
183c3da23be1673be4e738aea235604b4e6cb259655Corentin Chary#define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, int32_t)
184f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy/* Check if LEB is mapped command */
185a27ce8f55dd5fddf0b8ea179cce8f399c13dc94fCorentin Chary#define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, int32_t)
186766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani/* Set an UBI volume property */
187766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani#define UBI_IOCSETPROP _IOW(UBI_VOL_IOC_MAGIC, 6, struct ubi_set_prop_req)
188801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
1899b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy/* Maximum MTD device name length supported by UBI */
1909b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy#define MAX_UBI_MTD_NAME_LEN 127
1919b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy
192f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy/* Maximum amount of UBI volumes that can be re-named at one go */
193f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy#define UBI_MAX_RNVOL 32
194f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy
195801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy/*
196866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * UBI data type hint constants.
197866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy *
198866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * UBI_LONGTERM: long-term data
199866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * UBI_SHORTTERM: short-term data
200866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * UBI_UNKNOWN: data persistence is unknown
201866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy *
202866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * These constants are used when data is written to UBI volumes in order to
203866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * help the UBI wear-leveling unit to find more appropriate physical
204866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * eraseblocks.
205866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy */
206866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiyenum {
207866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy	UBI_LONGTERM  = 1,
208866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy	UBI_SHORTTERM = 2,
209866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy	UBI_UNKNOWN   = 3,
210866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy};
211866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy
212866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy/*
213801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * UBI volume type constants.
214801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
215801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * @UBI_DYNAMIC_VOLUME: dynamic volume
216801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * @UBI_STATIC_VOLUME:  static volume
217801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy */
218801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiyenum {
219801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy	UBI_DYNAMIC_VOLUME = 3,
220866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy	UBI_STATIC_VOLUME  = 4,
2219b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy};
2229b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy
223766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani/*
224766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * UBI set property ioctl constants
225766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani *
226766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * @UBI_PROP_DIRECT_WRITE: allow / disallow user to directly write and
227766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani *                         erase individual eraseblocks on dynamic volumes
228766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani */
229766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amanienum {
230766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani       UBI_PROP_DIRECT_WRITE = 1,
231766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani};
232766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani
2339b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy/**
2349b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * struct ubi_attach_req - attach MTD device request.
2359b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * @ubi_num: UBI device number to create
2369b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * @mtd_num: MTD device number to attach
2379b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * @vid_hdr_offset: VID header offset (use defaults if %0)
2389b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * @padding: reserved for future, not used, has to be zeroed
2399b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy *
2409b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * This data structure is used to specify MTD device UBI has to attach and the
2419b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * parameters it has to use. The number which should be assigned to the new UBI
242866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * device is passed in @ubi_num. UBI may automatically assign the number if
2439b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * @UBI_DEV_NUM_AUTO is passed. In this case, the device number is returned in
2449b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * @ubi_num.
2459b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy *
2469b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * Most applications should pass %0 in @vid_hdr_offset to make UBI use default
2479b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * offset of the VID header within physical eraseblocks. The default offset is
2489b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * the next min. I/O unit after the EC header. For example, it will be offset
2499b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * 512 in case of a 512 bytes page NAND flash with no sub-page support. Or
2509b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * it will be 512 in case of a 2KiB page NAND flash with 4 512-byte sub-pages.
2519b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy *
2529b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * But in rare cases, if this optimizes things, the VID header may be placed to
2539c9ec147709e63e4e8ac6a037c6bb50688ff8e9cArtem Bityutskiy * a different offset. For example, the boot-loader might do things faster if
2549c9ec147709e63e4e8ac6a037c6bb50688ff8e9cArtem Bityutskiy * the VID header sits at the end of the first 2KiB NAND page with 4 sub-pages.
2559c9ec147709e63e4e8ac6a037c6bb50688ff8e9cArtem Bityutskiy * As the boot-loader would not normally need to read EC headers (unless it
2569c9ec147709e63e4e8ac6a037c6bb50688ff8e9cArtem Bityutskiy * needs UBI in RW mode), it might be faster to calculate ECC. This is weird
2579c9ec147709e63e4e8ac6a037c6bb50688ff8e9cArtem Bityutskiy * example, but it real-life example. So, in this example, @vid_hdr_offer would
2589c9ec147709e63e4e8ac6a037c6bb50688ff8e9cArtem Bityutskiy * be 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes
2599c9ec147709e63e4e8ac6a037c6bb50688ff8e9cArtem Bityutskiy * aligned, which is OK, as UBI is clever enough to realize this is 4th
2609c9ec147709e63e4e8ac6a037c6bb50688ff8e9cArtem Bityutskiy * sub-page of the first page and add needed padding.
2619b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy */
2629b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiystruct ubi_attach_req {
2639b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy	int32_t ubi_num;
2649b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy	int32_t mtd_num;
2659b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy	int32_t vid_hdr_offset;
266f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy	int8_t padding[12];
267801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy};
268801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
269801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy/**
270801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * struct ubi_mkvol_req - volume description data structure used in
2719b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy *                        volume creation requests.
272801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * @vol_id: volume number
273801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * @alignment: volume alignment
274801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * @bytes: volume size in bytes
275801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
2769b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * @padding1: reserved for future, not used, has to be zeroed
277801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * @name_len: volume name length
2789b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy * @padding2: reserved for future, not used, has to be zeroed
279801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * @name: volume name
280801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
281866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * This structure is used by user-space programs when creating new volumes. The
282801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * @used_bytes field is only necessary when creating static volumes.
283801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
284801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * The @alignment field specifies the required alignment of the volume logical
285801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * eraseblock. This means, that the size of logical eraseblocks will be aligned
286801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * to this number, i.e.,
287801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *	(UBI device logical eraseblock size) mod (@alignment) = 0.
288801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
289801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * To put it differently, the logical eraseblock of this volume may be slightly
290801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * shortened in order to make it properly aligned. The alignment has to be
291801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * multiple of the flash minimal input/output unit, or %1 to utilize the entire
292801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * available space of logical eraseblocks.
293801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
294801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * The @alignment field may be useful, for example, when one wants to maintain
295801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * a block device on top of an UBI volume. In this case, it is desirable to fit
296801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * an integer number of blocks in logical eraseblocks of this UBI volume. With
297801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * alignment it is possible to update this volume using plane UBI volume image
298801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * BLOBs, without caring about how to properly align them.
299801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy */
300801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiystruct ubi_mkvol_req {
301801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy	int32_t vol_id;
302801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy	int32_t alignment;
303801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy	int64_t bytes;
304801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy	int8_t vol_type;
305801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy	int8_t padding1;
306801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy	int16_t name_len;
307801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy	int8_t padding2[4];
3089b79cc0f84edecceb04b806b9014fcec1306c34dArtem Bityutskiy	char name[UBI_MAX_VOLUME_NAME + 1];
309801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy} __attribute__ ((packed));
310801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
311801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy/**
312801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * struct ubi_rsvol_req - a data structure used in volume re-size requests.
313801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * @vol_id: ID of the volume to re-size
314801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * @bytes: new size of the volume in bytes
315801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy *
316801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * Re-sizing is possible for both dynamic and static volumes. But while dynamic
317801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * volumes may be re-sized arbitrarily, static volumes cannot be made to be
318025dfdafe77f20b3890981a394774baab7b9c827Frederik Schwarzer * smaller than the number of bytes they bear. To arbitrarily shrink a static
319801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * volume, it must be wiped out first (by means of volume update operation with
320801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy * zero number of bytes).
321801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy */
322801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiystruct ubi_rsvol_req {
323801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy	int64_t bytes;
324801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy	int32_t vol_id;
325801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy} __attribute__ ((packed));
326801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy
327866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy/**
328f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * struct ubi_rnvol_req - volumes re-name request.
329f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * @count: count of volumes to re-name
330f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * @padding1:  reserved for future, not used, has to be zeroed
331f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * @vol_id: ID of the volume to re-name
332f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * @name_len: name length
333f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * @padding2:  reserved for future, not used, has to be zeroed
334f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * @name: new volume name
335f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy *
336f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * UBI allows to re-name up to %32 volumes at one go. The count of volumes to
337f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * re-name is specified in the @count field. The ID of the volumes to re-name
338f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * and the new names are specified in the @vol_id and @name fields.
339f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy *
340f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * The UBI volume re-name operation is atomic, which means that should power cut
341f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * happen, the volumes will have either old name or new name. So the possible
342f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * use-cases of this command is atomic upgrade. Indeed, to upgrade, say, volumes
343f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * A and B one may create temporary volumes %A1 and %B1 with the new contents,
344f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * then atomically re-name A1->A and B1->B, in which case old %A and %B will
345f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * be removed.
346f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy *
347f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * If it is not desirable to remove old A and B, the re-name request has to
348f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * contain 4 entries: A1->A, A->A1, B1->B, B->B1, in which case old A1 and B1
349f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * become A and B, and old A and B will become A1 and B1.
350f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy *
351f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * It is also OK to request: A1->A, A1->X, B1->B, B->Y, in which case old A1
352f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * and B1 become A and B, and old A and B become X and Y.
353f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy *
354f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * In other words, in case of re-naming into an existing volume name, the
355f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * existing volume is removed, unless it is re-named as well at the same
356f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy * re-name request.
357f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy */
358f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiystruct ubi_rnvol_req {
359f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy	int32_t count;
360f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy	int8_t padding1[12];
361f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy	struct {
362f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy		int32_t vol_id;
363f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy		int16_t name_len;
364f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy		int8_t  padding2[2];
365f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy		char    name[UBI_MAX_VOLUME_NAME + 1];
366f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy	} ents[UBI_MAX_RNVOL];
367f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy} __attribute__ ((packed));
368f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy
369f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy/**
370f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * struct ubi_leb_change_req - a data structure used in atomic LEB change
371f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy *                             requests.
372866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * @lnum: logical eraseblock number to change
373866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * @bytes: how many bytes will be written to the logical eraseblock
374866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
375866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy * @padding: reserved for future, not used, has to be zeroed
376866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy */
377866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiystruct ubi_leb_change_req {
378866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy	int32_t lnum;
379866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy	int32_t bytes;
380f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy	int8_t  dtype;
381f40ac9cdf6991287f19bdafe9b0752ee40137908Artem Bityutskiy	int8_t  padding[7];
382866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy} __attribute__ ((packed));
383866136827b9a71c39dcb06d23ce523f719eab74bArtem Bityutskiy
384141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Chary/**
385f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7Artem Bityutskiy * struct ubi_map_req - a data structure used in map LEB requests.
386141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Chary * @lnum: logical eraseblock number to unmap
387141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Chary * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
388141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Chary * @padding: reserved for future, not used, has to be zeroed
389141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Chary */
390141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Charystruct ubi_map_req {
391141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Chary	int32_t lnum;
392141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Chary	int8_t  dtype;
393141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Chary	int8_t  padding[3];
394141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Chary} __attribute__ ((packed));
395141e6ebd1b1759bd5cebf092b7216b6f1c7b4c4fCorentin Chary
396766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani
397766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani/**
398766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * struct ubi_set_prop_req - a data structure used to set an ubi volume
399766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani *                           property.
400766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * @property: property to set (%UBI_PROP_DIRECT_WRITE)
401766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * @padding: reserved for future, not used, has to be zeroed
402766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani * @value: value to set
403766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani */
404766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amanistruct ubi_set_prop_req {
405766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani       uint8_t  property;
406766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani       uint8_t  padding[7];
407766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani       uint64_t value;
408766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani}  __attribute__ ((packed));
409766fb95ba06e1bbf531d30dc05e21b2d4a0e8dd2Sidney Amani
410801c135ce73d5df1caf3eca35b66a10824ae0707Artem B. Bityutskiy#endif /* __UBI_USER_H__ */
411