xref: /netbsd/usr.sbin/fstyp/fstyp.h (revision 75bd7610)
1 /*	$NetBSD: fstyp.h,v 1.9 2021/01/10 12:38:40 tkusumi Exp $	*/
2 
3 /*-
4  * Copyright (c) 2017 The NetBSD Foundation, Inc.
5  * Copyright (c) 2016 The DragonFly Project
6  * Copyright (c) 2014 The FreeBSD Foundation
7  * All rights reserved.
8  *
9  * This code is derived from software contributed to The NetBSD Foundation
10  * by Tomohiro Kusumi <kusumi.tomohiro@gmail.com>.
11  *
12  * This software was developed by Edward Tomasz Napierala under sponsorship
13  * from the FreeBSD Foundation.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  * 1. Redistributions of source code must retain the above copyright
19  *    notice, this list of conditions and the following disclaimer.
20  * 2. Redistributions in binary form must reproduce the above copyright
21  *    notice, this list of conditions and the following disclaimer in the
22  *    documentation and/or other materials provided with the distribution.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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
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
34  * SUCH DAMAGE.
35  *
36  * $FreeBSD$
37  */
38 
39 #ifndef FSTYP_H
40 #define	FSTYP_H
41 
42 #include <stdbool.h>
43 
44 /* Undefine this on FreeBSD and NetBSD. */
45 //#define HAS_DEVPATH
46 
47 /* The spec doesn't seem to permit UTF-16 surrogates; definitely LE. */
48 #define	EXFAT_ENC	"UCS-2LE"
49 /*
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.)
52  */
53 #define	NTFS_ENC	"UTF-16LE"
54 
55 extern bool	show_label;	/* -l flag */
56 
57 void	*read_buf(FILE *, off_t, size_t);
58 char	*checked_strdup(const char *);
59 void	rtrim(char *, size_t);
60 
61 int	fstyp_apfs(FILE *, char *, size_t);
62 int	fstyp_cd9660(FILE *, char *, size_t);
63 int	fstyp_exfat(FILE *, char *, size_t);
64 int	fstyp_ext2fs(FILE *, char *, size_t);
65 int	fstyp_hfsp(FILE *, char *, size_t);
66 int	fstyp_msdosfs(FILE *, char *, size_t);
67 int	fstyp_ntfs(FILE *, char *, size_t);
68 int	fstyp_ufs(FILE *, char *, size_t);
69 int	fstyp_hammer(FILE *, char *, size_t);
70 int	fstyp_hammer2(FILE *, char *, size_t);
71 #ifdef HAVE_ZFS
72 int	fstyp_zfs(FILE *, char *, size_t);
73 #endif
74 
75 int	fsvtyp_hammer(const char *, char *, size_t);
76 int	fsvtyp_hammer_partial(const char *, char *, size_t);
77 int	fsvtyp_hammer2(const char *, char *, size_t);
78 int	fsvtyp_hammer2_partial(const char *, char *, size_t);
79 
80 #endif /* !FSTYP_H */
81