~ubuntu-branches/debian/stretch/lvm2/stretch

« back to all changes in this revision

Viewing changes to lib/device/dev-type.c

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2014-08-19 15:37:06 UTC
  • mfrom: (30.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20140819153706-0p2sc6a53ef7xnvl
Tags: 2.02.109-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
460
460
                       uint32_t types_to_exclude, uint32_t types_no_prompt,
461
461
                       int yes, force_t force)
462
462
{
463
 
        static const char _msg_failed_offset[] = "Failed to get offset of the %s signature on %s.";
464
 
        static const char _msg_failed_length[] = "Failed to get length of the %s signature on %s.";
465
 
        static const char _msg_wiping[] = "Wiping %s signature on %s.";
 
463
        static const char const _msg_failed_offset[] = "Failed to get offset of the %s signature on %s.";
 
464
        static const char const _msg_failed_length[] = "Failed to get length of the %s signature on %s.";
 
465
        static const char const _msg_wiping[] = "Wiping %s signature on %s.";
466
466
        const char *offset = NULL, *type = NULL, *magic = NULL,
467
467
                   *usage = NULL, *label = NULL, *uuid = NULL;
468
468
        loff_t offset_value;
495
495
        offset_value = strtoll(offset, NULL, 10);
496
496
 
497
497
        if (!usage)
498
 
                blkid_probe_lookup_value(probe, "USAGE", &usage, NULL);
499
 
        blkid_probe_lookup_value(probe, "LABEL", &label, NULL);
500
 
        blkid_probe_lookup_value(probe, "UUID", &uuid, NULL);
 
498
                (void) blkid_probe_lookup_value(probe, "USAGE", &usage, NULL);
 
499
        (void) blkid_probe_lookup_value(probe, "LABEL", &label, NULL);
 
500
        (void) blkid_probe_lookup_value(probe, "UUID", &uuid, NULL);
 
501
        /* Return values ignored here, in the worst case we print NULL */
501
502
 
502
503
        log_verbose("Found existing signature on %s at offset %s: LABEL=\"%s\" "
503
504
                    "UUID=\"%s\" TYPE=\"%s\" USAGE=\"%s\"",
506
507
        if (!_type_in_flag_list(type, types_no_prompt)) {
507
508
                if (!yes && (force == PROMPT) &&
508
509
                    yes_no_prompt("WARNING: %s signature detected on %s at offset %s. "
509
 
                                  "Wipe it? [y/n] ", type, name, offset) != 'y')
510
 
                        return_0;
 
510
                                  "Wipe it? [y/n]: ", type, name, offset) == 'n') {
 
511
                        log_error("Aborted wiping of %s.", type);
 
512
                        return 0;
 
513
                }
511
514
                log_print_unless_silent(_msg_wiping, type, name);
512
515
        } else
513
516
                log_verbose(_msg_wiping, type, name);
590
593
 
591
594
        /* Specifying --yes => do not ask. */
592
595
        if (!yes && (force == PROMPT) &&
593
 
            yes_no_prompt("WARNING: %s detected on %s. Wipe it? [y/n] ",
594
 
                          type, name) != 'y')
595
 
                return_0;
 
596
            yes_no_prompt("WARNING: %s detected on %s. Wipe it? [y/n]: ",
 
597
                          type, name) == 'n') {
 
598
                log_error("Aborted wiping of %s.", type);
 
599
                return 0;
 
600
        }
596
601
 
597
602
        log_print_unless_silent("Wiping %s on %s.", type, name);
598
603
        if (!dev_set(dev, offset_found, wipe_len, 0)) {
675
680
         */
676
681
        if (stat(path, &info) == -1) {
677
682
                if (errno != ENOENT) {
678
 
                        log_sys_error("stat", path);
 
683
                        log_sys_debug("stat", path);
679
684
                        return 0;
680
685
                }
681
686
                if (!dev_get_primary_dev(dt, dev, &primary))
687
692
 
688
693
                if (stat(path, &info) == -1) {
689
694
                        if (errno != ENOENT)
690
 
                                log_sys_error("stat", path);
 
695
                                log_sys_debug("stat", path);
691
696
                        return 0;
692
697
                }
693
698
        }
694
699
 
695
700
        if (!(fp = fopen(path, "r"))) {
696
 
                log_sys_error("fopen", path);
 
701
                log_sys_debug("fopen", path);
697
702
                return 0;
698
703
        }
699
704
 
700
705
        if (!fgets(buffer, sizeof(buffer), fp)) {
701
 
                log_sys_error("fgets", path);
 
706
                log_sys_debug("fgets", path);
702
707
                goto out;
703
708
        }
704
709
 
705
710
        if (sscanf(buffer, "%lu", &result) != 1) {
706
 
                log_error("sysfs file %s not in expected format: %s", path,
707
 
                          buffer);
 
711
                log_warn("sysfs file %s not in expected format: %s", path, buffer);
708
712
                goto out;
709
713
        }
710
714
 
713
717
 
714
718
out:
715
719
        if (fclose(fp))
716
 
                log_sys_error("fclose", path);
 
720
                log_sys_debug("fclose", path);
717
721
 
718
722
        return result >> SECTOR_SHIFT;
719
723
}