paul@181 | 1 | /* |
paul@181 | 2 | * read.c - read the blkid cache from disk, to avoid scanning all devices |
paul@181 | 3 | * |
paul@181 | 4 | * Copyright (C) 2001, 2003 Theodore Y. Ts'o |
paul@181 | 5 | * Copyright (C) 2001 Andreas Dilger |
paul@181 | 6 | * |
paul@181 | 7 | * %Begin-Header% |
paul@181 | 8 | * This file may be redistributed under the terms of the |
paul@181 | 9 | * GNU Lesser General Public License. |
paul@181 | 10 | * %End-Header% |
paul@181 | 11 | */ |
paul@181 | 12 | |
paul@181 | 13 | #define _XOPEN_SOURCE 600 /* for inclusion of strtoull */ |
paul@181 | 14 | |
paul@181 | 15 | #include "config.h" |
paul@181 | 16 | #include <stdio.h> |
paul@181 | 17 | #include <ctype.h> |
paul@181 | 18 | #include <string.h> |
paul@181 | 19 | #include <time.h> |
paul@181 | 20 | #include <sys/types.h> |
paul@181 | 21 | #include <sys/stat.h> |
paul@181 | 22 | #include <fcntl.h> |
paul@181 | 23 | #include <unistd.h> |
paul@181 | 24 | #if HAVE_ERRNO_H |
paul@181 | 25 | #include <errno.h> |
paul@181 | 26 | #endif |
paul@181 | 27 | |
paul@181 | 28 | #include "blkidP.h" |
paul@181 | 29 | #include "uuid/uuid.h" |
paul@181 | 30 | |
paul@181 | 31 | #ifdef HAVE_STRTOULL |
paul@181 | 32 | #define STRTOULL strtoull /* defined in stdlib.h if you try hard enough */ |
paul@181 | 33 | #else |
paul@181 | 34 | /* FIXME: need to support real strtoull here */ |
paul@181 | 35 | #define STRTOULL strtoul |
paul@181 | 36 | #endif |
paul@181 | 37 | |
paul@181 | 38 | #if HAVE_STDLIB_H |
paul@181 | 39 | #include <stdlib.h> |
paul@181 | 40 | #endif |
paul@181 | 41 | |
paul@181 | 42 | #ifdef TEST_PROGRAM |
paul@181 | 43 | #define blkid_debug_dump_dev(dev) (debug_dump_dev(dev)) |
paul@181 | 44 | static void debug_dump_dev(blkid_dev dev); |
paul@181 | 45 | #endif |
paul@181 | 46 | |
paul@181 | 47 | /* |
paul@181 | 48 | * File format: |
paul@181 | 49 | * |
paul@181 | 50 | * <device [<NAME="value"> ...]>device_name</device> |
paul@181 | 51 | * |
paul@181 | 52 | * The following tags are required for each entry: |
paul@181 | 53 | * <ID="id"> unique (within this file) ID number of this device |
paul@181 | 54 | * <TIME="time"> (ascii time_t) time this entry was last read from disk |
paul@181 | 55 | * <TYPE="type"> (detected) type of filesystem/data for this partition |
paul@181 | 56 | * |
paul@181 | 57 | * The following tags may be present, depending on the device contents |
paul@181 | 58 | * <LABEL="label"> (user supplied) label (volume name, etc) |
paul@181 | 59 | * <UUID="uuid"> (generated) universally unique identifier (serial no) |
paul@181 | 60 | */ |
paul@181 | 61 | |
paul@181 | 62 | static char *skip_over_blank(char *cp) |
paul@181 | 63 | { |
paul@181 | 64 | while (*cp && isspace(*cp)) |
paul@181 | 65 | cp++; |
paul@181 | 66 | return cp; |
paul@181 | 67 | } |
paul@181 | 68 | |
paul@181 | 69 | static char *skip_over_word(char *cp) |
paul@181 | 70 | { |
paul@181 | 71 | char ch; |
paul@181 | 72 | |
paul@181 | 73 | while ((ch = *cp)) { |
paul@181 | 74 | /* If we see a backslash, skip the next character */ |
paul@181 | 75 | if (ch == '\\') { |
paul@181 | 76 | cp++; |
paul@181 | 77 | if (*cp == '\0') |
paul@181 | 78 | break; |
paul@181 | 79 | cp++; |
paul@181 | 80 | continue; |
paul@181 | 81 | } |
paul@181 | 82 | if (isspace(ch) || ch == '<' || ch == '>') |
paul@181 | 83 | break; |
paul@181 | 84 | cp++; |
paul@181 | 85 | } |
paul@181 | 86 | return cp; |
paul@181 | 87 | } |
paul@181 | 88 | |
paul@181 | 89 | static char *strip_line(char *line) |
paul@181 | 90 | { |
paul@181 | 91 | char *p; |
paul@181 | 92 | |
paul@181 | 93 | line = skip_over_blank(line); |
paul@181 | 94 | |
paul@181 | 95 | p = line + strlen(line) - 1; |
paul@181 | 96 | |
paul@181 | 97 | while (*line) { |
paul@181 | 98 | if (isspace(*p)) |
paul@181 | 99 | *p-- = '\0'; |
paul@181 | 100 | else |
paul@181 | 101 | break; |
paul@181 | 102 | } |
paul@181 | 103 | |
paul@181 | 104 | return line; |
paul@181 | 105 | } |
paul@181 | 106 | |
paul@181 | 107 | #if 0 |
paul@181 | 108 | static char *parse_word(char **buf) |
paul@181 | 109 | { |
paul@181 | 110 | char *word, *next; |
paul@181 | 111 | |
paul@181 | 112 | word = *buf; |
paul@181 | 113 | if (*word == '\0') |
paul@181 | 114 | return NULL; |
paul@181 | 115 | |
paul@181 | 116 | word = skip_over_blank(word); |
paul@181 | 117 | next = skip_over_word(word); |
paul@181 | 118 | if (*next) { |
paul@181 | 119 | char *end = next - 1; |
paul@181 | 120 | if (*end == '"' || *end == '\'') |
paul@181 | 121 | *end = '\0'; |
paul@181 | 122 | *next++ = '\0'; |
paul@181 | 123 | } |
paul@181 | 124 | *buf = next; |
paul@181 | 125 | |
paul@181 | 126 | if (*word == '"' || *word == '\'') |
paul@181 | 127 | word++; |
paul@181 | 128 | return word; |
paul@181 | 129 | } |
paul@181 | 130 | #endif |
paul@181 | 131 | |
paul@181 | 132 | /* |
paul@181 | 133 | * Start parsing a new line from the cache. |
paul@181 | 134 | * |
paul@181 | 135 | * line starts with "<device" return 1 -> continue parsing line |
paul@181 | 136 | * line starts with "<foo", empty, or # return 0 -> skip line |
paul@181 | 137 | * line starts with other, return -BLKID_ERR_CACHE -> error |
paul@181 | 138 | */ |
paul@181 | 139 | static int parse_start(char **cp) |
paul@181 | 140 | { |
paul@181 | 141 | char *p; |
paul@181 | 142 | |
paul@181 | 143 | p = strip_line(*cp); |
paul@181 | 144 | |
paul@181 | 145 | /* Skip comment or blank lines. We can't just NUL the first '#' char, |
paul@181 | 146 | * in case it is inside quotes, or escaped. |
paul@181 | 147 | */ |
paul@181 | 148 | if (*p == '\0' || *p == '#') |
paul@181 | 149 | return 0; |
paul@181 | 150 | |
paul@181 | 151 | if (!strncmp(p, "<device", 7)) { |
paul@181 | 152 | DBG(DEBUG_READ, printf("found device header: %8s\n", p)); |
paul@181 | 153 | p += 7; |
paul@181 | 154 | |
paul@181 | 155 | *cp = p; |
paul@181 | 156 | return 1; |
paul@181 | 157 | } |
paul@181 | 158 | |
paul@181 | 159 | if (*p == '<') |
paul@181 | 160 | return 0; |
paul@181 | 161 | |
paul@181 | 162 | return -BLKID_ERR_CACHE; |
paul@181 | 163 | } |
paul@181 | 164 | |
paul@181 | 165 | /* Consume the remaining XML on the line (cosmetic only) */ |
paul@181 | 166 | static int parse_end(char **cp) |
paul@181 | 167 | { |
paul@181 | 168 | *cp = skip_over_blank(*cp); |
paul@181 | 169 | |
paul@181 | 170 | if (!strncmp(*cp, "</device>", 9)) { |
paul@181 | 171 | DBG(DEBUG_READ, printf("found device trailer %9s\n", *cp)); |
paul@181 | 172 | *cp += 9; |
paul@181 | 173 | return 0; |
paul@181 | 174 | } |
paul@181 | 175 | |
paul@181 | 176 | return -BLKID_ERR_CACHE; |
paul@181 | 177 | } |
paul@181 | 178 | |
paul@181 | 179 | /* |
paul@181 | 180 | * Allocate a new device struct with device name filled in. Will handle |
paul@181 | 181 | * finding the device on lines of the form: |
paul@181 | 182 | * <device foo=bar>devname</device> |
paul@181 | 183 | * <device>devname<foo>bar</foo></device> |
paul@181 | 184 | */ |
paul@181 | 185 | static int parse_dev(blkid_cache cache, blkid_dev *dev, char **cp) |
paul@181 | 186 | { |
paul@181 | 187 | char *start, *tmp, *end, *name; |
paul@181 | 188 | int ret; |
paul@181 | 189 | |
paul@181 | 190 | if ((ret = parse_start(cp)) <= 0) |
paul@181 | 191 | return ret; |
paul@181 | 192 | |
paul@181 | 193 | start = tmp = strchr(*cp, '>'); |
paul@181 | 194 | if (!start) { |
paul@181 | 195 | DBG(DEBUG_READ, |
paul@181 | 196 | printf("blkid: short line parsing dev: %s\n", *cp)); |
paul@181 | 197 | return -BLKID_ERR_CACHE; |
paul@181 | 198 | } |
paul@181 | 199 | start = skip_over_blank(start + 1); |
paul@181 | 200 | end = skip_over_word(start); |
paul@181 | 201 | |
paul@181 | 202 | DBG(DEBUG_READ, printf("device should be %.*s\n", |
paul@181 | 203 | (int)(end - start), start)); |
paul@181 | 204 | |
paul@181 | 205 | if (**cp == '>') |
paul@181 | 206 | *cp = end; |
paul@181 | 207 | else |
paul@181 | 208 | (*cp)++; |
paul@181 | 209 | |
paul@181 | 210 | *tmp = '\0'; |
paul@181 | 211 | |
paul@181 | 212 | if (!(tmp = strrchr(end, '<')) || parse_end(&tmp) < 0) { |
paul@181 | 213 | DBG(DEBUG_READ, |
paul@181 | 214 | printf("blkid: missing </device> ending: %s\n", end)); |
paul@181 | 215 | } else if (tmp) |
paul@181 | 216 | *tmp = '\0'; |
paul@181 | 217 | |
paul@181 | 218 | if (end - start <= 1) { |
paul@181 | 219 | DBG(DEBUG_READ, printf("blkid: empty device name: %s\n", *cp)); |
paul@181 | 220 | return -BLKID_ERR_CACHE; |
paul@181 | 221 | } |
paul@181 | 222 | |
paul@181 | 223 | name = blkid_strndup(start, end-start); |
paul@181 | 224 | if (name == NULL) |
paul@181 | 225 | return -BLKID_ERR_MEM; |
paul@181 | 226 | |
paul@181 | 227 | DBG(DEBUG_READ, printf("found dev %s\n", name)); |
paul@181 | 228 | |
paul@181 | 229 | if (!(*dev = blkid_get_dev(cache, name, BLKID_DEV_CREATE))) { |
paul@181 | 230 | free(name); |
paul@181 | 231 | return -BLKID_ERR_MEM; |
paul@181 | 232 | } |
paul@181 | 233 | |
paul@181 | 234 | free(name); |
paul@181 | 235 | return 1; |
paul@181 | 236 | } |
paul@181 | 237 | |
paul@181 | 238 | /* |
paul@181 | 239 | * Extract a tag of the form NAME="value" from the line. |
paul@181 | 240 | */ |
paul@181 | 241 | static int parse_token(char **name, char **value, char **cp) |
paul@181 | 242 | { |
paul@181 | 243 | char *end; |
paul@181 | 244 | |
paul@181 | 245 | if (!name || !value || !cp) |
paul@181 | 246 | return -BLKID_ERR_PARAM; |
paul@181 | 247 | |
paul@181 | 248 | if (!(*value = strchr(*cp, '='))) |
paul@181 | 249 | return 0; |
paul@181 | 250 | |
paul@181 | 251 | **value = '\0'; |
paul@181 | 252 | *name = strip_line(*cp); |
paul@181 | 253 | *value = skip_over_blank(*value + 1); |
paul@181 | 254 | |
paul@181 | 255 | if (**value == '"') { |
paul@181 | 256 | end = strchr(*value + 1, '"'); |
paul@181 | 257 | if (!end) { |
paul@181 | 258 | DBG(DEBUG_READ, |
paul@181 | 259 | printf("unbalanced quotes at: %s\n", *value)); |
paul@181 | 260 | *cp = *value; |
paul@181 | 261 | return -BLKID_ERR_CACHE; |
paul@181 | 262 | } |
paul@181 | 263 | (*value)++; |
paul@181 | 264 | *end = '\0'; |
paul@181 | 265 | end++; |
paul@181 | 266 | } else { |
paul@181 | 267 | end = skip_over_word(*value); |
paul@181 | 268 | if (*end) { |
paul@181 | 269 | *end = '\0'; |
paul@181 | 270 | end++; |
paul@181 | 271 | } |
paul@181 | 272 | } |
paul@181 | 273 | *cp = end; |
paul@181 | 274 | |
paul@181 | 275 | return 1; |
paul@181 | 276 | } |
paul@181 | 277 | |
paul@181 | 278 | /* |
paul@181 | 279 | * Extract a tag of the form <NAME>value</NAME> from the line. |
paul@181 | 280 | */ |
paul@181 | 281 | /* |
paul@181 | 282 | static int parse_xml(char **name, char **value, char **cp) |
paul@181 | 283 | { |
paul@181 | 284 | char *end; |
paul@181 | 285 | |
paul@181 | 286 | if (!name || !value || !cp) |
paul@181 | 287 | return -BLKID_ERR_PARAM; |
paul@181 | 288 | |
paul@181 | 289 | *name = strip_line(*cp); |
paul@181 | 290 | |
paul@181 | 291 | if ((*name)[0] != '<' || (*name)[1] == '/') |
paul@181 | 292 | return 0; |
paul@181 | 293 | |
paul@181 | 294 | FIXME: finish this. |
paul@181 | 295 | } |
paul@181 | 296 | */ |
paul@181 | 297 | |
paul@181 | 298 | /* |
paul@181 | 299 | * Extract a tag from the line. |
paul@181 | 300 | * |
paul@181 | 301 | * Return 1 if a valid tag was found. |
paul@181 | 302 | * Return 0 if no tag found. |
paul@181 | 303 | * Return -ve error code. |
paul@181 | 304 | */ |
paul@181 | 305 | static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp) |
paul@181 | 306 | { |
paul@181 | 307 | char *name; |
paul@181 | 308 | char *value; |
paul@181 | 309 | int ret; |
paul@181 | 310 | |
paul@181 | 311 | if (!cache || !dev) |
paul@181 | 312 | return -BLKID_ERR_PARAM; |
paul@181 | 313 | |
paul@181 | 314 | if ((ret = parse_token(&name, &value, cp)) <= 0 /* && |
paul@181 | 315 | (ret = parse_xml(&name, &value, cp)) <= 0 */) |
paul@181 | 316 | return ret; |
paul@181 | 317 | |
paul@181 | 318 | /* Some tags are stored directly in the device struct */ |
paul@181 | 319 | if (!strcmp(name, "DEVNO")) |
paul@181 | 320 | dev->bid_devno = STRTOULL(value, 0, 0); |
paul@181 | 321 | else if (!strcmp(name, "PRI")) |
paul@181 | 322 | dev->bid_pri = strtol(value, 0, 0); |
paul@181 | 323 | else if (!strcmp(name, "TIME")) |
paul@181 | 324 | dev->bid_time = STRTOULL(value, 0, 0); |
paul@181 | 325 | else |
paul@181 | 326 | ret = blkid_set_tag(dev, name, value, strlen(value)); |
paul@181 | 327 | |
paul@181 | 328 | DBG(DEBUG_READ, printf(" tag: %s=\"%s\"\n", name, value)); |
paul@181 | 329 | |
paul@181 | 330 | return ret < 0 ? ret : 1; |
paul@181 | 331 | } |
paul@181 | 332 | |
paul@181 | 333 | /* |
paul@181 | 334 | * Parse a single line of data, and return a newly allocated dev struct. |
paul@181 | 335 | * Add the new device to the cache struct, if one was read. |
paul@181 | 336 | * |
paul@181 | 337 | * Lines are of the form <device [TAG="value" ...]>/dev/foo</device> |
paul@181 | 338 | * |
paul@181 | 339 | * Returns -ve value on error. |
paul@181 | 340 | * Returns 0 otherwise. |
paul@181 | 341 | * If a valid device was read, *dev_p is non-NULL, otherwise it is NULL |
paul@181 | 342 | * (e.g. comment lines, unknown XML content, etc). |
paul@181 | 343 | */ |
paul@181 | 344 | static int blkid_parse_line(blkid_cache cache, blkid_dev *dev_p, char *cp) |
paul@181 | 345 | { |
paul@181 | 346 | blkid_dev dev; |
paul@181 | 347 | int ret; |
paul@181 | 348 | |
paul@181 | 349 | if (!cache || !dev_p) |
paul@181 | 350 | return -BLKID_ERR_PARAM; |
paul@181 | 351 | |
paul@181 | 352 | *dev_p = NULL; |
paul@181 | 353 | |
paul@181 | 354 | DBG(DEBUG_READ, printf("line: %s\n", cp)); |
paul@181 | 355 | |
paul@181 | 356 | if ((ret = parse_dev(cache, dev_p, &cp)) <= 0) |
paul@181 | 357 | return ret; |
paul@181 | 358 | |
paul@181 | 359 | dev = *dev_p; |
paul@181 | 360 | |
paul@181 | 361 | while ((ret = parse_tag(cache, dev, &cp)) > 0) { |
paul@181 | 362 | ; |
paul@181 | 363 | } |
paul@181 | 364 | |
paul@181 | 365 | if (dev->bid_type == NULL) { |
paul@181 | 366 | DBG(DEBUG_READ, |
paul@181 | 367 | printf("blkid: device %s has no TYPE\n",dev->bid_name)); |
paul@181 | 368 | blkid_free_dev(dev); |
paul@181 | 369 | } |
paul@181 | 370 | |
paul@181 | 371 | DBG(DEBUG_READ, blkid_debug_dump_dev(dev)); |
paul@181 | 372 | |
paul@181 | 373 | return ret; |
paul@181 | 374 | } |
paul@181 | 375 | |
paul@181 | 376 | /* |
paul@181 | 377 | * Parse the specified filename, and return the data in the supplied or |
paul@181 | 378 | * a newly allocated cache struct. If the file doesn't exist, return a |
paul@181 | 379 | * new empty cache struct. |
paul@181 | 380 | */ |
paul@181 | 381 | void blkid_read_cache(blkid_cache cache) |
paul@181 | 382 | { |
paul@181 | 383 | FILE *file; |
paul@181 | 384 | char buf[4096]; |
paul@181 | 385 | int fd, lineno = 0; |
paul@181 | 386 | struct stat st; |
paul@181 | 387 | |
paul@181 | 388 | if (!cache) |
paul@181 | 389 | return; |
paul@181 | 390 | |
paul@181 | 391 | /* |
paul@181 | 392 | * If the file doesn't exist, then we just return an empty |
paul@181 | 393 | * struct so that the cache can be populated. |
paul@181 | 394 | */ |
paul@181 | 395 | if ((fd = open(cache->bic_filename, O_RDONLY)) < 0) |
paul@181 | 396 | return; |
paul@181 | 397 | if (fstat(fd, &st) < 0) |
paul@181 | 398 | goto errout; |
paul@181 | 399 | if ((st.st_mtime == cache->bic_ftime) || |
paul@181 | 400 | (cache->bic_flags & BLKID_BIC_FL_CHANGED)) { |
paul@181 | 401 | DBG(DEBUG_CACHE, printf("skipping re-read of %s\n", |
paul@181 | 402 | cache->bic_filename)); |
paul@181 | 403 | goto errout; |
paul@181 | 404 | } |
paul@181 | 405 | |
paul@181 | 406 | DBG(DEBUG_CACHE, printf("reading cache file %s\n", |
paul@181 | 407 | cache->bic_filename)); |
paul@181 | 408 | |
paul@181 | 409 | file = fdopen(fd, "r"); |
paul@181 | 410 | if (!file) |
paul@181 | 411 | goto errout; |
paul@181 | 412 | |
paul@181 | 413 | while (fgets(buf, sizeof(buf), file)) { |
paul@181 | 414 | blkid_dev dev; |
paul@181 | 415 | unsigned int end; |
paul@181 | 416 | |
paul@181 | 417 | lineno++; |
paul@181 | 418 | if (buf[0] == 0) |
paul@181 | 419 | continue; |
paul@181 | 420 | end = strlen(buf) - 1; |
paul@181 | 421 | /* Continue reading next line if it ends with a backslash */ |
paul@181 | 422 | while (buf[end] == '\\' && end < sizeof(buf) - 2 && |
paul@181 | 423 | fgets(buf + end, sizeof(buf) - end, file)) { |
paul@181 | 424 | end = strlen(buf) - 1; |
paul@181 | 425 | lineno++; |
paul@181 | 426 | } |
paul@181 | 427 | |
paul@181 | 428 | if (blkid_parse_line(cache, &dev, buf) < 0) { |
paul@181 | 429 | DBG(DEBUG_READ, |
paul@181 | 430 | printf("blkid: bad format on line %d\n", lineno)); |
paul@181 | 431 | continue; |
paul@181 | 432 | } |
paul@181 | 433 | } |
paul@181 | 434 | fclose(file); |
paul@181 | 435 | |
paul@181 | 436 | /* |
paul@181 | 437 | * Initially we do not need to write out the cache file. |
paul@181 | 438 | */ |
paul@181 | 439 | cache->bic_flags &= ~BLKID_BIC_FL_CHANGED; |
paul@181 | 440 | cache->bic_ftime = st.st_mtime; |
paul@181 | 441 | |
paul@181 | 442 | return; |
paul@181 | 443 | errout: |
paul@181 | 444 | close(fd); |
paul@181 | 445 | return; |
paul@181 | 446 | } |
paul@181 | 447 | |
paul@181 | 448 | #ifdef TEST_PROGRAM |
paul@181 | 449 | static void debug_dump_dev(blkid_dev dev) |
paul@181 | 450 | { |
paul@181 | 451 | struct list_head *p; |
paul@181 | 452 | |
paul@181 | 453 | if (!dev) { |
paul@181 | 454 | printf(" dev: NULL\n"); |
paul@181 | 455 | return; |
paul@181 | 456 | } |
paul@181 | 457 | |
paul@181 | 458 | printf(" dev: name = %s\n", dev->bid_name); |
paul@181 | 459 | printf(" dev: DEVNO=\"0x%0llx\"\n", (long long)dev->bid_devno); |
paul@181 | 460 | printf(" dev: TIME=\"%lld\"\n", (long long)dev->bid_time); |
paul@181 | 461 | printf(" dev: PRI=\"%d\"\n", dev->bid_pri); |
paul@181 | 462 | printf(" dev: flags = 0x%08X\n", dev->bid_flags); |
paul@181 | 463 | |
paul@181 | 464 | list_for_each(p, &dev->bid_tags) { |
paul@181 | 465 | blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags); |
paul@181 | 466 | if (tag) |
paul@181 | 467 | printf(" tag: %s=\"%s\"\n", tag->bit_name, |
paul@181 | 468 | tag->bit_val); |
paul@181 | 469 | else |
paul@181 | 470 | printf(" tag: NULL\n"); |
paul@181 | 471 | } |
paul@181 | 472 | printf("\n"); |
paul@181 | 473 | } |
paul@181 | 474 | |
paul@181 | 475 | int main(int argc, char**argv) |
paul@181 | 476 | { |
paul@181 | 477 | blkid_cache cache = NULL; |
paul@181 | 478 | int ret; |
paul@181 | 479 | |
paul@181 | 480 | blkid_debug_mask = DEBUG_ALL; |
paul@181 | 481 | if (argc > 2) { |
paul@181 | 482 | fprintf(stderr, "Usage: %s [filename]\n" |
paul@181 | 483 | "Test parsing of the cache (filename)\n", argv[0]); |
paul@181 | 484 | exit(1); |
paul@181 | 485 | } |
paul@181 | 486 | if ((ret = blkid_get_cache(&cache, argv[1])) < 0) |
paul@181 | 487 | fprintf(stderr, "error %d reading cache file %s\n", ret, |
paul@181 | 488 | argv[1] ? argv[1] : BLKID_CACHE_FILE); |
paul@181 | 489 | |
paul@181 | 490 | blkid_put_cache(cache); |
paul@181 | 491 | |
paul@181 | 492 | return ret; |
paul@181 | 493 | } |
paul@181 | 494 | #endif |