1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */ 247ae6693SKyungmin Park /* 3ff94bc40SHeiko Schocher * Copyright © International Business Machines Corp., 2006 447ae6693SKyungmin Park * 547ae6693SKyungmin Park * Author: Artem Bityutskiy (Битюцкий Артём) 647ae6693SKyungmin Park */ 747ae6693SKyungmin Park 847ae6693SKyungmin Park #ifndef __UBI_USER_H__ 947ae6693SKyungmin Park #define __UBI_USER_H__ 1047ae6693SKyungmin Park 11ff94bc40SHeiko Schocher #include <linux/types.h> 12ff94bc40SHeiko Schocher 1347ae6693SKyungmin Park /* 1447ae6693SKyungmin Park * UBI device creation (the same as MTD device attachment) 1547ae6693SKyungmin Park * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1647ae6693SKyungmin Park * 1747ae6693SKyungmin Park * MTD devices may be attached using %UBI_IOCATT ioctl command of the UBI 1847ae6693SKyungmin Park * control device. The caller has to properly fill and pass 1947ae6693SKyungmin Park * &struct ubi_attach_req object - UBI will attach the MTD device specified in 2047ae6693SKyungmin Park * the request and return the newly created UBI device number as the ioctl 2147ae6693SKyungmin Park * return value. 2247ae6693SKyungmin Park * 2347ae6693SKyungmin Park * UBI device deletion (the same as MTD device detachment) 2447ae6693SKyungmin Park * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547ae6693SKyungmin Park * 2647ae6693SKyungmin Park * An UBI device maybe deleted with %UBI_IOCDET ioctl command of the UBI 2747ae6693SKyungmin Park * control device. 2847ae6693SKyungmin Park * 2947ae6693SKyungmin Park * UBI volume creation 3047ae6693SKyungmin Park * ~~~~~~~~~~~~~~~~~~~ 3147ae6693SKyungmin Park * 32ff94bc40SHeiko Schocher * UBI volumes are created via the %UBI_IOCMKVOL ioctl command of UBI character 3347ae6693SKyungmin Park * device. A &struct ubi_mkvol_req object has to be properly filled and a 34ff94bc40SHeiko Schocher * pointer to it has to be passed to the ioctl. 3547ae6693SKyungmin Park * 3647ae6693SKyungmin Park * UBI volume deletion 3747ae6693SKyungmin Park * ~~~~~~~~~~~~~~~~~~~ 3847ae6693SKyungmin Park * 39ff94bc40SHeiko Schocher * To delete a volume, the %UBI_IOCRMVOL ioctl command of the UBI character 4047ae6693SKyungmin Park * device should be used. A pointer to the 32-bit volume ID hast to be passed 41ff94bc40SHeiko Schocher * to the ioctl. 4247ae6693SKyungmin Park * 4347ae6693SKyungmin Park * UBI volume re-size 4447ae6693SKyungmin Park * ~~~~~~~~~~~~~~~~~~ 4547ae6693SKyungmin Park * 46ff94bc40SHeiko Schocher * To re-size a volume, the %UBI_IOCRSVOL ioctl command of the UBI character 4747ae6693SKyungmin Park * device should be used. A &struct ubi_rsvol_req object has to be properly 48ff94bc40SHeiko Schocher * filled and a pointer to it has to be passed to the ioctl. 49ff94bc40SHeiko Schocher * 50ff94bc40SHeiko Schocher * UBI volumes re-name 51ff94bc40SHeiko Schocher * ~~~~~~~~~~~~~~~~~~~ 52ff94bc40SHeiko Schocher * 53ff94bc40SHeiko Schocher * To re-name several volumes atomically at one go, the %UBI_IOCRNVOL command 54ff94bc40SHeiko Schocher * of the UBI character device should be used. A &struct ubi_rnvol_req object 55ff94bc40SHeiko Schocher * has to be properly filled and a pointer to it has to be passed to the ioctl. 5647ae6693SKyungmin Park * 5747ae6693SKyungmin Park * UBI volume update 5847ae6693SKyungmin Park * ~~~~~~~~~~~~~~~~~ 5947ae6693SKyungmin Park * 60ff94bc40SHeiko Schocher * Volume update should be done via the %UBI_IOCVOLUP ioctl command of the 6147ae6693SKyungmin Park * corresponding UBI volume character device. A pointer to a 64-bit update 62ff94bc40SHeiko Schocher * size should be passed to the ioctl. After this, UBI expects user to write 6347ae6693SKyungmin Park * this number of bytes to the volume character device. The update is finished 6447ae6693SKyungmin Park * when the claimed number of bytes is passed. So, the volume update sequence 6547ae6693SKyungmin Park * is something like: 6647ae6693SKyungmin Park * 6747ae6693SKyungmin Park * fd = open("/dev/my_volume"); 6847ae6693SKyungmin Park * ioctl(fd, UBI_IOCVOLUP, &image_size); 6947ae6693SKyungmin Park * write(fd, buf, image_size); 7047ae6693SKyungmin Park * close(fd); 7147ae6693SKyungmin Park * 72ff94bc40SHeiko Schocher * Logical eraseblock erase 7347ae6693SKyungmin Park * ~~~~~~~~~~~~~~~~~~~~~~~~ 7447ae6693SKyungmin Park * 75ff94bc40SHeiko Schocher * To erase a logical eraseblock, the %UBI_IOCEBER ioctl command of the 76ff94bc40SHeiko Schocher * corresponding UBI volume character device should be used. This command 77ff94bc40SHeiko Schocher * unmaps the requested logical eraseblock, makes sure the corresponding 78ff94bc40SHeiko Schocher * physical eraseblock is successfully erased, and returns. 79ff94bc40SHeiko Schocher * 80ff94bc40SHeiko Schocher * Atomic logical eraseblock change 81ff94bc40SHeiko Schocher * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 82ff94bc40SHeiko Schocher * 83ff94bc40SHeiko Schocher * Atomic logical eraseblock change operation is called using the %UBI_IOCEBCH 84ff94bc40SHeiko Schocher * ioctl command of the corresponding UBI volume character device. A pointer to 85ff94bc40SHeiko Schocher * a &struct ubi_leb_change_req object has to be passed to the ioctl. Then the 86ff94bc40SHeiko Schocher * user is expected to write the requested amount of bytes (similarly to what 87ff94bc40SHeiko Schocher * should be done in case of the "volume update" ioctl). 88ff94bc40SHeiko Schocher * 89ff94bc40SHeiko Schocher * Logical eraseblock map 90ff94bc40SHeiko Schocher * ~~~~~~~~~~~~~~~~~~~~~ 91ff94bc40SHeiko Schocher * 92ff94bc40SHeiko Schocher * To map a logical eraseblock to a physical eraseblock, the %UBI_IOCEBMAP 93ff94bc40SHeiko Schocher * ioctl command should be used. A pointer to a &struct ubi_map_req object is 94ff94bc40SHeiko Schocher * expected to be passed. The ioctl maps the requested logical eraseblock to 95ff94bc40SHeiko Schocher * a physical eraseblock and returns. Only non-mapped logical eraseblocks can 96ff94bc40SHeiko Schocher * be mapped. If the logical eraseblock specified in the request is already 97ff94bc40SHeiko Schocher * mapped to a physical eraseblock, the ioctl fails and returns error. 98ff94bc40SHeiko Schocher * 99ff94bc40SHeiko Schocher * Logical eraseblock unmap 100ff94bc40SHeiko Schocher * ~~~~~~~~~~~~~~~~~~~~~~~~ 101ff94bc40SHeiko Schocher * 102ff94bc40SHeiko Schocher * To unmap a logical eraseblock to a physical eraseblock, the %UBI_IOCEBUNMAP 103ff94bc40SHeiko Schocher * ioctl command should be used. The ioctl unmaps the logical eraseblocks, 104ff94bc40SHeiko Schocher * schedules corresponding physical eraseblock for erasure, and returns. Unlike 105ff94bc40SHeiko Schocher * the "LEB erase" command, it does not wait for the physical eraseblock being 106ff94bc40SHeiko Schocher * erased. Note, the side effect of this is that if an unclean reboot happens 107ff94bc40SHeiko Schocher * after the unmap ioctl returns, you may find the LEB mapped again to the same 108ff94bc40SHeiko Schocher * physical eraseblock after the UBI is run again. 109ff94bc40SHeiko Schocher * 110ff94bc40SHeiko Schocher * Check if logical eraseblock is mapped 111ff94bc40SHeiko Schocher * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 112ff94bc40SHeiko Schocher * 113ff94bc40SHeiko Schocher * To check if a logical eraseblock is mapped to a physical eraseblock, the 114ff94bc40SHeiko Schocher * %UBI_IOCEBISMAP ioctl command should be used. It returns %0 if the LEB is 115ff94bc40SHeiko Schocher * not mapped, and %1 if it is mapped. 116ff94bc40SHeiko Schocher * 117ff94bc40SHeiko Schocher * Set an UBI volume property 118ff94bc40SHeiko Schocher * ~~~~~~~~~~~~~~~~~~~~~~~~~ 119ff94bc40SHeiko Schocher * 120ff94bc40SHeiko Schocher * To set an UBI volume property the %UBI_IOCSETPROP ioctl command should be 121ff94bc40SHeiko Schocher * used. A pointer to a &struct ubi_set_vol_prop_req object is expected to be 122ff94bc40SHeiko Schocher * passed. The object describes which property should be set, and to which value 123ff94bc40SHeiko Schocher * it should be set. 1244e67c571SHeiko Schocher * 1254e67c571SHeiko Schocher * Block devices on UBI volumes 1264e67c571SHeiko Schocher * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1274e67c571SHeiko Schocher * 1284e67c571SHeiko Schocher * To create a R/O block device on top of an UBI volume the %UBI_IOCVOLCRBLK 1294e67c571SHeiko Schocher * should be used. A pointer to a &struct ubi_blkcreate_req object is expected 1304e67c571SHeiko Schocher * to be passed, which is not used and reserved for future usage. 1314e67c571SHeiko Schocher * 1324e67c571SHeiko Schocher * Conversely, to remove a block device the %UBI_IOCVOLRMBLK should be used, 1334e67c571SHeiko Schocher * which takes no arguments. 13447ae6693SKyungmin Park */ 13547ae6693SKyungmin Park 13647ae6693SKyungmin Park /* 13747ae6693SKyungmin Park * When a new UBI volume or UBI device is created, users may either specify the 13847ae6693SKyungmin Park * volume/device number they want to create or to let UBI automatically assign 13947ae6693SKyungmin Park * the number using these constants. 14047ae6693SKyungmin Park */ 14147ae6693SKyungmin Park #define UBI_VOL_NUM_AUTO (-1) 14247ae6693SKyungmin Park #define UBI_DEV_NUM_AUTO (-1) 14347ae6693SKyungmin Park 14447ae6693SKyungmin Park /* Maximum volume name length */ 14547ae6693SKyungmin Park #define UBI_MAX_VOLUME_NAME 127 14647ae6693SKyungmin Park 147ff94bc40SHeiko Schocher /* ioctl commands of UBI character devices */ 14847ae6693SKyungmin Park 14947ae6693SKyungmin Park #define UBI_IOC_MAGIC 'o' 15047ae6693SKyungmin Park 15147ae6693SKyungmin Park /* Create an UBI volume */ 15247ae6693SKyungmin Park #define UBI_IOCMKVOL _IOW(UBI_IOC_MAGIC, 0, struct ubi_mkvol_req) 15347ae6693SKyungmin Park /* Remove an UBI volume */ 154ff94bc40SHeiko Schocher #define UBI_IOCRMVOL _IOW(UBI_IOC_MAGIC, 1, __s32) 15547ae6693SKyungmin Park /* Re-size an UBI volume */ 15647ae6693SKyungmin Park #define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req) 157ff94bc40SHeiko Schocher /* Re-name volumes */ 158ff94bc40SHeiko Schocher #define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req) 15947ae6693SKyungmin Park 160ff94bc40SHeiko Schocher /* ioctl commands of the UBI control character device */ 16147ae6693SKyungmin Park 16247ae6693SKyungmin Park #define UBI_CTRL_IOC_MAGIC 'o' 16347ae6693SKyungmin Park 16447ae6693SKyungmin Park /* Attach an MTD device */ 16547ae6693SKyungmin Park #define UBI_IOCATT _IOW(UBI_CTRL_IOC_MAGIC, 64, struct ubi_attach_req) 16647ae6693SKyungmin Park /* Detach an MTD device */ 167ff94bc40SHeiko Schocher #define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, __s32) 16847ae6693SKyungmin Park 169ff94bc40SHeiko Schocher /* ioctl commands of UBI volume character devices */ 17047ae6693SKyungmin Park 17147ae6693SKyungmin Park #define UBI_VOL_IOC_MAGIC 'O' 17247ae6693SKyungmin Park 173ff94bc40SHeiko Schocher /* Start UBI volume update 174ff94bc40SHeiko Schocher * Note: This actually takes a pointer (__s64*), but we can't change 175ff94bc40SHeiko Schocher * that without breaking the ABI on 32bit systems 176ff94bc40SHeiko Schocher */ 177ff94bc40SHeiko Schocher #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, __s64) 178ff94bc40SHeiko Schocher /* LEB erasure command, used for debugging, disabled by default */ 179ff94bc40SHeiko Schocher #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, __s32) 180ff94bc40SHeiko Schocher /* Atomic LEB change command */ 181ff94bc40SHeiko Schocher #define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, __s32) 182ff94bc40SHeiko Schocher /* Map LEB command */ 183ff94bc40SHeiko Schocher #define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req) 184ff94bc40SHeiko Schocher /* Unmap LEB command */ 185ff94bc40SHeiko Schocher #define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, __s32) 186ff94bc40SHeiko Schocher /* Check if LEB is mapped command */ 187ff94bc40SHeiko Schocher #define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, __s32) 188ff94bc40SHeiko Schocher /* Set an UBI volume property */ 189ff94bc40SHeiko Schocher #define UBI_IOCSETVOLPROP _IOW(UBI_VOL_IOC_MAGIC, 6, \ 190ff94bc40SHeiko Schocher struct ubi_set_vol_prop_req) 1914e67c571SHeiko Schocher /* Create a R/O block device on top of an UBI volume */ 1924e67c571SHeiko Schocher #define UBI_IOCVOLCRBLK _IOW(UBI_VOL_IOC_MAGIC, 7, struct ubi_blkcreate_req) 1934e67c571SHeiko Schocher /* Remove the R/O block device */ 1944e67c571SHeiko Schocher #define UBI_IOCVOLRMBLK _IO(UBI_VOL_IOC_MAGIC, 8) 19547ae6693SKyungmin Park 19647ae6693SKyungmin Park /* Maximum MTD device name length supported by UBI */ 19747ae6693SKyungmin Park #define MAX_UBI_MTD_NAME_LEN 127 19847ae6693SKyungmin Park 199ff94bc40SHeiko Schocher /* Maximum amount of UBI volumes that can be re-named at one go */ 200ff94bc40SHeiko Schocher #define UBI_MAX_RNVOL 32 20147ae6693SKyungmin Park 20247ae6693SKyungmin Park /* 20347ae6693SKyungmin Park * UBI volume type constants. 20447ae6693SKyungmin Park * 20547ae6693SKyungmin Park * @UBI_DYNAMIC_VOLUME: dynamic volume 20647ae6693SKyungmin Park * @UBI_STATIC_VOLUME: static volume 20747ae6693SKyungmin Park */ 20847ae6693SKyungmin Park enum { 20947ae6693SKyungmin Park UBI_DYNAMIC_VOLUME = 3, 21047ae6693SKyungmin Park UBI_STATIC_VOLUME = 4, 21147ae6693SKyungmin Park }; 21247ae6693SKyungmin Park 213ff94bc40SHeiko Schocher /* 214ff94bc40SHeiko Schocher * UBI set volume property ioctl constants. 215ff94bc40SHeiko Schocher * 216ff94bc40SHeiko Schocher * @UBI_VOL_PROP_DIRECT_WRITE: allow (any non-zero value) or disallow (value 0) 217ff94bc40SHeiko Schocher * user to directly write and erase individual 218ff94bc40SHeiko Schocher * eraseblocks on dynamic volumes 219ff94bc40SHeiko Schocher */ 220ff94bc40SHeiko Schocher enum { 221ff94bc40SHeiko Schocher UBI_VOL_PROP_DIRECT_WRITE = 1, 222ff94bc40SHeiko Schocher }; 223ff94bc40SHeiko Schocher 22447ae6693SKyungmin Park /** 22547ae6693SKyungmin Park * struct ubi_attach_req - attach MTD device request. 22647ae6693SKyungmin Park * @ubi_num: UBI device number to create 22747ae6693SKyungmin Park * @mtd_num: MTD device number to attach 22847ae6693SKyungmin Park * @vid_hdr_offset: VID header offset (use defaults if %0) 229ff94bc40SHeiko Schocher * @max_beb_per1024: maximum expected number of bad PEB per 1024 PEBs 23047ae6693SKyungmin Park * @padding: reserved for future, not used, has to be zeroed 23147ae6693SKyungmin Park * 23247ae6693SKyungmin Park * This data structure is used to specify MTD device UBI has to attach and the 23347ae6693SKyungmin Park * parameters it has to use. The number which should be assigned to the new UBI 23447ae6693SKyungmin Park * device is passed in @ubi_num. UBI may automatically assign the number if 23547ae6693SKyungmin Park * @UBI_DEV_NUM_AUTO is passed. In this case, the device number is returned in 23647ae6693SKyungmin Park * @ubi_num. 23747ae6693SKyungmin Park * 23847ae6693SKyungmin Park * Most applications should pass %0 in @vid_hdr_offset to make UBI use default 23947ae6693SKyungmin Park * offset of the VID header within physical eraseblocks. The default offset is 24047ae6693SKyungmin Park * the next min. I/O unit after the EC header. For example, it will be offset 24147ae6693SKyungmin Park * 512 in case of a 512 bytes page NAND flash with no sub-page support. Or 24247ae6693SKyungmin Park * it will be 512 in case of a 2KiB page NAND flash with 4 512-byte sub-pages. 24347ae6693SKyungmin Park * 24447ae6693SKyungmin Park * But in rare cases, if this optimizes things, the VID header may be placed to 245ff94bc40SHeiko Schocher * a different offset. For example, the boot-loader might do things faster if 246ff94bc40SHeiko Schocher * the VID header sits at the end of the first 2KiB NAND page with 4 sub-pages. 247ff94bc40SHeiko Schocher * As the boot-loader would not normally need to read EC headers (unless it 248ff94bc40SHeiko Schocher * needs UBI in RW mode), it might be faster to calculate ECC. This is weird 249ff94bc40SHeiko Schocher * example, but it real-life example. So, in this example, @vid_hdr_offer would 250ff94bc40SHeiko Schocher * be 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes 251ff94bc40SHeiko Schocher * aligned, which is OK, as UBI is clever enough to realize this is 4th 252ff94bc40SHeiko Schocher * sub-page of the first page and add needed padding. 253ff94bc40SHeiko Schocher * 254ff94bc40SHeiko Schocher * The @max_beb_per1024 is the maximum amount of bad PEBs UBI expects on the 255ff94bc40SHeiko Schocher * UBI device per 1024 eraseblocks. This value is often given in an other form 256ff94bc40SHeiko Schocher * in the NAND datasheet (min NVB i.e. minimal number of valid blocks). The 257ff94bc40SHeiko Schocher * maximum expected bad eraseblocks per 1024 is then: 258ff94bc40SHeiko Schocher * 1024 * (1 - MinNVB / MaxNVB) 259ff94bc40SHeiko Schocher * Which gives 20 for most NAND devices. This limit is used in order to derive 260ff94bc40SHeiko Schocher * amount of eraseblock UBI reserves for handling new bad blocks. If the device 261ff94bc40SHeiko Schocher * has more bad eraseblocks than this limit, UBI does not reserve any physical 262ff94bc40SHeiko Schocher * eraseblocks for new bad eraseblocks, but attempts to use available 263ff94bc40SHeiko Schocher * eraseblocks (if any). The accepted range is 0-768. If 0 is given, the 264ff94bc40SHeiko Schocher * default kernel value of %CONFIG_MTD_UBI_BEB_LIMIT will be used. 26547ae6693SKyungmin Park */ 26647ae6693SKyungmin Park struct ubi_attach_req { 267ff94bc40SHeiko Schocher __s32 ubi_num; 268ff94bc40SHeiko Schocher __s32 mtd_num; 269ff94bc40SHeiko Schocher __s32 vid_hdr_offset; 270ff94bc40SHeiko Schocher __s16 max_beb_per1024; 271ff94bc40SHeiko Schocher __s8 padding[10]; 27247ae6693SKyungmin Park }; 27347ae6693SKyungmin Park 27447ae6693SKyungmin Park /** 27547ae6693SKyungmin Park * struct ubi_mkvol_req - volume description data structure used in 27647ae6693SKyungmin Park * volume creation requests. 27747ae6693SKyungmin Park * @vol_id: volume number 27847ae6693SKyungmin Park * @alignment: volume alignment 27947ae6693SKyungmin Park * @bytes: volume size in bytes 28047ae6693SKyungmin Park * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) 28147ae6693SKyungmin Park * @padding1: reserved for future, not used, has to be zeroed 28247ae6693SKyungmin Park * @name_len: volume name length 28347ae6693SKyungmin Park * @padding2: reserved for future, not used, has to be zeroed 28447ae6693SKyungmin Park * @name: volume name 28547ae6693SKyungmin Park * 28647ae6693SKyungmin Park * This structure is used by user-space programs when creating new volumes. The 28747ae6693SKyungmin Park * @used_bytes field is only necessary when creating static volumes. 28847ae6693SKyungmin Park * 28947ae6693SKyungmin Park * The @alignment field specifies the required alignment of the volume logical 29047ae6693SKyungmin Park * eraseblock. This means, that the size of logical eraseblocks will be aligned 29147ae6693SKyungmin Park * to this number, i.e., 29247ae6693SKyungmin Park * (UBI device logical eraseblock size) mod (@alignment) = 0. 29347ae6693SKyungmin Park * 29447ae6693SKyungmin Park * To put it differently, the logical eraseblock of this volume may be slightly 29547ae6693SKyungmin Park * shortened in order to make it properly aligned. The alignment has to be 29647ae6693SKyungmin Park * multiple of the flash minimal input/output unit, or %1 to utilize the entire 29747ae6693SKyungmin Park * available space of logical eraseblocks. 29847ae6693SKyungmin Park * 29947ae6693SKyungmin Park * The @alignment field may be useful, for example, when one wants to maintain 30047ae6693SKyungmin Park * a block device on top of an UBI volume. In this case, it is desirable to fit 30147ae6693SKyungmin Park * an integer number of blocks in logical eraseblocks of this UBI volume. With 30247ae6693SKyungmin Park * alignment it is possible to update this volume using plane UBI volume image 30347ae6693SKyungmin Park * BLOBs, without caring about how to properly align them. 30447ae6693SKyungmin Park */ 30547ae6693SKyungmin Park struct ubi_mkvol_req { 306ff94bc40SHeiko Schocher __s32 vol_id; 307ff94bc40SHeiko Schocher __s32 alignment; 308ff94bc40SHeiko Schocher __s64 bytes; 309ff94bc40SHeiko Schocher __s8 vol_type; 310ff94bc40SHeiko Schocher __s8 padding1; 311ff94bc40SHeiko Schocher __s16 name_len; 312ff94bc40SHeiko Schocher __s8 padding2[4]; 31347ae6693SKyungmin Park char name[UBI_MAX_VOLUME_NAME + 1]; 314ff94bc40SHeiko Schocher } __packed; 31547ae6693SKyungmin Park 31647ae6693SKyungmin Park /** 31747ae6693SKyungmin Park * struct ubi_rsvol_req - a data structure used in volume re-size requests. 31847ae6693SKyungmin Park * @vol_id: ID of the volume to re-size 31947ae6693SKyungmin Park * @bytes: new size of the volume in bytes 32047ae6693SKyungmin Park * 32147ae6693SKyungmin Park * Re-sizing is possible for both dynamic and static volumes. But while dynamic 32247ae6693SKyungmin Park * volumes may be re-sized arbitrarily, static volumes cannot be made to be 323ff94bc40SHeiko Schocher * smaller than the number of bytes they bear. To arbitrarily shrink a static 32447ae6693SKyungmin Park * volume, it must be wiped out first (by means of volume update operation with 32547ae6693SKyungmin Park * zero number of bytes). 32647ae6693SKyungmin Park */ 32747ae6693SKyungmin Park struct ubi_rsvol_req { 328ff94bc40SHeiko Schocher __s64 bytes; 329ff94bc40SHeiko Schocher __s32 vol_id; 330ff94bc40SHeiko Schocher } __packed; 33147ae6693SKyungmin Park 33247ae6693SKyungmin Park /** 333ff94bc40SHeiko Schocher * struct ubi_rnvol_req - volumes re-name request. 334ff94bc40SHeiko Schocher * @count: count of volumes to re-name 335ff94bc40SHeiko Schocher * @padding1: reserved for future, not used, has to be zeroed 336ff94bc40SHeiko Schocher * @vol_id: ID of the volume to re-name 337ff94bc40SHeiko Schocher * @name_len: name length 338ff94bc40SHeiko Schocher * @padding2: reserved for future, not used, has to be zeroed 339ff94bc40SHeiko Schocher * @name: new volume name 340ff94bc40SHeiko Schocher * 341ff94bc40SHeiko Schocher * UBI allows to re-name up to %32 volumes at one go. The count of volumes to 342ff94bc40SHeiko Schocher * re-name is specified in the @count field. The ID of the volumes to re-name 343ff94bc40SHeiko Schocher * and the new names are specified in the @vol_id and @name fields. 344ff94bc40SHeiko Schocher * 345ff94bc40SHeiko Schocher * The UBI volume re-name operation is atomic, which means that should power cut 346ff94bc40SHeiko Schocher * happen, the volumes will have either old name or new name. So the possible 347ff94bc40SHeiko Schocher * use-cases of this command is atomic upgrade. Indeed, to upgrade, say, volumes 348ff94bc40SHeiko Schocher * A and B one may create temporary volumes %A1 and %B1 with the new contents, 349ff94bc40SHeiko Schocher * then atomically re-name A1->A and B1->B, in which case old %A and %B will 350ff94bc40SHeiko Schocher * be removed. 351ff94bc40SHeiko Schocher * 352ff94bc40SHeiko Schocher * If it is not desirable to remove old A and B, the re-name request has to 353ff94bc40SHeiko Schocher * contain 4 entries: A1->A, A->A1, B1->B, B->B1, in which case old A1 and B1 354ff94bc40SHeiko Schocher * become A and B, and old A and B will become A1 and B1. 355ff94bc40SHeiko Schocher * 356ff94bc40SHeiko Schocher * It is also OK to request: A1->A, A1->X, B1->B, B->Y, in which case old A1 357ff94bc40SHeiko Schocher * and B1 become A and B, and old A and B become X and Y. 358ff94bc40SHeiko Schocher * 359ff94bc40SHeiko Schocher * In other words, in case of re-naming into an existing volume name, the 360ff94bc40SHeiko Schocher * existing volume is removed, unless it is re-named as well at the same 361ff94bc40SHeiko Schocher * re-name request. 362ff94bc40SHeiko Schocher */ 363ff94bc40SHeiko Schocher struct ubi_rnvol_req { 364ff94bc40SHeiko Schocher __s32 count; 365ff94bc40SHeiko Schocher __s8 padding1[12]; 366ff94bc40SHeiko Schocher struct { 367ff94bc40SHeiko Schocher __s32 vol_id; 368ff94bc40SHeiko Schocher __s16 name_len; 369ff94bc40SHeiko Schocher __s8 padding2[2]; 370ff94bc40SHeiko Schocher char name[UBI_MAX_VOLUME_NAME + 1]; 371ff94bc40SHeiko Schocher } ents[UBI_MAX_RNVOL]; 372ff94bc40SHeiko Schocher } __packed; 373ff94bc40SHeiko Schocher 374ff94bc40SHeiko Schocher /** 375ff94bc40SHeiko Schocher * struct ubi_leb_change_req - a data structure used in atomic LEB change 376ff94bc40SHeiko Schocher * requests. 37747ae6693SKyungmin Park * @lnum: logical eraseblock number to change 37847ae6693SKyungmin Park * @bytes: how many bytes will be written to the logical eraseblock 379ff94bc40SHeiko Schocher * @dtype: pass "3" for better compatibility with old kernels 38047ae6693SKyungmin Park * @padding: reserved for future, not used, has to be zeroed 381ff94bc40SHeiko Schocher * 382ff94bc40SHeiko Schocher * The @dtype field used to inform UBI about what kind of data will be written 383ff94bc40SHeiko Schocher * to the LEB: long term (value 1), short term (value 2), unknown (value 3). 384ff94bc40SHeiko Schocher * UBI tried to pick a PEB with lower erase counter for short term data and a 385ff94bc40SHeiko Schocher * PEB with higher erase counter for long term data. But this was not really 386ff94bc40SHeiko Schocher * used because users usually do not know this and could easily mislead UBI. We 387ff94bc40SHeiko Schocher * removed this feature in May 2012. UBI currently just ignores the @dtype 388ff94bc40SHeiko Schocher * field. But for better compatibility with older kernels it is recommended to 389ff94bc40SHeiko Schocher * set @dtype to 3 (unknown). 39047ae6693SKyungmin Park */ 39147ae6693SKyungmin Park struct ubi_leb_change_req { 392ff94bc40SHeiko Schocher __s32 lnum; 393ff94bc40SHeiko Schocher __s32 bytes; 394ff94bc40SHeiko Schocher __s8 dtype; /* obsolete, do not use! */ 395ff94bc40SHeiko Schocher __s8 padding[7]; 396ff94bc40SHeiko Schocher } __packed; 397ff94bc40SHeiko Schocher 398ff94bc40SHeiko Schocher /** 399ff94bc40SHeiko Schocher * struct ubi_map_req - a data structure used in map LEB requests. 400ff94bc40SHeiko Schocher * @dtype: pass "3" for better compatibility with old kernels 401ff94bc40SHeiko Schocher * @lnum: logical eraseblock number to unmap 402ff94bc40SHeiko Schocher * @padding: reserved for future, not used, has to be zeroed 403ff94bc40SHeiko Schocher */ 404ff94bc40SHeiko Schocher struct ubi_map_req { 405ff94bc40SHeiko Schocher __s32 lnum; 406ff94bc40SHeiko Schocher __s8 dtype; /* obsolete, do not use! */ 407ff94bc40SHeiko Schocher __s8 padding[3]; 408ff94bc40SHeiko Schocher } __packed; 409ff94bc40SHeiko Schocher 410ff94bc40SHeiko Schocher 411ff94bc40SHeiko Schocher /** 412ff94bc40SHeiko Schocher * struct ubi_set_vol_prop_req - a data structure used to set an UBI volume 413ff94bc40SHeiko Schocher * property. 414ff94bc40SHeiko Schocher * @property: property to set (%UBI_VOL_PROP_DIRECT_WRITE) 415ff94bc40SHeiko Schocher * @padding: reserved for future, not used, has to be zeroed 416ff94bc40SHeiko Schocher * @value: value to set 417ff94bc40SHeiko Schocher */ 418ff94bc40SHeiko Schocher struct ubi_set_vol_prop_req { 419ff94bc40SHeiko Schocher __u8 property; 420ff94bc40SHeiko Schocher __u8 padding[7]; 421ff94bc40SHeiko Schocher __u64 value; 422ff94bc40SHeiko Schocher } __packed; 42347ae6693SKyungmin Park 4244e67c571SHeiko Schocher /** 4254e67c571SHeiko Schocher * struct ubi_blkcreate_req - a data structure used in block creation requests. 4264e67c571SHeiko Schocher * @padding: reserved for future, not used, has to be zeroed 4274e67c571SHeiko Schocher */ 4284e67c571SHeiko Schocher struct ubi_blkcreate_req { 4294e67c571SHeiko Schocher __s8 padding[128]; 4304e67c571SHeiko Schocher } __packed; 4314e67c571SHeiko Schocher 43247ae6693SKyungmin Park #endif /* __UBI_USER_H__ */ 433