Wed Jan 1 09:17:27 2020 UTC ()
fstyp: Add HAMMER1 multi-volume support (missed in "fstyp: Add HAMMER1/2 support")

taken-from: DragonFlyBSD


(tkusumi)
diff -r1.9 -r1.10 src/usr.sbin/fstyp/fstyp.c

cvs diff -r1.9 -r1.10 src/usr.sbin/fstyp/fstyp.c (expand / switch to unified diff)

--- src/usr.sbin/fstyp/fstyp.c 2020/01/01 09:08:52 1.9
+++ src/usr.sbin/fstyp/fstyp.c 2020/01/01 09:17:27 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fstyp.c,v 1.9 2020/01/01 09:08:52 tkusumi Exp $ */ 1/* $NetBSD: fstyp.c,v 1.10 2020/01/01 09:17:27 tkusumi Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2017 The NetBSD Foundation, Inc. 4 * Copyright (c) 2017 The NetBSD Foundation, Inc.
5 * Copyright (c) 2016 The DragonFly Project 5 * Copyright (c) 2016 The DragonFly Project
6 * Copyright (c) 2014 The FreeBSD Foundation 6 * Copyright (c) 2014 The FreeBSD Foundation
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * This code is derived from software contributed to The NetBSD Foundation 9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Tomohiro Kusumi <kusumi.tomohiro@gmail.com>. 10 * by Tomohiro Kusumi <kusumi.tomohiro@gmail.com>.
11 * 11 *
12 * This software was developed by Edward Tomasz Napierala under sponsorship 12 * This software was developed by Edward Tomasz Napierala under sponsorship
13 * from the FreeBSD Foundation. 13 * from the FreeBSD Foundation.
14 * 14 *
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 */ 36 */
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__RCSID("$NetBSD: fstyp.c,v 1.9 2020/01/01 09:08:52 tkusumi Exp $"); 38__RCSID("$NetBSD: fstyp.c,v 1.10 2020/01/01 09:17:27 tkusumi Exp $");
39 39
40#include <sys/disklabel.h> 40#include <sys/disklabel.h>
41#include <sys/dkio.h> 41#include <sys/dkio.h>
42#include <sys/ioctl.h> 42#include <sys/ioctl.h>
43#include <sys/stat.h> 43#include <sys/stat.h>
44#include <err.h> 44#include <err.h>
45#include <errno.h> 45#include <errno.h>
46#include <iconv.h> 46#include <iconv.h>
47#include <locale.h> 47#include <locale.h>
48#include <stdbool.h> 48#include <stdbool.h>
49#include <stddef.h> 49#include <stddef.h>
50#include <stdio.h> 50#include <stdio.h>
51#include <stdlib.h> 51#include <stdlib.h>
@@ -80,26 +80,28 @@ static struct { @@ -80,26 +80,28 @@ static struct {
80 { "hammer2", &fstyp_hammer2, false, NULL }, 80 { "hammer2", &fstyp_hammer2, false, NULL },
81#ifdef HAVE_ZFS 81#ifdef HAVE_ZFS
82 { "zfs", &fstyp_zfs, true, NULL }, 82 { "zfs", &fstyp_zfs, true, NULL },
83#endif 83#endif
84 { NULL, NULL, NULL, NULL } 84 { NULL, NULL, NULL, NULL }
85}; 85};
86 86
87static struct { 87static struct {
88 const char *name; 88 const char *name;
89 fsvtyp_function function; 89 fsvtyp_function function;
90 bool unmountable; 90 bool unmountable;
91 const char *precache_encoding; 91 const char *precache_encoding;
92} fsvtypes[] = { 92} fsvtypes[] = {
 93 { "hammer", &fsvtyp_hammer, false, NULL }, /* Must be before partial */
 94 { "hammer(partial)", &fsvtyp_hammer_partial, true, NULL },
93 { NULL, NULL, NULL, NULL } 95 { NULL, NULL, NULL, NULL }
94}; 96};
95 97
96void * 98void *
97read_buf(FILE *fp, off_t off, size_t len) 99read_buf(FILE *fp, off_t off, size_t len)
98{ 100{
99 int error; 101 int error;
100 size_t nread; 102 size_t nread;
101 void *buf; 103 void *buf;
102 104
103 error = fseeko(fp, off, SEEK_SET); 105 error = fseeko(fp, off, SEEK_SET);
104 if (error != 0) { 106 if (error != 0) {
105 warn("cannot seek to %jd", (uintmax_t)off); 107 warn("cannot seek to %jd", (uintmax_t)off);