diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-17 17:40:29 +0100 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-17 17:40:29 +0100 |
commit | d24316a6b41305f91346e0115ae1f9fe38bff2ce (patch) | |
tree | 3472e0415c1716952aa79571923829da7fdc24a2 | |
parent | d99cd375fcade0ec6afb3b3d3e96a39dce49760e (diff) | |
download | monitoring-plugins-d24316a6b41305f91346e0115ae1f9fe38bff2ce.tar.gz |
check_disk: clang-format
-rw-r--r-- | plugins/check_disk.c | 129 |
1 files changed, 86 insertions, 43 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 037a6f7a..c3534060 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -191,8 +191,9 @@ int main(int argc, char **argv) { | |||
191 | /* Parse extra opts if any */ | 191 | /* Parse extra opts if any */ |
192 | argv = np_extra_opts(&argc, argv, progname); | 192 | argv = np_extra_opts(&argc, argv, progname); |
193 | 193 | ||
194 | if (process_arguments(argc, argv) == ERROR) | 194 | if (process_arguments(argc, argv) == ERROR) { |
195 | usage4(_("Could not parse arguments")); | 195 | usage4(_("Could not parse arguments")); |
196 | } | ||
196 | 197 | ||
197 | /* If a list of paths has not been selected, find entire | 198 | /* If a list of paths has not been selected, find entire |
198 | mount list and create list of paths | 199 | mount list and create list of paths |
@@ -245,12 +246,14 @@ int main(int argc, char **argv) { | |||
245 | 246 | ||
246 | /* Process for every path in list */ | 247 | /* Process for every path in list */ |
247 | for (path = path_select_list; path; path = path->name_next) { | 248 | for (path = path_select_list; path; path = path->name_next) { |
248 | if (verbose >= 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL) | 249 | if (verbose >= 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL) { |
249 | printf("Thresholds(pct) for %s warn: %f crit %f\n", path->name, path->freespace_percent->warning->end, | 250 | printf("Thresholds(pct) for %s warn: %f crit %f\n", path->name, path->freespace_percent->warning->end, |
250 | path->freespace_percent->critical->end); | 251 | path->freespace_percent->critical->end); |
252 | } | ||
251 | 253 | ||
252 | if (verbose >= 3 && path->group != NULL) | 254 | if (verbose >= 3 && path->group != NULL) { |
253 | printf("Group of %s: %s\n", path->name, path->group); | 255 | printf("Group of %s: %s\n", path->name, path->group); |
256 | } | ||
254 | 257 | ||
255 | /* reset disk result */ | 258 | /* reset disk result */ |
256 | disk_result = STATE_UNKNOWN; | 259 | disk_result = STATE_UNKNOWN; |
@@ -262,11 +265,13 @@ int main(int argc, char **argv) { | |||
262 | } | 265 | } |
263 | 266 | ||
264 | #ifdef __CYGWIN__ | 267 | #ifdef __CYGWIN__ |
265 | if (strncmp(path->name, "/cygdrive/", 10) != 0 || strlen(path->name) > 11) | 268 | if (strncmp(path->name, "/cygdrive/", 10) != 0 || strlen(path->name) > 11) { |
266 | continue; | 269 | continue; |
270 | } | ||
267 | snprintf(mountdir, sizeof(mountdir), "%s:\\", me->me_mountdir + 10); | 271 | snprintf(mountdir, sizeof(mountdir), "%s:\\", me->me_mountdir + 10); |
268 | if (GetDriveType(mountdir) != DRIVE_FIXED) | 272 | if (GetDriveType(mountdir) != DRIVE_FIXED) { |
269 | me->me_remote = 1; | 273 | me->me_remote = 1; |
274 | } | ||
270 | #endif | 275 | #endif |
271 | /* Filters */ | 276 | /* Filters */ |
272 | 277 | ||
@@ -327,33 +332,39 @@ int main(int argc, char **argv) { | |||
327 | /* Threshold comparisons */ | 332 | /* Threshold comparisons */ |
328 | 333 | ||
329 | temp_result = get_status(path->dfree_units, path->freespace_units); | 334 | temp_result = get_status(path->dfree_units, path->freespace_units); |
330 | if (verbose >= 3) | 335 | if (verbose >= 3) { |
331 | printf("Freespace_units result=%d\n", temp_result); | 336 | printf("Freespace_units result=%d\n", temp_result); |
337 | } | ||
332 | disk_result = max_state(disk_result, temp_result); | 338 | disk_result = max_state(disk_result, temp_result); |
333 | 339 | ||
334 | temp_result = get_status(path->dfree_pct, path->freespace_percent); | 340 | temp_result = get_status(path->dfree_pct, path->freespace_percent); |
335 | if (verbose >= 3) | 341 | if (verbose >= 3) { |
336 | printf("Freespace%% result=%d\n", temp_result); | 342 | printf("Freespace%% result=%d\n", temp_result); |
343 | } | ||
337 | disk_result = max_state(disk_result, temp_result); | 344 | disk_result = max_state(disk_result, temp_result); |
338 | 345 | ||
339 | temp_result = get_status(path->dused_units, path->usedspace_units); | 346 | temp_result = get_status(path->dused_units, path->usedspace_units); |
340 | if (verbose >= 3) | 347 | if (verbose >= 3) { |
341 | printf("Usedspace_units result=%d\n", temp_result); | 348 | printf("Usedspace_units result=%d\n", temp_result); |
349 | } | ||
342 | disk_result = max_state(disk_result, temp_result); | 350 | disk_result = max_state(disk_result, temp_result); |
343 | 351 | ||
344 | temp_result = get_status(path->dused_pct, path->usedspace_percent); | 352 | temp_result = get_status(path->dused_pct, path->usedspace_percent); |
345 | if (verbose >= 3) | 353 | if (verbose >= 3) { |
346 | printf("Usedspace_percent result=%d\n", temp_result); | 354 | printf("Usedspace_percent result=%d\n", temp_result); |
355 | } | ||
347 | disk_result = max_state(disk_result, temp_result); | 356 | disk_result = max_state(disk_result, temp_result); |
348 | 357 | ||
349 | temp_result = get_status(path->dused_inodes_percent, path->usedinodes_percent); | 358 | temp_result = get_status(path->dused_inodes_percent, path->usedinodes_percent); |
350 | if (verbose >= 3) | 359 | if (verbose >= 3) { |
351 | printf("Usedinodes_percent result=%d\n", temp_result); | 360 | printf("Usedinodes_percent result=%d\n", temp_result); |
361 | } | ||
352 | disk_result = max_state(disk_result, temp_result); | 362 | disk_result = max_state(disk_result, temp_result); |
353 | 363 | ||
354 | temp_result = get_status(path->dfree_inodes_percent, path->freeinodes_percent); | 364 | temp_result = get_status(path->dfree_inodes_percent, path->freeinodes_percent); |
355 | if (verbose >= 3) | 365 | if (verbose >= 3) { |
356 | printf("Freeinodes_percent result=%d\n", temp_result); | 366 | printf("Freeinodes_percent result=%d\n", temp_result); |
367 | } | ||
357 | disk_result = max_state(disk_result, temp_result); | 368 | disk_result = max_state(disk_result, temp_result); |
358 | 369 | ||
359 | result = max_state(result, disk_result); | 370 | result = max_state(result, disk_result); |
@@ -414,8 +425,9 @@ int main(int argc, char **argv) { | |||
414 | true, path->inodes_total)); | 425 | true, path->inodes_total)); |
415 | } | 426 | } |
416 | 427 | ||
417 | if (disk_result == STATE_OK && erronly && !verbose) | 428 | if (disk_result == STATE_OK && erronly && !verbose) { |
418 | continue; | 429 | continue; |
430 | } | ||
419 | 431 | ||
420 | if (disk_result && verbose >= 1) { | 432 | if (disk_result && verbose >= 1) { |
421 | xasprintf(&flag_header, " %s [", state_text(disk_result)); | 433 | xasprintf(&flag_header, " %s [", state_text(disk_result)); |
@@ -434,8 +446,9 @@ int main(int argc, char **argv) { | |||
434 | } | 446 | } |
435 | } | 447 | } |
436 | 448 | ||
437 | if (verbose >= 2) | 449 | if (verbose >= 2) { |
438 | xasprintf(&output, "%s%s", output, details); | 450 | xasprintf(&output, "%s%s", output, details); |
451 | } | ||
439 | 452 | ||
440 | if (strcmp(output, "") == 0 && !erronly) { | 453 | if (strcmp(output, "") == 0 && !erronly) { |
441 | preamble = ""; | 454 | preamble = ""; |
@@ -509,20 +522,24 @@ int process_arguments(int argc, char **argv) { | |||
509 | {"help", no_argument, 0, 'h'}, | 522 | {"help", no_argument, 0, 'h'}, |
510 | {0, 0, 0, 0}}; | 523 | {0, 0, 0, 0}}; |
511 | 524 | ||
512 | if (argc < 2) | 525 | if (argc < 2) { |
513 | return ERROR; | 526 | return ERROR; |
527 | } | ||
514 | 528 | ||
515 | np_add_regex(&fs_exclude_list, "iso9660", REG_EXTENDED); | 529 | np_add_regex(&fs_exclude_list, "iso9660", REG_EXTENDED); |
516 | 530 | ||
517 | for (c = 1; c < argc; c++) | 531 | for (c = 1; c < argc; c++) { |
518 | if (strcmp("-to", argv[c]) == 0) | 532 | if (strcmp("-to", argv[c]) == 0) { |
519 | strcpy(argv[c], "-t"); | 533 | strcpy(argv[c], "-t"); |
534 | } | ||
535 | } | ||
520 | 536 | ||
521 | while (1) { | 537 | while (1) { |
522 | c = getopt_long(argc, argv, "+?VqhvefCt:c:w:K:W:u:p:x:X:N:mklLPg:R:r:i:I:MEAn", longopts, &option); | 538 | c = getopt_long(argc, argv, "+?VqhvefCt:c:w:K:W:u:p:x:X:N:mklLPg:R:r:i:I:MEAn", longopts, &option); |
523 | 539 | ||
524 | if (c == -1 || c == EOF) | 540 | if (c == -1 || c == EOF) { |
525 | break; | 541 | break; |
542 | } | ||
526 | 543 | ||
527 | switch (c) { | 544 | switch (c) { |
528 | case 't': /* timeout period */ | 545 | case 't': /* timeout period */ |
@@ -594,8 +611,9 @@ int process_arguments(int argc, char **argv) { | |||
594 | } | 611 | } |
595 | break; | 612 | break; |
596 | case 'u': | 613 | case 'u': |
597 | if (units) | 614 | if (units) { |
598 | free(units); | 615 | free(units); |
616 | } | ||
599 | if (!strcasecmp(optarg, "bytes")) { | 617 | if (!strcasecmp(optarg, "bytes")) { |
600 | mult = (uintmax_t)1; | 618 | mult = (uintmax_t)1; |
601 | units = strdup("B"); | 619 | units = strdup("B"); |
@@ -632,19 +650,22 @@ int process_arguments(int argc, char **argv) { | |||
632 | } else { | 650 | } else { |
633 | die(STATE_UNKNOWN, _("unit type %s not known\n"), optarg); | 651 | die(STATE_UNKNOWN, _("unit type %s not known\n"), optarg); |
634 | } | 652 | } |
635 | if (units == NULL) | 653 | if (units == NULL) { |
636 | die(STATE_UNKNOWN, _("failed allocating storage for '%s'\n"), "units"); | 654 | die(STATE_UNKNOWN, _("failed allocating storage for '%s'\n"), "units"); |
655 | } | ||
637 | break; | 656 | break; |
638 | case 'k': /* display mountpoint */ | 657 | case 'k': /* display mountpoint */ |
639 | mult = 1024; | 658 | mult = 1024; |
640 | if (units) | 659 | if (units) { |
641 | free(units); | 660 | free(units); |
661 | } | ||
642 | units = strdup("kiB"); | 662 | units = strdup("kiB"); |
643 | break; | 663 | break; |
644 | case 'm': /* display mountpoint */ | 664 | case 'm': /* display mountpoint */ |
645 | mult = 1024 * 1024; | 665 | mult = 1024 * 1024; |
646 | if (units) | 666 | if (units) { |
647 | free(units); | 667 | free(units); |
668 | } | ||
648 | units = strdup("MiB"); | 669 | units = strdup("MiB"); |
649 | break; | 670 | break; |
650 | case 'L': | 671 | case 'L': |
@@ -715,25 +736,28 @@ int process_arguments(int argc, char **argv) { | |||
715 | erronly = true; | 736 | erronly = true; |
716 | break; | 737 | break; |
717 | case 'E': | 738 | case 'E': |
718 | if (path_selected) | 739 | if (path_selected) { |
719 | die(STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set -E before selecting paths\n")); | 740 | die(STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set -E before selecting paths\n")); |
741 | } | ||
720 | exact_match = true; | 742 | exact_match = true; |
721 | break; | 743 | break; |
722 | case 'f': | 744 | case 'f': |
723 | freespace_ignore_reserved = true; | 745 | freespace_ignore_reserved = true; |
724 | break; | 746 | break; |
725 | case 'g': | 747 | case 'g': |
726 | if (path_selected) | 748 | if (path_selected) { |
727 | die(STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set group value before selecting paths\n")); | 749 | die(STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set group value before selecting paths\n")); |
750 | } | ||
728 | group = optarg; | 751 | group = optarg; |
729 | break; | 752 | break; |
730 | case 'I': | 753 | case 'I': |
731 | cflags |= REG_ICASE; | 754 | cflags |= REG_ICASE; |
732 | // Intentional fallthrough | 755 | // Intentional fallthrough |
733 | case 'i': | 756 | case 'i': |
734 | if (!path_selected) | 757 | if (!path_selected) { |
735 | die(STATE_UNKNOWN, "DISK %s: %s\n", _("UNKNOWN"), | 758 | die(STATE_UNKNOWN, "DISK %s: %s\n", _("UNKNOWN"), |
736 | _("Paths need to be selected before using -i/-I. Use -A to select all paths explicitly")); | 759 | _("Paths need to be selected before using -i/-I. Use -A to select all paths explicitly")); |
760 | } | ||
737 | err = regcomp(&re, optarg, cflags); | 761 | err = regcomp(&re, optarg, cflags); |
738 | if (err != 0) { | 762 | if (err != 0) { |
739 | regerror(err, &re, errbuf, MAX_INPUT_BUFFER); | 763 | regerror(err, &re, errbuf, MAX_INPUT_BUFFER); |
@@ -747,13 +771,15 @@ int process_arguments(int argc, char **argv) { | |||
747 | if (temp_list->best_match) { | 771 | if (temp_list->best_match) { |
748 | if (np_regex_match_mount_entry(temp_list->best_match, &re)) { | 772 | if (np_regex_match_mount_entry(temp_list->best_match, &re)) { |
749 | 773 | ||
750 | if (verbose >= 3) | 774 | if (verbose >= 3) { |
751 | printf("ignoring %s matching regex\n", temp_list->name); | 775 | printf("ignoring %s matching regex\n", temp_list->name); |
776 | } | ||
752 | 777 | ||
753 | temp_list = np_del_parameter(temp_list, previous); | 778 | temp_list = np_del_parameter(temp_list, previous); |
754 | /* pointer to first element needs to be updated if first item gets deleted */ | 779 | /* pointer to first element needs to be updated if first item gets deleted */ |
755 | if (previous == NULL) | 780 | if (previous == NULL) { |
756 | path_select_list = temp_list; | 781 | path_select_list = temp_list; |
782 | } | ||
757 | } else { | 783 | } else { |
758 | previous = temp_list; | 784 | previous = temp_list; |
759 | temp_list = temp_list->name_next; | 785 | temp_list = temp_list->name_next; |
@@ -793,8 +819,9 @@ int process_arguments(int argc, char **argv) { | |||
793 | for (me = mount_list; me; me = me->me_next) { | 819 | for (me = mount_list; me; me = me->me_next) { |
794 | if (np_regex_match_mount_entry(me, &re)) { | 820 | if (np_regex_match_mount_entry(me, &re)) { |
795 | fnd = true; | 821 | fnd = true; |
796 | if (verbose >= 3) | 822 | if (verbose >= 3) { |
797 | printf("%s %s matching expression %s\n", me->me_devname, me->me_mountdir, optarg); | 823 | printf("%s %s matching expression %s\n", me->me_devname, me->me_mountdir, optarg); |
824 | } | ||
798 | 825 | ||
799 | /* add parameter if not found. overwrite thresholds if path has already been added */ | 826 | /* add parameter if not found. overwrite thresholds if path has already been added */ |
800 | if (!(se = np_find_parameter(path_select_list, me->me_mountdir))) { | 827 | if (!(se = np_find_parameter(path_select_list, me->me_mountdir))) { |
@@ -810,8 +837,9 @@ int process_arguments(int argc, char **argv) { | |||
810 | path_selected = true; | 837 | path_selected = true; |
811 | break; | 838 | break; |
812 | } | 839 | } |
813 | if (!fnd) | 840 | if (!fnd) { |
814 | die(STATE_UNKNOWN, "DISK %s: %s - %s\n", _("UNKNOWN"), _("Regular expression did not match any path or disk"), optarg); | 841 | die(STATE_UNKNOWN, "DISK %s: %s - %s\n", _("UNKNOWN"), _("Regular expression did not match any path or disk"), optarg); |
842 | } | ||
815 | 843 | ||
816 | fnd = false; | 844 | fnd = false; |
817 | path_selected = true; | 845 | path_selected = true; |
@@ -827,8 +855,9 @@ int process_arguments(int argc, char **argv) { | |||
827 | if (path_selected == false) { | 855 | if (path_selected == false) { |
828 | struct parameter_list *path; | 856 | struct parameter_list *path; |
829 | for (me = mount_list; me; me = me->me_next) { | 857 | for (me = mount_list; me; me = me->me_next) { |
830 | if (!(path = np_find_parameter(path_select_list, me->me_mountdir))) | 858 | if (!(path = np_find_parameter(path_select_list, me->me_mountdir))) { |
831 | path = np_add_parameter(&path_select_list, me->me_mountdir); | 859 | path = np_add_parameter(&path_select_list, me->me_mountdir); |
860 | } | ||
832 | path->best_match = me; | 861 | path->best_match = me; |
833 | path->group = group; | 862 | path->group = group; |
834 | set_all_thresholds(path); | 863 | set_all_thresholds(path); |
@@ -863,11 +892,13 @@ int process_arguments(int argc, char **argv) { | |||
863 | 892 | ||
864 | /* Support for "check_disk warn crit [fs]" with thresholds at used% level */ | 893 | /* Support for "check_disk warn crit [fs]" with thresholds at used% level */ |
865 | c = optind; | 894 | c = optind; |
866 | if (warn_usedspace_percent == NULL && argc > c && is_intnonneg(argv[c])) | 895 | if (warn_usedspace_percent == NULL && argc > c && is_intnonneg(argv[c])) { |
867 | warn_usedspace_percent = argv[c++]; | 896 | warn_usedspace_percent = argv[c++]; |
897 | } | ||
868 | 898 | ||
869 | if (crit_usedspace_percent == NULL && argc > c && is_intnonneg(argv[c])) | 899 | if (crit_usedspace_percent == NULL && argc > c && is_intnonneg(argv[c])) { |
870 | crit_usedspace_percent = argv[c++]; | 900 | crit_usedspace_percent = argv[c++]; |
901 | } | ||
871 | 902 | ||
872 | if (argc > c) { | 903 | if (argc > c) { |
873 | se = np_add_parameter(&path_select_list, strdup(argv[c++])); | 904 | se = np_add_parameter(&path_select_list, strdup(argv[c++])); |
@@ -884,23 +915,29 @@ int process_arguments(int argc, char **argv) { | |||
884 | } | 915 | } |
885 | 916 | ||
886 | void set_all_thresholds(struct parameter_list *path) { | 917 | void set_all_thresholds(struct parameter_list *path) { |
887 | if (path->freespace_units != NULL) | 918 | if (path->freespace_units != NULL) { |
888 | free(path->freespace_units); | 919 | free(path->freespace_units); |
920 | } | ||
889 | set_thresholds(&path->freespace_units, warn_freespace_units, crit_freespace_units); | 921 | set_thresholds(&path->freespace_units, warn_freespace_units, crit_freespace_units); |
890 | if (path->freespace_percent != NULL) | 922 | if (path->freespace_percent != NULL) { |
891 | free(path->freespace_percent); | 923 | free(path->freespace_percent); |
924 | } | ||
892 | set_thresholds(&path->freespace_percent, warn_freespace_percent, crit_freespace_percent); | 925 | set_thresholds(&path->freespace_percent, warn_freespace_percent, crit_freespace_percent); |
893 | if (path->usedspace_units != NULL) | 926 | if (path->usedspace_units != NULL) { |
894 | free(path->usedspace_units); | 927 | free(path->usedspace_units); |
928 | } | ||
895 | set_thresholds(&path->usedspace_units, warn_usedspace_units, crit_usedspace_units); | 929 | set_thresholds(&path->usedspace_units, warn_usedspace_units, crit_usedspace_units); |
896 | if (path->usedspace_percent != NULL) | 930 | if (path->usedspace_percent != NULL) { |
897 | free(path->usedspace_percent); | 931 | free(path->usedspace_percent); |
932 | } | ||
898 | set_thresholds(&path->usedspace_percent, warn_usedspace_percent, crit_usedspace_percent); | 933 | set_thresholds(&path->usedspace_percent, warn_usedspace_percent, crit_usedspace_percent); |
899 | if (path->usedinodes_percent != NULL) | 934 | if (path->usedinodes_percent != NULL) { |
900 | free(path->usedinodes_percent); | 935 | free(path->usedinodes_percent); |
936 | } | ||
901 | set_thresholds(&path->usedinodes_percent, warn_usedinodes_percent, crit_usedinodes_percent); | 937 | set_thresholds(&path->usedinodes_percent, warn_usedinodes_percent, crit_usedinodes_percent); |
902 | if (path->freeinodes_percent != NULL) | 938 | if (path->freeinodes_percent != NULL) { |
903 | free(path->freeinodes_percent); | 939 | free(path->freeinodes_percent); |
940 | } | ||
904 | set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent); | 941 | set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent); |
905 | } | 942 | } |
906 | 943 | ||
@@ -1011,11 +1048,13 @@ void print_usage(void) { | |||
1011 | 1048 | ||
1012 | bool stat_path(struct parameter_list *p) { | 1049 | bool stat_path(struct parameter_list *p) { |
1013 | /* Stat entry to check that dir exists and is accessible */ | 1050 | /* Stat entry to check that dir exists and is accessible */ |
1014 | if (verbose >= 3) | 1051 | if (verbose >= 3) { |
1015 | printf("calling stat on %s\n", p->name); | 1052 | printf("calling stat on %s\n", p->name); |
1053 | } | ||
1016 | if (stat(p->name, &stat_buf[0])) { | 1054 | if (stat(p->name, &stat_buf[0])) { |
1017 | if (verbose >= 3) | 1055 | if (verbose >= 3) { |
1018 | printf("stat failed on %s\n", p->name); | 1056 | printf("stat failed on %s\n", p->name); |
1057 | } | ||
1019 | if (ignore_missing == true) { | 1058 | if (ignore_missing == true) { |
1020 | return false; | 1059 | return false; |
1021 | } | 1060 | } |
@@ -1036,18 +1075,21 @@ void get_stats(struct parameter_list *p, struct fs_usage *fsp) { | |||
1036 | /* find all group members */ | 1075 | /* find all group members */ |
1037 | for (p_list = path_select_list; p_list; p_list = p_list->name_next) { | 1076 | for (p_list = path_select_list; p_list; p_list = p_list->name_next) { |
1038 | #ifdef __CYGWIN__ | 1077 | #ifdef __CYGWIN__ |
1039 | if (strncmp(p_list->name, "/cygdrive/", 10) != 0) | 1078 | if (strncmp(p_list->name, "/cygdrive/", 10) != 0) { |
1040 | continue; | 1079 | continue; |
1080 | } | ||
1041 | #endif | 1081 | #endif |
1042 | if (p_list->group && !(strcmp(p_list->group, p->group))) { | 1082 | if (p_list->group && !(strcmp(p_list->group, p->group))) { |
1043 | if (!stat_path(p_list)) | 1083 | if (!stat_path(p_list)) { |
1044 | continue; | 1084 | continue; |
1085 | } | ||
1045 | get_fs_usage(p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp); | 1086 | get_fs_usage(p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp); |
1046 | get_path_stats(p_list, &tmpfsp); | 1087 | get_path_stats(p_list, &tmpfsp); |
1047 | if (verbose >= 3) | 1088 | if (verbose >= 3) { |
1048 | printf("Group %s: adding %lu blocks sized %lu, (%s) used_units=%lu free_units=%lu total_units=%lu mult=%lu\n", | 1089 | printf("Group %s: adding %lu blocks sized %lu, (%s) used_units=%lu free_units=%lu total_units=%lu mult=%lu\n", |
1049 | p_list->group, tmpfsp.fsu_blocks, tmpfsp.fsu_blocksize, p_list->best_match->me_mountdir, p_list->dused_units, | 1090 | p_list->group, tmpfsp.fsu_blocks, tmpfsp.fsu_blocksize, p_list->best_match->me_mountdir, p_list->dused_units, |
1050 | p_list->dfree_units, p_list->dtotal_units, mult); | 1091 | p_list->dfree_units, p_list->dtotal_units, mult); |
1092 | } | ||
1051 | 1093 | ||
1052 | /* prevent counting the first FS of a group twice since its parameter_list entry | 1094 | /* prevent counting the first FS of a group twice since its parameter_list entry |
1053 | * is used to carry the information of all file systems of the entire group */ | 1095 | * is used to carry the information of all file systems of the entire group */ |
@@ -1067,9 +1109,10 @@ void get_stats(struct parameter_list *p, struct fs_usage *fsp) { | |||
1067 | } | 1109 | } |
1068 | first = 0; | 1110 | first = 0; |
1069 | } | 1111 | } |
1070 | if (verbose >= 3) | 1112 | if (verbose >= 3) { |
1071 | printf("Group %s now has: used_units=%lu free_units=%lu total_units=%lu fsu_blocksize=%lu mult=%lu\n", p->group, | 1113 | printf("Group %s now has: used_units=%lu free_units=%lu total_units=%lu fsu_blocksize=%lu mult=%lu\n", p->group, |
1072 | p->dused_units, p->dfree_units, p->dtotal_units, tmpfsp.fsu_blocksize, mult); | 1114 | p->dused_units, p->dfree_units, p->dtotal_units, tmpfsp.fsu_blocksize, mult); |
1115 | } | ||
1073 | } | 1116 | } |
1074 | /* modify devname and mountdir for output */ | 1117 | /* modify devname and mountdir for output */ |
1075 | p->best_match->me_mountdir = p->best_match->me_devname = p->group; | 1118 | p->best_match->me_mountdir = p->best_match->me_devname = p->group; |