libubi_int.h 4.2 KB

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