xref: /onnv-gate/usr/src/uts/common/sys/gfs.h (revision 12321:c2943f5c6eb9)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53898Srsb  * Common Development and Distribution License (the "License").
63898Srsb  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
213957Sth199096 
220Sstevel@tonic-gate /*
23*12321SStephanie.Scheffler@Sun.COM  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24*12321SStephanie.Scheffler@Sun.COM  */
25*12321SStephanie.Scheffler@Sun.COM 
26*12321SStephanie.Scheffler@Sun.COM /*
27*12321SStephanie.Scheffler@Sun.COM  * These are Consolidation Private interfaces and are subject to change.
280Sstevel@tonic-gate  */
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifndef _SYS_GFS_H
310Sstevel@tonic-gate #define	_SYS_GFS_H
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <sys/types.h>
340Sstevel@tonic-gate #include <sys/vnode.h>
353898Srsb #include <sys/vfs_opreg.h>
360Sstevel@tonic-gate #include <sys/mutex.h>
370Sstevel@tonic-gate #include <sys/dirent.h>
385663Sck153898 #include <sys/extdirent.h>
390Sstevel@tonic-gate #include <sys/uio.h>
400Sstevel@tonic-gate #include <sys/list.h>
410Sstevel@tonic-gate #include <sys/pathname.h>
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #ifdef	__cplusplus
440Sstevel@tonic-gate extern "C" {
450Sstevel@tonic-gate #endif
460Sstevel@tonic-gate 
470Sstevel@tonic-gate typedef struct gfs_opsvec {
480Sstevel@tonic-gate 	const char		*gfsv_name;	/* vnode description */
490Sstevel@tonic-gate 	const fs_operation_def_t *gfsv_template; /* ops template */
500Sstevel@tonic-gate 	vnodeops_t		**gfsv_ops;	/* ptr to result */
510Sstevel@tonic-gate } gfs_opsvec_t;
520Sstevel@tonic-gate 
530Sstevel@tonic-gate int gfs_make_opsvec(gfs_opsvec_t *);
540Sstevel@tonic-gate 
550Sstevel@tonic-gate #define	GFS_CACHE_VNODE		0x1
560Sstevel@tonic-gate 
570Sstevel@tonic-gate typedef struct gfs_dirent {
580Sstevel@tonic-gate 	char			*gfse_name;	/* entry name */
590Sstevel@tonic-gate 	vnode_t *(*gfse_ctor)(vnode_t *);	/* constructor */
600Sstevel@tonic-gate 	int			gfse_flags;	/* flags */
610Sstevel@tonic-gate 	list_node_t		gfse_link;	/* dynamic list */
620Sstevel@tonic-gate 	vnode_t			*gfse_vnode;	/* cached vnode */
630Sstevel@tonic-gate } gfs_dirent_t;
640Sstevel@tonic-gate 
650Sstevel@tonic-gate typedef enum gfs_type {
660Sstevel@tonic-gate 	GFS_DIR,
670Sstevel@tonic-gate 	GFS_FILE
680Sstevel@tonic-gate } gfs_type_t;
690Sstevel@tonic-gate 
700Sstevel@tonic-gate typedef struct gfs_file {
710Sstevel@tonic-gate 	vnode_t		*gfs_vnode;	/* current vnode */
720Sstevel@tonic-gate 	vnode_t		*gfs_parent;	/* parent vnode */
730Sstevel@tonic-gate 	size_t		gfs_size;	/* size of private data structure */
740Sstevel@tonic-gate 	gfs_type_t	gfs_type;	/* type of vnode */
750Sstevel@tonic-gate 	int		gfs_index;	/* index in parent dir */
760Sstevel@tonic-gate 	ino64_t		gfs_ino;	/* inode for this vnode */
770Sstevel@tonic-gate } gfs_file_t;
780Sstevel@tonic-gate 
795663Sck153898 typedef int (*gfs_readdir_cb)(vnode_t *, void *, int *, offset_t *,
805663Sck153898     offset_t *, void *, int);
815331Samw typedef int (*gfs_lookup_cb)(vnode_t *, const char *, vnode_t **, ino64_t *,
826492Stimh     cred_t *, int, int *, pathname_t *);
830Sstevel@tonic-gate typedef ino64_t (*gfs_inode_cb)(vnode_t *, int);
840Sstevel@tonic-gate 
850Sstevel@tonic-gate typedef struct gfs_dir {
860Sstevel@tonic-gate 	gfs_file_t	gfsd_file;	/* generic file attributes */
870Sstevel@tonic-gate 	gfs_dirent_t	*gfsd_static;	/* statically defined entries */
880Sstevel@tonic-gate 	int		gfsd_nstatic;	/* # static entries */
890Sstevel@tonic-gate 	kmutex_t	gfsd_lock;	/* protects entries */
900Sstevel@tonic-gate 	int		gfsd_maxlen;	/* maximum name length */
910Sstevel@tonic-gate 	gfs_readdir_cb	gfsd_readdir;	/* readdir() callback */
920Sstevel@tonic-gate 	gfs_lookup_cb	gfsd_lookup;	/* lookup() callback */
930Sstevel@tonic-gate 	gfs_inode_cb	gfsd_inode;	/* get an inode number */
940Sstevel@tonic-gate } gfs_dir_t;
950Sstevel@tonic-gate 
960Sstevel@tonic-gate struct vfs;
970Sstevel@tonic-gate 
980Sstevel@tonic-gate extern vnode_t *gfs_file_create(size_t, vnode_t *, vnodeops_t *);
990Sstevel@tonic-gate extern vnode_t *gfs_dir_create(size_t, vnode_t *, vnodeops_t *,
1000Sstevel@tonic-gate     gfs_dirent_t *, gfs_inode_cb, int, gfs_readdir_cb, gfs_lookup_cb);
1010Sstevel@tonic-gate extern vnode_t *gfs_root_create(size_t, struct vfs *, vnodeops_t *, ino64_t,
1020Sstevel@tonic-gate     gfs_dirent_t *, gfs_inode_cb, int, gfs_readdir_cb, gfs_lookup_cb);
1033957Sth199096 extern vnode_t *gfs_root_create_file(size_t, struct vfs *, vnodeops_t *,
1043957Sth199096     ino64_t);
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate extern void *gfs_file_inactive(vnode_t *);
1070Sstevel@tonic-gate extern void *gfs_dir_inactive(vnode_t *);
1080Sstevel@tonic-gate 
1096492Stimh extern int gfs_dir_case_lookup(vnode_t *, const char *, vnode_t **, cred_t *,
1106492Stimh     int, int *, pathname_t *);
1116492Stimh extern int gfs_dir_lookup(vnode_t *, const char *, vnode_t **, cred_t *,
1126492Stimh     int, int *, pathname_t *);
1135331Samw extern int gfs_dir_readdir(vnode_t *, uio_t *, int *, void *, cred_t *,
1145663Sck153898     caller_context_t *, int flags);
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate #define	gfs_dir_lock(gd)	mutex_enter(&(gd)->gfsd_lock)
1170Sstevel@tonic-gate #define	gfs_dir_unlock(gd)	mutex_exit(&(gd)->gfsd_lock)
1186492Stimh #define	GFS_DIR_LOCKED(gd)	MUTEX_HELD(&(gd)->gfsd_lock)
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate #define	gfs_file_parent(vp)	(((gfs_file_t *)(vp)->v_data)->gfs_parent)
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate #define	gfs_file_index(vp)	(((gfs_file_t *)(vp)->v_data)->gfs_index)
1230Sstevel@tonic-gate #define	gfs_file_set_index(vp, idx)	\
1240Sstevel@tonic-gate 	(((gfs_file_t *)(vp)->v_data)->gfs_index = (idx))
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate #define	gfs_file_inode(vp)	(((gfs_file_t *)(vp)->v_data)->gfs_ino)
1270Sstevel@tonic-gate #define	gfs_file_set_inode(vp, ino)	\
1280Sstevel@tonic-gate 	(((gfs_file_t *)(vp)->v_data)->gfs_ino = (ino))
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate typedef struct gfs_readdir_state {
1315663Sck153898 	void		*grd_dirent;	/* directory entry buffer */
1320Sstevel@tonic-gate 	size_t		grd_namlen;	/* max file name length */
1330Sstevel@tonic-gate 	size_t		grd_ureclen;	/* exported record size */
1340Sstevel@tonic-gate 	ssize_t		grd_oresid;	/* original uio_resid */
1350Sstevel@tonic-gate 	ino64_t		grd_parent;	/* inode of parent */
1360Sstevel@tonic-gate 	ino64_t		grd_self;	/* inode of self */
1375663Sck153898 	int		grd_flags;	/* flags from VOP_READDIR */
1380Sstevel@tonic-gate } gfs_readdir_state_t;
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate extern int gfs_readdir_init(gfs_readdir_state_t *, int, int, uio_t *, ino64_t,
1415663Sck153898     ino64_t, int);
1420Sstevel@tonic-gate extern int gfs_readdir_emit(gfs_readdir_state_t *, uio_t *, offset_t, ino64_t,
1435663Sck153898     const char *, int);
1440Sstevel@tonic-gate extern int gfs_readdir_emitn(gfs_readdir_state_t *, uio_t *, offset_t, ino64_t,
1450Sstevel@tonic-gate     unsigned long);
1460Sstevel@tonic-gate extern int gfs_readdir_pred(gfs_readdir_state_t *, uio_t *, offset_t *);
1470Sstevel@tonic-gate extern int gfs_readdir_fini(gfs_readdir_state_t *, int, int *, int);
1485663Sck153898 extern int gfs_get_parent_ino(vnode_t *, cred_t *, caller_context_t *,
1495663Sck153898     ino64_t *, ino64_t *);
1500Sstevel@tonic-gate 
1515331Samw /*
1525331Samw  * Objects with real extended attributes will get their . and ..
1535331Samw  * readdir entries from the real xattr directory. GFS_STATIC_ENTRY_OFFSET
1545331Samw  * lets us skip right to the static entries in the GFS directory.
1555331Samw  */
1565331Samw #define	GFS_STATIC_ENTRY_OFFSET	((offset_t)2)
1575331Samw 
1580Sstevel@tonic-gate extern int gfs_lookup_dot(vnode_t **, vnode_t *, vnode_t *, const char *);
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate extern int gfs_vop_lookup(vnode_t *, char *, vnode_t **, pathname_t *,
1615331Samw     int, vnode_t *, cred_t *, caller_context_t *, int *, pathname_t *);
1625331Samw extern int gfs_vop_readdir(vnode_t *, uio_t *, cred_t *, int *,
1635331Samw     caller_context_t *, int);
1640Sstevel@tonic-gate extern int gfs_vop_map(vnode_t *, offset_t, struct as *, caddr_t *,
1655331Samw     size_t, uchar_t, uchar_t, uint_t, cred_t *, caller_context_t *);
1665331Samw extern void gfs_vop_inactive(vnode_t *, cred_t *, caller_context_t *);
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate 
1690Sstevel@tonic-gate #ifdef	__cplusplus
1700Sstevel@tonic-gate }
1710Sstevel@tonic-gate #endif
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate #endif	/* _SYS_GFS_H */
174