xref: /titanic_44/usr/src/cmd/fs.d/nfs/lib/smfcfg.h (revision e47aa97b65b6eaa7016357de7fb7974c1982858c)
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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef	_SMFCFG_H
26 #define	_SMFCFG_H
27 
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <syslog.h>
31 #include <stdarg.h>
32 #include <rpc/rpc.h>
33 #include <synch.h>
34 #include <thread.h>
35 #include <libintl.h>
36 #include <strings.h>
37 #include <inttypes.h>
38 #include <limits.h>
39 #include <assert.h>
40 #include <libscf.h>
41 #include <libshare.h>
42 #include <locale.h>
43 #include <errno.h>
44 #include <sys/types.h>
45 
46 #ifdef	__cplusplus
47 extern	"C" {
48 #endif
49 
50 typedef enum {
51 	NFS_SMF = 1,
52 	AUTOFS_SMF
53 } smf_fstype_t;
54 
55 typedef struct fs_smfhandle {
56 	scf_handle_t		*fs_handle;
57 	scf_service_t		*fs_service;
58 	scf_scope_t		*fs_scope;
59 	scf_instance_t		*fs_instance;
60 	scf_propertygroup_t	*fs_pg;
61 	scf_property_t		*fs_property;
62 	scf_value_t		*fs_value;
63 } fs_smfhandle_t;
64 
65 #define	DEFAULT_INSTANCE	"default"
66 
67 /*
68  * NFS Property Group names.
69  */
70 #define	SMF_PG_NFSPROPS		((const char *)"com.oracle.nfs,props")
71 #define	NFS_PROPS_PGNAME	((const char *)"nfs-props")
72 #define	SVC_NFS_CLIENT		"svc:/network/nfs/client"
73 
74 /*
75  * AUTOFS Property Group Names.
76  */
77 #define	SMF_PG_AUTOFS		((const char *)"com.oracle.autofs,props")
78 #define	AUTOFS_PROPS_PGNAME	((const char *)"autofs-props")
79 
80 #define	AUTOFS_FMRI		"svc:/system/filesystem/autofs"
81 #define	AUTOFS_DEFAULT_FMRI	"svc:/system/filesystem/autofs:default"
82 #define	MAXDIGITS	32
83 
84 /*
85  * ERRORS
86  */
87 #define	SMF_OK			0
88 #define	SMF_SYSTEM_ERR		-1
89 #define	STATE_INITIALIZING	1
90 #define	SMF_NO_PERMISSION	2
91 #define	SMF_NO_PGTYPE		3
92 
93 extern int nfs_smf_get_iprop(char *, int *, char *, scf_type_t, char *);
94 extern int nfs_smf_get_prop(char *, char *, char *, scf_type_t, char *, int *);
95 extern int fs_smf_get_prop(smf_fstype_t,  char *, char *, char *, scf_type_t,
96 	char *, int *);
97 extern int nfs_smf_set_prop(char *, char *, char *, scf_type_t, char *);
98 extern int fs_smf_set_prop(smf_fstype_t, char *, char *,
99     char *, scf_type_t, char *);
100 extern int autofs_smf_set_prop(char *, char *, char *, scf_type_t, char *);
101 extern int autofs_smf_get_prop(char *, char *, char *, scf_type_t,
102     char *, int *);
103 extern void fs_smf_fini(fs_smfhandle_t *);
104 extern boolean_t string_to_boolean(const char *);
105 
106 #ifdef	__cplusplus
107 }
108 #endif
109 
110 #endif	/* _SMFCFG_H */
111