| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: biosdisk.c,v 1.56 2021/12/28 00:34:30 simonb Exp $ */ | | 1 | /* $NetBSD: biosdisk.c,v 1.57 2021/12/28 00:37:16 simonb Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1996, 1998 | | 4 | * Copyright (c) 1996, 1998 |
5 | * Matthias Drochner. All rights reserved. | | 5 | * Matthias Drochner. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -1018,46 +1018,48 @@ next_raidrame: | | | @@ -1018,46 +1018,48 @@ next_raidrame: |
1018 | #endif | | 1018 | #endif |
1019 | } | | 1019 | } |
1020 | | | 1020 | |
1021 | /* Determine likely partition for possible sector number of dos | | 1021 | /* Determine likely partition for possible sector number of dos |
1022 | * partition. | | 1022 | * partition. |
1023 | */ | | 1023 | */ |
1024 | | | 1024 | |
1025 | int | | 1025 | int |
1026 | biosdisk_findpartition(int biosdev, daddr_t sector, | | 1026 | biosdisk_findpartition(int biosdev, daddr_t sector, |
1027 | int *partition, const char **part_name) | | 1027 | int *partition, const char **part_name) |
1028 | { | | 1028 | { |
1029 | #if defined(NO_DISKLABEL) && defined(NO_GPT) | | 1029 | #if defined(NO_DISKLABEL) && defined(NO_GPT) |
1030 | *partition = 0; | | 1030 | *partition = 0; |
1031 | *part_name = NULL; | | 1031 | if (part_name) |
| | | 1032 | *part_name = NULL; |
1032 | return 0; | | 1033 | return 0; |
1033 | #else | | 1034 | #else |
1034 | int i; | | 1035 | int i; |
1035 | struct biosdisk *d; | | 1036 | struct biosdisk *d; |
1036 | int biosboot_sector_part = -1; | | 1037 | int biosboot_sector_part = -1; |
1037 | int bootable_fs_part = -1; | | 1038 | int bootable_fs_part = -1; |
1038 | int boot_part = 0; | | 1039 | int boot_part = 0; |
1039 | #ifndef NO_GPT | | 1040 | #ifndef NO_GPT |
1040 | int gpt_bootme_part = -1; | | 1041 | int gpt_bootme_part = -1; |
1041 | static char namebuf[MAXDEVNAME + 1]; | | 1042 | static char namebuf[MAXDEVNAME + 1]; |
1042 | #endif | | 1043 | #endif |
1043 | | | 1044 | |
1044 | #ifdef DISK_DEBUG | | 1045 | #ifdef DISK_DEBUG |
1045 | printf("looking for partition device %x, sector %"PRId64"\n", biosdev, sector); | | 1046 | printf("looking for partition device %x, sector %"PRId64"\n", biosdev, sector); |
1046 | #endif | | 1047 | #endif |
1047 | | | 1048 | |
1048 | /* default to first partition */ | | 1049 | /* default to first partition */ |
1049 | *partition = 0; | | 1050 | *partition = 0; |
1050 | *part_name = NULL; | | 1051 | if (part_name) |
| | | 1052 | *part_name = NULL; |
1051 | | | 1053 | |
1052 | /* Look for netbsd partition that is the dos boot one */ | | 1054 | /* Look for netbsd partition that is the dos boot one */ |
1053 | d = alloc_biosdisk(biosdev); | | 1055 | d = alloc_biosdisk(biosdev); |
1054 | if (d == NULL) | | 1056 | if (d == NULL) |
1055 | return -1; | | 1057 | return -1; |
1056 | | | 1058 | |
1057 | if (read_partitions(d, 0, 0) == 0) { | | 1059 | if (read_partitions(d, 0, 0) == 0) { |
1058 | for (i = 0; i < BIOSDISKNPART; i++) { | | 1060 | for (i = 0; i < BIOSDISKNPART; i++) { |
1059 | if (d->part[i].fstype == FS_UNUSED) | | 1061 | if (d->part[i].fstype == FS_UNUSED) |
1060 | continue; | | 1062 | continue; |
1061 | | | 1063 | |
1062 | if (d->part[i].offset == sector && | | 1064 | if (d->part[i].offset == sector && |
1063 | biosboot_sector_part == -1) | | 1065 | biosboot_sector_part == -1) |