1 /* @(#)table.h	1.18 17/02/12 Copyright 1994, 1996, 2000-2017 J. Schilling */
2 /*
3  *	Conversion table definitions for efficient conversion
4  *	of different file type representations
5  *
6  *	Copyright (c) 1994, 1996, 2000-2017 J. Schilling
7  */
8 /*
9  * The contents of this file are subject to the terms of the
10  * Common Development and Distribution License, Version 1.0 only
11  * (the "License").  You may not use this file except in compliance
12  * with the License.
13  *
14  * See the file CDDL.Schily.txt in this distribution for details.
15  * A copy of the CDDL is also available via the Internet at
16  * http://www.opensource.org/licenses/cddl1.txt
17  *
18  * When distributing Covered Code, include this CDDL HEADER in each
19  * file and include the License file CDDL.Schily.txt from this distribution.
20  */
21 
22 #ifndef	_TABLE_H
23 #define	_TABLE_H
24 
25 #ifndef _SCHILY_MCONFIG_H
26 #include <schily/mconfig.h>
27 #endif
28 #ifndef _SCHILY_UTYPES_H
29 #include <schily/utypes.h>
30 #endif
31 
32 /*
33  * Unix uses the following file types
34  */
35 #ifdef	comment
36 		0000000		/* Unallocated			*/
37 S_IFIFO		0010000	FIFO	/* Named pipe			*/
38 S_IFCHR		0020000	CHR	/* Character special		*/
39 S_IFMPC		0030000		/* UNUSED multiplexed c		*/
40 S_IFDIR		0040000	DIR	/* Directory			*/
41 S_IFNAM		0050000	NAM	/* Named file (XENIX)		*/
42 S_IFBLK		0060000	BLK	/* Block special		*/
43 S_IFMPB		0070000		/* UNUSED multiplexed b		*/
44 S_IFREG		0100000	REG	/* Regular file 		*/
45 S_IFCTG		0110000	CTG	/* Contiguous file		*/
46 S_IFLNK		0120000	SLNK	/* Symbolic link		*/
47 S_IFSHAD	0130000		/* Solaris shadow inode		*/
48 S_IFSOCK	0140000	SOCK	/* UNIX domain socket		*/
49 S_IFDOOR	0150000		/* Solaris DOOR			*/
50 S_IFWHT		0160000		/* BSD whiteout			*/
51 		0160200		/* Solaris cpio acl		*/
52 		0170000		/* UNUSED on UNIX		*/
53 S_IFEVC		0170000		/* UNOS event count		*/
54 				/* UNOS/UNIX compat only	*/
55 #endif
56 
57 /*
58  * Internal table of file types.
59  *
60  * N.B. The order in this table is not important,
61  * new real file types may be added before XT_DUMPDIR,
62  * new symbolic file types may be added before XT_BAD.
63  */
64 #define	XT_NONE		0	/* unallocated file			    */
65 #define	XT_FILE		1	/* regular file				    */
66 #define	XT_CONT		2	/* contiguous file			    */
67 #define	XT_LINK		3	/* hard link (needed for internal use)	    */
68 #define	XT_SLINK	4	/* symbolic link			    */
69 #define	XT_DIR		5	/* directory				    */
70 #define	XT_CHR		6	/* character special			    */
71 #define	XT_BLK		7	/* block special			    */
72 #define	XT_FIFO		8	/* fifo (named pipe)			    */
73 #define	XT_SOCK		9	/* unix domain socket			    */
74 #define	XT_MPC		10	/* multiplexed character special	    */
75 #define	XT_MPB		11	/* multiplexed block special		    */
76 #define	XT_NSEM		12	/* XENIX named semaphore		    */
77 #define	XT_NSHD		13	/* XENIX named shared data		    */
78 #define	XT_DOOR		14	/* Solaris DOOR				    */
79 #define	XT_EVENT	15	/* UNOS Event Count			    */
80 #define	XT_WHT		16	/* BSD whiteout				    */
81 				/* ... Reserved ...			    */
82 #define	XT_DUMPDIR	20	/* Dir entry containing filenames	    */
83 #define	XT_LONGLINK	21	/* Next file on tape has a long link	    */
84 #define	XT_LONGNAME	22	/* Next file on tape has a long name	    */
85 #define	XT_MULTIVOL	23	/* Continuation of a file from another tape */
86 #define	XT_NAMES	24	/* OLD					    */
87 #define	XT_SPARSE	25	/* for files with holes in it		    */
88 #define	XT_VOLHDR	26	/* Tape Volume header			    */
89 #define	XT_META		27	/* Inode meta data only			    */
90 #define	XT_BAD		31	/* illegal file type			    */
91 
92 extern UInt8_t	iftoxt_tab[];
93 extern UInt8_t	ustoxt_tab[];
94 extern UInt8_t	vttoxt_tab[];
95 
96 extern mode_t	xttoif_tab[];
97 extern UInt8_t	xttost_tab[];
98 extern UInt8_t	xttous_tab[];
99 
100 extern UInt8_t	xtv7tar_tab[];
101 extern UInt8_t	xttar_tab[];
102 extern UInt8_t	xtstar_tab[];
103 extern UInt8_t	xtustar_tab[];
104 extern UInt8_t	xtexustar_tab[];
105 
106 extern UInt8_t	xtcpio_tab[];
107 
108 extern char	*xttostr_tab[];
109 extern char	*xttoname_tab[];
110 extern UInt8_t	xtnamelen_tab[];
111 
112 #define	IFTOXT(t)	(iftoxt_tab[((t)&S_IFMT)>>12])	/* UNIX to XT	*/
113 #define	USTOXT(t)	(ustoxt(t))			/* ustar to XT	*/
114 #define	_USTOXT(t)	(ustoxt_tab[(t)-REGTYPE])	/* ustar to XT	*/
115 #define	_VTTOXT(t)	(vttoxt_tab[(t)-'A'])		/* vendor to XT	*/
116 
117 #define	XTTOIF(t)	(xttoif_tab[(t)])		/* XT to UNIX	*/
118 #define	XTTOST(t)	(xttost_tab[(t)])		/* XT to star	*/
119 #define	XTTOUS(t)	(xttous_tab[(t)])		/* XT to ustar	*/
120 #define	XTTOSTR(t)	(xttostr_tab[(t)])		/* XT to string	*/
121 #define	XTTONAME(t)	(xttoname_tab[(t)])		/* XT to name	*/
122 
123 #endif	/* _TABLE_H */
124