xref: /illumos-gate/usr/src/uts/common/sys/fs/decomp.h (revision 1d7f3fad)
1986fd29aSsetje /*
2986fd29aSsetje  * CDDL HEADER START
3986fd29aSsetje  *
4986fd29aSsetje  * The contents of this file are subject to the terms of the
5986fd29aSsetje  * Common Development and Distribution License (the "License").
6986fd29aSsetje  * You may not use this file except in compliance with the License.
7986fd29aSsetje  *
8986fd29aSsetje  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9986fd29aSsetje  * or http://www.opensolaris.org/os/licensing.
10986fd29aSsetje  * See the License for the specific language governing permissions
11986fd29aSsetje  * and limitations under the License.
12986fd29aSsetje  *
13986fd29aSsetje  * When distributing Covered Code, include this CDDL HEADER in each
14986fd29aSsetje  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15986fd29aSsetje  * If applicable, add the following below this CDDL HEADER, with the
16986fd29aSsetje  * fields enclosed by brackets "[]" replaced with your own identifying
17986fd29aSsetje  * information: Portions Copyright [yyyy] [name of copyright owner]
18986fd29aSsetje  *
19986fd29aSsetje  * CDDL HEADER END
20986fd29aSsetje  */
21986fd29aSsetje /*
22*1d7f3fadSKrishnendu Sadhukhan - Sun Microsystems  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23986fd29aSsetje  * Use is subject to license terms.
24986fd29aSsetje  */
25986fd29aSsetje 
26986fd29aSsetje #ifndef	_SYS_DECOMP_H
27986fd29aSsetje #define	_SYS_DECOMP_H
28986fd29aSsetje 
29986fd29aSsetje #ifdef	__cplusplus
30986fd29aSsetje extern "C" {
31986fd29aSsetje #endif
32986fd29aSsetje 
33*1d7f3fadSKrishnendu Sadhukhan - Sun Microsystems #define	CH_MAGIC_ZLIB	0x5a636d70	/* ZLIB compression */
34*1d7f3fadSKrishnendu Sadhukhan - Sun Microsystems #define	CH_MAGIC_GZIP	0x8B1F		/* GZIP compression */
35986fd29aSsetje 
36986fd29aSsetje #define	CH_VERSION	1
37986fd29aSsetje 
38986fd29aSsetje #define	CH_ALG_ZLIB	1
39986fd29aSsetje 
40986fd29aSsetje struct comphdr {
41986fd29aSsetje 	uint64_t	ch_magic;
42986fd29aSsetje 	uint64_t	ch_version;
43986fd29aSsetje 	uint64_t	ch_algorithm;
44986fd29aSsetje 	uint64_t	ch_fsize;
45986fd29aSsetje 	uint64_t	ch_blksize;
46986fd29aSsetje 	uint64_t	ch_blkmap[1];
47986fd29aSsetje };
48986fd29aSsetje 
49986fd29aSsetje #define	ZMAXBUF(n)	((n) + ((n) / 1000) + 12)
50986fd29aSsetje 
51986fd29aSsetje #ifdef	_KERNEL
52986fd29aSsetje 
53986fd29aSsetje struct dcnode {
54986fd29aSsetje 	struct vnode	*dc_vp;
55986fd29aSsetje 	struct vnode	*dc_subvp;
56986fd29aSsetje 	struct kmem_cache *dc_bufcache;
57986fd29aSsetje 	kmutex_t	dc_lock;
58986fd29aSsetje 	struct dcnode	*dc_hash;
59986fd29aSsetje 	struct dcnode	*dc_lrunext;
60986fd29aSsetje 	struct dcnode	*dc_lruprev;
61986fd29aSsetje 	struct comphdr	*dc_hdr;
62986fd29aSsetje 	size_t		dc_hdrsize;
63986fd29aSsetje 	size_t		dc_zmax;
64986fd29aSsetje 	int		dc_mapcnt;
65986fd29aSsetje };
66986fd29aSsetje 
67986fd29aSsetje #define	VTODC(vp)	((struct dcnode *)(vp)->v_data)
68986fd29aSsetje #define	DCTOV(dp)	((dp)->dc_vp)
69986fd29aSsetje 
70986fd29aSsetje struct vnode	*decompvp(struct vnode *, struct cred *, caller_context_t *);
71986fd29aSsetje 
72986fd29aSsetje #endif
73986fd29aSsetje 
74986fd29aSsetje #ifdef	__cplusplus
75986fd29aSsetje }
76986fd29aSsetje #endif
77986fd29aSsetje #endif	/* _SYS_DECOMP_H */
78