xref: /illumos-gate/usr/src/uts/common/fs/fs_reparse.h (revision 7a286c471efbab8562f7655a82931904703fffe0)
1*7a286c47SDai Ngo /*
2*7a286c47SDai Ngo  * CDDL HEADER START
3*7a286c47SDai Ngo  *
4*7a286c47SDai Ngo  * The contents of this file are subject to the terms of the
5*7a286c47SDai Ngo  * Common Development and Distribution License (the "License").
6*7a286c47SDai Ngo  * You may not use this file except in compliance with the License.
7*7a286c47SDai Ngo  *
8*7a286c47SDai Ngo  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7a286c47SDai Ngo  * or http://www.opensolaris.org/os/licensing.
10*7a286c47SDai Ngo  * See the License for the specific language governing permissions
11*7a286c47SDai Ngo  * and limitations under the License.
12*7a286c47SDai Ngo  *
13*7a286c47SDai Ngo  * When distributing Covered Code, include this CDDL HEADER in each
14*7a286c47SDai Ngo  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7a286c47SDai Ngo  * If applicable, add the following below this CDDL HEADER, with the
16*7a286c47SDai Ngo  * fields enclosed by brackets "[]" replaced with your own identifying
17*7a286c47SDai Ngo  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7a286c47SDai Ngo  *
19*7a286c47SDai Ngo  * CDDL HEADER END
20*7a286c47SDai Ngo  */
21*7a286c47SDai Ngo /*
22*7a286c47SDai Ngo  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23*7a286c47SDai Ngo  * Use is subject to license terms.
24*7a286c47SDai Ngo  */
25*7a286c47SDai Ngo 
26*7a286c47SDai Ngo #ifndef _FS_REPARSE_H
27*7a286c47SDai Ngo #define	_FS_REPARSE_H
28*7a286c47SDai Ngo 
29*7a286c47SDai Ngo #ifdef __cplusplus
30*7a286c47SDai Ngo extern "C" {
31*7a286c47SDai Ngo #endif
32*7a286c47SDai Ngo 
33*7a286c47SDai Ngo #include <sys/types.h>
34*7a286c47SDai Ngo #include <sys/param.h>
35*7a286c47SDai Ngo #ifdef _KERNEL
36*7a286c47SDai Ngo #include <sys/time.h>
37*7a286c47SDai Ngo #include <sys/nvpair.h>
38*7a286c47SDai Ngo #else
39*7a286c47SDai Ngo #include <libnvpair.h>
40*7a286c47SDai Ngo #endif
41*7a286c47SDai Ngo 
42*7a286c47SDai Ngo #define	FS_REPARSE_TAG_STR		"@{REPARSE"
43*7a286c47SDai Ngo #define	FS_REPARSE_TAG_END_CHAR		'}'
44*7a286c47SDai Ngo #define	FS_REPARSE_TAG_END_STR		"}"
45*7a286c47SDai Ngo #define	FS_TOKEN_START_STR		"@{"
46*7a286c47SDai Ngo #define	FS_TOKEN_END_STR		"}"
47*7a286c47SDai Ngo 
48*7a286c47SDai Ngo #define	REPARSED			"svc:/system/filesystem/reparse:default"
49*7a286c47SDai Ngo #define	MAXREPARSELEN			MAXPATHLEN
50*7a286c47SDai Ngo #define	REPARSED_DOOR			"/var/run/reparsed_door"
51*7a286c47SDai Ngo #define	REPARSED_DOORCALL_MAX_RETRY	4
52*7a286c47SDai Ngo 
53*7a286c47SDai Ngo /*
54*7a286c47SDai Ngo  * This structure is shared between kernel code and user reparsed daemon.
55*7a286c47SDai Ngo  * The 'res_len' must be defined as int, and not size_t, for 32-bit reparsed
56*7a286c47SDai Ngo  * binary and 64-bit kernel code to work together.
57*7a286c47SDai Ngo  */
58*7a286c47SDai Ngo typedef struct reparsed_door_res {
59*7a286c47SDai Ngo 	int	res_status;
60*7a286c47SDai Ngo 	int	res_len;
61*7a286c47SDai Ngo 	char	res_data[1];
62*7a286c47SDai Ngo } reparsed_door_res_t;
63*7a286c47SDai Ngo 
64*7a286c47SDai Ngo extern nvlist_t *reparse_init(void);
65*7a286c47SDai Ngo extern void reparse_free(nvlist_t *nvl);
66*7a286c47SDai Ngo extern int reparse_parse(const char *reparse_data, nvlist_t *nvl);
67*7a286c47SDai Ngo extern int reparse_validate(const char *reparse_data);
68*7a286c47SDai Ngo 
69*7a286c47SDai Ngo #ifdef _KERNEL
70*7a286c47SDai Ngo extern int reparse_kderef(const char *svc_type, const char *svc_data,
71*7a286c47SDai Ngo 			char *buf, size_t *bufsz);
72*7a286c47SDai Ngo extern int reparse_vnode_parse(vnode_t *vp, nvlist_t *nvl);
73*7a286c47SDai Ngo #else
74*7a286c47SDai Ngo extern int reparse_add(nvlist_t *nvl, const char *svc_type,
75*7a286c47SDai Ngo 			const char *svc_data);
76*7a286c47SDai Ngo extern int reparse_remove(nvlist_t *nvl, const char *svc_type);
77*7a286c47SDai Ngo extern int reparse_unparse(nvlist_t *nvl, char **stringp);
78*7a286c47SDai Ngo extern int reparse_create(const char *path, const char *string);
79*7a286c47SDai Ngo extern int reparse_delete(const char *path);
80*7a286c47SDai Ngo extern int reparse_deref(const char *svc_type, const char *svc_data,
81*7a286c47SDai Ngo 			char *buf, size_t *bufsz);
82*7a286c47SDai Ngo #endif
83*7a286c47SDai Ngo 
84*7a286c47SDai Ngo #ifdef __cplusplus
85*7a286c47SDai Ngo }
86*7a286c47SDai Ngo #endif
87*7a286c47SDai Ngo 
88*7a286c47SDai Ngo #endif	/* _FS_REPARSE_H */
89