xref: /illumos-gate/usr/src/uts/common/sys/fs/hsfs_susp.h (revision 2d6eb4a5)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*d10b6702Sfrankho  * Common Development and Distribution License (the "License").
6*d10b6702Sfrankho  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
227c478bd9Sstevel@tonic-gate  * ISO 9660 RRIP extension filesystem specifications
23*d10b6702Sfrankho  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24*d10b6702Sfrankho  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_FS_HSFS_SUSP_H
287c478bd9Sstevel@tonic-gate #define	_SYS_FS_HSFS_SUSP_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
317c478bd9Sstevel@tonic-gate extern "C" {
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #define	DEBUGGING_ALL	0
357c478bd9Sstevel@tonic-gate #define	DEBUGGING	0
367c478bd9Sstevel@tonic-gate #define	DPRINTF		if (DEBUGGING) printf
377c478bd9Sstevel@tonic-gate #define	DPRINTF_ALL	if (DEBUGGING_ALL) printf
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * 	return values from SUA parsing
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate #define	SUA_NULL_POINTER	-1
437c478bd9Sstevel@tonic-gate #define	END_OF_SUA_PARSING	-2
447c478bd9Sstevel@tonic-gate #define	END_OF_SUA		-3
457c478bd9Sstevel@tonic-gate #define	GET_CONTINUATION	-4
467c478bd9Sstevel@tonic-gate #define	SUA_ENOMEM		-5
477c478bd9Sstevel@tonic-gate #define	SUA_EINVAL		-6
487c478bd9Sstevel@tonic-gate #define	RELOC_DIR		-7	/* actually for rrip */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /*
517c478bd9Sstevel@tonic-gate  * For dealing with implemented bits...
527c478bd9Sstevel@tonic-gate  *    These here expect the fsp and a bit as an agument
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate #define	SET_IMPL_BIT(fsp, y)	((fsp->hsfs_ext_impl)  |= (0x01L) << (y))
557c478bd9Sstevel@tonic-gate #define	UNSET_IMPL_BIT(fsp, y)	((fsp->hsfs_ext_impl)  &= ~((0x01L) << (y)))
567c478bd9Sstevel@tonic-gate #define	IS_IMPL_BIT_SET(fsp, y)	((fsp->hsfs_ext_impl)  & ((0x01L) << (y)))
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #define	HAVE_SUSP		0	/* have a SUSP */
597c478bd9Sstevel@tonic-gate #define	HAVE_PROHIBITED		1	/* prohibited file/dir type in fs */
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  * For dealing with implemented bits...
637c478bd9Sstevel@tonic-gate  *    These here expect just the fsp->hsfs_ext_impl
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate #define	SET_SUSP_BIT(fsp)	(SET_IMPL_BIT((fsp), HAVE_SUSP))
667c478bd9Sstevel@tonic-gate #define	UNSET_SUSP_BIT(fsp)	(UNSET_IMPL_BIT((fsp), HAVE_SUSP))
677c478bd9Sstevel@tonic-gate #define	IS_SUSP_IMPLEMENTED(fsp) (IS_IMPL_BIT_SET(fsp, 0) ? 1 : 0)
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #define	SUSP_VERSION	1
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /*
727c478bd9Sstevel@tonic-gate  * SUSP signagure definitions
737c478bd9Sstevel@tonic-gate  */
747c478bd9Sstevel@tonic-gate #define	SUSP_SP		"SP"
757c478bd9Sstevel@tonic-gate #define	SUSP_CE		"CE"
767c478bd9Sstevel@tonic-gate #define	SUSP_PD		"PD"
777c478bd9Sstevel@tonic-gate #define	SUSP_ER		"ER"
787c478bd9Sstevel@tonic-gate #define	SUSP_ST		"ST"
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /*
817c478bd9Sstevel@tonic-gate  * 	Generic System Use Field (SUF) Macros and declarations
827c478bd9Sstevel@tonic-gate  */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate #define	SUF_SIG_LEN	2			/* length of signatures */
857c478bd9Sstevel@tonic-gate #define	SUF_MIN_LEN	4			/* minimum length of a */
867c478bd9Sstevel@tonic-gate 						/* 	signature field */
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate #define	SUF_LEN(x)	*(SUF_len(x))		/* SUF length */
897c478bd9Sstevel@tonic-gate #define	SUF_len(x)	(&((uchar_t *)x)[2])	/* SUF length */
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate #define	SUF_VER(x)	*(SUF_ver(x))		/* SUF version */
927c478bd9Sstevel@tonic-gate #define	SUF_ver(x)	(&((uchar_t *)x)[3])	/* SUF version */
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * Extension Reference Macros
967c478bd9Sstevel@tonic-gate  */
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate #define	ER_ID_LEN(x)	*(ER_id_len(x))	/* Extension ref id length */
997c478bd9Sstevel@tonic-gate #define	ER_id_len(x)	(&((uchar_t *)x)[4])	/* Extension ref id length */
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate #define	ER_DES_LEN(x)	*(ER_des_len(x))	/* Extension ref description */
1037c478bd9Sstevel@tonic-gate 						/* 	length */
1047c478bd9Sstevel@tonic-gate #define	ER_des_len(x)	(&((uchar_t *)x)[5])	/* Extension ref description */
1057c478bd9Sstevel@tonic-gate 						/* 	length */
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate #define	ER_SRC_LEN(x)	*(ER_src_len(x))	/* Extension ref source */
1087c478bd9Sstevel@tonic-gate 						/* 	description length */
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #define	ER_src_len(x)	(&((uchar_t *)x)[6])	/* Extension ref source */
1117c478bd9Sstevel@tonic-gate 						/* description length */
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate #define	ER_EXT_VER(x)	*(ER_ext_ver(x))	/* Extension ref description */
1157c478bd9Sstevel@tonic-gate 						/*  length */
1167c478bd9Sstevel@tonic-gate #define	ER_ext_ver(x)	(&((uchar_t *)x)[7])	/* Extension ref description */
1177c478bd9Sstevel@tonic-gate 						/* length */
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate #define	ER_EXT_ID_LOC	8			/* location where the ER id */
1207c478bd9Sstevel@tonic-gate 						/* string begins */
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #define	ER_ext_id(x)	(&((uchar_t *)x)[ER_EXT_ID_LOC])
1237c478bd9Sstevel@tonic-gate 						/* extension id string */
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate #define	ER_ext_des(x)	(&((uchar_t *)x)[ER_EXT_ID_LOC + ER_ID_LEN(x)])
1267c478bd9Sstevel@tonic-gate 						/* ext. description string */
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate #define	ER_ext_src(x)	(&((uchar_t *)x)[ER_EXT_ID_LOC + ER_ID_LEN(x) + \
1297c478bd9Sstevel@tonic-gate 					ER_DES_LEN(x)])
1307c478bd9Sstevel@tonic-gate 						/* ext. source string */
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate /*
1347c478bd9Sstevel@tonic-gate  * Continuation Area Macros
1357c478bd9Sstevel@tonic-gate  */
1367c478bd9Sstevel@tonic-gate #define	CE_BLK_LOC(x)	BOTH_INT(CE_blk_loc(x))	/* cont. starting block */
1377c478bd9Sstevel@tonic-gate #define	CE_blk_loc(x)	(&((uchar_t *)x)[4])	/* cont. starting block */
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate #define	CE_OFFSET(x)	BOTH_INT(CE_offset(x))	/* cont. offset */
1407c478bd9Sstevel@tonic-gate #define	CE_offset(x)	(&((uchar_t *)x)[12])	/* cont. offset */
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #define	CE_CONT_LEN(x)	BOTH_INT(CE_cont_len(x))	/* continuation len */
1437c478bd9Sstevel@tonic-gate #define	CE_cont_len(x)	(&((uchar_t *)x)[20])	/* continuation len */
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate /*
1477c478bd9Sstevel@tonic-gate  * Sharing Protocol (SP) Macros
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate #define	SP_CHK_BYTE_1(x)	*(SP_chk_byte_1(x))	/* check bytes */
1507c478bd9Sstevel@tonic-gate #define	SP_chk_byte_1(x)	(&((uchar_t *)x)[4])	/* check bytes */
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate #define	SP_CHK_BYTE_2(x)	*(SP_chk_byte_2(x))	/* check bytes */
1537c478bd9Sstevel@tonic-gate #define	SP_chk_byte_2(x)	(&((uchar_t *)x)[5])	/* check bytes */
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate #define	SUSP_CHECK_BYTE_1	(uchar_t)0xBE		/* check for 0xBE */
1567c478bd9Sstevel@tonic-gate #define	SUSP_CHECK_BYTE_2	(uchar_t)0xEF		/* check for 0xEF */
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate #define	CHECK_BYTES_OK(x)	((SP_CHK_BYTE_1(x) == SUSP_CHECK_BYTE_1) && \
1597c478bd9Sstevel@tonic-gate 				(SP_CHK_BYTE_2(x) == SUSP_CHECK_BYTE_2))
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #define	SP_SUA_OFFSET(x)	*(SP_sua_offset(x))	/* SUA bytes to skip */
1627c478bd9Sstevel@tonic-gate #define	SP_sua_offset(x)	(&((uchar_t *)x)[6])	/* SUA bytes to skip */
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate /*
1677c478bd9Sstevel@tonic-gate  * Forward declarations
1687c478bd9Sstevel@tonic-gate  */
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate #ifdef _KERNEL
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate extern uchar_t *share_protocol();
1737c478bd9Sstevel@tonic-gate extern uchar_t *share_ext_ref();
1747c478bd9Sstevel@tonic-gate extern uchar_t *share_continue();
1757c478bd9Sstevel@tonic-gate extern uchar_t *share_padding();
1767c478bd9Sstevel@tonic-gate extern uchar_t *share_stop();
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate #endif
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate /*
1817c478bd9Sstevel@tonic-gate  * Extension signature structure, to corrolate the handler functions
1827c478bd9Sstevel@tonic-gate  * with the signatures
1837c478bd9Sstevel@tonic-gate  */
1847c478bd9Sstevel@tonic-gate struct extension_signature_struct {
1857c478bd9Sstevel@tonic-gate 	char	*ext_signature;		/* extension signature */
1867c478bd9Sstevel@tonic-gate 	uchar_t	*(*sig_handler)();	/* extension handler function */
1877c478bd9Sstevel@tonic-gate };
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate typedef	struct extension_signature_struct	ext_signature_t;
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate /*
1937c478bd9Sstevel@tonic-gate  * Extension name structure, to corrolate the extensions with their own
1947c478bd9Sstevel@tonic-gate  * 	signature tables.
1957c478bd9Sstevel@tonic-gate  */
1967c478bd9Sstevel@tonic-gate struct extension_name_struct {
1977c478bd9Sstevel@tonic-gate 	char  		*extension_name;	/* ER field identifier */
1987c478bd9Sstevel@tonic-gate 	ushort_t	ext_version;		/* version # of extensions */
1997c478bd9Sstevel@tonic-gate 	ext_signature_t	*signature_table;	/* pointer to signature */
2007c478bd9Sstevel@tonic-gate 						/*   table for appropriate */
2017c478bd9Sstevel@tonic-gate 						/*   extension */
2027c478bd9Sstevel@tonic-gate };
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate typedef	struct extension_name_struct extension_name_t;
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate /*
2077c478bd9Sstevel@tonic-gate  * Extern declaration for all supported extensions
2087c478bd9Sstevel@tonic-gate  */
2097c478bd9Sstevel@tonic-gate struct	cont_info_struct	{
2107c478bd9Sstevel@tonic-gate 	uint_t	cont_lbn;	/* location  of cont */
2117c478bd9Sstevel@tonic-gate 	uint_t	cont_offset;	/* offset into cont */
2127c478bd9Sstevel@tonic-gate 	uint_t	cont_len;	/* len of cont */
2137c478bd9Sstevel@tonic-gate };
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate typedef struct cont_info_struct	cont_info_t;
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate /*
2187c478bd9Sstevel@tonic-gate  * Structure for passing arguments to sig_handler()'s.  Since there are
2197c478bd9Sstevel@tonic-gate  * so many sig_handler()'s, it would be slower to pass multiple
2207c478bd9Sstevel@tonic-gate  * arguments to all of them. It would also ease maintainance
2217c478bd9Sstevel@tonic-gate  */
2227c478bd9Sstevel@tonic-gate struct sig_args_struct {
2237c478bd9Sstevel@tonic-gate 	uchar_t			*dirp;		/* pointer to ISO dir entry */
2247c478bd9Sstevel@tonic-gate 	uchar_t			*name_p;	/* dir entry name */
2257c478bd9Sstevel@tonic-gate 	int			*name_len_p;	/* dir entry name length */
2267c478bd9Sstevel@tonic-gate 	short			flags;		/* misc flags */
2277c478bd9Sstevel@tonic-gate 	ulong_t			name_flags;		/* misc flags */
2287c478bd9Sstevel@tonic-gate 	uchar_t			*SUF_ptr;	/* pointer to current SUF */
2297c478bd9Sstevel@tonic-gate 	struct hs_direntry	*hdp;		/* directory entry  */
2307c478bd9Sstevel@tonic-gate 	struct hsfs		*fsp;		/* file system  */
2317c478bd9Sstevel@tonic-gate 	cont_info_t		*cont_info_p;	/* continuation area */
2327c478bd9Sstevel@tonic-gate };
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate typedef struct sig_args_struct	sig_args_t;
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate /*
2387c478bd9Sstevel@tonic-gate  * Extern declaration for all supported extensions
2397c478bd9Sstevel@tonic-gate  */
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate #ifdef _KERNEL
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate extern ext_signature_t		rrip_signature_table[];
2447c478bd9Sstevel@tonic-gate extern ext_signature_t		susp_signature_table[];
2457c478bd9Sstevel@tonic-gate extern extension_name_t		extension_name_table[];
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate extern ext_signature_t		*susp_sp;
2487c478bd9Sstevel@tonic-gate 
249*d10b6702Sfrankho extern int parse_sua(uchar_t *, int *name_len_p, int *, uchar_t *, uint_t,
250*d10b6702Sfrankho 	struct hs_direntry *,	struct hsfs *,	uchar_t	*, int search_num);
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2557c478bd9Sstevel@tonic-gate }
2567c478bd9Sstevel@tonic-gate #endif
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate #endif	/* _SYS_FS_HSFS_SUSP_H */
259