1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_BRAND_H 28 #define _SYS_BRAND_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #include <sys/proc.h> 35 #include <sys/exec.h> 36 37 /* 38 * All Brands supported by this kernel must use BRAND_VER_1. 39 */ 40 #define BRAND_VER_1 1 41 42 /* 43 * sub-commands to brandsys. 44 * 1 - 128 are for common commands 45 * 128+ are available for brand-specific commands. 46 */ 47 #define B_REGISTER 1 48 #define B_TTYMODES 2 49 #define B_ELFDATA 3 50 #define B_EXEC_NATIVE 4 51 #define B_EXEC_BRAND 5 52 53 /* 54 * Structure used by zoneadmd to communicate the name of a brand and the 55 * supporting brand module into the kernel. 56 */ 57 struct brand_attr { 58 char ba_brandname[MAXNAMELEN]; 59 char ba_modname[MAXPATHLEN]; 60 }; 61 62 /* What we call the native brand. */ 63 #define NATIVE_BRAND_NAME "native" 64 65 /* What we call the labeled brand. */ 66 #define LABELED_BRAND_NAME "labeled" 67 68 #ifdef _KERNEL 69 70 /* Root for branded zone's native binaries */ 71 #define NATIVE_ROOT "/native/" 72 73 struct proc; 74 struct uarg; 75 struct brand_mach_ops; 76 struct intpdata; 77 struct execa; 78 79 struct brand_ops { 80 void (*b_init_brand_data)(zone_t *); 81 void (*b_free_brand_data)(zone_t *); 82 int (*b_brandsys)(int, int64_t *, uintptr_t, uintptr_t, uintptr_t, 83 uintptr_t, uintptr_t, uintptr_t); 84 void (*b_setbrand)(struct proc *); 85 int (*b_getattr)(zone_t *, int, void *, size_t *); 86 int (*b_setattr)(zone_t *, int, void *, size_t); 87 void (*b_copy_procdata)(struct proc *, struct proc *); 88 void (*b_proc_exit)(struct proc *, klwp_t *); 89 void (*b_exec)(); 90 void (*b_lwp_setrval)(klwp_t *, int, int); 91 int (*b_initlwp)(klwp_t *); 92 void (*b_forklwp)(klwp_t *, klwp_t *); 93 void (*b_freelwp)(klwp_t *); 94 void (*b_lwpexit)(klwp_t *); 95 int (*b_elfexec)(struct vnode *vp, struct execa *uap, 96 struct uarg *args, struct intpdata *idata, int level, 97 long *execsz, int setid, caddr_t exec_file, 98 struct cred *cred, int brand_action); 99 int b_nsig; 100 }; 101 102 /* 103 * The b_version field must always be the first entry in this struct. 104 */ 105 typedef struct brand { 106 int b_version; 107 char *b_name; 108 struct brand_ops *b_ops; 109 struct brand_mach_ops *b_machops; 110 } brand_t; 111 112 extern brand_t native_brand; 113 114 /* 115 * Convenience macros 116 */ 117 #define lwptolwpbrand(l) ((l)->lwp_brand) 118 #define ttolwpbrand(t) (lwptolwpbrand(ttolwp(t))) 119 #define PROC_IS_BRANDED(p) ((p)->p_brand != &native_brand) 120 #define ZONE_IS_BRANDED(z) ((z)->zone_brand != &native_brand) 121 #define BROP(p) ((p)->p_brand->b_ops) 122 #define ZBROP(z) ((z)->zone_brand->b_ops) 123 #define BRMOP(p) ((p)->p_brand->b_machops) 124 125 extern void brand_init(); 126 extern int brand_register(brand_t *); 127 extern int brand_unregister(brand_t *); 128 extern brand_t *brand_register_zone(struct brand_attr *); 129 extern brand_t *brand_find_name(char *); 130 extern void brand_unregister_zone(brand_t *); 131 extern int brand_zone_count(brand_t *); 132 extern void brand_setbrand(proc_t *); 133 extern void brand_clearbrand(proc_t *); 134 #endif /* _KERNEL */ 135 136 #ifdef __cplusplus 137 } 138 #endif 139 140 #endif /* _SYS_BRAND_H */ 141