3
0

blkidP.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * blkidP.h - Internal interfaces for libblkid
  4. *
  5. * Copyright (C) 2001 Andreas Dilger
  6. * Copyright (C) 2003 Theodore Ts'o
  7. *
  8. * %Begin-Header%
  9. * This file may be redistributed under the terms of the
  10. * GNU Lesser General Public License.
  11. * %End-Header%
  12. */
  13. #ifndef _BLKID_BLKIDP_H
  14. #define _BLKID_BLKIDP_H
  15. #include <sys/types.h>
  16. #include <stdio.h>
  17. #include "blkid.h"
  18. #include "list.h"
  19. #ifdef __GNUC__
  20. #define __BLKID_ATTR(x) __attribute__(x)
  21. #else
  22. #define __BLKID_ATTR(x)
  23. #endif
  24. /*
  25. * This describes the attributes of a specific device.
  26. * We can traverse all of the tags by bid_tags (linking to the tag bit_names).
  27. * The bid_label and bid_uuid fields are shortcuts to the LABEL and UUID tag
  28. * values, if they exist.
  29. */
  30. struct blkid_struct_dev
  31. {
  32. struct list_head bid_devs; /* All devices in the cache */
  33. struct list_head bid_tags; /* All tags for this device */
  34. blkid_cache bid_cache; /* Dev belongs to this cache */
  35. char *bid_name; /* Device inode pathname */
  36. char *bid_type; /* Preferred device TYPE */
  37. int bid_pri; /* Device priority */
  38. dev_t bid_devno; /* Device major/minor number */
  39. time_t bid_time; /* Last update time of device */
  40. unsigned int bid_flags; /* Device status bitflags */
  41. char *bid_label; /* Shortcut to device LABEL */
  42. char *bid_uuid; /* Shortcut to binary UUID */
  43. };
  44. #define BLKID_BID_FL_VERIFIED 0x0001 /* Device data validated from disk */
  45. #define BLKID_BID_FL_INVALID 0x0004 /* Device is invalid */
  46. /*
  47. * Each tag defines a NAME=value pair for a particular device. The tags
  48. * are linked via bit_names for a single device, so that traversing the
  49. * names list will get you a list of all tags associated with a device.
  50. * They are also linked via bit_values for all devices, so one can easily
  51. * search all tags with a given NAME for a specific value.
  52. */
  53. struct blkid_struct_tag
  54. {
  55. struct list_head bit_tags; /* All tags for this device */
  56. struct list_head bit_names; /* All tags with given NAME */
  57. char *bit_name; /* NAME of tag (shared) */
  58. char *bit_val; /* value of tag */
  59. blkid_dev bit_dev; /* pointer to device */
  60. };
  61. typedef struct blkid_struct_tag *blkid_tag;
  62. /*
  63. * Minimum number of seconds between device probes, even when reading
  64. * from the cache. This is to avoid re-probing all devices which were
  65. * just probed by another program that does not share the cache.
  66. */
  67. #define BLKID_PROBE_MIN 2
  68. /*
  69. * Time in seconds an entry remains verified in the in-memory cache
  70. * before being reverified (in case of long-running processes that
  71. * keep a cache in memory and continue to use it for a long time).
  72. */
  73. #define BLKID_PROBE_INTERVAL 200
  74. /* This describes an entire blkid cache file and probed devices.
  75. * We can traverse all of the found devices via bic_list.
  76. * We can traverse all of the tag types by bic_tags, which hold empty tags
  77. * for each tag type. Those tags can be used as list_heads for iterating
  78. * through all devices with a specific tag type (e.g. LABEL).
  79. */
  80. struct blkid_struct_cache
  81. {
  82. struct list_head bic_devs; /* List head of all devices */
  83. struct list_head bic_tags; /* List head of all tag types */
  84. time_t bic_time; /* Last probe time */
  85. time_t bic_ftime; /* Mod time of the cachefile */
  86. unsigned int bic_flags; /* Status flags of the cache */
  87. char *bic_filename; /* filename of cache */
  88. };
  89. #define BLKID_BIC_FL_PROBED 0x0002 /* We probed /proc/partition devices */
  90. #define BLKID_BIC_FL_CHANGED 0x0004 /* Cache has changed from disk */
  91. extern char *blkid_strdup(const char *s);
  92. extern char *blkid_strndup(const char *s, const int length);
  93. #define BLKID_CACHE_FILE "/etc/blkid.tab"
  94. extern const char *blkid_devdirs[];
  95. #define BLKID_ERR_IO 5
  96. #define BLKID_ERR_PROC 9
  97. #define BLKID_ERR_MEM 12
  98. #define BLKID_ERR_CACHE 14
  99. #define BLKID_ERR_DEV 19
  100. #define BLKID_ERR_PARAM 22
  101. #define BLKID_ERR_BIG 27
  102. /*
  103. * Priority settings for different types of devices
  104. */
  105. #define BLKID_PRI_EVMS 30
  106. #define BLKID_PRI_LVM 20
  107. #define BLKID_PRI_MD 10
  108. #if defined(TEST_PROGRAM) && !defined(CONFIG_BLKID_DEBUG)
  109. #define CONFIG_BLKID_DEBUG
  110. #endif
  111. #define DEBUG_CACHE 0x0001
  112. #define DEBUG_DUMP 0x0002
  113. #define DEBUG_DEV 0x0004
  114. #define DEBUG_DEVNAME 0x0008
  115. #define DEBUG_DEVNO 0x0010
  116. #define DEBUG_PROBE 0x0020
  117. #define DEBUG_READ 0x0040
  118. #define DEBUG_RESOLVE 0x0080
  119. #define DEBUG_SAVE 0x0100
  120. #define DEBUG_TAG 0x0200
  121. #define DEBUG_INIT 0x8000
  122. #define DEBUG_ALL 0xFFFF
  123. #ifdef CONFIG_BLKID_DEBUG
  124. #include <stdio.h>
  125. extern int blkid_debug_mask;
  126. #define DBG(m,x) if ((m) & blkid_debug_mask) x;
  127. #else
  128. #define DBG(m,x)
  129. #endif
  130. #ifdef CONFIG_BLKID_DEBUG
  131. extern void blkid_debug_dump_dev(blkid_dev dev);
  132. extern void blkid_debug_dump_tag(blkid_tag tag);
  133. #endif
  134. /* lseek.c */
  135. /* extern blkid_loff_t blkid_llseek(int fd, blkid_loff_t offset, int whence); */
  136. #ifdef CONFIG_LFS
  137. # define blkid_llseek lseek64
  138. #else
  139. # define blkid_llseek lseek
  140. #endif
  141. /* read.c */
  142. extern void blkid_read_cache(blkid_cache cache);
  143. /* save.c */
  144. extern int blkid_flush_cache(blkid_cache cache);
  145. /*
  146. * Functions to create and find a specific tag type: tag.c
  147. */
  148. extern void blkid_free_tag(blkid_tag tag);
  149. extern blkid_tag blkid_find_tag_dev(blkid_dev dev, const char *type);
  150. extern int blkid_set_tag(blkid_dev dev, const char *name,
  151. const char *value, const int vlength);
  152. /*
  153. * Functions to create and find a specific tag type: dev.c
  154. */
  155. extern blkid_dev blkid_new_dev(void);
  156. extern void blkid_free_dev(blkid_dev dev);
  157. #ifdef __cplusplus
  158. }
  159. #endif
  160. #endif /* _BLKID_BLKIDP_H */