| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: main.c,v 1.55 2020/09/29 02:58:52 msaitoh Exp $ */ | | 1 | /* $NetBSD: main.c,v 1.56 2021/05/29 17:41:51 christos Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Julio M. Merino Vidal. | | 8 | * by Julio M. Merino Vidal. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -66,27 +66,27 @@ | | | @@ -66,27 +66,27 @@ |
66 | #endif | | 66 | #endif |
67 | | | 67 | |
68 | #include <sys/cdefs.h> | | 68 | #include <sys/cdefs.h> |
69 | #ifndef lint | | 69 | #ifndef lint |
70 | __COPYRIGHT("@(#) Copyright (c) 1987, 1993\ | | 70 | __COPYRIGHT("@(#) Copyright (c) 1987, 1993\ |
71 | The Regents of the University of California. All rights reserved."); | | 71 | The Regents of the University of California. All rights reserved."); |
72 | #endif /* not lint */ | | 72 | #endif /* not lint */ |
73 | | | 73 | |
74 | #ifndef lint | | 74 | #ifndef lint |
75 | #if 0 | | 75 | #if 0 |
76 | static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; | | 76 | static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; |
77 | /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ | | 77 | /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ |
78 | #else | | 78 | #else |
79 | __RCSID("$NetBSD: main.c,v 1.55 2020/09/29 02:58:52 msaitoh Exp $"); | | 79 | __RCSID("$NetBSD: main.c,v 1.56 2021/05/29 17:41:51 christos Exp $"); |
80 | #endif | | 80 | #endif |
81 | #endif /* not lint */ | | 81 | #endif /* not lint */ |
82 | | | 82 | |
83 | #include <sys/param.h> | | 83 | #include <sys/param.h> |
84 | #include <sys/file.h> | | 84 | #include <sys/file.h> |
85 | #include <sys/stat.h> | | 85 | #include <sys/stat.h> |
86 | #include <sys/wait.h> | | 86 | #include <sys/wait.h> |
87 | #define DKTYPENAMES | | 87 | #define DKTYPENAMES |
88 | #define FSTYPENAMES | | 88 | #define FSTYPENAMES |
89 | | | 89 | |
90 | #include <ctype.h> | | 90 | #include <ctype.h> |
91 | #include <err.h> | | 91 | #include <err.h> |
92 | #include <errno.h> | | 92 | #include <errno.h> |
| @@ -1228,29 +1228,29 @@ find_label(int f, u_int sector) | | | @@ -1228,29 +1228,29 @@ find_label(int f, u_int sector) |
1228 | return NULL; | | 1228 | return NULL; |
1229 | } | | 1229 | } |
1230 | | | 1230 | |
1231 | if (verbose > 2) | | 1231 | if (verbose > 2) |
1232 | warnx("read sector %u len %d looking for label", | | 1232 | warnx("read sector %u len %d looking for label", |
1233 | sector, bootarea_len); | | 1233 | sector, bootarea_len); |
1234 | | | 1234 | |
1235 | /* Check expected offset first */ | | 1235 | /* Check expected offset first */ |
1236 | for (offset = LABEL_OFFSET, i = -4;; offset = i += 4) { | | 1236 | for (offset = LABEL_OFFSET, i = -4;; offset = i += 4) { |
1237 | is_deleted = ""; | | 1237 | is_deleted = ""; |
1238 | if (i == LABEL_OFFSET) | | 1238 | if (i == LABEL_OFFSET) |
1239 | continue; | | 1239 | continue; |
1240 | disk_lp = (void *)(bootarea + offset); | | 1240 | disk_lp = (void *)(bootarea + offset); |
1241 | memcpy(&tlp, disk_lp, sizeof(tlp)); | | | |
1242 | if ((char *)(disk_lp + 1) > bootarea + bootarea_len) | | 1241 | if ((char *)(disk_lp + 1) > bootarea + bootarea_len) |
1243 | break; | | 1242 | break; |
| | | 1243 | memcpy(&tlp, disk_lp, sizeof(tlp)); |
1244 | if (tlp.d_magic2 != tlp.d_magic) | | 1244 | if (tlp.d_magic2 != tlp.d_magic) |
1245 | continue; | | 1245 | continue; |
1246 | if (read_all && (tlp.d_magic == DISKMAGIC_DELETED || | | 1246 | if (read_all && (tlp.d_magic == DISKMAGIC_DELETED || |
1247 | tlp.d_magic == DISKMAGIC_DELETED_REV)) { | | 1247 | tlp.d_magic == DISKMAGIC_DELETED_REV)) { |
1248 | tlp.d_magic ^= ~0u; | | 1248 | tlp.d_magic ^= ~0u; |
1249 | tlp.d_magic2 ^= ~0u; | | 1249 | tlp.d_magic2 ^= ~0u; |
1250 | is_deleted = "deleted "; | | 1250 | is_deleted = "deleted "; |
1251 | } | | 1251 | } |
1252 | if (target32toh(tlp.d_magic) != DISKMAGIC) { | | 1252 | if (target32toh(tlp.d_magic) != DISKMAGIC) { |
1253 | /* XXX: Do something about byte-swapped labels ? */ | | 1253 | /* XXX: Do something about byte-swapped labels ? */ |
1254 | if (target32toh(tlp.d_magic) == DISKMAGIC_REV && | | 1254 | if (target32toh(tlp.d_magic) == DISKMAGIC_REV && |
1255 | target32toh(tlp.d_magic2) == DISKMAGIC_REV) | | 1255 | target32toh(tlp.d_magic2) == DISKMAGIC_REV) |
1256 | warnx("ignoring %sbyteswapped label" | | 1256 | warnx("ignoring %sbyteswapped label" |