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