| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: hammer.c,v 1.2 2020/01/03 08:19:14 tkusumi Exp $ */ | | 1 | /* $NetBSD: hammer.c,v 1.3 2020/01/15 15:30:46 tkusumi Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2016-2019 The DragonFly Project | | 4 | * Copyright (c) 2016-2019 The DragonFly Project |
5 | * Copyright (c) 2016-2019 Tomohiro Kusumi <tkusumi@netbsd.org> | | 5 | * Copyright (c) 2016-2019 Tomohiro Kusumi <tkusumi@netbsd.org> |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND | | 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE | | 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE |
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 | * SUCH DAMAGE. | | 27 | * SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.2 2020/01/03 08:19:14 tkusumi Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: hammer.c,v 1.3 2020/01/15 15:30:46 tkusumi Exp $"); |
31 | | | 31 | |
32 | #include <stdio.h> | | 32 | #include <stdio.h> |
33 | #include <stdlib.h> | | 33 | #include <stdlib.h> |
34 | #include <string.h> | | 34 | #include <string.h> |
35 | #include <err.h> | | 35 | #include <err.h> |
36 | #include <assert.h> | | 36 | #include <assert.h> |
37 | | | 37 | |
38 | #include "fstyp.h" | | 38 | #include "fstyp.h" |
39 | #include "hammer_disk.h" | | 39 | #include "hammer_disk.h" |
40 | | | 40 | |
41 | static hammer_volume_ondisk_t | | 41 | static hammer_volume_ondisk_t |
42 | read_ondisk(FILE *fp) | | 42 | read_ondisk(FILE *fp) |
43 | { | | 43 | { |
| @@ -62,35 +62,35 @@ test_ondisk(const hammer_volume_ondisk_t | | | @@ -62,35 +62,35 @@ test_ondisk(const hammer_volume_ondisk_t |
62 | return (1); | | 62 | return (1); |
63 | if (ondisk->vol_rootvol != HAMMER_ROOT_VOLNO) | | 63 | if (ondisk->vol_rootvol != HAMMER_ROOT_VOLNO) |
64 | return (2); | | 64 | return (2); |
65 | if (ondisk->vol_no < 0 || ondisk->vol_no > HAMMER_MAX_VOLUMES - 1) | | 65 | if (ondisk->vol_no < 0 || ondisk->vol_no > HAMMER_MAX_VOLUMES - 1) |
66 | return (3); | | 66 | return (3); |
67 | if (ondisk->vol_count < 1 || ondisk->vol_count > HAMMER_MAX_VOLUMES) | | 67 | if (ondisk->vol_count < 1 || ondisk->vol_count > HAMMER_MAX_VOLUMES) |
68 | return (4); | | 68 | return (4); |
69 | | | 69 | |
70 | if (count == 0) { | | 70 | if (count == 0) { |
71 | count = ondisk->vol_count; | | 71 | count = ondisk->vol_count; |
72 | assert(count != 0); | | 72 | assert(count != 0); |
73 | memcpy(&fsid, &ondisk->vol_fsid, sizeof(fsid)); | | 73 | memcpy(&fsid, &ondisk->vol_fsid, sizeof(fsid)); |
74 | memcpy(&fstype, &ondisk->vol_fstype, sizeof(fstype)); | | 74 | memcpy(&fstype, &ondisk->vol_fstype, sizeof(fstype)); |
75 | strncpy(label, ondisk->vol_label, sizeof(label)); | | 75 | strlcpy(label, ondisk->vol_label, sizeof(label)); |
76 | } else { | | 76 | } else { |
77 | if (ondisk->vol_count != count) | | 77 | if (ondisk->vol_count != count) |
78 | return (5); | | 78 | return (5); |
79 | if (memcmp(&ondisk->vol_fsid, &fsid, sizeof(fsid))) | | 79 | if (memcmp(&ondisk->vol_fsid, &fsid, sizeof(fsid))) |
80 | return (6); | | 80 | return (6); |
81 | if (memcmp(&ondisk->vol_fstype, &fstype, sizeof(fstype))) | | 81 | if (memcmp(&ondisk->vol_fstype, &fstype, sizeof(fstype))) |
82 | return (7); | | 82 | return (7); |
83 | if (strncmp(ondisk->vol_label, label, sizeof(label))) | | 83 | if (strcmp(ondisk->vol_label, label)) |
84 | return (8); | | 84 | return (8); |
85 | } | | 85 | } |
86 | | | 86 | |
87 | return (0); | | 87 | return (0); |
88 | } | | 88 | } |
89 | | | 89 | |
90 | int | | 90 | int |
91 | fstyp_hammer(FILE *fp, char *label, size_t size) | | 91 | fstyp_hammer(FILE *fp, char *label, size_t size) |
92 | { | | 92 | { |
93 | hammer_volume_ondisk_t ondisk; | | 93 | hammer_volume_ondisk_t ondisk; |
94 | int error = 1; | | 94 | int error = 1; |
95 | #ifdef HAS_DEVPATH | | 95 | #ifdef HAS_DEVPATH |
96 | const char *p; | | 96 | const char *p; |