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