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 /* 233898Srsb * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_GFS_H 280Sstevel@tonic-gate #define _SYS_GFS_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <sys/types.h> 330Sstevel@tonic-gate #include <sys/vnode.h> 343898Srsb #include <sys/vfs_opreg.h> 350Sstevel@tonic-gate #include <sys/mutex.h> 360Sstevel@tonic-gate #include <sys/dirent.h> 370Sstevel@tonic-gate #include <sys/uio.h> 380Sstevel@tonic-gate #include <sys/list.h> 390Sstevel@tonic-gate #include <sys/pathname.h> 400Sstevel@tonic-gate 410Sstevel@tonic-gate #ifdef __cplusplus 420Sstevel@tonic-gate extern "C" { 430Sstevel@tonic-gate #endif 440Sstevel@tonic-gate 450Sstevel@tonic-gate typedef struct gfs_opsvec { 460Sstevel@tonic-gate const char *gfsv_name; /* vnode description */ 470Sstevel@tonic-gate const fs_operation_def_t *gfsv_template; /* ops template */ 480Sstevel@tonic-gate vnodeops_t **gfsv_ops; /* ptr to result */ 490Sstevel@tonic-gate } gfs_opsvec_t; 500Sstevel@tonic-gate 510Sstevel@tonic-gate int gfs_make_opsvec(gfs_opsvec_t *); 520Sstevel@tonic-gate 530Sstevel@tonic-gate #define GFS_CACHE_VNODE 0x1 540Sstevel@tonic-gate 550Sstevel@tonic-gate typedef struct gfs_dirent { 560Sstevel@tonic-gate char *gfse_name; /* entry name */ 570Sstevel@tonic-gate vnode_t *(*gfse_ctor)(vnode_t *); /* constructor */ 580Sstevel@tonic-gate int gfse_flags; /* flags */ 590Sstevel@tonic-gate list_node_t gfse_link; /* dynamic list */ 600Sstevel@tonic-gate vnode_t *gfse_vnode; /* cached vnode */ 610Sstevel@tonic-gate } gfs_dirent_t; 620Sstevel@tonic-gate 630Sstevel@tonic-gate typedef enum gfs_type { 640Sstevel@tonic-gate GFS_DIR, 650Sstevel@tonic-gate GFS_FILE 660Sstevel@tonic-gate } gfs_type_t; 670Sstevel@tonic-gate 680Sstevel@tonic-gate typedef struct gfs_file { 690Sstevel@tonic-gate vnode_t *gfs_vnode; /* current vnode */ 700Sstevel@tonic-gate vnode_t *gfs_parent; /* parent vnode */ 710Sstevel@tonic-gate size_t gfs_size; /* size of private data structure */ 720Sstevel@tonic-gate gfs_type_t gfs_type; /* type of vnode */ 730Sstevel@tonic-gate int gfs_index; /* index in parent dir */ 740Sstevel@tonic-gate ino64_t gfs_ino; /* inode for this vnode */ 750Sstevel@tonic-gate } gfs_file_t; 760Sstevel@tonic-gate 770Sstevel@tonic-gate typedef int (*gfs_readdir_cb)(vnode_t *, struct dirent64 *, int *, offset_t *, 780Sstevel@tonic-gate offset_t *, void *); 79*5331Samw typedef int (*gfs_lookup_cb)(vnode_t *, const char *, vnode_t **, ino64_t *, 80*5331Samw cred_t *); 810Sstevel@tonic-gate typedef ino64_t (*gfs_inode_cb)(vnode_t *, int); 820Sstevel@tonic-gate 830Sstevel@tonic-gate typedef struct gfs_dir { 840Sstevel@tonic-gate gfs_file_t gfsd_file; /* generic file attributes */ 850Sstevel@tonic-gate gfs_dirent_t *gfsd_static; /* statically defined entries */ 860Sstevel@tonic-gate int gfsd_nstatic; /* # static entries */ 870Sstevel@tonic-gate kmutex_t gfsd_lock; /* protects entries */ 880Sstevel@tonic-gate int gfsd_maxlen; /* maximum name length */ 890Sstevel@tonic-gate gfs_readdir_cb gfsd_readdir; /* readdir() callback */ 900Sstevel@tonic-gate gfs_lookup_cb gfsd_lookup; /* lookup() callback */ 910Sstevel@tonic-gate gfs_inode_cb gfsd_inode; /* get an inode number */ 920Sstevel@tonic-gate } gfs_dir_t; 930Sstevel@tonic-gate 940Sstevel@tonic-gate struct vfs; 950Sstevel@tonic-gate 960Sstevel@tonic-gate extern vnode_t *gfs_file_create(size_t, vnode_t *, vnodeops_t *); 970Sstevel@tonic-gate extern vnode_t *gfs_dir_create(size_t, vnode_t *, vnodeops_t *, 980Sstevel@tonic-gate gfs_dirent_t *, gfs_inode_cb, int, gfs_readdir_cb, gfs_lookup_cb); 990Sstevel@tonic-gate extern vnode_t *gfs_root_create(size_t, struct vfs *, vnodeops_t *, ino64_t, 1000Sstevel@tonic-gate gfs_dirent_t *, gfs_inode_cb, int, gfs_readdir_cb, gfs_lookup_cb); 1013957Sth199096 extern vnode_t *gfs_root_create_file(size_t, struct vfs *, vnodeops_t *, 1023957Sth199096 ino64_t); 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate extern void *gfs_file_inactive(vnode_t *); 1050Sstevel@tonic-gate extern void *gfs_dir_inactive(vnode_t *); 1060Sstevel@tonic-gate 107*5331Samw extern int gfs_dir_lookup(vnode_t *, const char *, vnode_t **, cred_t *); 108*5331Samw extern int gfs_dir_readdir(vnode_t *, uio_t *, int *, void *, cred_t *, 109*5331Samw caller_context_t *); 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate #define gfs_dir_lock(gd) mutex_enter(&(gd)->gfsd_lock) 1120Sstevel@tonic-gate #define gfs_dir_unlock(gd) mutex_exit(&(gd)->gfsd_lock) 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate #define gfs_file_parent(vp) (((gfs_file_t *)(vp)->v_data)->gfs_parent) 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate #define gfs_file_index(vp) (((gfs_file_t *)(vp)->v_data)->gfs_index) 1170Sstevel@tonic-gate #define gfs_file_set_index(vp, idx) \ 1180Sstevel@tonic-gate (((gfs_file_t *)(vp)->v_data)->gfs_index = (idx)) 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate #define gfs_file_inode(vp) (((gfs_file_t *)(vp)->v_data)->gfs_ino) 1210Sstevel@tonic-gate #define gfs_file_set_inode(vp, ino) \ 1220Sstevel@tonic-gate (((gfs_file_t *)(vp)->v_data)->gfs_ino = (ino)) 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate typedef struct gfs_readdir_state { 1250Sstevel@tonic-gate struct dirent64 *grd_dirent; /* directory entry buffer */ 1260Sstevel@tonic-gate size_t grd_namlen; /* max file name length */ 1270Sstevel@tonic-gate size_t grd_ureclen; /* exported record size */ 1280Sstevel@tonic-gate ssize_t grd_oresid; /* original uio_resid */ 1290Sstevel@tonic-gate ino64_t grd_parent; /* inode of parent */ 1300Sstevel@tonic-gate ino64_t grd_self; /* inode of self */ 1310Sstevel@tonic-gate } gfs_readdir_state_t; 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate extern int gfs_readdir_init(gfs_readdir_state_t *, int, int, uio_t *, ino64_t, 1340Sstevel@tonic-gate ino64_t); 1350Sstevel@tonic-gate extern int gfs_readdir_emit(gfs_readdir_state_t *, uio_t *, offset_t, ino64_t, 1360Sstevel@tonic-gate const char *); 1370Sstevel@tonic-gate extern int gfs_readdir_emitn(gfs_readdir_state_t *, uio_t *, offset_t, ino64_t, 1380Sstevel@tonic-gate unsigned long); 1390Sstevel@tonic-gate extern int gfs_readdir_pred(gfs_readdir_state_t *, uio_t *, offset_t *); 1400Sstevel@tonic-gate extern int gfs_readdir_fini(gfs_readdir_state_t *, int, int *, int); 1410Sstevel@tonic-gate 142*5331Samw /* 143*5331Samw * Objects with real extended attributes will get their . and .. 144*5331Samw * readdir entries from the real xattr directory. GFS_STATIC_ENTRY_OFFSET 145*5331Samw * lets us skip right to the static entries in the GFS directory. 146*5331Samw */ 147*5331Samw #define GFS_STATIC_ENTRY_OFFSET ((offset_t)2) 148*5331Samw 1490Sstevel@tonic-gate extern int gfs_lookup_dot(vnode_t **, vnode_t *, vnode_t *, const char *); 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate extern int gfs_vop_lookup(vnode_t *, char *, vnode_t **, pathname_t *, 152*5331Samw int, vnode_t *, cred_t *, caller_context_t *, int *, pathname_t *); 153*5331Samw extern int gfs_vop_readdir(vnode_t *, uio_t *, cred_t *, int *, 154*5331Samw caller_context_t *, int); 1550Sstevel@tonic-gate extern int gfs_vop_map(vnode_t *, offset_t, struct as *, caddr_t *, 156*5331Samw size_t, uchar_t, uchar_t, uint_t, cred_t *, caller_context_t *); 157*5331Samw extern void gfs_vop_inactive(vnode_t *, cred_t *, caller_context_t *); 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate #ifdef __cplusplus 1610Sstevel@tonic-gate } 1620Sstevel@tonic-gate #endif 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate #endif /* _SYS_GFS_H */ 165