xref: /onnv-gate/usr/src/cmd/fs.d/cachefs/common/subr.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright (c) 1996-1998, by Sun Microsystems, Inc.
24*0Sstevel@tonic-gate  * All Rights Reserved.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_SUBR_H
28*0Sstevel@tonic-gate #define	_SUBR_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  *
34*0Sstevel@tonic-gate  *			subr.h
35*0Sstevel@tonic-gate  *
36*0Sstevel@tonic-gate  * Function prototypes for subr.c
37*0Sstevel@tonic-gate  */
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate #include <ftw.h>
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate /* size to make a buffer for holding a pathname */
42*0Sstevel@tonic-gate #define	CACHEFS_XMAXPATH (PATH_MAX + MAXNAMELEN + 2)
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate #ifdef __cplusplus
45*0Sstevel@tonic-gate extern "C" {
46*0Sstevel@tonic-gate #endif
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate /* resource file info */
49*0Sstevel@tonic-gate struct cachefs_rinfo {
50*0Sstevel@tonic-gate 	int	r_fsize;	/* total file size */
51*0Sstevel@tonic-gate 	int	r_ptroffset;	/* offset to pointers area */
52*0Sstevel@tonic-gate 	int	r_ptrsize;	/* size of pointers area */
53*0Sstevel@tonic-gate 	int	r_identoffset;	/* offset to idents area */
54*0Sstevel@tonic-gate 	int	r_identsize;	/* size of idents area */
55*0Sstevel@tonic-gate };
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate struct cachefs_user_values {
58*0Sstevel@tonic-gate 	int uv_maxblocks;
59*0Sstevel@tonic-gate 	int uv_minblocks;
60*0Sstevel@tonic-gate 	int uv_threshblocks;
61*0Sstevel@tonic-gate 	int uv_maxfiles;
62*0Sstevel@tonic-gate 	int uv_minfiles;
63*0Sstevel@tonic-gate 	int uv_threshfiles;
64*0Sstevel@tonic-gate 	int uv_maxfilesize;
65*0Sstevel@tonic-gate 	int uv_hiblocks;
66*0Sstevel@tonic-gate 	int uv_lowblocks;
67*0Sstevel@tonic-gate 	int uv_hifiles;
68*0Sstevel@tonic-gate 	int uv_lowfiles;
69*0Sstevel@tonic-gate };
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate int cachefs_dir_lock(const char *cachedirp, int shared);
72*0Sstevel@tonic-gate int cachefs_dir_unlock(int fd);
73*0Sstevel@tonic-gate int cachefs_label_file_get(const char *filep, struct cache_label *clabelp);
74*0Sstevel@tonic-gate int cachefs_label_file_put(const char *filep, struct cache_label *clabelp);
75*0Sstevel@tonic-gate int cachefs_inuse(const char *cachedirp);
76*0Sstevel@tonic-gate int cachefs_label_file_vcheck(char *filep, struct cache_label *clabelp);
77*0Sstevel@tonic-gate void cachefs_resource_size(int maxinodes, struct cachefs_rinfo *rinfop);
78*0Sstevel@tonic-gate int cachefs_create_cache(char *dirp, struct cachefs_user_values *,
79*0Sstevel@tonic-gate     struct cache_label *);
80*0Sstevel@tonic-gate int cachefs_delete_all_cache(char *dirp);
81*0Sstevel@tonic-gate int cachefs_delete_cache(char *dirp, char *namep);
82*0Sstevel@tonic-gate int cachefs_delete_file(const char *namep, const struct stat64 *statp, int flg,
83*0Sstevel@tonic-gate     struct FTW *ftwp);
84*0Sstevel@tonic-gate int cachefs_convert_uv2cl(const struct cachefs_user_values *uvp,
85*0Sstevel@tonic-gate     struct cache_label *clp, const char *dirp);
86*0Sstevel@tonic-gate int cachefs_convert_cl2uv(const struct cache_label *clp,
87*0Sstevel@tonic-gate     struct cachefs_user_values *uvp, const char *dirp);
88*0Sstevel@tonic-gate char *cachefs_file_to_dir(const char *);
89*0Sstevel@tonic-gate int cachefs_clean_flag_test(const char *cachedirp);
90*0Sstevel@tonic-gate void pr_err(char *fmt, ...);
91*0Sstevel@tonic-gate time32_t get_boottime(void);
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate #ifdef __cplusplus
94*0Sstevel@tonic-gate }
95*0Sstevel@tonic-gate #endif
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate #endif /* _SUBR_H */
98