xref: /titanic_41/usr/src/uts/common/sys/fs/cachefs_ioctl.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 1996-1998,2001-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_FS_CACHEFS_IOCTL_H
28 #define	_SYS_FS_CACHEFS_IOCTL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /* set of subcommands to CACHEFSIO_DCMD */
37 enum cfsdcmd_cmds {
38 	CFSDCMD_DAEMONID, CFSDCMD_STATEGET, CFSDCMD_STATESET,
39 	CFSDCMD_XWAIT, CFSDCMD_EXISTS, CFSDCMD_LOSTFOUND, CFSDCMD_GETINFO,
40 	CFSDCMD_CIDTOFID, CFSDCMD_GETATTRFID, CFSDCMD_GETATTRNAME,
41 	CFSDCMD_GETSTATS, CFSDCMD_ROOTFID,
42 	CFSDCMD_CREATE, CFSDCMD_REMOVE, CFSDCMD_LINK, CFSDCMD_RENAME,
43 	CFSDCMD_MKDIR, CFSDCMD_RMDIR, CFSDCMD_SYMLINK, CFSDCMD_SETATTR,
44 	CFSDCMD_SETSECATTR, CFSDCMD_PUSHBACK
45 };
46 typedef enum cfsdcmd_cmds cfsdcmd_cmds_t;
47 
48 /* file system states passed to stateset, returned from stateget */
49 #define	CFS_FS_CONNECTED	0x00	/* fscache connected to backfs */
50 #define	CFS_FS_DISCONNECTED	0x01	/* fscache disconnected from backfs */
51 #define	CFS_FS_RECONNECTING	0x02	/* fscache is reconnecting to backfs */
52 
53 /* bits returned by packinfo */
54 #define	CACHEFS_PACKED_FILE	1	/* file is marked as packed */
55 #define	CACHEFS_PACKED_DATA	2	/* file data is in the cache */
56 #define	CACHEFS_PACKED_NOCACHE	4	/* file marked as not for caching */
57 
58 struct cachefsio_pack {
59 	char		p_name[MAXNAMELEN];	/* name of file */
60 	int		p_status;		/* status of operation */
61 };
62 typedef struct cachefsio_pack cachefsio_pack_t;
63 
64 struct cachefsio_dcmd {
65 	cfsdcmd_cmds_t	 d_cmd;			/* cmd to execute */
66 	void		*d_sdata;		/* data for command */
67 	int		 d_slen;		/* len of data */
68 	void		*d_rdata;		/* data to return */
69 	int		 d_rlen;		/* len of data */
70 };
71 typedef struct cachefsio_dcmd cachefsio_dcmd_t;
72 
73 struct cachefsio_getinfo {
74 	cfs_cid_t	gi_cid;			/* entry to lookup */
75 	int		gi_modified;		/* returns if modified data */
76 	cfs_vattr_t	gi_attr;		/* return file attributes */
77 	cfs_cid_t	gi_pcid;		/* returns the parent dir */
78 	uint_t		gi_seq;			/* sequence number */
79 	char		gi_name[MAXNAMELEN];	/* returns name of file */
80 };
81 typedef struct cachefsio_getinfo cachefsio_getinfo_t;
82 
83 struct cachefsio_lostfound_arg {
84 	cfs_cid_t	lf_cid;			/* file to move */
85 	char		lf_name[MAXNAMELEN];	/* suggested name */
86 };
87 typedef struct cachefsio_lostfound_arg cachefsio_lostfound_arg_t;
88 
89 struct cachefsio_lostfound_return {
90 	char		lf_name[MAXNAMELEN];	/* returns actual name */
91 };
92 typedef struct cachefsio_lostfound_return cachefsio_lostfound_return_t;
93 
94 struct cachefsio_getattrfid {
95 	cfs_fid_t	cg_backfid;	/* backfs fid of file */
96 	dl_cred_t	cg_cred;	/* creds */
97 	gid_t	cg_groups[NGROUPS_MAX_DEFAULT-1];
98 };
99 typedef struct cachefsio_getattrfid cachefsio_getattrfid_t;
100 
101 struct cachefsio_getattrname_arg {
102 	cfs_fid_t	cg_dir;			/* backfs fid of directory */
103 	char	cg_name[MAXNAMELEN];	/* name of file in directory cg_dir */
104 	dl_cred_t	cg_cred;	/* creds */
105 	gid_t	cg_groups[NGROUPS_MAX_DEFAULT-1];
106 };
107 typedef	struct cachefsio_getattrname_arg cachefsio_getattrname_arg_t;
108 
109 struct cachefsio_getattrname_return {
110 	cfs_vattr_t	cg_attr;		/* returns attributes of file */
111 	cfs_fid_t	cg_fid;			/* returns fid of file */
112 };
113 typedef	struct cachefsio_getattrname_return cachefsio_getattrname_return_t;
114 
115 struct cachefsio_getstats {
116 	int		gs_total;		/* total blocks */
117 	int		gs_gc;			/* number of gc blocks */
118 	int		gs_active;		/* number of active blocks */
119 	int		gs_packed;		/* number of packed blocks */
120 	int		gs_free;		/* number of free blocks */
121 	cfs_time_t	gs_gctime;		/* atime of front of gc list */
122 };
123 typedef struct cachefsio_getstats cachefsio_getstats_t;
124 
125 struct cachefsio_create_arg {
126 	cfs_fid_t	cr_backfid;		/* backfs fid of directory */
127 	char		cr_name[MAXNAMELEN];	/* name of file to create */
128 	cfs_cid_t	cr_cid;			/* cid of file being created */
129 	cfs_vattr_t	cr_va;			/* attributes for create */
130 	int		cr_exclusive;		/* exclusive create or not */
131 	int		cr_mode;		/* mode */
132 	dl_cred_t	cr_cred;		/* creds */
133 	gid_t		cr_groups[NGROUPS_MAX_DEFAULT-1];
134 };
135 typedef struct cachefsio_create_arg cachefsio_create_arg_t;
136 
137 struct cachefsio_create_return {
138 	cfs_fid_t	cr_newfid;		/* returns fid of new file */
139 	cfs_timestruc_t	cr_ctime;		/* returns new ctime */
140 	cfs_timestruc_t	cr_mtime;		/* returns new mtime */
141 };
142 typedef struct cachefsio_create_return cachefsio_create_return_t;
143 
144 struct cachefsio_pushback_arg {
145 	cfs_cid_t	pb_cid;			/* file to push back */
146 	cfs_fid_t	pb_fid;			/* back fs fid to push to */
147 	dl_cred_t	pb_cred;		/* creds */
148 	gid_t		pb_groups[NGROUPS_MAX_DEFAULT-1];
149 };
150 typedef struct cachefsio_pushback_arg cachefsio_pushback_arg_t;
151 
152 struct cachefsio_pushback_return {
153 	cfs_timestruc_t	pb_ctime;		/* returns new ctime */
154 	cfs_timestruc_t	pb_mtime;		/* returns new mtime */
155 };
156 typedef struct cachefsio_pushback_return cachefsio_pushback_return_t;
157 
158 struct cachefsio_remove {
159 	cfs_cid_t	rm_cid;			/* cid of deleted file */
160 	cfs_fid_t	rm_fid;			/* fid of parent directory */
161 	char		rm_name[MAXNAMELEN];	/* name of file to remove */
162 	int		rm_getctime;		/* 1 means return new ctime */
163 	dl_cred_t	rm_cred;		/* creds */
164 	gid_t		rm_groups[NGROUPS_MAX_DEFAULT-1];
165 };
166 typedef struct cachefsio_remove cachefsio_remove_t;
167 
168 struct cachefsio_link {
169 	cfs_fid_t	ln_dirfid;		/* backfid of parent dir */
170 	char		ln_name[MAXNAMELEN];	/* name of new link */
171 	cfs_fid_t	ln_filefid;		/* backfid of file to link to */
172 	cfs_cid_t	ln_cid;			/* cid of link */
173 	dl_cred_t	ln_cred;		/* creds */
174 	gid_t		ln_groups[NGROUPS_MAX_DEFAULT-1];
175 };
176 typedef struct cachefsio_link cachefsio_link_t;
177 
178 struct cachefsio_rename_arg {
179 	cfs_fid_t	rn_olddir;		/* backfs fid of old dir */
180 	char		rn_oldname[MAXNAMELEN];	/* old name of file */
181 	cfs_fid_t	rn_newdir;		/* backfs fid of new dir */
182 	char		rn_newname[MAXNAMELEN];	/* new name of file */
183 	cfs_cid_t	rn_cid;			/* cid of renamed file */
184 	int		rn_del_getctime;	/* 1 means fill in del_ctime */
185 	cfs_cid_t	rn_del_cid;		/* cid of deleted file */
186 	dl_cred_t	rn_cred;		/* creds */
187 	gid_t		rn_groups[NGROUPS_MAX_DEFAULT-1];
188 };
189 typedef struct cachefsio_rename_arg cachefsio_rename_arg_t;
190 
191 struct cachefsio_rename_return {
192 	cfs_timestruc_t	rn_ctime;		/* returns new file ctime */
193 	cfs_timestruc_t	rn_del_ctime;		/* returns new del file ctime */
194 };
195 typedef struct cachefsio_rename_return cachefsio_rename_return_t;
196 
197 struct cachefsio_mkdir {
198 	cfs_fid_t	md_dirfid;		/* backfs fid of dir */
199 	char		md_name[MAXNAMELEN];	/* name of the new dir */
200 	cfs_cid_t	md_cid;			/* cid of dir being created */
201 	cfs_vattr_t	md_vattr;		/* attributes */
202 	dl_cred_t	md_cred;		/* creds */
203 	gid_t		md_groups[NGROUPS_MAX_DEFAULT-1];
204 };
205 typedef struct cachefsio_mkdir cachefsio_mkdir_t;
206 
207 struct cachefsio_rmdir {
208 	cfs_fid_t	rd_dirfid;		/* backfs fid of dir */
209 	char		rd_name[MAXNAMELEN];	/* name of the dir to delete */
210 	dl_cred_t	rd_cred;		/* creds */
211 	gid_t		rd_groups[NGROUPS_MAX_DEFAULT-1];
212 };
213 typedef struct cachefsio_rmdir cachefsio_rmdir_t;
214 
215 struct cachefsio_symlink_arg {
216 	cfs_fid_t	sy_dirfid;		/* backfs fid of dir */
217 	char		sy_name[MAXNAMELEN];	/* name of symlink to create */
218 	cfs_cid_t	sy_cid;			/* cid of symlink */
219 	char		sy_link[MAXPATHLEN];	/* contents of the symlink */
220 	cfs_vattr_t	sy_vattr;		/* attributes */
221 	dl_cred_t	sy_cred;		/* creds */
222 	gid_t		sy_groups[NGROUPS_MAX_DEFAULT-1];
223 };
224 typedef struct cachefsio_symlink_arg cachefsio_symlink_arg_t;
225 
226 struct cachefsio_symlink_return {
227 	cfs_fid_t	sy_newfid;		/* returns fid of symlink */
228 	cfs_timestruc_t	sy_ctime;		/* returns new ctime */
229 	cfs_timestruc_t	sy_mtime;		/* returns new mtime */
230 };
231 typedef struct cachefsio_symlink_return cachefsio_symlink_return_t;
232 
233 struct cachefsio_setattr_arg {
234 	cfs_fid_t	sa_backfid;		/* backfs fid of file */
235 	cfs_cid_t	sa_cid;			/* cid of file */
236 	cfs_vattr_t	sa_vattr;		/* attributes */
237 	int		sa_flags;		/* flags */
238 	dl_cred_t	sa_cred;		/* creds */
239 	gid_t		sa_groups[NGROUPS_MAX_DEFAULT-1];
240 };
241 typedef struct cachefsio_setattr_arg cachefsio_setattr_arg_t;
242 
243 struct cachefsio_setattr_return {
244 	cfs_timestruc_t	sa_ctime;		/* returns new ctime */
245 	cfs_timestruc_t	sa_mtime;		/* returns new mtime */
246 };
247 typedef struct cachefsio_setattr_return cachefsio_setattr_return_t;
248 
249 struct cachefsio_setsecattr_arg {
250 	cfs_fid_t	sc_backfid;		/* backfs fid of file */
251 	cfs_cid_t	sc_cid;			/* cid of file */
252 	uint_t		sc_mask;		/* mask for setsec */
253 	int		sc_aclcnt;		/* count of ACLs */
254 	int		sc_dfaclcnt;		/* count of default ACLs */
255 	aclent_t	sc_acl[MAX_ACL_ENTRIES]; /* ACLs */
256 	dl_cred_t	sc_cred;		/* creds */
257 	gid_t		sc_groups[NGROUPS_MAX_DEFAULT-1];
258 };
259 typedef struct cachefsio_setsecattr_arg cachefsio_setsecattr_arg_t;
260 
261 struct cachefsio_setsecattr_return {
262 	cfs_timestruc_t	sc_ctime;		/* returns new ctime */
263 	cfs_timestruc_t	sc_mtime;		/* returns new mtime */
264 };
265 typedef struct cachefsio_setsecattr_return cachefsio_setsecattr_return_t;
266 
267 #ifdef _SYSCALL32
268 
269 /*
270  * Solaris 64 - the following structs are used for user/kernel communication.
271  */
272 
273 struct cachefsio_dcmd32 {
274 	cfsdcmd_cmds_t	 d_cmd;			/* cmd to execute */
275 	caddr32_t	 d_sdata;		/* data for command */
276 	int32_t		 d_slen;		/* len of data */
277 	caddr32_t	 d_rdata;		/* data to return */
278 	int32_t		 d_rlen;		/* len of data */
279 };
280 typedef struct cachefsio_dcmd32 cachefsio_dcmd32_t;
281 
282 #endif /* _SYSCALL32 */
283 
284 int cachefs_pack(vnode_t *, char *, cred_t *);
285 int cachefs_unpack(vnode_t *, char *, cred_t *);
286 int cachefs_packinfo(vnode_t *dvp, char *name, int *statusp, cred_t *cr);
287 int cachefs_unpackall(vnode_t *);
288 
289 int cachefs_io_daemonid(vnode_t *vp, void *dinp, void *doutp);
290 int cachefs_io_stateget(vnode_t *vp, void *dinp, void *doutp);
291 int cachefs_io_stateset(vnode_t *vp, void *dinp, void *doutp);
292 int cachefs_io_xwait(vnode_t *vp, void *dinp, void *doutp);
293 int cachefs_io_exists(vnode_t *vp, void *dinp, void *doutp);
294 int cachefs_io_lostfound(vnode_t *vp, void *dinp, void *doutp);
295 int cachefs_io_getinfo(vnode_t *vp, void *dinp, void *doutp);
296 int cachefs_io_cidtofid(vnode_t *vp, void *dinp, void *doutp);
297 int cachefs_io_getattrfid(vnode_t *vp, void *dinp, void *doutp);
298 int cachefs_io_getattrname(vnode_t *vp, void *dinp, void *doutp);
299 int cachefs_io_getstats(vnode_t *vp, void *dinp, void *doutp);
300 int cachefs_io_rootfid(vnode_t *vp, void *dinp, void *doutp);
301 int cachefs_io_create(vnode_t *vp, void *dinp, void *doutp);
302 int cachefs_io_remove(vnode_t *vp, void *dinp, void *doutp);
303 int cachefs_io_link(vnode_t *vp, void *dinp, void *doutp);
304 int cachefs_io_rename(vnode_t *vp, void *dinp, void *doutp);
305 int cachefs_io_mkdir(vnode_t *vp, void *dinp, void *doutp);
306 int cachefs_io_rmdir(vnode_t *vp, void *dinp, void *doutp);
307 int cachefs_io_symlink(vnode_t *vp, void *dinp, void *doutp);
308 int cachefs_io_setattr(vnode_t *vp, void *dinp, void *doutp);
309 int cachefs_io_setsecattr(vnode_t *vp, void *dinp, void *doutp);
310 int cachefs_io_pushback(vnode_t *vp, void *dinp, void *doutp);
311 
312 #ifdef __cplusplus
313 }
314 #endif
315 
316 #endif	/* _SYS_FS_CACHEFS_IOCTL_H */
317