brand.h revision 6994:f537e4b46012
175584Sru/* 275584Sru * CDDL HEADER START 375584Sru * 475584Sru * The contents of this file are subject to the terms of the 575584Sru * Common Development and Distribution License (the "License"). 675584Sru * You may not use this file except in compliance with the License. 775584Sru * 875584Sru * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 975584Sru * or http://www.opensolaris.org/os/licensing. 1075584Sru * See the License for the specific language governing permissions 1175584Sru * and limitations under the License. 1275584Sru * 1375584Sru * When distributing Covered Code, include this CDDL HEADER in each 1475584Sru * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1575584Sru * If applicable, add the following below this CDDL HEADER, with the 1675584Sru * fields enclosed by brackets "[]" replaced with your own identifying 1775584Sru * information: Portions Copyright [yyyy] [name of copyright owner] 1875584Sru * 1975584Sru * CDDL HEADER END 2075584Sru */ 2175584Sru/* 2275584Sru * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2375584Sru * Use is subject to license terms. 2475584Sru */ 2575584Sru 2675584Sru#ifndef _SYS_BRAND_H 2775584Sru#define _SYS_BRAND_H 2875584Sru 2975584Sru#pragma ident "%Z%%M% %I% %E% SMI" 3075584Sru 3175584Sru#ifdef __cplusplus 3275584Sruextern "C" { 3375584Sru#endif 3475584Sru 3575584Sru#include <sys/proc.h> 3675584Sru#include <sys/exec.h> 3775584Sru 3875584Sru/* 3975584Sru * All Brands supported by this kernel must use BRAND_VER_1. 4075584Sru */ 4175584Sru#define BRAND_VER_1 1 4275584Sru 4375584Sru/* 4475584Sru * sub-commands to brandsys. 4575584Sru * 1 - 128 are for common commands 4675584Sru * 128+ are available for brand-specific commands. 4775584Sru */ 4875584Sru#define B_REGISTER 1 4975584Sru#define B_TTYMODES 2 5075584Sru#define B_ELFDATA 3 5175584Sru#define B_EXEC_NATIVE 4 5275584Sru#define B_EXEC_BRAND 5 5375584Sru 5475584Sru/* 5575584Sru * Structure used by zoneadmd to communicate the name of a brand and the 5675584Sru * supporting brand module into the kernel. 5775584Sru */ 5875584Srustruct brand_attr { 5975584Sru char ba_brandname[MAXNAMELEN]; 6075584Sru char ba_modname[MAXPATHLEN]; 6175584Sru}; 6275584Sru 6375584Sru/* What we call the native brand. */ 6475584Sru#define NATIVE_BRAND_NAME "native" 6575584Sru 6675584Sru#ifdef _KERNEL 6775584Sru 6875584Sru/* Root for branded zone's native binaries */ 6975584Sru#define NATIVE_ROOT "/native/" 7075584Sru 7175584Srustruct proc; 7275584Srustruct uarg; 7375584Srustruct brand_mach_ops; 7475584Srustruct intpdata; 7575584Srustruct execa; 7675584Sru 7775584Srustruct brand_ops { 7875584Sru void (*b_init_brand_data)(zone_t *); 7975584Sru void (*b_free_brand_data)(zone_t *); 8075584Sru int (*b_brandsys)(int, int64_t *, uintptr_t, uintptr_t, uintptr_t, 8175584Sru uintptr_t, uintptr_t, uintptr_t); 8275584Sru void (*b_setbrand)(struct proc *); 8375584Sru int (*b_getattr)(zone_t *, int, void *, size_t *); 8475584Sru int (*b_setattr)(zone_t *, int, void *, size_t); 8575584Sru void (*b_copy_procdata)(struct proc *, struct proc *); 8675584Sru void (*b_proc_exit)(struct proc *, klwp_t *); 8775584Sru void (*b_exec)(); 8875584Sru void (*b_lwp_setrval)(klwp_t *, int, int); 8975584Sru int (*b_initlwp)(klwp_t *); 9075584Sru void (*b_forklwp)(klwp_t *, klwp_t *); 9175584Sru void (*b_freelwp)(klwp_t *); 9275584Sru void (*b_lwpexit)(klwp_t *); 9375584Sru int (*b_elfexec)(struct vnode *vp, struct execa *uap, 9475584Sru struct uarg *args, struct intpdata *idata, int level, 9575584Sru long *execsz, int setid, caddr_t exec_file, 9675584Sru struct cred *cred, int brand_action); 9775584Sru}; 9875584Sru 9975584Sru/* 10075584Sru * The b_version field must always be the first entry in this struct. 10175584Sru */ 10275584Srutypedef struct brand { 10375584Sru int b_version; 10475584Sru char *b_name; 10575584Sru struct brand_ops *b_ops; 10675584Sru struct brand_mach_ops *b_machops; 10775584Sru} brand_t; 10875584Sru 10975584Sruextern brand_t native_brand; 11075584Sru 11175584Sru/* 11275584Sru * Convenience macros 11375584Sru */ 11475584Sru#define lwptolwpbrand(l) ((l)->lwp_brand) 11575584Sru#define ttolwpbrand(t) (lwptolwpbrand(ttolwp(t))) 11675584Sru#define PROC_IS_BRANDED(p) ((p)->p_brand != &native_brand) 11775584Sru#define ZONE_IS_BRANDED(z) ((z)->zone_brand != &native_brand) 11875584Sru#define BROP(p) ((p)->p_brand->b_ops) 11975584Sru#define ZBROP(z) ((z)->zone_brand->b_ops) 12075584Sru#define BRMOP(p) ((p)->p_brand->b_machops) 12175584Sru 12275584Sruextern void brand_init(); 12375584Sruextern int brand_register(brand_t *); 12475584Sruextern int brand_unregister(brand_t *); 12575584Sruextern brand_t *brand_register_zone(struct brand_attr *); 12675584Sruextern brand_t *brand_find_name(char *); 12775584Sruextern void brand_unregister_zone(brand_t *); 12875584Sruextern int brand_zone_count(brand_t *); 12975584Sruextern void brand_setbrand(proc_t *); 13075584Sruextern void brand_clearbrand(proc_t *); 13175584Sru#endif /* _KERNEL */ 13275584Sru 13375584Sru#ifdef __cplusplus 13475584Sru} 13575584Sru#endif 13675584Sru 13775584Sru#endif /* _SYS_BRAND_H */ 13875584Sru