xref: /netbsd/sys/miscfs/umapfs/umap.h (revision 81f5c57c)
1*81f5c57cSperseant /*	$NetBSD: umap.h,v 1.19 2019/08/20 21:18:10 perseant Exp $	*/
2cf92afd6Scgd 
3cde1d475Smycroft /*
4cde1d475Smycroft  * Copyright (c) 1992, 1993
5cde1d475Smycroft  *	The Regents of the University of California.  All rights reserved.
6cde1d475Smycroft  *
7cde1d475Smycroft  * This code is derived from software donated to Berkeley by
8cde1d475Smycroft  * the UCLA Ficus project.
9cde1d475Smycroft  *
10cde1d475Smycroft  * Redistribution and use in source and binary forms, with or without
11cde1d475Smycroft  * modification, are permitted provided that the following conditions
12cde1d475Smycroft  * are met:
13cde1d475Smycroft  * 1. Redistributions of source code must retain the above copyright
14cde1d475Smycroft  *    notice, this list of conditions and the following disclaimer.
15cde1d475Smycroft  * 2. Redistributions in binary form must reproduce the above copyright
16cde1d475Smycroft  *    notice, this list of conditions and the following disclaimer in the
17cde1d475Smycroft  *    documentation and/or other materials provided with the distribution.
18aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
19cde1d475Smycroft  *    may be used to endorse or promote products derived from this software
20cde1d475Smycroft  *    without specific prior written permission.
21cde1d475Smycroft  *
22cde1d475Smycroft  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23cde1d475Smycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24cde1d475Smycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25cde1d475Smycroft  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26cde1d475Smycroft  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27cde1d475Smycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28cde1d475Smycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29cde1d475Smycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30cde1d475Smycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31cde1d475Smycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32cde1d475Smycroft  * SUCH DAMAGE.
33cde1d475Smycroft  *
34cde1d475Smycroft  *	from: @(#)null_vnops.c       1.5 (Berkeley) 7/10/92
35e5bc90f4Sfvdl  *	@(#)umap.h	8.4 (Berkeley) 8/20/94
36cde1d475Smycroft  */
37cde1d475Smycroft 
389866514dSwrstuden #include <miscfs/genfs/layer.h>
399866514dSwrstuden 
40cde1d475Smycroft #define MAPFILEENTRIES 64
41cde1d475Smycroft #define GMAPFILEENTRIES 16
42cde1d475Smycroft #define NOBODY 32767
43cde1d475Smycroft #define NULLGROUP 65534
44cde1d475Smycroft 
45cde1d475Smycroft struct umap_args {
469866514dSwrstuden 	struct layer_args la;		/* generic layerfs args. Includes
479866514dSwrstuden 					 * target and export info */
489866514dSwrstuden #define	umap_target	la.target
499866514dSwrstuden #define	umap_export	la.export
50cde1d475Smycroft 	int 		nentries;       /* # of entries in user map array */
51cde1d475Smycroft 	int 		gnentries;	/* # of entries in group map array */
52df052e72Scgd 	u_long 		(*mapdata)[2];	/* pointer to array of user mappings */
53df052e72Scgd 	u_long 		(*gmapdata)[2];	/* pointer to array of group mappings */
54cfd321e5Sperseant 	u_long		fsid;		/* user-supplied per-fs ident */
55cde1d475Smycroft };
56cde1d475Smycroft 
579866514dSwrstuden #ifdef _KERNEL
589866514dSwrstuden 
59cde1d475Smycroft struct umap_mount {
609866514dSwrstuden 	struct layer_mount lm;
61cde1d475Smycroft 	int             info_nentries;  /* number of uid mappings */
62cde1d475Smycroft 	int		info_gnentries;	/* number of gid mappings */
63df052e72Scgd 	u_long		info_mapdata[MAPFILEENTRIES][2]; /* mapping data for
64cde1d475Smycroft 	    user mapping in ficus */
65df052e72Scgd 	u_long		info_gmapdata[GMAPFILEENTRIES][2]; /*mapping data for
66cde1d475Smycroft 	    group mapping in ficus */
67cde1d475Smycroft };
689866514dSwrstuden #define	umapm_rootvp		lm.layerm_rootvp
699866514dSwrstuden #define	umapm_export		lm.layerm_export
709866514dSwrstuden #define	umapm_flags		lm.layerm_flags
719866514dSwrstuden #define	umapm_size		lm.layerm_size
729866514dSwrstuden #define	umapm_tag		lm.layerm_tag
739866514dSwrstuden #define	umapm_bypass		lm.layerm_bypass
749866514dSwrstuden #define	umapm_alloc		lm.layerm_alloc
759866514dSwrstuden #define	umapm_vnodeop_p		lm.layerm_vnodeop_p
769866514dSwrstuden #define	umapm_node_hashtbl	lm.layerm_node_hashtbl
779866514dSwrstuden #define	umapm_node_hash		lm.layerm_node_hash
789866514dSwrstuden #define	umapm_hashlock		lm.layerm_hashlock
79cde1d475Smycroft 
80cde1d475Smycroft /*
81cde1d475Smycroft  * A cache of vnode references
82cde1d475Smycroft  */
83cde1d475Smycroft struct umap_node {
849866514dSwrstuden 	struct	layer_node	ln;
85cde1d475Smycroft };
86cde1d475Smycroft 
87af97f2e8Sxtraeme u_long umap_reverse_findid(u_long id, u_long map[][2], int nentries);
88fc9422c9Selad void umap_mapids(struct mount *v_mount, kauth_cred_t credp);
899866514dSwrstuden 
909866514dSwrstuden #define	umap_hash	ln.layer_hash
919866514dSwrstuden #define	umap_lowervp	ln.layer_lowervp
929866514dSwrstuden #define	umap_vnode	ln.layer_vnode
939866514dSwrstuden #define	umap_flags	ln.layer_flags
94cde1d475Smycroft 
95cde1d475Smycroft #define	MOUNTTOUMAPMOUNT(mp) ((struct umap_mount *)((mp)->mnt_data))
96cde1d475Smycroft #define	VTOUMAP(vp) ((struct umap_node *)(vp)->v_data)
97cde1d475Smycroft #define UMAPTOV(xp) ((xp)->umap_vnode)
98*81f5c57cSperseant #ifdef UMAPFS_DIAGNOSTIC
999866514dSwrstuden #define	UMAPVPTOLOWERVP(vp) layer_checkvp((vp), __FILE__, __LINE__)
100*81f5c57cSperseant #else
101cde1d475Smycroft #define	UMAPVPTOLOWERVP(vp) (VTOUMAP(vp)->umap_lowervp)
102*81f5c57cSperseant #endif
103cde1d475Smycroft 
104af97f2e8Sxtraeme extern int (**umap_vnodeop_p)(void *);
105c9efd056Sthorpej extern struct vfsops umapfs_vfsops;
106631ccba6Schristos 
107af97f2e8Sxtraeme int     umap_bypass(void *);
1089866514dSwrstuden 
1099866514dSwrstuden #define NUMAPNODECACHE	16
110631ccba6Schristos 
1116efcd1b6Sbriggs #endif /* _KERNEL */
112