1 /* $NetBSD: getfstypename.c,v 1.11 2021/07/22 13:54:38 skrll Exp $ */
2
3 /*-
4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38 #ifndef _STANDALONE
39 # include <sys/cdefs.h>
40 # ifndef _KERNEL
41 # if !defined(lint)
42 __RCSID("$NetBSD: getfstypename.c,v 1.11 2021/07/22 13:54:38 skrll Exp $");
43 # endif
44 # else
45 __KERNEL_RCSID(0, "$NetBSD: getfstypename.c,v 1.11 2021/07/22 13:54:38 skrll Exp $");
46 # endif /* _KERNEL */
47
48 # define FSTYPE_ENUMNAME fstype_enum
49
50 # include <sys/param.h>
51 # include <sys/types.h>
52 # include <sys/disk.h>
53 # include <sys/disklabel.h>
54 # ifndef _KERNEL
55 # include <util.h>
56 # endif
57
58 const char *
getfstypename(int fstype)59 getfstypename(int fstype)
60 {
61 /*
62 * The cast is so that the compiler can check that we
63 * cover all the enum values
64 */
65 switch ((enum fstype_enum)fstype) {
66 case FS_UNUSED:
67 return DKW_PTYPE_UNUSED;
68 case FS_SWAP:
69 return DKW_PTYPE_SWAP;
70 case FS_V6:
71 return DKW_PTYPE_V6;
72 case FS_V7:
73 return DKW_PTYPE_V7;
74 case FS_SYSV:
75 return DKW_PTYPE_SYSV;
76 case FS_V71K:
77 return DKW_PTYPE_V71K;
78 case FS_V8:
79 return DKW_PTYPE_V8;
80 case FS_BSDFFS:
81 return DKW_PTYPE_FFS;
82 case FS_MSDOS:
83 return DKW_PTYPE_FAT;
84 case FS_BSDLFS:
85 return DKW_PTYPE_LFS;
86 case FS_OTHER:
87 return DKW_PTYPE_OTHER;
88 case FS_HPFS:
89 return DKW_PTYPE_HPFS;
90 case FS_ISO9660:
91 return DKW_PTYPE_ISO9660;
92 case FS_BOOT:
93 return DKW_PTYPE_BOOT;
94 case FS_ADOS:
95 return DKW_PTYPE_AMIGADOS;
96 case FS_HFS:
97 return DKW_PTYPE_APPLEHFS;
98 case FS_FILECORE:
99 return DKW_PTYPE_FILECORE;
100 case FS_EX2FS:
101 return DKW_PTYPE_EXT2FS;
102 case FS_NTFS:
103 return DKW_PTYPE_NTFS;
104 case FS_RAID:
105 return DKW_PTYPE_RAIDFRAME;
106 case FS_CCD:
107 return DKW_PTYPE_CCD;
108 case FS_JFS2:
109 return DKW_PTYPE_JFS2;
110 case FS_APPLEUFS:
111 return DKW_PTYPE_APPLEUFS;
112 case FS_VINUM:
113 return DKW_PTYPE_VINUM;
114 case FS_UDF:
115 return DKW_PTYPE_UDF;
116 case FS_SYSVBFS:
117 return DKW_PTYPE_SYSVBFS;
118 case FS_EFS:
119 return DKW_PTYPE_EFS;
120 case FS_NILFS:
121 return DKW_PTYPE_NILFS;
122 case FS_CGD:
123 return DKW_PTYPE_CGD;
124 case FSMAXTYPES:
125 return DKW_PTYPE_UNKNOWN;
126 case FS_MINIXFS3:
127 return DKW_PTYPE_MINIXFS3;
128 case FS_VMKCORE:
129 return DKW_PTYPE_VMKCORE;
130 case FS_VMFS:
131 return DKW_PTYPE_VMFS;
132 case FS_VMWRESV:
133 return DKW_PTYPE_VMWRESV;
134 case FS_ZFS:
135 return DKW_PTYPE_ZFS;
136 }
137 /* Stupid gcc, should know it is impossible to get here */
138 /*NOTREACHED*/
139 return DKW_PTYPE_UNKNOWN;
140 }
141 #endif /* !_STANDALONE */
142