Wed Jan 1 09:08:52 2020 UTC ()
fstyp: Cleanup and minor sync up with FreeBSD/DragonFlyBSD


(tkusumi)
diff -r1.8 -r1.9 src/usr.sbin/fstyp/fstyp.c
diff -r1.7 -r1.8 src/usr.sbin/fstyp/fstyp.h

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

--- src/usr.sbin/fstyp/fstyp.c 2020/01/01 08:56:41 1.8
+++ src/usr.sbin/fstyp/fstyp.c 2020/01/01 09:08:52 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fstyp.c,v 1.8 2020/01/01 08:56:41 tkusumi Exp $ */ 1/* $NetBSD: fstyp.c,v 1.9 2020/01/01 09:08:52 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.8 2020/01/01 08:56:41 tkusumi Exp $"); 38__RCSID("$NetBSD: fstyp.c,v 1.9 2020/01/01 09:08:52 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>
@@ -78,28 +78,29 @@ static struct { @@ -78,28 +78,29 @@ static struct {
78 { "ufs", &fstyp_ufs, false, NULL }, 78 { "ufs", &fstyp_ufs, false, NULL },
79 { "hammer", &fstyp_hammer, false, NULL }, 79 { "hammer", &fstyp_hammer, false, NULL },
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} fsvtypes[] = { 92} fsvtypes[] = {
92 { NULL, NULL, NULL } 93 { NULL, NULL, NULL, NULL }
93}; 94};
94 95
95void * 96void *
96read_buf(FILE *fp, off_t off, size_t len) 97read_buf(FILE *fp, off_t off, size_t len)
97{ 98{
98 int error; 99 int error;
99 size_t nread; 100 size_t nread;
100 void *buf; 101 void *buf;
101 102
102 error = fseeko(fp, off, SEEK_SET); 103 error = fseeko(fp, off, SEEK_SET);
103 if (error != 0) { 104 if (error != 0) {
104 warn("cannot seek to %jd", (uintmax_t)off); 105 warn("cannot seek to %jd", (uintmax_t)off);
105 return NULL; 106 return NULL;

cvs diff -r1.7 -r1.8 src/usr.sbin/fstyp/fstyp.h (expand / switch to unified diff)

--- src/usr.sbin/fstyp/fstyp.h 2020/01/01 08:56:41 1.7
+++ src/usr.sbin/fstyp/fstyp.h 2020/01/01 09:08:52 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fstyp.h,v 1.7 2020/01/01 08:56:41 tkusumi Exp $ */ 1/* $NetBSD: fstyp.h,v 1.8 2020/01/01 09:08:52 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 *
@@ -48,31 +48,31 @@ @@ -48,31 +48,31 @@
48#define EXFAT_ENC "UCS-2LE" 48#define EXFAT_ENC "UCS-2LE"
49/* 49/*
50 * NTFS itself is agnostic to encoding; it just stores 255 u16 wchars. In 50 * NTFS itself is agnostic to encoding; it just stores 255 u16 wchars. In
51 * practice, UTF-16 seems expected for NTFS. (Maybe also for exFAT.) 51 * practice, UTF-16 seems expected for NTFS. (Maybe also for exFAT.)
52 */ 52 */
53#define NTFS_ENC "UTF-16LE" 53#define NTFS_ENC "UTF-16LE"
54 54
55extern bool show_label; /* -l flag */ 55extern bool show_label; /* -l flag */
56 56
57void *read_buf(FILE *, off_t, size_t); 57void *read_buf(FILE *, off_t, size_t);
58char *checked_strdup(const char *); 58char *checked_strdup(const char *);
59void rtrim(char *, size_t); 59void rtrim(char *, size_t);
60 60
61int fstyp_apfs(FILE *fp, char *label, size_t size); 61int fstyp_apfs(FILE *, char *, size_t);
62int fstyp_cd9660(FILE *, char *, size_t); 62int fstyp_cd9660(FILE *, char *, size_t);
63int fstyp_exfat(FILE *fp, char *label, size_t size); 63int fstyp_exfat(FILE *, char *, size_t);
64int fstyp_ext2fs(FILE *, char *, size_t); 64int fstyp_ext2fs(FILE *, char *, size_t);
65int fstyp_hfsp(FILE *fp, char *label, size_t size); 65int fstyp_hfsp(FILE *, char *, size_t);
66int fstyp_msdosfs(FILE *, char *, size_t); 66int fstyp_msdosfs(FILE *, char *, size_t);
67int fstyp_ntfs(FILE *, char *, size_t); 67int fstyp_ntfs(FILE *, char *, size_t);
68int fstyp_ufs(FILE *, char *, size_t); 68int fstyp_ufs(FILE *, char *, size_t);
69int fstyp_hammer(FILE *, char *, size_t); 69int fstyp_hammer(FILE *, char *, size_t);
70int fstyp_hammer2(FILE *, char *, size_t); 70int fstyp_hammer2(FILE *, char *, size_t);
71#ifdef HAVE_ZFS 71#ifdef HAVE_ZFS
72int fstyp_zfs(FILE *, char *, size_t); 72int fstyp_zfs(FILE *, char *, size_t);
73#endif 73#endif
74 74
75int fsvtyp_hammer(const char *blkdevs, char *label, size_t size); 75int fsvtyp_hammer(const char *, char *, size_t);
76int fsvtyp_hammer_partial(const char *blkdevs, char *label, size_t size); 76int fsvtyp_hammer_partial(const char *, char *, size_t);
77 77
78#endif /* !FSTYP_H */ 78#endif /* !FSTYP_H */