2 * Copyright (c) International Business Machines Corp., 2006
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 * the GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author: Artem Bityutskiy (Битюцкий Артём)
21 #ifndef __UBI_USER_H__
22 #define __UBI_USER_H__
28 * UBI volumes are created via the %UBI_IOCMKVOL IOCTL command of UBI character
29 * device. A &struct ubi_mkvol_req object has to be properly filled and a
30 * pointer to it has to be passed to the IOCTL.
35 * To delete a volume, the %UBI_IOCRMVOL IOCTL command of the UBI character
36 * device should be used. A pointer to the 32-bit volume ID hast to be passed
42 * To re-size a volume, the %UBI_IOCRSVOL IOCTL command of the UBI character
43 * device should be used. A &struct ubi_rsvol_req object has to be properly
44 * filled and a pointer to it has to be passed to the IOCTL.
49 * Volume update should be done via the %UBI_IOCVOLUP IOCTL command of the
50 * corresponding UBI volume character device. A pointer to a 64-bit update
51 * size should be passed to the IOCTL. After then, UBI expects user to write
52 * this number of bytes to the volume character device. The update is finished
53 * when the claimed number of bytes is passed. So, the volume update sequence
56 * fd = open("/dev/my_volume");
57 * ioctl(fd, UBI_IOCVOLUP, &image_size);
58 * write(fd, buf, image_size);
63 * When a new volume is created, users may either specify the volume number they
64 * want to create or to let UBI automatically assign a volume number using this
67 #define UBI_VOL_NUM_AUTO (-1)
69 /* Maximum volume name length */
70 #define UBI_MAX_VOLUME_NAME 127
72 /* IOCTL commands of UBI character devices */
74 #define UBI_IOC_MAGIC 'o'
76 /* Create an UBI volume */
77 #define UBI_IOCMKVOL _IOW(UBI_IOC_MAGIC, 0, struct ubi_mkvol_req)
78 /* Remove an UBI volume */
79 #define UBI_IOCRMVOL _IOW(UBI_IOC_MAGIC, 1, int32_t)
80 /* Re-size an UBI volume */
81 #define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req)
83 /* IOCTL commands of UBI volume character devices */
85 #define UBI_VOL_IOC_MAGIC 'O'
87 /* Start UBI volume update */
88 #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t)
89 /* An eraseblock erasure command, used for debugging, disabled by default */
90 #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t)
93 * UBI volume type constants.
95 * @UBI_DYNAMIC_VOLUME: dynamic volume
96 * @UBI_STATIC_VOLUME: static volume
99 UBI_DYNAMIC_VOLUME = 3,
100 UBI_STATIC_VOLUME = 4
104 * struct ubi_mkvol_req - volume description data structure used in
105 * volume creation requests.
106 * @vol_id: volume number
107 * @alignment: volume alignment
108 * @bytes: volume size in bytes
109 * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
110 * @padding1: reserved for future, not used
111 * @name_len: volume name length
112 * @padding2: reserved for future, not used
115 * This structure is used by userspace programs when creating new volumes. The
116 * @used_bytes field is only necessary when creating static volumes.
118 * The @alignment field specifies the required alignment of the volume logical
119 * eraseblock. This means, that the size of logical eraseblocks will be aligned
120 * to this number, i.e.,
121 * (UBI device logical eraseblock size) mod (@alignment) = 0.
123 * To put it differently, the logical eraseblock of this volume may be slightly
124 * shortened in order to make it properly aligned. The alignment has to be
125 * multiple of the flash minimal input/output unit, or %1 to utilize the entire
126 * available space of logical eraseblocks.
128 * The @alignment field may be useful, for example, when one wants to maintain
129 * a block device on top of an UBI volume. In this case, it is desirable to fit
130 * an integer number of blocks in logical eraseblocks of this UBI volume. With
131 * alignment it is possible to update this volume using plane UBI volume image
132 * BLOBs, without caring about how to properly align them.
134 struct ubi_mkvol_req {
142 char name[UBI_MAX_VOLUME_NAME+1];
143 } __attribute__ ((packed));
146 * struct ubi_rsvol_req - a data structure used in volume re-size requests.
147 * @vol_id: ID of the volume to re-size
148 * @bytes: new size of the volume in bytes
150 * Re-sizing is possible for both dynamic and static volumes. But while dynamic
151 * volumes may be re-sized arbitrarily, static volumes cannot be made to be
152 * smaller then the number of bytes they bear. To arbitrarily shrink a static
153 * volume, it must be wiped out first (by means of volume update operation with
154 * zero number of bytes).
156 struct ubi_rsvol_req {
159 } __attribute__ ((packed));
161 #endif /* __UBI_USER_H__ */