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 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_BRAND_H 27 #define _SYS_BRAND_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 #include <sys/proc.h> 36 #include <sys/exec.h> 37 38 /* 39 * All Brands supported by this kernel must use BRAND_VER_1. 40 */ 41 #define BRAND_VER_1 1 42 43 /* 44 * sub-commands to brandsys. 45 * 1 - 128 are for common commands 46 * 128+ are available for brand-specific commands. 47 */ 48 #define B_REGISTER 1 49 #define B_TTYMODES 2 50 #define B_ELFDATA 3 51 #define B_EXEC_NATIVE 4 52 #define B_EXEC_BRAND 5 53 54 /* 55 * Structure used by zoneadmd to communicate the name of a brand and the 56 * supporting brand module into the kernel. 57 */ 58 struct brand_attr { 59 char ba_brandname[MAXNAMELEN]; 60 char ba_modname[MAXPATHLEN]; 61 }; 62 63 /* What we call the native brand. */ 64 #define NATIVE_BRAND_NAME "native" 65 66 #ifdef _KERNEL 67 68 /* Root for branded zone's native binaries */ 69 #define NATIVE_ROOT "/native/" 70 71 struct proc; 72 struct uarg; 73 struct brand_mach_ops; 74 struct intpdata; 75 struct execa; 76 77 struct brand_ops { 78 int (*b_brandsys)(int, int64_t *, uintptr_t, uintptr_t, uintptr_t, 79 uintptr_t, uintptr_t, uintptr_t); 80 void (*b_setbrand)(struct proc *); 81 int (*b_getattr)(zone_t *, int, void *, size_t *); 82 int (*b_setattr)(zone_t *, int, void *, size_t); 83 void (*b_copy_procdata)(struct proc *, struct proc *); 84 void (*b_proc_exit)(struct proc *, klwp_t *); 85 void (*b_exec)(); 86 void (*b_lwp_setrval)(klwp_t *, int, int); 87 int (*b_initlwp)(klwp_t *); 88 void (*b_forklwp)(klwp_t *, klwp_t *); 89 void (*b_freelwp)(klwp_t *); 90 void (*b_lwpexit)(klwp_t *); 91 int (*b_elfexec)(struct vnode *vp, struct execa *uap, 92 struct uarg *args, struct intpdata *idata, int level, 93 long *execsz, int setid, caddr_t exec_file, 94 struct cred *cred, int brand_action); 95 }; 96 97 /* 98 * The b_version field must always be the first entry in this struct. 99 */ 100 typedef struct brand { 101 int b_version; 102 char *b_name; 103 struct brand_ops *b_ops; 104 struct brand_mach_ops *b_machops; 105 } brand_t; 106 107 extern brand_t native_brand; 108 109 /* 110 * Convenience macros 111 */ 112 #define lwptolwpbrand(l) ((l)->lwp_brand) 113 #define ttolwpbrand(t) (lwptolwpbrand(ttolwp(t))) 114 #define PROC_IS_BRANDED(p) ((p)->p_brand != &native_brand) 115 #define ZONE_IS_BRANDED(z) ((z)->zone_brand != &native_brand) 116 #define BROP(p) ((p)->p_brand->b_ops) 117 #define ZBROP(z) ((z)->zone_brand->b_ops) 118 #define BRMOP(p) ((p)->p_brand->b_machops) 119 120 extern void brand_init(); 121 extern int brand_register(brand_t *); 122 extern int brand_unregister(brand_t *); 123 extern brand_t *brand_register_zone(struct brand_attr *); 124 extern brand_t *brand_find_name(char *); 125 extern void brand_unregister_zone(brand_t *); 126 extern int brand_zone_count(brand_t *); 127 extern void brand_setbrand(proc_t *); 128 #endif /* _KERNEL */ 129 130 #ifdef __cplusplus 131 } 132 #endif 133 134 #endif /* _SYS_BRAND_H */ 135