xref: /freebsd/usr.sbin/fstyp/fstyp.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1be3a49eeSEdward Tomasz Napierala /*-
2be3a49eeSEdward Tomasz Napierala  * Copyright (c) 2014 The FreeBSD Foundation
3be3a49eeSEdward Tomasz Napierala  *
4be3a49eeSEdward Tomasz Napierala  * This software was developed by Edward Tomasz Napierala under sponsorship
5be3a49eeSEdward Tomasz Napierala  * from the FreeBSD Foundation.
6be3a49eeSEdward Tomasz Napierala  *
7be3a49eeSEdward Tomasz Napierala  * Redistribution and use in source and binary forms, with or without
8be3a49eeSEdward Tomasz Napierala  * modification, are permitted provided that the following conditions
9be3a49eeSEdward Tomasz Napierala  * are met:
10be3a49eeSEdward Tomasz Napierala  * 1. Redistributions of source code must retain the above copyright
11be3a49eeSEdward Tomasz Napierala  *    notice, this list of conditions and the following disclaimer.
12be3a49eeSEdward Tomasz Napierala  * 2. Redistributions in binary form must reproduce the above copyright
13be3a49eeSEdward Tomasz Napierala  *    notice, this list of conditions and the following disclaimer in the
14be3a49eeSEdward Tomasz Napierala  *    documentation and/or other materials provided with the distribution.
15be3a49eeSEdward Tomasz Napierala  *
16be3a49eeSEdward Tomasz Napierala  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17be3a49eeSEdward Tomasz Napierala  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18be3a49eeSEdward Tomasz Napierala  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19be3a49eeSEdward Tomasz Napierala  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20be3a49eeSEdward Tomasz Napierala  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21be3a49eeSEdward Tomasz Napierala  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22be3a49eeSEdward Tomasz Napierala  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23be3a49eeSEdward Tomasz Napierala  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24be3a49eeSEdward Tomasz Napierala  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25be3a49eeSEdward Tomasz Napierala  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26be3a49eeSEdward Tomasz Napierala  * SUCH DAMAGE.
27be3a49eeSEdward Tomasz Napierala  */
28be3a49eeSEdward Tomasz Napierala 
29be3a49eeSEdward Tomasz Napierala #ifndef FSTYP_H
30be3a49eeSEdward Tomasz Napierala #define	FSTYP_H
31be3a49eeSEdward Tomasz Napierala 
3285b4c344SConrad Meyer #include <stdbool.h>
3385b4c344SConrad Meyer 
34be3a49eeSEdward Tomasz Napierala #define	MIN(a,b) (((a)<(b))?(a):(b))
35be3a49eeSEdward Tomasz Napierala 
3685b4c344SConrad Meyer /* The spec doesn't seem to permit UTF-16 surrogates; definitely LE. */
3785b4c344SConrad Meyer #define	EXFAT_ENC	"UCS-2LE"
38ec80d2eeSConrad Meyer /*
39ec80d2eeSConrad Meyer  * NTFS itself is agnostic to encoding; it just stores 255 u16 wchars.  In
40ec80d2eeSConrad Meyer  * practice, UTF-16 seems expected for NTFS.  (Maybe also for exFAT.)
41ec80d2eeSConrad Meyer  */
42ec80d2eeSConrad Meyer #define	NTFS_ENC	"UTF-16LE"
4385b4c344SConrad Meyer 
4485b4c344SConrad Meyer extern bool	show_label;	/* -l flag */
4585b4c344SConrad Meyer 
46be3a49eeSEdward Tomasz Napierala void	*read_buf(FILE *fp, off_t off, size_t len);
47be3a49eeSEdward Tomasz Napierala char	*checked_strdup(const char *s);
48628b7128SEdward Tomasz Napierala void	rtrim(char *label, size_t size);
49be3a49eeSEdward Tomasz Napierala 
50e41d6276SConrad Meyer int	fstyp_apfs(FILE *fp, char *label, size_t size);
51*0e92585cSPiotr Pawel Stefaniak int	fstyp_befs(FILE *fp, char *label, size_t size);
52be3a49eeSEdward Tomasz Napierala int	fstyp_cd9660(FILE *fp, char *label, size_t size);
53e2660756SConrad Meyer int	fstyp_exfat(FILE *fp, char *label, size_t size);
54be3a49eeSEdward Tomasz Napierala int	fstyp_ext2fs(FILE *fp, char *label, size_t size);
55398e498eSAllan Jude int	fstyp_geli(FILE *fp, char *label, size_t size);
56509798eaSPedro F. Giffuni int	fstyp_hammer(FILE *fp, char *label, size_t size);
57509798eaSPedro F. Giffuni int	fstyp_hammer2(FILE *fp, char *label, size_t size);
5850c59bbbSConrad Meyer int	fstyp_hfsp(FILE *fp, char *label, size_t size);
59be3a49eeSEdward Tomasz Napierala int	fstyp_msdosfs(FILE *fp, char *label, size_t size);
60be3a49eeSEdward Tomasz Napierala int	fstyp_ntfs(FILE *fp, char *label, size_t size);
61be3a49eeSEdward Tomasz Napierala int	fstyp_ufs(FILE *fp, char *label, size_t size);
6269f172f2SAllan Jude #ifdef HAVE_ZFS
63398e498eSAllan Jude int	fstyp_zfs(FILE *fp, char *label, size_t size);
64398e498eSAllan Jude #endif
65be3a49eeSEdward Tomasz Napierala 
66be3a49eeSEdward Tomasz Napierala #endif /* !FSTYP_H */
67