libfstools: properly label ext4 overlay
[project/fstools.git] / libubi / libubi_int.h
1 /*
2 * Copyright (c) International Business Machines Corp., 2006
3 *
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.
8 *
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.
13 *
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., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 * Author: Artem Bityutskiy
19 *
20 * UBI (Unsorted Block Images) library.
21 */
22
23 #ifndef __LIBUBI_INT_H__
24 #define __LIBUBI_INT_H__
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /*
31 * The below are pre-define UBI file and directory names.
32 *
33 * Note, older kernels put 'ubiX_Y' directories straight to '/sys/class/ubi/'.
34 * New kernels puts 'ubiX_Y' directories to '/sys/class/ubi/ubiX/', which is
35 * saner. And for compatibility reasons it also puts symlinks to 'ubiX_Y'
36 * directories to '/sys/class/ubi/'. For now libubi assumes old layout.
37 */
38
39 #define SYSFS_UBI "class/ubi"
40 #define SYSFS_CTRL "class/misc/ubi_ctrl/"
41
42 #define CTRL_DEV "dev"
43
44 #define UBI_VER "version"
45 #define UBI_DEV_NAME_PATT "ubi%d"
46
47 #define DEV_DEV "dev"
48 #define DEV_AVAIL_EBS "avail_eraseblocks"
49 #define DEV_TOTAL_EBS "total_eraseblocks"
50 #define DEV_BAD_COUNT "bad_peb_count"
51 #define DEV_EB_SIZE "eraseblock_size"
52 #define DEV_MAX_EC "max_ec"
53 #define DEV_MAX_RSVD "reserved_for_bad"
54 #define DEV_MAX_VOLS "max_vol_count"
55 #define DEV_MIN_IO_SIZE "min_io_size"
56 #define DEV_MTD_NUM "mtd_num"
57
58 #define UBI_VOL_NAME_PATT "ubi%d_%d"
59 #define VOL_TYPE "type"
60 #define VOL_DEV "dev"
61 #define VOL_ALIGNMENT "alignment"
62 #define VOL_DATA_BYTES "data_bytes"
63 #define VOL_RSVD_EBS "reserved_ebs"
64 #define VOL_EB_SIZE "usable_eb_size"
65 #define VOL_CORRUPTED "corrupted"
66 #define VOL_NAME "name"
67
68 /**
69 * libubi - UBI library description data structure.
70 * @sysfs: sysfs file system path
71 * @sysfs_ctrl: UBI control device directory in sysfs
72 * @ctrl_dev: UBI control device major/minor numbers sysfs file
73 * @sysfs_ubi: UBI directory in sysfs
74 * @ubi_dev: UBI device sysfs directory pattern
75 * @ubi_version: UBI version file sysfs path
76 * @dev_dev: UBI device major/minor numbers file pattern
77 * @dev_avail_ebs: count of available eraseblocks sysfs path pattern
78 * @dev_total_ebs: total eraseblocks count sysfs path pattern
79 * @dev_bad_count: count of bad eraseblocks sysfs path pattern
80 * @dev_eb_size: size of UBI device's eraseblocks sysfs path pattern
81 * @dev_max_ec: maximum erase counter sysfs path pattern
82 * @dev_bad_rsvd: count of physical eraseblock reserved for bad eraseblocks
83 * handling
84 * @dev_max_vols: maximum volumes number count sysfs path pattern
85 * @dev_min_io_size: minimum I/O unit size sysfs path pattern
86 * @dev_mtd_num: MTD device number
87 * @ubi_vol: UBI volume sysfs directory pattern
88 * @vol_type: volume type sysfs path pattern
89 * @vol_dev: volume major/minor numbers file pattern
90 * @vol_alignment: volume alignment sysfs path pattern
91 * @vol_data_bytes: volume data size sysfs path pattern
92 * @vol_rsvd_ebs: volume reserved size sysfs path pattern
93 * @vol_eb_size: volume eraseblock size sysfs path pattern
94 * @vol_corrupted: volume corruption flag sysfs path pattern
95 * @vol_name: volume name sysfs path pattern
96 */
97 struct libubi
98 {
99 char *sysfs;
100 char *sysfs_ctrl;
101 char *ctrl_dev;
102 char *sysfs_ubi;
103 char *ubi_dev;
104 char *ubi_version;
105 char *dev_dev;
106 char *dev_avail_ebs;
107 char *dev_total_ebs;
108 char *dev_bad_count;
109 char *dev_eb_size;
110 char *dev_max_ec;
111 char *dev_bad_rsvd;
112 char *dev_max_vols;
113 char *dev_min_io_size;
114 char *dev_mtd_num;
115 char *ubi_vol;
116 char *vol_type;
117 char *vol_dev;
118 char *vol_alignment;
119 char *vol_data_bytes;
120 char *vol_rsvd_ebs;
121 char *vol_eb_size;
122 char *vol_corrupted;
123 char *vol_name;
124 char *vol_max_count;
125 };
126
127 #ifdef __cplusplus
128 }
129 #endif
130
131 #endif /* !__LIBUBI_INT_H__ */