fstyp.h revision 1.7
1/*	$NetBSD: fstyp.h,v 1.7 2020/01/01 08:56:41 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
55extern bool	show_label;	/* -l flag */
56
57void	*read_buf(FILE *, off_t, size_t);
58char	*checked_strdup(const char *);
59void	rtrim(char *, size_t);
60
61int	fstyp_apfs(FILE *fp, char *label, size_t size);
62int	fstyp_cd9660(FILE *, char *, size_t);
63int	fstyp_exfat(FILE *fp, char *label, size_t size);
64int	fstyp_ext2fs(FILE *, char *, size_t);
65int	fstyp_hfsp(FILE *fp, char *label, size_t size);
66int	fstyp_msdosfs(FILE *, char *, size_t);
67int	fstyp_ntfs(FILE *, char *, size_t);
68int	fstyp_ufs(FILE *, char *, size_t);
69int	fstyp_hammer(FILE *, char *, size_t);
70int	fstyp_hammer2(FILE *, char *, size_t);
71#ifdef HAVE_ZFS
72int	fstyp_zfs(FILE *, char *, size_t);
73#endif
74
75int	fsvtyp_hammer(const char *blkdevs, char *label, size_t size);
76int	fsvtyp_hammer_partial(const char *blkdevs, char *label, size_t size);
77
78#endif /* !FSTYP_H */
79