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