xref: /original-bsd/sys/miscfs/umapfs/umap.h (revision 333da485)
1 /*
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software donated to Berkeley by
6  * the UCLA Ficus project.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)umap.h	8.3 (Berkeley) 01/21/94
11  *
12  * @(#)null_vnops.c       1.5 (Berkeley) 7/10/92
13  */
14 
15 #define MAPFILEENTRIES 64
16 #define GMAPFILEENTRIES 16
17 #define NOBODY 32767
18 #define NULLGROUP 65534
19 
20 struct umap_args {
21 	char		*target;	/* Target of loopback  */
22 	int 		nentries;       /* # of entries in user map array */
23 	int 		gnentries;	/* # of entries in group map array */
24 	u_long 		(*mapdata)[2];	/* pointer to array of user mappings */
25 	u_long 		(*gmapdata)[2];	/* pointer to array of group mappings */
26 };
27 
28 struct umap_mount {
29 	struct mount	*umapm_vfs;
30 	struct vnode	*umapm_rootvp;	/* Reference to root umap_node */
31 	int             info_nentries;  /* number of uid mappings */
32 	int		info_gnentries;	/* number of gid mappings */
33 	u_long		info_mapdata[MAPFILEENTRIES][2]; /* mapping data for
34 	    user mapping in ficus */
35 	u_long		info_gmapdata[GMAPFILEENTRIES][2]; /*mapping data for
36 	    group mapping in ficus */
37 };
38 
39 #ifdef KERNEL
40 /*
41  * A cache of vnode references
42  */
43 struct umap_node {
44 	struct umap_node	*umap_forw;	/* Hash chain */
45 	struct umap_node	*umap_back;
46 	struct vnode	*umap_lowervp;	/* Aliased vnode - VREFed once */
47 	struct vnode	*umap_vnode;	/* Back pointer to vnode/umap_node */
48 };
49 
50 extern int umap_node_create __P((struct mount *mp, struct vnode *target, struct vnode **vpp));
51 extern u_long umap_reverse_findid __P((u_long id, u_long map[][2], int nentries));
52 extern void umap_mapids __P((struct mount *v_mount, struct ucred *credp));
53 
54 #define	MOUNTTOUMAPMOUNT(mp) ((struct umap_mount *)((mp)->mnt_data))
55 #define	VTOUMAP(vp) ((struct umap_node *)(vp)->v_data)
56 #define UMAPTOV(xp) ((xp)->umap_vnode)
57 #ifdef UMAPFS_DIAGNOSTIC
58 extern struct vnode *umap_checkvp __P((struct vnode *vp, char *fil, int lno));
59 #define	UMAPVPTOLOWERVP(vp) umap_checkvp((vp), __FILE__, __LINE__)
60 #else
61 #define	UMAPVPTOLOWERVP(vp) (VTOUMAP(vp)->umap_lowervp)
62 #endif
63 
64 extern int (**umap_vnodeop_p)();
65 extern struct vfsops umap_vfsops;
66 #endif /* KERNEL */
67