| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: util.c,v 1.50 2020/10/25 08:50:32 martin Exp $ */ | | 1 | /* $NetBSD: util.c,v 1.51 2020/10/26 20:18:33 martin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 1997 Piermont Information Systems Inc. | | 4 | * Copyright 1997 Piermont Information Systems Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. | | 7 | * Written by Philip A. Nelson for Piermont Information Systems Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -505,38 +505,38 @@ get_available_cds_helper(void *arg, cons | | | @@ -505,38 +505,38 @@ get_available_cds_helper(void *arg, cons |
505 | } | | 505 | } |
506 | | | 506 | |
507 | return true; | | 507 | return true; |
508 | } | | 508 | } |
509 | | | 509 | |
510 | /* | | 510 | /* |
511 | * Get a list of all available CD media (not drives!), return | | 511 | * Get a list of all available CD media (not drives!), return |
512 | * the number of entries collected. | | 512 | * the number of entries collected. |
513 | */ | | 513 | */ |
514 | static int | | 514 | static int |
515 | get_available_cds(void) | | 515 | get_available_cds(void) |
516 | { | | 516 | { |
517 | struct get_available_cds_state data; | | 517 | struct get_available_cds_state data; |
518 | int n, __diagused e; | | 518 | int n, m; |
519 | | | 519 | |
520 | memset(&data, 0, sizeof data); | | 520 | memset(&data, 0, sizeof data); |
521 | data.info = cds; | | 521 | data.info = cds; |
522 | | | 522 | |
523 | n = getvfsstat(NULL, 0, ST_NOWAIT); | | 523 | n = getvfsstat(NULL, 0, ST_NOWAIT); |
524 | if (n > 0) { | | 524 | if (n > 0) { |
525 | data.mounted = calloc(n, sizeof(*data.mounted)); | | 525 | data.mounted = calloc(n, sizeof(*data.mounted)); |
526 | e = getvfsstat(data.mounted, n*sizeof(*data.mounted), | | 526 | m = getvfsstat(data.mounted, n*sizeof(*data.mounted), |
527 | ST_NOWAIT); | | 527 | ST_NOWAIT); |
528 | assert(e == n); | | 528 | assert(m >= 0 && m <= n); |
529 | data.num_mounted = n; | | 529 | data.num_mounted = m; |
530 | } | | 530 | } |
531 | | | 531 | |
532 | enumerate_disks(&data, get_available_cds_helper); | | 532 | enumerate_disks(&data, get_available_cds_helper); |
533 | | | 533 | |
534 | free(data.mounted); | | 534 | free(data.mounted); |
535 | | | 535 | |
536 | return data.count; | | 536 | return data.count; |
537 | } | | 537 | } |
538 | | | 538 | |
539 | static int | | 539 | static int |
540 | cd_has_sets(void) | | 540 | cd_has_sets(void) |
541 | { | | 541 | { |
542 | /* Mount it */ | | 542 | /* Mount it */ |