Path: blob/buildjre8/ios-missing-include/libproc.h
861 views
/*1* Copyright (c) 2006, 2007, 2010 Apple Inc. All rights reserved.2*3* @APPLE_LICENSE_HEADER_START@4*5* This file contains Original Code and/or Modifications of Original Code6* as defined in and that are subject to the Apple Public Source License7* Version 2.0 (the 'License'). You may not use this file except in8* compliance with the License. Please obtain a copy of the License at9* http://www.opensource.apple.com/apsl/ and read it before using this10* file.11*12* The Original Code and all software distributed under the License are13* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER14* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,15* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.17* Please see the License for the specific language governing rights and18* limitations under the License.19*20* @APPLE_LICENSE_HEADER_END@21*/22#ifndef _LIBPROC_H_23#define _LIBPROC_H_2425#include <sys/cdefs.h>26#include <sys/param.h>27#include <sys/types.h>28#include <sys/stat.h>29#include <sys/mount.h>30#include <sys/resource.h>31#include <stdint.h>32#include <stdbool.h>33#include <mach/message.h> /* for audit_token_t */3435#include <sys/proc_info.h>3637#include <Availability.h>38#include <os/availability.h>3940/*41* This header file contains private interfaces to obtain process information.42* These interfaces are subject to change in future releases.43*/4445/*!46* @define PROC_LISTPIDSPATH_PATH_IS_VOLUME47* @discussion This flag indicates that all processes that hold open48* file references on the volume associated with the specified49* path should be returned.50*/51#define PROC_LISTPIDSPATH_PATH_IS_VOLUME 1525354/*!55* @define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY56* @discussion This flag indicates that file references that were opened57* with the O_EVTONLY flag should be excluded from the matching58* criteria.59*/60#define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY 26162__BEGIN_DECLS636465/*!66* @function proc_listpidspath67* @discussion A function which will search through the current68* processes looking for open file references which match69* a specified path or volume.70* @param type types of processes to be searched (see proc_listpids)71* @param typeinfo adjunct information for type72* @param path file or volume path73* @param pathflags flags to control which files should be considered74* during the process search.75* @param buffer a C array of int-sized values to be filled with76* process identifiers that hold an open file reference77* matching the specified path or volume. Pass NULL to78* obtain the minimum buffer size needed to hold the79* currently active processes.80* @param buffersize the size (in bytes) of the provided buffer.81* @result the number of bytes of data returned in the provided buffer;82* -1 if an error was encountered;83*/84int proc_listpidspath(uint32_t type,85uint32_t typeinfo,86const char *path,87uint32_t pathflags,88void *buffer,89int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);9091int proc_listpids(uint32_t type, uint32_t typeinfo, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);92int proc_listallpids(void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);93int proc_listpgrppids(pid_t pgrpid, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);94int proc_listchildpids(pid_t ppid, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);95int proc_pidinfo(int pid, int flavor, uint64_t arg, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);96int proc_pidfdinfo(int pid, int fd, int flavor, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);97int proc_pidfileportinfo(int pid, uint32_t fileport, int flavor, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);98int proc_name(int pid, void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);99int proc_regionfilename(int pid, uint64_t address, void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);100int proc_kmsgbuf(void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);101int proc_pidpath(int pid, void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);102int proc_pidpath_audittoken(audit_token_t *audittoken, void * buffer, uint32_t buffersize) API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0));103int proc_libversion(int *major, int * minor) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);104105/*106* Return resource usage information for the given pid, which can be a live process or a zombie.107*108* Returns 0 on success; or -1 on failure, with errno set to indicate the specific error.109*/110int proc_pid_rusage(int pid, int flavor, rusage_info_t *buffer) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);111112/*113* A process can use the following api to set its own process control114* state on resoure starvation. The argument can have one of the PROC_SETPC_XX values115*/116#define PROC_SETPC_NONE 0117#define PROC_SETPC_THROTTLEMEM 1118#define PROC_SETPC_SUSPEND 2119#define PROC_SETPC_TERMINATE 3120121int proc_setpcontrol(const int control) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);122int proc_setpcontrol(const int control);123124int proc_track_dirty(pid_t pid, uint32_t flags);125int proc_set_dirty(pid_t pid, bool dirty);126int proc_get_dirty(pid_t pid, uint32_t *flags);127int proc_clear_dirty(pid_t pid, uint32_t flags);128129int proc_terminate(pid_t pid, int *sig);130131/*132* NO_SMT means that on an SMT CPU, this thread must be scheduled alone,133* with the paired CPU idle.134*135* Set NO_SMT on the current proc (all existing and future threads)136* This attribute is inherited on fork and exec137*/138int proc_set_no_smt(void) __API_AVAILABLE(macos(11.0));139140/* Set NO_SMT on the current thread */141int proc_setthread_no_smt(void) __API_AVAILABLE(macos(11.0));142143/*144* CPU Security Mitigation APIs145*146* Set CPU security mitigation on the current proc (all existing and future threads)147* This attribute is inherited on fork and exec148*/149int proc_set_csm(uint32_t flags) __API_AVAILABLE(macos(11.0));150151/* Set CPU security mitigation on the current thread */152int proc_setthread_csm(uint32_t flags) __API_AVAILABLE(macos(11.0));153154/*155* flags for CPU Security Mitigation APIs156* PROC_CSM_ALL should be used in most cases,157* the individual flags are provided only for performance evaluation etc158*/159#define PROC_CSM_ALL 0x0001 /* Set all available mitigations */160#define PROC_CSM_NOSMT 0x0002 /* Set NO_SMT - see above */161#define PROC_CSM_TECS 0x0004 /* Execute VERW on every return to user mode */162163#ifdef PRIVATE164#include <sys/event.h>165/*166* Enumerate potential userspace pointers embedded in kernel data structures.167* Currently inspects kqueues only.168*169* NOTE: returned "pointers" are opaque user-supplied values and thus not170* guaranteed to address valid objects or be pointers at all.171*172* Returns the number of pointers found (which may exceed buffersize), or -1 on173* failure and errno set appropriately.174*/175int proc_list_uptrs(pid_t pid, uint64_t *buffer, uint32_t buffersize);176177int proc_list_dynkqueueids(int pid, kqueue_id_t *buf, uint32_t bufsz);178int proc_piddynkqueueinfo(int pid, int flavor, kqueue_id_t kq_id, void *buffer,179int buffersize);180#endif /* PRIVATE */181182int proc_udata_info(int pid, int flavor, void *buffer, int buffersize);183184__END_DECLS185186#endif /*_LIBPROC_H_ */187188189