xref: /onnv-gate/usr/src/cmd/filebench/common/fsplug.h (revision 8615:fa52c2eca6c5)
1*8615SAndrew.W.Wilson@sun.com /*
2*8615SAndrew.W.Wilson@sun.com  * CDDL HEADER START
3*8615SAndrew.W.Wilson@sun.com  *
4*8615SAndrew.W.Wilson@sun.com  * The contents of this file are subject to the terms of the
5*8615SAndrew.W.Wilson@sun.com  * Common Development and Distribution License (the "License").
6*8615SAndrew.W.Wilson@sun.com  * You may not use this file except in compliance with the License.
7*8615SAndrew.W.Wilson@sun.com  *
8*8615SAndrew.W.Wilson@sun.com  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*8615SAndrew.W.Wilson@sun.com  * or http://www.opensolaris.org/os/licensing.
10*8615SAndrew.W.Wilson@sun.com  * See the License for the specific language governing permissions
11*8615SAndrew.W.Wilson@sun.com  * and limitations under the License.
12*8615SAndrew.W.Wilson@sun.com  *
13*8615SAndrew.W.Wilson@sun.com  * When distributing Covered Code, include this CDDL HEADER in each
14*8615SAndrew.W.Wilson@sun.com  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*8615SAndrew.W.Wilson@sun.com  * If applicable, add the following below this CDDL HEADER, with the
16*8615SAndrew.W.Wilson@sun.com  * fields enclosed by brackets "[]" replaced with your own identifying
17*8615SAndrew.W.Wilson@sun.com  * information: Portions Copyright [yyyy] [name of copyright owner]
18*8615SAndrew.W.Wilson@sun.com  *
19*8615SAndrew.W.Wilson@sun.com  * CDDL HEADER END
20*8615SAndrew.W.Wilson@sun.com  */
21*8615SAndrew.W.Wilson@sun.com /*
22*8615SAndrew.W.Wilson@sun.com  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23*8615SAndrew.W.Wilson@sun.com  * Use is subject to license terms.
24*8615SAndrew.W.Wilson@sun.com  *
25*8615SAndrew.W.Wilson@sun.com  */
26*8615SAndrew.W.Wilson@sun.com 
27*8615SAndrew.W.Wilson@sun.com 
28*8615SAndrew.W.Wilson@sun.com #ifndef _FSPLUG_H
29*8615SAndrew.W.Wilson@sun.com #define	_FSPLUG_H
30*8615SAndrew.W.Wilson@sun.com 
31*8615SAndrew.W.Wilson@sun.com #include <dirent.h>
32*8615SAndrew.W.Wilson@sun.com #include "config.h"
33*8615SAndrew.W.Wilson@sun.com #include <sys/stat.h>
34*8615SAndrew.W.Wilson@sun.com 
35*8615SAndrew.W.Wilson@sun.com /*
36*8615SAndrew.W.Wilson@sun.com  * Type of file system client plug-in desired.
37*8615SAndrew.W.Wilson@sun.com  */
38*8615SAndrew.W.Wilson@sun.com typedef enum fb_plugin_type {
39*8615SAndrew.W.Wilson@sun.com 	LOCAL_FS_PLUG = 0,
40*8615SAndrew.W.Wilson@sun.com 	NFS3_PLUG,
41*8615SAndrew.W.Wilson@sun.com 	NFS4_PLUG,
42*8615SAndrew.W.Wilson@sun.com 	CIFS_PLUG
43*8615SAndrew.W.Wilson@sun.com } fb_plugin_type_t;
44*8615SAndrew.W.Wilson@sun.com 
45*8615SAndrew.W.Wilson@sun.com /* universal file descriptor for both local and nfs file systems */
46*8615SAndrew.W.Wilson@sun.com typedef union fb_fdesc {
47*8615SAndrew.W.Wilson@sun.com 	int		fd_num;		/* OS file descriptor number */
48*8615SAndrew.W.Wilson@sun.com 	void		*fd_ptr;	/* Pointer to nfs information block */
49*8615SAndrew.W.Wilson@sun.com } fb_fdesc_t;
50*8615SAndrew.W.Wilson@sun.com 
51*8615SAndrew.W.Wilson@sun.com typedef struct aiolist aiol_t;
52*8615SAndrew.W.Wilson@sun.com 
53*8615SAndrew.W.Wilson@sun.com /* Functions vector for file system plug-ins */
54*8615SAndrew.W.Wilson@sun.com typedef struct fsplug_func_s {
55*8615SAndrew.W.Wilson@sun.com 	char fs_name[16];
56*8615SAndrew.W.Wilson@sun.com 	int (*fsp_freemem)(fb_fdesc_t *, off64_t);
57*8615SAndrew.W.Wilson@sun.com 	int (*fsp_open)(fb_fdesc_t *, char *, int, int);
58*8615SAndrew.W.Wilson@sun.com 	int (*fsp_pread)(fb_fdesc_t *, caddr_t, fbint_t, off64_t);
59*8615SAndrew.W.Wilson@sun.com 	int (*fsp_read)(fb_fdesc_t *, caddr_t, fbint_t);
60*8615SAndrew.W.Wilson@sun.com 	int (*fsp_pwrite)(fb_fdesc_t *, caddr_t, fbint_t, off64_t);
61*8615SAndrew.W.Wilson@sun.com 	int (*fsp_write)(fb_fdesc_t *, caddr_t, fbint_t);
62*8615SAndrew.W.Wilson@sun.com 	int (*fsp_lseek)(fb_fdesc_t *, off64_t, int);
63*8615SAndrew.W.Wilson@sun.com 	int (*fsp_ftrunc)(fb_fdesc_t *, off64_t);
64*8615SAndrew.W.Wilson@sun.com 	int (*fsp_rename)(const char *, const char *);
65*8615SAndrew.W.Wilson@sun.com 	int (*fsp_close)(fb_fdesc_t *);
66*8615SAndrew.W.Wilson@sun.com 	int (*fsp_link)(const char *, const char *);
67*8615SAndrew.W.Wilson@sun.com 	int (*fsp_symlink)(const char *, const char *);
68*8615SAndrew.W.Wilson@sun.com 	int (*fsp_unlink)(char *);
69*8615SAndrew.W.Wilson@sun.com 	ssize_t (*fsp_readlink)(const char *, char *, size_t);
70*8615SAndrew.W.Wilson@sun.com 	int (*fsp_mkdir)(char *, int);
71*8615SAndrew.W.Wilson@sun.com 	int (*fsp_rmdir)(char *);
72*8615SAndrew.W.Wilson@sun.com 	DIR *(*fsp_opendir)(char *);
73*8615SAndrew.W.Wilson@sun.com 	struct dirent *(*fsp_readdir)(DIR *);
74*8615SAndrew.W.Wilson@sun.com 	int (*fsp_closedir)(DIR *);
75*8615SAndrew.W.Wilson@sun.com 	int (*fsp_fsync)(fb_fdesc_t *);
76*8615SAndrew.W.Wilson@sun.com 	int (*fsp_stat)(char *, struct stat64 *);
77*8615SAndrew.W.Wilson@sun.com 	int (*fsp_fstat)(fb_fdesc_t *, struct stat64 *);
78*8615SAndrew.W.Wilson@sun.com 	int (*fsp_access)(const char *, int);
79*8615SAndrew.W.Wilson@sun.com } fsplug_func_t;
80*8615SAndrew.W.Wilson@sun.com 
81*8615SAndrew.W.Wilson@sun.com extern fsplug_func_t *fs_functions_vec;
82*8615SAndrew.W.Wilson@sun.com 
83*8615SAndrew.W.Wilson@sun.com /* Macros for calling functions */
84*8615SAndrew.W.Wilson@sun.com #define	FB_FREEMEM(fd, sz) \
85*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_freemem)(fd, sz)
86*8615SAndrew.W.Wilson@sun.com 
87*8615SAndrew.W.Wilson@sun.com #define	FB_OPEN(fd, path, flags, perms) \
88*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_open)(fd, path, flags, perms)
89*8615SAndrew.W.Wilson@sun.com 
90*8615SAndrew.W.Wilson@sun.com #define	FB_PREAD(fdesc, iobuf, iosize, offset) \
91*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_pread)(fdesc, iobuf, iosize, offset)
92*8615SAndrew.W.Wilson@sun.com 
93*8615SAndrew.W.Wilson@sun.com #define	FB_READ(fdesc, iobuf, iosize) \
94*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_read)(fdesc, iobuf, iosize)
95*8615SAndrew.W.Wilson@sun.com 
96*8615SAndrew.W.Wilson@sun.com #define	FB_PWRITE(fdesc, iobuf, iosize, offset) \
97*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_pwrite)(fdesc, iobuf, iosize, offset)
98*8615SAndrew.W.Wilson@sun.com 
99*8615SAndrew.W.Wilson@sun.com #define	FB_WRITE(fdesc, iobuf, iosize) \
100*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_write)(fdesc, iobuf, iosize)
101*8615SAndrew.W.Wilson@sun.com 
102*8615SAndrew.W.Wilson@sun.com #define	FB_LSEEK(fdesc, amnt, whence) \
103*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_lseek)(fdesc, amnt, whence)
104*8615SAndrew.W.Wilson@sun.com 
105*8615SAndrew.W.Wilson@sun.com #define	FB_CLOSE(fdesc) \
106*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_close)(fdesc)
107*8615SAndrew.W.Wilson@sun.com 
108*8615SAndrew.W.Wilson@sun.com #define	FB_UNLINK(path) \
109*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_unlink)(path)
110*8615SAndrew.W.Wilson@sun.com 
111*8615SAndrew.W.Wilson@sun.com #define	FB_MKDIR(path, perm) \
112*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_mkdir)(path, perm)
113*8615SAndrew.W.Wilson@sun.com 
114*8615SAndrew.W.Wilson@sun.com #define	FB_RMDIR(path) \
115*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_rmdir)(path)
116*8615SAndrew.W.Wilson@sun.com 
117*8615SAndrew.W.Wilson@sun.com #define	FB_OPENDIR(path) \
118*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_opendir)(path)
119*8615SAndrew.W.Wilson@sun.com 
120*8615SAndrew.W.Wilson@sun.com #define	FB_READDIR(dir) \
121*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_readdir)(dir)
122*8615SAndrew.W.Wilson@sun.com 
123*8615SAndrew.W.Wilson@sun.com #define	FB_CLOSEDIR(dir) \
124*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_closedir)(dir)
125*8615SAndrew.W.Wilson@sun.com 
126*8615SAndrew.W.Wilson@sun.com #define	FB_FSYNC(fdesc) \
127*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_fsync)(fdesc)
128*8615SAndrew.W.Wilson@sun.com 
129*8615SAndrew.W.Wilson@sun.com #define	FB_STAT(path, statp) \
130*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_stat)(path, statp)
131*8615SAndrew.W.Wilson@sun.com 
132*8615SAndrew.W.Wilson@sun.com #define	FB_FSTAT(fdesc, statp) \
133*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_fstat)(fdesc, statp)
134*8615SAndrew.W.Wilson@sun.com 
135*8615SAndrew.W.Wilson@sun.com #define	FB_FTRUNC(fdesc, size) \
136*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_ftrunc)(fdesc, size)
137*8615SAndrew.W.Wilson@sun.com 
138*8615SAndrew.W.Wilson@sun.com #define	FB_LINK(existing, new) \
139*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_link)(existing, new)
140*8615SAndrew.W.Wilson@sun.com 
141*8615SAndrew.W.Wilson@sun.com #define	FB_SYMLINK(name1, name2) \
142*8615SAndrew.W.Wilson@sun.com 	(*fs_functions_vec->fsp_symlink)(name1, name2)
143*8615SAndrew.W.Wilson@sun.com 
144*8615SAndrew.W.Wilson@sun.com #endif /* _FSPLUG_H */
145