| 1 |
/* |
| 2 |
* blkidP.h - Internal interfaces for libblkid |
| 3 |
* |
| 4 |
* Copyright (C) 2001 Andreas Dilger |
| 5 |
* Copyright (C) 2003 Theodore Ts'o |
| 6 |
* |
| 7 |
* %Begin-Header% |
| 8 |
* This file may be redistributed under the terms of the |
| 9 |
* GNU Lesser General Public License. |
| 10 |
* %End-Header% |
| 11 |
*/ |
| 12 |
|
| 13 |
#ifndef _BLKID_BLKIDP_H |
| 14 |
#define _BLKID_BLKIDP_H |
| 15 |
|
| 16 |
/* Always confirm that /dev/disk-by symlinks match with LABEL/UUID on device */ |
| 17 |
/* #define CONFIG_BLKID_VERIFY_UDEV 1 */ |
| 18 |
|
| 19 |
#include <sys/types.h> |
| 20 |
#include <dirent.h> |
| 21 |
#include <sys/stat.h> |
| 22 |
#include <stdio.h> |
| 23 |
#include <stdarg.h> |
| 24 |
#include <stdint.h> |
| 25 |
|
| 26 |
#ifndef UUID_STR_LEN |
| 27 |
# define UUID_STR_LEN 37 |
| 28 |
#endif |
| 29 |
|
| 30 |
#include "c.h" |
| 31 |
#include "bitops.h" /* $(top_srcdir)/include/ */ |
| 32 |
#include "blkdev.h" |
| 33 |
|
| 34 |
#include "debug.h" |
| 35 |
#include "blkid.h" |
| 36 |
#include "list.h" |
| 37 |
#include "encode.h" |
| 38 |
|
| 39 |
/* |
| 40 |
* This describes the attributes of a specific device. |
| 41 |
* We can traverse all of the tags by bid_tags (linking to the tag bit_names). |
| 42 |
* The bid_label and bid_uuid fields are shortcuts to the LABEL and UUID tag |
| 43 |
* values, if they exist. |
| 44 |
*/ |
| 45 |
struct blkid_struct_dev |
| 46 |
{ |
| 47 |
struct list_head bid_devs; /* All devices in the cache */ |
| 48 |
struct list_head bid_tags; /* All tags for this device */ |
| 49 |
blkid_cache bid_cache; /* Dev belongs to this cache */ |
| 50 |
char *bid_name; /* Device real path (as used in cache) */ |
| 51 |
char *bid_xname; /* Device path as used by application (maybe symlink..) */ |
| 52 |
char *bid_type; /* Preferred device TYPE */ |
| 53 |
int bid_pri; /* Device priority */ |
| 54 |
dev_t bid_devno; /* Device major/minor number */ |
| 55 |
time_t bid_time; /* Last update time of device */ |
| 56 |
suseconds_t bid_utime; /* Last update time (microseconds) */ |
| 57 |
unsigned int bid_flags; /* Device status bitflags */ |
| 58 |
char *bid_label; /* Shortcut to device LABEL */ |
| 59 |
char *bid_uuid; /* Shortcut to binary UUID */ |
| 60 |
}; |
| 61 |
|
| 62 |
#define BLKID_BID_FL_VERIFIED 0x0001 /* Device data validated from disk */ |
| 63 |
#define BLKID_BID_FL_INVALID 0x0004 /* Device is invalid */ |
| 64 |
#define BLKID_BID_FL_REMOVABLE 0x0008 /* Device added by blkid_probe_all_removable() */ |
| 65 |
|
| 66 |
/* |
| 67 |
* Each tag defines a NAME=value pair for a particular device. The tags |
| 68 |
* are linked via bit_names for a single device, so that traversing the |
| 69 |
* names list will get you a list of all tags associated with a device. |
| 70 |
* They are also linked via bit_values for all devices, so one can easily |
| 71 |
* search all tags with a given NAME for a specific value. |
| 72 |
*/ |
| 73 |
struct blkid_struct_tag |
| 74 |
{ |
| 75 |
struct list_head bit_tags; /* All tags for this device */ |
| 76 |
struct list_head bit_names; /* All tags with given NAME */ |
| 77 |
char *bit_name; /* NAME of tag (shared) */ |
| 78 |
char *bit_val; /* value of tag */ |
| 79 |
blkid_dev bit_dev; /* pointer to device */ |
| 80 |
}; |
| 81 |
typedef struct blkid_struct_tag *blkid_tag; |
| 82 |
|
| 83 |
/* |
| 84 |
* Chain IDs |
| 85 |
*/ |
| 86 |
enum { |
| 87 |
BLKID_CHAIN_SUBLKS, /* FS/RAID superblocks (enabled by default) */ |
| 88 |
BLKID_CHAIN_TOPLGY, /* Block device topology */ |
| 89 |
BLKID_CHAIN_PARTS, /* Partition tables */ |
| 90 |
|
| 91 |
BLKID_NCHAINS /* number of chains */ |
| 92 |
}; |
| 93 |
|
| 94 |
struct blkid_chain { |
| 95 |
const struct blkid_chaindrv *driver; /* chain driver */ |
| 96 |
|
| 97 |
int enabled; /* boolean */ |
| 98 |
int flags; /* BLKID_<chain>_* */ |
| 99 |
int binary; /* boolean */ |
| 100 |
int idx; /* index of the current prober (or -1) */ |
| 101 |
unsigned long *fltr; /* filter or NULL */ |
| 102 |
void *data; /* private chain data or NULL */ |
| 103 |
}; |
| 104 |
|
| 105 |
/* |
| 106 |
* Chain driver |
| 107 |
*/ |
| 108 |
struct blkid_chaindrv { |
| 109 |
const size_t id; /* BLKID_CHAIN_* */ |
| 110 |
const char *name; /* name of chain (for debug purpose) */ |
| 111 |
const int dflt_flags; /* default chain flags */ |
| 112 |
const int dflt_enabled; /* default enabled boolean */ |
| 113 |
int has_fltr; /* boolean */ |
| 114 |
|
| 115 |
const struct blkid_idinfo **idinfos; /* description of probing functions */ |
| 116 |
const size_t nidinfos; /* number of idinfos */ |
| 117 |
|
| 118 |
/* driver operations */ |
| 119 |
int (*probe)(blkid_probe, struct blkid_chain *); |
| 120 |
int (*safeprobe)(blkid_probe, struct blkid_chain *); |
| 121 |
void (*free_data)(blkid_probe, void *); |
| 122 |
}; |
| 123 |
|
| 124 |
/* chains */ |
| 125 |
extern const struct blkid_chaindrv superblocks_drv; |
| 126 |
extern const struct blkid_chaindrv topology_drv; |
| 127 |
extern const struct blkid_chaindrv partitions_drv; |
| 128 |
|
| 129 |
/* |
| 130 |
* Low-level probe result |
| 131 |
*/ |
| 132 |
struct blkid_prval |
| 133 |
{ |
| 134 |
const char *name; /* value name */ |
| 135 |
unsigned char *data; /* value data */ |
| 136 |
size_t len; /* length of value data */ |
| 137 |
|
| 138 |
struct blkid_chain *chain; /* owner */ |
| 139 |
struct list_head prvals; /* list of results */ |
| 140 |
}; |
| 141 |
|
| 142 |
/* |
| 143 |
* Filesystem / Raid magic strings |
| 144 |
*/ |
| 145 |
struct blkid_idmag |
| 146 |
{ |
| 147 |
const char *magic; /* magic string */ |
| 148 |
unsigned int len; /* length of magic */ |
| 149 |
unsigned int hint; /* hint for prober */ |
| 150 |
|
| 151 |
const char *hoff; /* hint which contains byte offset to kboff */ |
| 152 |
long kboff; /* kilobyte offset of superblock */ |
| 153 |
unsigned int sboff; /* byte offset within superblock */ |
| 154 |
|
| 155 |
int is_zoned; /* indicate magic location is calculated based on zone position */ |
| 156 |
long zonenum; /* zone number which has superblock */ |
| 157 |
long kboff_inzone; /* kilobyte offset of superblock in a zone */ |
| 158 |
}; |
| 159 |
|
| 160 |
/* |
| 161 |
* Filesystem / Raid description |
| 162 |
*/ |
| 163 |
struct blkid_idinfo |
| 164 |
{ |
| 165 |
const char *name; /* fs, raid or partition table name */ |
| 166 |
int usage; /* BLKID_USAGE_* flag */ |
| 167 |
int flags; /* BLKID_IDINFO_* flags */ |
| 168 |
int minsz; /* minimal device size */ |
| 169 |
|
| 170 |
/* probe function */ |
| 171 |
int (*probefunc)(blkid_probe pr, const struct blkid_idmag *mag); |
| 172 |
|
| 173 |
struct blkid_idmag magics[]; /* NULL or array with magic strings */ |
| 174 |
}; |
| 175 |
|
| 176 |
#define BLKID_NONE_MAGIC {{ NULL }} |
| 177 |
|
| 178 |
/* |
| 179 |
* tolerant FS - can share the same device with more filesystems (e.g. typical |
| 180 |
* on CD-ROMs). We need this flag to detect ambivalent results (e.g. valid fat |
| 181 |
* and valid linux swap on the same device). |
| 182 |
*/ |
| 183 |
#define BLKID_IDINFO_TOLERANT (1 << 1) |
| 184 |
|
| 185 |
struct blkid_bufinfo { |
| 186 |
unsigned char *data; |
| 187 |
uint64_t off; |
| 188 |
uint64_t len; |
| 189 |
struct list_head bufs; /* list of buffers */ |
| 190 |
}; |
| 191 |
|
| 192 |
/* |
| 193 |
* Probing hint |
| 194 |
*/ |
| 195 |
struct blkid_hint { |
| 196 |
char *name; |
| 197 |
uint64_t value; |
| 198 |
struct list_head hints; |
| 199 |
}; |
| 200 |
|
| 201 |
/* |
| 202 |
* Low-level probing control struct |
| 203 |
*/ |
| 204 |
struct blkid_struct_probe |
| 205 |
{ |
| 206 |
int fd; /* device file descriptor */ |
| 207 |
uint64_t off; /* begin of data on the device */ |
| 208 |
uint64_t size; /* end of data on the device */ |
| 209 |
uint64_t io_size; /* optimal size of IO */ |
| 210 |
|
| 211 |
dev_t devno; /* device number (st.st_rdev) */ |
| 212 |
dev_t disk_devno; /* devno of the whole-disk or 0 */ |
| 213 |
unsigned int blkssz; /* sector size (BLKSSZGET ioctl) */ |
| 214 |
mode_t mode; /* struct stat.sb_mode */ |
| 215 |
uint64_t zone_size; /* zone size (BLKGETZONESZ ioctl) */ |
| 216 |
|
| 217 |
int flags; /* private library flags */ |
| 218 |
int prob_flags; /* always zeroized by blkid_do_*() */ |
| 219 |
|
| 220 |
uint64_t wipe_off; /* begin of the wiped area */ |
| 221 |
uint64_t wipe_size; /* size of the wiped area */ |
| 222 |
struct blkid_chain *wipe_chain; /* superblock, partition, ... */ |
| 223 |
|
| 224 |
struct list_head buffers; /* list of buffers */ |
| 225 |
struct list_head prunable_buffers; /* list of prunable buffers */ |
| 226 |
struct list_head hints; |
| 227 |
|
| 228 |
struct blkid_chain chains[BLKID_NCHAINS]; /* array of chains */ |
| 229 |
struct blkid_chain *cur_chain; /* current chain */ |
| 230 |
|
| 231 |
struct list_head values; /* results */ |
| 232 |
|
| 233 |
struct blkid_struct_probe *parent; /* for clones */ |
| 234 |
struct blkid_struct_probe *disk_probe; /* whole-disk probing */ |
| 235 |
}; |
| 236 |
|
| 237 |
/* private flags library flags */ |
| 238 |
#define BLKID_FL_PRIVATE_FD (1 << 1) /* see blkid_new_probe_from_filename() */ |
| 239 |
#define BLKID_FL_TINY_DEV (1 << 2) /* <= 1.47MiB (floppy or so) */ |
| 240 |
#define BLKID_FL_CDROM_DEV (1 << 3) /* is a CD/DVD drive */ |
| 241 |
#define BLKID_FL_NOSCAN_DEV (1 << 4) /* do not scan this device */ |
| 242 |
#define BLKID_FL_MODIF_BUFF (1 << 5) /* cached buffers has been modified */ |
| 243 |
#define BLKID_FL_OPAL_LOCKED (1 << 6) /* OPAL device is locked (I/O errors) */ |
| 244 |
#define BLKID_FL_OPAL_CHECKED (1 << 7) /* OPAL lock checked */ |
| 245 |
|
| 246 |
/* private per-probing flags */ |
| 247 |
#define BLKID_PROBE_FL_IGNORE_PT (1 << 1) /* ignore partition table */ |
| 248 |
#define BLKID_PROBE_FL_SAFEPROBE (1 << 2) /* safeprobe mode */ |
| 249 |
|
| 250 |
extern blkid_probe blkid_clone_probe(blkid_probe parent); |
| 251 |
extern blkid_probe blkid_probe_get_wholedisk_probe(blkid_probe pr); |
| 252 |
|
| 253 |
/* |
| 254 |
* Evaluation methods (for blkid_eval_* API) |
| 255 |
*/ |
| 256 |
enum { |
| 257 |
BLKID_EVAL_UDEV = 0, |
| 258 |
BLKID_EVAL_SCAN, |
| 259 |
|
| 260 |
__BLKID_EVAL_LAST |
| 261 |
}; |
| 262 |
|
| 263 |
/* |
| 264 |
* Library config options |
| 265 |
*/ |
| 266 |
struct blkid_config { |
| 267 |
int eval[__BLKID_EVAL_LAST]; /* array with EVALUATION=<udev,cache> options */ |
| 268 |
int nevals; /* number of elems in eval array */ |
| 269 |
int uevent; /* SEND_UEVENT=<yes|not> option */ |
| 270 |
char *cachefile; /* CACHE_FILE=<path> option */ |
| 271 |
}; |
| 272 |
|
| 273 |
extern struct blkid_config *blkid_read_config(const char *filename) |
| 274 |
__ul_attribute__((warn_unused_result)); |
| 275 |
extern void blkid_free_config(struct blkid_config *conf); |
| 276 |
|
| 277 |
/* |
| 278 |
* Minimum number of seconds between device probes, even when reading |
| 279 |
* from the cache. This is to avoid re-probing all devices which were |
| 280 |
* just probed by another program that does not share the cache. |
| 281 |
*/ |
| 282 |
#define BLKID_PROBE_MIN 2 |
| 283 |
|
| 284 |
/* |
| 285 |
* Time in seconds an entry remains verified in the in-memory cache |
| 286 |
* before being reverified (in case of long-running processes that |
| 287 |
* keep a cache in memory and continue to use it for a long time). |
| 288 |
*/ |
| 289 |
#define BLKID_PROBE_INTERVAL 200 |
| 290 |
|
| 291 |
/* This describes an entire blkid cache file and probed devices. |
| 292 |
* We can traverse all of the found devices via bic_list. |
| 293 |
* We can traverse all of the tag types by bic_tags, which hold empty tags |
| 294 |
* for each tag type. Those tags can be used as list_heads for iterating |
| 295 |
* through all devices with a specific tag type (e.g. LABEL). |
| 296 |
*/ |
| 297 |
struct blkid_struct_cache |
| 298 |
{ |
| 299 |
struct list_head bic_devs; /* List head of all devices */ |
| 300 |
struct list_head bic_tags; /* List head of all tag types */ |
| 301 |
time_t bic_time; /* Last probe time */ |
| 302 |
time_t bic_ftime; /* Mod time of the cachefile */ |
| 303 |
unsigned int bic_flags; /* Status flags of the cache */ |
| 304 |
char *bic_filename; /* filename of cache */ |
| 305 |
blkid_probe probe; /* low-level probing stuff */ |
| 306 |
}; |
| 307 |
|
| 308 |
#define BLKID_BIC_FL_PROBED 0x0002 /* We probed /proc/partition devices */ |
| 309 |
#define BLKID_BIC_FL_CHANGED 0x0004 /* Cache has changed from disk */ |
| 310 |
|
| 311 |
/* config file */ |
| 312 |
#define BLKID_CONFIG_FILE "/etc/blkid.conf" |
| 313 |
|
| 314 |
/* cache file on systemds with /run */ |
| 315 |
#define BLKID_RUNTIME_TOPDIR "/run" |
| 316 |
#define BLKID_RUNTIME_DIR BLKID_RUNTIME_TOPDIR "/blkid" |
| 317 |
#define BLKID_CACHE_FILE BLKID_RUNTIME_DIR "/blkid.tab" |
| 318 |
|
| 319 |
/* old systems */ |
| 320 |
#define BLKID_CACHE_FILE_OLD "/etc/blkid.tab" |
| 321 |
|
| 322 |
#define BLKID_ERR_IO 5 |
| 323 |
#define BLKID_ERR_SYSFS 9 |
| 324 |
#define BLKID_ERR_MEM 12 |
| 325 |
#define BLKID_ERR_CACHE 14 |
| 326 |
#define BLKID_ERR_DEV 19 |
| 327 |
#define BLKID_ERR_PARAM 22 |
| 328 |
#define BLKID_ERR_BIG 27 |
| 329 |
|
| 330 |
/* |
| 331 |
* Priority settings for different types of devices |
| 332 |
*/ |
| 333 |
#define BLKID_PRI_UBI 50 |
| 334 |
#define BLKID_PRI_DM 40 |
| 335 |
#define BLKID_PRI_EVMS 30 |
| 336 |
#define BLKID_PRI_LVM 20 |
| 337 |
#define BLKID_PRI_MD 10 |
| 338 |
|
| 339 |
#define BLKID_DEBUG_HELP (1 << 0) |
| 340 |
#define BLKID_DEBUG_INIT (1 << 1) |
| 341 |
#define BLKID_DEBUG_CACHE (1 << 2) |
| 342 |
#define BLKID_DEBUG_CONFIG (1 << 3) |
| 343 |
#define BLKID_DEBUG_DEV (1 << 4) |
| 344 |
#define BLKID_DEBUG_DEVNAME (1 << 5) |
| 345 |
#define BLKID_DEBUG_DEVNO (1 << 6) |
| 346 |
#define BLKID_DEBUG_EVALUATE (1 << 7) |
| 347 |
#define BLKID_DEBUG_LOWPROBE (1 << 8) |
| 348 |
#define BLKID_DEBUG_PROBE (1 << 9) |
| 349 |
#define BLKID_DEBUG_READ (1 << 10) |
| 350 |
#define BLKID_DEBUG_SAVE (1 << 11) |
| 351 |
#define BLKID_DEBUG_TAG (1 << 12) |
| 352 |
#define BLKID_DEBUG_BUFFER (1 << 13) |
| 353 |
#define BLKID_DEBUG_ALL 0xFFFF /* (1 << 16) aka FFFF is expected by API */ |
| 354 |
|
| 355 |
UL_DEBUG_DECLARE_MASK(libblkid); |
| 356 |
#define DBG(m, x) __UL_DBG(libblkid, BLKID_DEBUG_, m, x) |
| 357 |
#define ON_DBG(m, x) __UL_DBG_CALL(libblkid, BLKID_DEBUG_, m, x) |
| 358 |
|
| 359 |
#define UL_DEBUG_CURRENT_MASK UL_DEBUG_MASK(libblkid) |
| 360 |
#include "debugobj.h" |
| 361 |
|
| 362 |
extern void blkid_debug_dump_dev(blkid_dev dev); |
| 363 |
|
| 364 |
|
| 365 |
/* devno.c */ |
| 366 |
struct dir_list { |
| 367 |
char *name; |
| 368 |
struct dir_list *next; |
| 369 |
}; |
| 370 |
extern void blkid__scan_dir(char *, dev_t, struct dir_list **, char **) |
| 371 |
__attribute__((nonnull(1,4))); |
| 372 |
extern int blkid_driver_has_major(const char *drvname, int drvmaj) |
| 373 |
__attribute__((warn_unused_result)); |
| 374 |
|
| 375 |
/* read.c */ |
| 376 |
extern void blkid_read_cache(blkid_cache cache) |
| 377 |
__attribute__((nonnull)); |
| 378 |
|
| 379 |
/* save.c */ |
| 380 |
extern int blkid_flush_cache(blkid_cache cache) |
| 381 |
__attribute__((nonnull)); |
| 382 |
|
| 383 |
/* cache */ |
| 384 |
extern char *blkid_safe_getenv(const char *arg) |
| 385 |
__attribute__((nonnull)) |
| 386 |
__attribute__((warn_unused_result)); |
| 387 |
|
| 388 |
extern char *blkid_get_cache_filename(struct blkid_config *conf) |
| 389 |
__attribute__((warn_unused_result)); |
| 390 |
/* |
| 391 |
* Functions to create and find a specific tag type: tag.c |
| 392 |
*/ |
| 393 |
extern void blkid_free_tag(blkid_tag tag); |
| 394 |
extern blkid_tag blkid_find_tag_dev(blkid_dev dev, const char *type) |
| 395 |
__attribute__((nonnull)) |
| 396 |
__attribute__((warn_unused_result)); |
| 397 |
|
| 398 |
extern int blkid_set_tag(blkid_dev dev, const char *name, |
| 399 |
const char *value, const int vlength) |
| 400 |
__attribute__((nonnull(1,2))); |
| 401 |
|
| 402 |
/* |
| 403 |
* Functions to create and find a specific tag type: dev.c |
| 404 |
*/ |
| 405 |
extern blkid_dev blkid_new_dev(void) |
| 406 |
__attribute__((warn_unused_result)); |
| 407 |
extern void blkid_free_dev(blkid_dev dev); |
| 408 |
|
| 409 |
/* probe.c */ |
| 410 |
extern int blkid_probe_is_tiny(blkid_probe pr) |
| 411 |
__attribute__((nonnull)) |
| 412 |
__attribute__((warn_unused_result)); |
| 413 |
extern int blkid_probe_is_cdrom(blkid_probe pr) |
| 414 |
__attribute__((nonnull)) |
| 415 |
__attribute__((warn_unused_result)); |
| 416 |
extern int blkdid_probe_is_opal_locked(blkid_probe pr) |
| 417 |
__attribute__((nonnull)) |
| 418 |
__attribute__((warn_unused_result)); |
| 419 |
|
| 420 |
extern const unsigned char *blkid_probe_get_buffer(blkid_probe pr, |
| 421 |
uint64_t off, uint64_t len) |
| 422 |
__attribute__((nonnull)) |
| 423 |
__attribute__((warn_unused_result)); |
| 424 |
|
| 425 |
extern const unsigned char *blkid_probe_get_buffer_direct(blkid_probe pr, |
| 426 |
uint64_t off, uint64_t len) |
| 427 |
__attribute__((nonnull)) |
| 428 |
__attribute__((warn_unused_result)); |
| 429 |
|
| 430 |
extern const unsigned char *blkid_probe_get_sector(blkid_probe pr, unsigned int sector) |
| 431 |
__attribute__((nonnull)) |
| 432 |
__attribute__((warn_unused_result)); |
| 433 |
|
| 434 |
extern int blkid_probe_get_dimension(blkid_probe pr, |
| 435 |
uint64_t *off, uint64_t *size) |
| 436 |
__attribute__((nonnull)); |
| 437 |
|
| 438 |
extern int blkid_probe_set_dimension(blkid_probe pr, |
| 439 |
uint64_t off, uint64_t size) |
| 440 |
__attribute__((nonnull)); |
| 441 |
|
| 442 |
extern int blkid_probe_get_idmag(blkid_probe pr, const struct blkid_idinfo *id, |
| 443 |
uint64_t *offset, const struct blkid_idmag **res) |
| 444 |
__attribute__((nonnull(1))); |
| 445 |
|
| 446 |
extern void blkid_probe_prune_buffers(blkid_probe pr); |
| 447 |
|
| 448 |
/* returns superblock according to 'struct blkid_idmag' */ |
| 449 |
extern const unsigned char *blkid_probe_get_sb_buffer(blkid_probe pr, const struct blkid_idmag *mag, size_t size); |
| 450 |
#define blkid_probe_get_sb(_pr, _mag, type) \ |
| 451 |
((const type *) blkid_probe_get_sb_buffer((_pr), _mag, sizeof(type))) |
| 452 |
|
| 453 |
extern uint64_t blkid_probe_get_idmag_off(blkid_probe pr, const struct blkid_idmag *mag) |
| 454 |
__attribute__((nonnull)); |
| 455 |
|
| 456 |
extern blkid_partlist blkid_probe_get_partlist(blkid_probe pr) |
| 457 |
__attribute__((nonnull)) |
| 458 |
__attribute__((warn_unused_result)); |
| 459 |
|
| 460 |
extern int blkid_probe_is_covered_by_pt(blkid_probe pr, |
| 461 |
uint64_t offset, uint64_t size) |
| 462 |
__attribute__((warn_unused_result)); |
| 463 |
|
| 464 |
extern void blkid_probe_chain_reset_values(blkid_probe pr, struct blkid_chain *chn) |
| 465 |
__attribute__((nonnull)); |
| 466 |
extern int blkid_probe_chain_save_values(blkid_probe pr, |
| 467 |
struct blkid_chain *chn, |
| 468 |
struct list_head *vals) |
| 469 |
__attribute__((nonnull)); |
| 470 |
|
| 471 |
extern struct blkid_prval *blkid_probe_assign_value(blkid_probe pr, |
| 472 |
const char *name) |
| 473 |
__attribute__((nonnull)) |
| 474 |
__attribute__((warn_unused_result)); |
| 475 |
|
| 476 |
extern void blkid_probe_free_value(struct blkid_prval *v); |
| 477 |
|
| 478 |
|
| 479 |
extern void blkid_probe_append_values_list(blkid_probe pr, |
| 480 |
struct list_head *vals) |
| 481 |
__attribute__((nonnull)); |
| 482 |
|
| 483 |
extern void blkid_probe_free_values_list(struct list_head *vals); |
| 484 |
|
| 485 |
extern struct blkid_chain *blkid_probe_get_chain(blkid_probe pr) |
| 486 |
__attribute__((nonnull)) |
| 487 |
__attribute__((warn_unused_result)); |
| 488 |
|
| 489 |
extern struct blkid_prval *__blkid_probe_get_value(blkid_probe pr, int num) |
| 490 |
__attribute__((nonnull)) |
| 491 |
__attribute__((warn_unused_result)); |
| 492 |
|
| 493 |
extern struct blkid_prval *__blkid_probe_lookup_value(blkid_probe pr, const char *name) |
| 494 |
__attribute__((nonnull)) |
| 495 |
__attribute__((warn_unused_result)); |
| 496 |
|
| 497 |
extern unsigned long *blkid_probe_get_filter(blkid_probe pr, int chain, int create) |
| 498 |
__attribute__((nonnull)) |
| 499 |
__attribute__((warn_unused_result)); |
| 500 |
|
| 501 |
extern int __blkid_probe_invert_filter(blkid_probe pr, int chain) |
| 502 |
__attribute__((nonnull)); |
| 503 |
extern int __blkid_probe_reset_filter(blkid_probe pr, int chain) |
| 504 |
__attribute__((nonnull)); |
| 505 |
extern int __blkid_probe_filter_types(blkid_probe pr, int chain, int flag, char *names[]) |
| 506 |
__attribute__((nonnull)); |
| 507 |
|
| 508 |
extern void *blkid_probe_get_binary_data(blkid_probe pr, struct blkid_chain *chn) |
| 509 |
__attribute__((nonnull)) |
| 510 |
__attribute__((warn_unused_result)); |
| 511 |
|
| 512 |
extern struct blkid_prval *blkid_probe_new_val(void) |
| 513 |
__attribute__((warn_unused_result)); |
| 514 |
extern int blkid_probe_set_value(blkid_probe pr, const char *name, |
| 515 |
const unsigned char *data, size_t len) |
| 516 |
__attribute__((nonnull)); |
| 517 |
extern int blkid_probe_value_set_data(struct blkid_prval *v, |
| 518 |
const unsigned char *data, size_t len) |
| 519 |
__attribute__((nonnull)); |
| 520 |
|
| 521 |
extern int blkid_probe_vsprintf_value(blkid_probe pr, const char *name, |
| 522 |
const char *fmt, va_list ap) |
| 523 |
__attribute__((nonnull)); |
| 524 |
|
| 525 |
extern int blkid_probe_sprintf_value(blkid_probe pr, const char *name, |
| 526 |
const char *fmt, ...) |
| 527 |
__attribute__((nonnull)) |
| 528 |
__attribute__ ((__format__ (__printf__, 3, 4))); |
| 529 |
|
| 530 |
extern int blkid_probe_set_magic(blkid_probe pr, uint64_t offset, |
| 531 |
size_t len, const unsigned char *magic) |
| 532 |
__attribute__((nonnull)); |
| 533 |
|
| 534 |
extern int blkid_probe_verify_csum(blkid_probe pr, uint64_t csum, uint64_t expected) |
| 535 |
__attribute__((nonnull)); |
| 536 |
extern int blkid_probe_verify_csum_buf(blkid_probe pr, size_t n, const void *csum, |
| 537 |
const void *expected) __attribute__((nonnull)); |
| 538 |
|
| 539 |
extern void blkid_unparse_uuid(const unsigned char *uuid, char *str, size_t len) |
| 540 |
__attribute__((nonnull)); |
| 541 |
extern int blkid_uuid_is_empty(const unsigned char *buf, size_t len); |
| 542 |
|
| 543 |
extern size_t blkid_rtrim_whitespace(unsigned char *str) |
| 544 |
__attribute__((nonnull)); |
| 545 |
extern size_t blkid_ltrim_whitespace(unsigned char *str) |
| 546 |
__attribute__((nonnull)); |
| 547 |
|
| 548 |
extern void blkid_probe_set_wiper(blkid_probe pr, uint64_t off, |
| 549 |
uint64_t size) |
| 550 |
__attribute__((nonnull)); |
| 551 |
extern int blkid_probe_is_wiped(blkid_probe pr, struct blkid_chain **chn, |
| 552 |
uint64_t off, uint64_t size) |
| 553 |
__attribute__((nonnull)) |
| 554 |
__attribute__((warn_unused_result)); |
| 555 |
extern void blkid_probe_use_wiper(blkid_probe pr, uint64_t off, uint64_t size) |
| 556 |
__attribute__((nonnull)); |
| 557 |
|
| 558 |
extern int blkid_probe_get_hint(blkid_probe pr, const char *name, uint64_t *value) |
| 559 |
__attribute__((nonnull(1,2))) |
| 560 |
__attribute__((warn_unused_result)); |
| 561 |
|
| 562 |
extern int blkid_probe_get_partitions_flags(blkid_probe pr) |
| 563 |
__attribute__((nonnull)); |
| 564 |
|
| 565 |
/* filter bitmap macros */ |
| 566 |
#define blkid_bmp_wordsize (8 * sizeof(unsigned long)) |
| 567 |
#define blkid_bmp_idx_bit(item) (1UL << ((item) % blkid_bmp_wordsize)) |
| 568 |
#define blkid_bmp_idx_byte(item) ((item) / blkid_bmp_wordsize) |
| 569 |
|
| 570 |
#define blkid_bmp_set_item(bmp, item) \ |
| 571 |
((bmp)[ blkid_bmp_idx_byte(item) ] |= blkid_bmp_idx_bit(item)) |
| 572 |
|
| 573 |
#define blkid_bmp_unset_item(bmp, item) \ |
| 574 |
((bmp)[ blkid_bmp_idx_byte(item) ] &= ~blkid_bmp_idx_bit(item)) |
| 575 |
|
| 576 |
#define blkid_bmp_get_item(bmp, item) \ |
| 577 |
((bmp)[ blkid_bmp_idx_byte(item) ] & blkid_bmp_idx_bit(item)) |
| 578 |
|
| 579 |
#define blkid_bmp_nwords(max_items) \ |
| 580 |
(((max_items) + blkid_bmp_wordsize) / blkid_bmp_wordsize) |
| 581 |
|
| 582 |
#define blkid_bmp_nbytes(max_items) \ |
| 583 |
(blkid_bmp_nwords(max_items) * sizeof(unsigned long)) |
| 584 |
|
| 585 |
#endif /* _BLKID_BLKIDP_H */ |