11541Srgrimes/*- 21541Srgrimes * Copyright (c) 1992, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * (c) UNIX System Laboratories, Inc. 51541Srgrimes * All or some portions of this file are derived from material licensed 61541Srgrimes * to the University of California by American Telephone and Telegraph 71541Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 81541Srgrimes * the permission of UNIX System Laboratories, Inc. 91541Srgrimes * 101541Srgrimes * Redistribution and use in source and binary forms, with or without 111541Srgrimes * modification, are permitted provided that the following conditions 121541Srgrimes * are met: 131541Srgrimes * 1. Redistributions of source code must retain the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer. 151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161541Srgrimes * notice, this list of conditions and the following disclaimer in the 171541Srgrimes * documentation and/or other materials provided with the distribution. 181541Srgrimes * 4. Neither the name of the University nor the names of its contributors 191541Srgrimes * may be used to endorse or promote products derived from this software 201541Srgrimes * without specific prior written permission. 211541Srgrimes * 221541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 231541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 241541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 261541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321541Srgrimes * SUCH DAMAGE. 331541Srgrimes * 341541Srgrimes * @(#)exec.h 8.3 (Berkeley) 1/21/94 3550477Speter * $FreeBSD$ 361541Srgrimes */ 371541Srgrimes 382165Spaul#ifndef _SYS_EXEC_H_ 392165Spaul#define _SYS_EXEC_H_ 402165Spaul 411541Srgrimes/* 42270670Swblock * Before ps_args existed, the following structure, found at the top of 43270670Swblock * the user stack of each user process, was used by ps(1) to locate 44270670Swblock * environment and argv strings. Normally ps_argvstr points to the 45270670Swblock * argv vector, and ps_nargvstr is the same as the program's argc. The 46270670Swblock * fields ps_envstr and ps_nenvstr are the equivalent for the environment. 47270670Swblock * 48270670Swblock * Programs should now use setproctitle(3) to change ps output. 49270670Swblock * setproctitle() always informs the kernel with sysctl and sets the 50270670Swblock * pointers in ps_strings. The kern.proc.args sysctl first tries p_args. 51270670Swblock * If p_args is NULL, it then falls back to reading ps_strings and following 52270670Swblock * the pointers. 531541Srgrimes */ 541541Srgrimesstruct ps_strings { 5512679Speter char **ps_argvstr; /* first of 0 or more argument strings */ 56144011Sdas unsigned int ps_nargvstr; /* the number of argument strings */ 5712679Speter char **ps_envstr; /* first of 0 or more environment strings */ 58144011Sdas unsigned int ps_nenvstr; /* the number of environment strings */ 591541Srgrimes}; 601541Srgrimes 611541Srgrimes/* 621541Srgrimes * Address of ps_strings structure (in user space). 63270670Swblock * Prefer the kern.ps_strings or kern.proc.ps_strings sysctls to this constant. 641541Srgrimes */ 6541871Sbde#define PS_STRINGS (USRSTACK - sizeof(struct ps_strings)) 66122252Speter#define SPARE_USRSPACE 4096 671541Srgrimes 6812251Sbdestruct image_params; 6912251Sbde 702124Sdgstruct execsw { 7192719Salfred int (*ex_imgact)(struct image_params *); 722124Sdg const char *ex_name; 732124Sdg}; 742124Sdg 753058Sdg#include <machine/exec.h> 763058Sdg 7755205Speter#ifdef _KERNEL 7833983Speter#include <sys/cdefs.h> 7933983Speter 8092719Salfredint exec_map_first_page(struct image_params *); 8192719Salfredvoid exec_unmap_first_page(struct image_params *); 8240435Speter 8392719Salfredint exec_register(const struct execsw *); 8492719Salfredint exec_unregister(const struct execsw *); 8540435Speter 86295454Sjhbextern int coredump_pack_fileinfo; 87295454Sjhbextern int coredump_pack_vmmapinfo; 88295454Sjhb 8943387Sdillon/* 9043387Sdillon * note: name##_mod cannot be const storage because the 9143387Sdillon * linker_file_sysinit() function modifies _file in the 9243387Sdillon * moduledata_t. 9343387Sdillon */ 9443387Sdillon 9540435Speter#include <sys/module.h> 9643387Sdillon 9740435Speter#define EXEC_SET(name, execsw_arg) \ 98108647Sjake static int __CONCAT(name,_modevent)(module_t mod, int type, \ 99108647Sjake void *data) \ 10040435Speter { \ 10140435Speter struct execsw *exec = (struct execsw *)data; \ 10240435Speter int error = 0; \ 10340435Speter switch (type) { \ 10440435Speter case MOD_LOAD: \ 10540435Speter /* printf(#name " module loaded\n"); */ \ 10640435Speter error = exec_register(exec); \ 10740435Speter if (error) \ 108108647Sjake printf(__XSTRING(name) "register failed\n"); \ 10940435Speter break; \ 11040435Speter case MOD_UNLOAD: \ 11140435Speter /* printf(#name " module unloaded\n"); */ \ 11240435Speter error = exec_unregister(exec); \ 11340435Speter if (error) \ 114108647Sjake printf(__XSTRING(name) " unregister failed\n");\ 11540435Speter break; \ 11640435Speter default: \ 117132199Sphk error = EOPNOTSUPP; \ 11840435Speter break; \ 11940435Speter } \ 12040435Speter return error; \ 12140435Speter } \ 122108647Sjake static moduledata_t __CONCAT(name,_mod) = { \ 123108647Sjake __XSTRING(name), \ 124108647Sjake __CONCAT(name,_modevent), \ 12540435Speter (void *)& execsw_arg \ 12640435Speter }; \ 127213716Skib DECLARE_MODULE_TIED(name, __CONCAT(name,_mod), SI_SUB_EXEC, \ 128213716Skib SI_ORDER_ANY) 1292165Spaul#endif 13033983Speter 13133983Speter#endif 132