xref: /titanic_44/usr/src/cmd/fs.d/cachefs/cfsd/cfsd_logelem.h (revision 56b2bdd1f04d465cfe4a95b88ae5cba5884154e4)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1994-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_CFSD_LOGELEM_H
28 #define	_CFSD_LOGELEM_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Include file for the logelem class.
34  */
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* typedefs for logelem type */
41 #define	NO_OBJECT_TYPE		0
42 #define	SETATTR_OBJECT_TYPE	1
43 #define	SETSECATTR_OBJECT_TYPE	2
44 #define	CREATE_OBJECT_TYPE	3
45 #define	REMOVE_OBJECT_TYPE	4
46 #define	RMDIR_OBJECT_TYPE	5
47 #define	MKDIR_OBJECT_TYPE	6
48 #define	LINK_OBJECT_TYPE	7
49 #define	SYMLINK_OBJECT_TYPE	8
50 #define	RENAME_OBJECT_TYPE	9
51 #define	MODIFIED_OBJECT_TYPE	10
52 #define	MAPFID_OBJECT_TYPE	11
53 
54 #define	CFSDMesgMax		4096
55 /* BEGIN CSTYLED */
56 /* defines for refrencing objects */
57 #define	SETATTR_OBJECT(ptr)		ptr->i_operation.i_setattr_object
58 #define	SETATTR_OBJECT_PTR(ptr)		&(ptr->i_operation.i_setattr_object)
59 #define	SETSECATTR_OBJECT(ptr)		ptr->i_operation.i_setsecattr_object
60 #define	SETSECATTR_OBJECT_PTR(ptr)	&(ptr->i_operation.i_setsecattr_object)
61 #define	CREATE_OBJECT(ptr)		ptr->i_operation.i_create_object
62 #define	CREATE_OBJECT_PTR(ptr)		&(ptr->i_operation.i_create_object)
63 #define	REMOVE_OBJECT(ptr)		ptr->i_operation.i_remove_object
64 #define	REMOVE_OBJECT_PTR(ptr)		&(ptr->i_operation.i_remove_object)
65 #define	RMDIR_OBJECT(ptr)		ptr->i_operation.i_rmdir_object
66 #define	RMDIR_OBJECT_PTR(ptr)		&(ptr->i_operation.i_rmdir_object)
67 #define	MKDIR_OBJECT(ptr)		ptr->i_operation.i_mkdir_object
68 #define	MKDIR_OBJECT_PTR(ptr)		&(ptr->i_operation.i_mkdir_object)
69 #define	LINK_OBJECT(ptr)		ptr->i_operation.i_link_object
70 #define	LINK_OBJECT_PTR(ptr)		&(ptr->i_operation.i_link_object)
71 #define	SYMLINK_OBJECT(ptr)		ptr->i_operation.i_symlink_object
72 #define	SYMLINK_OBJECT_PTR(ptr)		&(ptr->i_operation.i_symlink_object)
73 #define	RENAME_OBJECT(ptr)		ptr->i_operation.i_rename_object
74 #define	RENAME_OBJECT_PTR(ptr)		&(ptr->i_operation.i_rename_object)
75 #define	MODIFIED_OBJECT(ptr)		ptr->i_operation.i_modified_object
76 #define	MODIFIED_OBJECT_PTR(ptr)	&(ptr->i_operation.i_modified_object)
77 #define	MAPFID_OBJECT(ptr)		ptr->i_operation.i_mapfid_object
78 #define	MAPFID_OBJECT_PTR(ptr)		&(ptr->i_operation.i_mapfid_object)
79 /* END CSTYLED */
80 
81 /* setattr */
82 typedef struct cfsd_logelem_setattr_object {
83 	struct cfs_dlog_setattr	*i_up;
84 } cfsd_logelem_setattr_object_t;
85 
86 /* setsecattr */
87 typedef struct cfsd_logelem_setsecattr_oject {
88 	struct cfs_dlog_setsecattr	*i_up;
89 	const aclent_t			*i_acl;
90 } cfsd_logelem_setsecattr_object_t;
91 
92 /* create */
93 typedef struct cfsd_logelem_create_object {
94 	struct cfs_dlog_create	*i_up;
95 	const char		*i_namep;	/* name of file to create */
96 } cfsd_logelem_create_object_t;
97 
98 /* remove */
99 typedef struct cfsd_logelem_remove_object {
100 	struct cfs_dlog_remove	*i_up;
101 	const char		*i_namep;	/* name of file to remove */
102 } cfsd_logelem_remove_object_t;
103 
104 /* rmdir */
105 typedef struct cfsd_logelem_rmdir_object {
106 	struct cfs_dlog_rmdir	*i_up;
107 	const char		*i_namep;	/* name of dir to rmdir */
108 } cfsd_logelem_rmdir_object_t;
109 
110 /* mkdir */
111 typedef struct cfsd_logelem_mkdir_object {
112 	struct cfs_dlog_mkdir	*i_up;
113 	const char		*i_namep;	/* name of dir to mkdir */
114 } cfsd_logelem_mkdir_object_t;
115 
116 /* link */
117 typedef struct cfsd_logelem_link_object {
118 	struct cfs_dlog_link	*i_up;
119 	const char		*i_namep;	/* name of link */
120 } cfsd_logelem_link_object_t;
121 
122 /* symlink */
123 typedef struct cfsd_logelem_symlink_object {
124 	struct cfs_dlog_symlink	*i_up;
125 	const char		*i_namep;	/* name of symlink */
126 	const char		*i_contentsp;	/* contents of symlink */
127 } cfsd_logelem_symlink_object_t;
128 
129 /* rename */
130 typedef struct cfsd_logelem_rename_object {
131 	struct cfs_dlog_rename	*i_up;
132 	const char		*i_orignamep;	/* original name */
133 	const char		*i_newnamep;	/* new name */
134 } cfsd_logelem_rename_object_t;
135 
136 /* modify */
137 typedef struct cfsd_logelem_modified_object {
138 	struct cfs_dlog_modify	*i_up;
139 } cfsd_logelem_modified_object_t;
140 
141 /* mapfid */
142 typedef struct cfsd_logelem_mapfid_object {
143 	struct cfs_dlog_mapfid	*i_up;
144 } cfsd_logelem_mapfid_object_t;
145 
146 /* Abstract base class used by the other logelem classes. */
147 #define	LOGELM_FIDBUFLEN	1024
148 typedef struct cfsd_logelem_object {
149 
150 	cfsd_maptbl_object_t	*i_maptbl_object_p;
151 	cfsd_logfile_object_t	*i_logfile_object_p;
152 	cfsd_kmod_object_t	*i_kmod_object_p;
153 	char			 i_messagep[CFSDMesgMax];	/* message */
154 	char			 i_fidbuf[LOGELM_FIDBUFLEN];	/* debugging */
155 	cfs_dlog_entry_t	*i_entp;
156 	off_t			 i_offset;
157 	int			 i_type;
158 	union {
159 		cfsd_logelem_setattr_object_t	i_setattr_object;
160 		cfsd_logelem_setsecattr_object_t	i_setsecattr_object;
161 		cfsd_logelem_create_object_t	i_create_object;
162 		cfsd_logelem_remove_object_t	i_remove_object;
163 		cfsd_logelem_rmdir_object_t	i_rmdir_object;
164 		cfsd_logelem_mkdir_object_t	i_mkdir_object;
165 		cfsd_logelem_link_object_t	i_link_object;
166 		cfsd_logelem_symlink_object_t	i_symlink_object;
167 		cfsd_logelem_rename_object_t	i_rename_object;
168 		cfsd_logelem_modified_object_t	i_modified_object;
169 		cfsd_logelem_mapfid_object_t	i_mapfid_object;
170 	}i_operation;
171 }cfsd_logelem_object_t;
172 
173 cfsd_logelem_object_t *cfsd_logelem_create(
174     cfsd_maptbl_object_t *maptbl_object_p,
175     cfsd_logfile_object_t *logfile_object_p,
176     cfsd_kmod_object_t *kmod_object_p);
177 void cfsd_logelem_destroy(cfsd_logelem_object_t *logelem_object_p);
178 void logelem_print_cred(dl_cred_t *credp);
179 void logelem_print_attr(vattr_t *vp);
180 void logelem_format_fid(cfsd_logelem_object_t *logelem_object_p, fid_t *fidp);
181 int logelem_lostfound(cfsd_logelem_object_t *logelem_object_p,
182     cfs_cid_t *cidp,
183     cfs_cid_t *pcidp,
184     const char *namep,
185     dl_cred_t *cred);
186 void logelem_problem(cfsd_logelem_object_t *logelem_object_p,
187 	char *strp);
188 void logelem_resolution(cfsd_logelem_object_t *logelem_object_p,
189 	char *strp);
190 void logelem_message_append(char *strp1, char *strp2);
191 void logelem_message(cfsd_logelem_object_t *logelem_object_p,
192 	char *prefix, char *strp);
193 void logelem_log_opfailed(cfsd_logelem_object_t *logelem_object_p,
194 	char *opp, char *info, const char *namep, int xx);
195 void logelem_log_opskipped(cfsd_logelem_object_t *logelem_object_p,
196 	const char *namep);
197 void logelem_log_timelogmesg(cfsd_logelem_object_t *logelem_object_p,
198 	char *opp, const char *namep, char *mesgp, int time_log);
199 
200 
201 cfsd_logelem_object_t *cfsd_logelem_setattr_create(
202     cfsd_maptbl_object_t *maptbl_object_p,
203     cfsd_logfile_object_t *logfile_object_p,
204     cfsd_kmod_object_t *kmod_object_p);
205 
206 cfsd_logelem_object_t *cfsd_logelem_setsecattr_create(
207     cfsd_maptbl_object_t *maptbl_object_p,
208     cfsd_logfile_object_t *logfile_object_p,
209     cfsd_kmod_object_t *kmod_object_p);
210 
211 cfsd_logelem_object_t *cfsd_logelem_create_create(
212     cfsd_maptbl_object_t *maptbl_object_p,
213     cfsd_logfile_object_t *logfile_object_p,
214     cfsd_kmod_object_t *kmod_object_p);
215 
216 cfsd_logelem_object_t *cfsd_logelem_remove_create(
217     cfsd_maptbl_object_t *maptbl_object_p,
218     cfsd_logfile_object_t *logfile_object_p,
219     cfsd_kmod_object_t *kmod_object_p);
220 
221 cfsd_logelem_object_t *cfsd_logelem_rmdir_create(
222     cfsd_maptbl_object_t *maptbl_object_p,
223     cfsd_logfile_object_t *logfile_object_p,
224     cfsd_kmod_object_t *kmod_object_p);
225 
226 cfsd_logelem_object_t *cfsd_logelem_mkdir_create(
227     cfsd_maptbl_object_t *maptbl_object_p,
228     cfsd_logfile_object_t *logfile_object_p,
229     cfsd_kmod_object_t *kmod_object_p);
230 
231 cfsd_logelem_object_t *cfsd_logelem_link_create(
232     cfsd_maptbl_object_t *maptbl_object_p,
233     cfsd_logfile_object_t *logfile_object_p,
234     cfsd_kmod_object_t *kmod_object_p);
235 
236 cfsd_logelem_object_t *cfsd_logelem_symlink_create(
237     cfsd_maptbl_object_t *maptbl_object_p,
238     cfsd_logfile_object_t *logfile_object_p,
239     cfsd_kmod_object_t *kmod_object_p);
240 
241 cfsd_logelem_object_t *cfsd_logelem_rename_create(
242     cfsd_maptbl_object_t *maptbl_object_p,
243     cfsd_logfile_object_t *logfile_object_p,
244     cfsd_kmod_object_t *kmod_object_p);
245 
246 cfsd_logelem_object_t *cfsd_logelem_modified_create(
247     cfsd_maptbl_object_t *maptbl_object_p,
248     cfsd_logfile_object_t *logfile_object_p,
249     cfsd_kmod_object_t *kmod_object_p);
250 
251 cfsd_logelem_object_t *cfsd_logelem_mapfid_create(
252     cfsd_maptbl_object_t *maptbl_object_p,
253     cfsd_logfile_object_t *logfile_object_p,
254     cfsd_kmod_object_t *kmod_object_p);
255 
256 int logelem_roll(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp);
257 
258 int logelem_roll_setattr(cfsd_logelem_object_t *logelem_object_p,
259     ulong_t *seqp);
260 int logelem_roll_setsecattr(cfsd_logelem_object_t *logelem_object_p,
261     ulong_t *seqp);
262 int logelem_roll_create(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp);
263 int logelem_roll_remove(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp);
264 int logelem_roll_rmdir(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp);
265 int logelem_roll_mkdir(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp);
266 int logelem_roll_link(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp);
267 int logelem_roll_symlink(cfsd_logelem_object_t *logelem_object_p,
268     ulong_t *seqp);
269 int logelem_roll_rename(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp);
270 int logelem_roll_modified(cfsd_logelem_object_t *logelem_object_p,
271     ulong_t *seqp);
272 int logelem_roll_mapfid(cfsd_logelem_object_t *logelem_object_p);
273 
274 void logelem_dump(cfsd_logelem_object_t *logelem_object_p);
275 void logelem_dump_setattr(cfsd_logelem_object_t *logelem_object_p);
276 void logelem_dump_setsecattr(cfsd_logelem_object_t *logelem_object_p);
277 void logelem_dump_create(cfsd_logelem_object_t *logelem_object_p);
278 void logelem_dump_remove(cfsd_logelem_object_t *logelem_object_p);
279 void logelem_dump_rmdir(cfsd_logelem_object_t *logelem_object_p);
280 void logelem_dump_mkdir(cfsd_logelem_object_t *logelem_object_p);
281 void logelem_dump_link(cfsd_logelem_object_t *logelem_object_p);
282 void logelem_dump_symlink(cfsd_logelem_object_t *logelem_object_p);
283 void logelem_dump_rename(cfsd_logelem_object_t *logelem_object_p);
284 void logelem_dump_modified(cfsd_logelem_object_t *logelem_object_p);
285 void logelem_dump_mapfid(cfsd_logelem_object_t *logelem_object_p);
286 
287 #ifdef __cplusplus
288 }
289 #endif
290 
291 #endif /* _CFSD_LOGELEM_H */
292