xref: /onnv-gate/usr/src/cmd/filebench/common/fileset.h (revision 5184:da60d2b4a9e2)
1*5184Sek110237 /*
2*5184Sek110237  * CDDL HEADER START
3*5184Sek110237  *
4*5184Sek110237  * The contents of this file are subject to the terms of the
5*5184Sek110237  * Common Development and Distribution License (the "License").
6*5184Sek110237  * You may not use this file except in compliance with the License.
7*5184Sek110237  *
8*5184Sek110237  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*5184Sek110237  * or http://www.opensolaris.org/os/licensing.
10*5184Sek110237  * See the License for the specific language governing permissions
11*5184Sek110237  * and limitations under the License.
12*5184Sek110237  *
13*5184Sek110237  * When distributing Covered Code, include this CDDL HEADER in each
14*5184Sek110237  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*5184Sek110237  * If applicable, add the following below this CDDL HEADER, with the
16*5184Sek110237  * fields enclosed by brackets "[]" replaced with your own identifying
17*5184Sek110237  * information: Portions Copyright [yyyy] [name of copyright owner]
18*5184Sek110237  *
19*5184Sek110237  * CDDL HEADER END
20*5184Sek110237  */
21*5184Sek110237 /*
22*5184Sek110237  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*5184Sek110237  * Use is subject to license terms.
24*5184Sek110237  */
25*5184Sek110237 
26*5184Sek110237 #ifndef _FB_FILESET_H
27*5184Sek110237 #define	_FB_FILESET_H
28*5184Sek110237 
29*5184Sek110237 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*5184Sek110237 
31*5184Sek110237 #include "config.h"
32*5184Sek110237 
33*5184Sek110237 #ifndef HAVE_OFF64_T
34*5184Sek110237 /*
35*5184Sek110237  * We are probably on linux.
36*5184Sek110237  * According to http://www.suse.de/~aj/linux_lfs.html, defining the
37*5184Sek110237  * above, automatically changes type of off_t to off64_t. so let
38*5184Sek110237  * us use only off_t as off64_t is not defined
39*5184Sek110237  */
40*5184Sek110237 #define	off64_t off_t
41*5184Sek110237 #endif /* HAVE_OFF64_T */
42*5184Sek110237 
43*5184Sek110237 
44*5184Sek110237 #include <stdio.h>
45*5184Sek110237 #include <stdlib.h>
46*5184Sek110237 #include <unistd.h>
47*5184Sek110237 #include <sys/stat.h>
48*5184Sek110237 #include <sys/types.h>
49*5184Sek110237 #include <sys/param.h>
50*5184Sek110237 #include <sys/resource.h>
51*5184Sek110237 #include <pthread.h>
52*5184Sek110237 
53*5184Sek110237 #include "fileobj.h"
54*5184Sek110237 
55*5184Sek110237 #ifdef	__cplusplus
56*5184Sek110237 extern "C" {
57*5184Sek110237 #endif
58*5184Sek110237 
59*5184Sek110237 #define	FSE_MAXTID 16384
60*5184Sek110237 
61*5184Sek110237 #define	FSE_MAXPATHLEN 16
62*5184Sek110237 #define	FSE_DIR		0x1
63*5184Sek110237 #define	FSE_FREE	0x2
64*5184Sek110237 #define	FSE_EXISTS	0x4
65*5184Sek110237 #define	FSE_BUSY	0x8
66*5184Sek110237 
67*5184Sek110237 typedef struct filesetentry {
68*5184Sek110237 	struct filesetentry	*fse_next;
69*5184Sek110237 	struct filesetentry	*fse_parent;
70*5184Sek110237 	struct filesetentry	*fse_filenext;	/* List of files */
71*5184Sek110237 	struct filesetentry	*fse_dirnext;	/* List of directories */
72*5184Sek110237 	struct fileset		*fse_fileset;	/* Parent fileset */
73*5184Sek110237 	pthread_mutex_t		fse_lock;
74*5184Sek110237 	char			*fse_path;
75*5184Sek110237 	int			fse_depth;
76*5184Sek110237 	off64_t			fse_size;
77*5184Sek110237 	int			fse_flags;
78*5184Sek110237 } filesetentry_t;
79*5184Sek110237 
80*5184Sek110237 #define	FILESET_PICKANY	    0x1 /* Pick any file from the set */
81*5184Sek110237 #define	FILESET_PICKUNIQUE  0x2 /* Pick a unique file from set until empty */
82*5184Sek110237 #define	FILESET_PICKRESET   0x4 /* Reset FILESET_PICKUNIQUE selection list */
83*5184Sek110237 #define	FILESET_PICKDIR	    0x8 /* Pick a directory */
84*5184Sek110237 #define	FILESET_PICKEXISTS  0x10 /* Pick an existing file */
85*5184Sek110237 #define	FILESET_PICKNOEXIST 0x20 /* Pick a file that doesn't exist */
86*5184Sek110237 
87*5184Sek110237 typedef struct fileset {
88*5184Sek110237 	struct fileset	*fs_next;	/* Next in list */
89*5184Sek110237 	char		fs_name[128];	/* Name */
90*5184Sek110237 	pthread_t	fs_tid;		/* Thread id, for par alloc */
91*5184Sek110237 	var_string_t	fs_path;	/* Pathname prefix in fs */
92*5184Sek110237 	var_integer_t	fs_entries;	/* Set size */
93*5184Sek110237 	var_integer_t	fs_preallocpercent; /* Prealloc size */
94*5184Sek110237 	int		fs_attrs;	/* Attributes */
95*5184Sek110237 	var_integer_t	fs_dirwidth;	/* Explicit or 0 for distribution */
96*5184Sek110237 	var_integer_t	fs_size;	/* Explicit or 0 for distribution */
97*5184Sek110237 	var_integer_t	fs_dirgamma;  /* Dirwidth Gamma distribution (* 1000) */
98*5184Sek110237 	var_integer_t	fs_sizegamma; /* Filesize Gamma distribution (* 1000) */
99*5184Sek110237 	var_integer_t	fs_create;	/* Attr */
100*5184Sek110237 	var_integer_t	fs_prealloc;	/* Attr */
101*5184Sek110237 	var_integer_t	fs_cached;	/* Attr */
102*5184Sek110237 	var_integer_t	fs_reuse;	/* Attr */
103*5184Sek110237 	double		fs_meandepth;	/* Computed mean depth */
104*5184Sek110237 	double		fs_meanwidth;	/* Specified mean dir width */
105*5184Sek110237 	double		fs_meansize;	/* Specified mean file size */
106*5184Sek110237 	int		fs_realfiles;	/* Actual files */
107*5184Sek110237 	off64_t		fs_bytes; /* Space potentially consumed by all files */
108*5184Sek110237 	filesetentry_t	*fs_filelist;	/* List of files */
109*5184Sek110237 	filesetentry_t	*fs_dirlist;	/* List of directories */
110*5184Sek110237 	filesetentry_t	*fs_filefree;	/* Ptr to next free file */
111*5184Sek110237 	filesetentry_t	*fs_dirfree;	/* Ptr to next free directory */
112*5184Sek110237 	filesetentry_t	*fs_filerotor[FSE_MAXTID]; /* next file to select */
113*5184Sek110237 	filesetentry_t	*fs_dirrotor;	/* Ptr to next directory to select */
114*5184Sek110237 } fileset_t;
115*5184Sek110237 
116*5184Sek110237 int fileset_createset(fileset_t *);
117*5184Sek110237 int fileset_openfile(fileset_t *fileset, filesetentry_t *entry,
118*5184Sek110237     int flag, int mode, int attrs);
119*5184Sek110237 fileset_t *fileset_define(char *);
120*5184Sek110237 fileset_t *fileset_find(char *name);
121*5184Sek110237 filesetentry_t *fileset_pick(fileset_t *fileset, int flags, int tid);
122*5184Sek110237 char *fileset_resolvepath(filesetentry_t *entry);
123*5184Sek110237 void fileset_usage(void);
124*5184Sek110237 
125*5184Sek110237 #ifdef	__cplusplus
126*5184Sek110237 }
127*5184Sek110237 #endif
128*5184Sek110237 
129*5184Sek110237 #endif	/* _FB_FILESET_H */
130