1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 2006 Roman Divacky 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer 12 * in this position and unchanged. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * $FreeBSD$ 31 */ 32 33 #ifndef _LINUX_MISC_H_ 34 #define _LINUX_MISC_H_ 35 36 #include <sys/sysctl.h> 37 38 /* bits per mask */ 39 #define LINUX_NFDBITS sizeof(l_fd_mask) * 8 40 41 /* 42 * Miscellaneous 43 */ 44 #define LINUX_NAME_MAX 255 45 #define LINUX_MAX_UTSNAME 65 46 47 #define LINUX_CTL_MAXNAME 10 48 49 /* defines for prctl */ 50 #define LINUX_PR_SET_PDEATHSIG 1 /* Second arg is a signal. */ 51 #define LINUX_PR_GET_PDEATHSIG 2 /* 52 * Second arg is a ptr to return the 53 * signal. 54 */ 55 #define LINUX_PR_GET_KEEPCAPS 7 /* Get drop capabilities on setuid */ 56 #define LINUX_PR_SET_KEEPCAPS 8 /* Set drop capabilities on setuid */ 57 #define LINUX_PR_SET_NAME 15 /* Set process name. */ 58 #define LINUX_PR_GET_NAME 16 /* Get process name. */ 59 60 #define LINUX_MAX_COMM_LEN 16 /* Maximum length of the process name. */ 61 62 #define LINUX_MREMAP_MAYMOVE 1 63 #define LINUX_MREMAP_FIXED 2 64 65 #define LINUX_PATH_MAX 4096 66 67 extern const char *linux_kplatform; 68 69 /* 70 * Non-standard aux entry types used in Linux ELF binaries. 71 */ 72 73 #define LINUX_AT_PLATFORM 15 /* String identifying CPU */ 74 #define LINUX_AT_HWCAP 16 /* CPU capabilities */ 75 #define LINUX_AT_CLKTCK 17 /* frequency at which times() increments */ 76 #define LINUX_AT_SECURE 23 /* secure mode boolean */ 77 #define LINUX_AT_BASE_PLATFORM 24 /* string identifying real platform, may 78 * differ from AT_PLATFORM. 79 */ 80 #define LINUX_AT_RANDOM 25 /* address of random bytes */ 81 #define LINUX_AT_EXECFN 31 /* filename of program */ 82 #define LINUX_AT_SYSINFO 32 /* vsyscall */ 83 #define LINUX_AT_SYSINFO_EHDR 33 /* vdso header */ 84 85 #define LINUX_AT_RANDOM_LEN 16 /* size of random bytes */ 86 87 /* Linux sets the i387 to extended precision. */ 88 #if defined(__i386__) || defined(__amd64__) 89 #define __LINUX_NPXCW__ 0x37f 90 #endif 91 92 #define LINUX_CLONE_VM 0x00000100 93 #define LINUX_CLONE_FS 0x00000200 94 #define LINUX_CLONE_FILES 0x00000400 95 #define LINUX_CLONE_SIGHAND 0x00000800 96 #define LINUX_CLONE_PID 0x00001000 /* No longer exist in Linux */ 97 #define LINUX_CLONE_VFORK 0x00004000 98 #define LINUX_CLONE_PARENT 0x00008000 99 #define LINUX_CLONE_THREAD 0x00010000 100 #define LINUX_CLONE_SETTLS 0x00080000 101 #define LINUX_CLONE_PARENT_SETTID 0x00100000 102 #define LINUX_CLONE_CHILD_CLEARTID 0x00200000 103 #define LINUX_CLONE_CHILD_SETTID 0x01000000 104 105 /* Scheduling policies */ 106 #define LINUX_SCHED_OTHER 0 107 #define LINUX_SCHED_FIFO 1 108 #define LINUX_SCHED_RR 2 109 110 struct l_new_utsname { 111 char sysname[LINUX_MAX_UTSNAME]; 112 char nodename[LINUX_MAX_UTSNAME]; 113 char release[LINUX_MAX_UTSNAME]; 114 char version[LINUX_MAX_UTSNAME]; 115 char machine[LINUX_MAX_UTSNAME]; 116 char domainname[LINUX_MAX_UTSNAME]; 117 }; 118 119 #define LINUX_UTIME_NOW 0x3FFFFFFF 120 #define LINUX_UTIME_OMIT 0x3FFFFFFE 121 122 extern int stclohz; 123 124 #define LINUX_WNOHANG 0x00000001 125 #define LINUX_WUNTRACED 0x00000002 126 #define LINUX_WSTOPPED LINUX_WUNTRACED 127 #define LINUX_WEXITED 0x00000004 128 #define LINUX_WCONTINUED 0x00000008 129 #define LINUX_WNOWAIT 0x01000000 130 131 132 #define __WNOTHREAD 0x20000000 133 #define __WALL 0x40000000 134 #define __WCLONE 0x80000000 135 136 /* Linux waitid idtype */ 137 #define LINUX_P_ALL 0 138 #define LINUX_P_PID 1 139 #define LINUX_P_PGID 2 140 141 #define LINUX_RLIMIT_LOCKS RLIM_NLIMITS + 1 142 #define LINUX_RLIMIT_SIGPENDING RLIM_NLIMITS + 2 143 #define LINUX_RLIMIT_MSGQUEUE RLIM_NLIMITS + 3 144 #define LINUX_RLIMIT_NICE RLIM_NLIMITS + 4 145 #define LINUX_RLIMIT_RTPRIO RLIM_NLIMITS + 5 146 #define LINUX_RLIMIT_RTTIME RLIM_NLIMITS + 6 147 148 #define LINUX_RLIM_INFINITY (~0UL) 149 150 /* Linux getrandom flags */ 151 #define LINUX_GRND_NONBLOCK 0x0001 152 #define LINUX_GRND_RANDOM 0x0002 153 154 int linux_common_wait(struct thread *td, int pid, int *status, 155 int options, struct rusage *ru); 156 void linux_to_bsd_waitopts(int options, int *bsdopts); 157 int linux_set_upcall_kse(struct thread *td, register_t stack); 158 int linux_set_cloned_tls(struct thread *td, void *desc); 159 struct thread *linux_tdfind(struct thread *, lwpid_t, pid_t); 160 161 int linux_sysctl_debug(SYSCTL_HANDLER_ARGS); 162 163 #endif /* _LINUX_MISC_H_ */ 164