hurd-types.h (15311B)
1 /* C declarations for Hurd server interfaces 2 Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002, 3 2010 Free Software Foundation, Inc. 4 5 This file is part of the GNU Hurd. 6 7 The GNU Hurd is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2, or (at your option) 10 any later version. 11 12 The GNU Hurd is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with the GNU Hurd; see the file COPYING. If not, write to 19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 20 21 #ifndef _HURD_TYPES_H 22 #define _HURD_TYPES_H 23 24 #ifndef _FILE_OFFSET_BITS 25 #define _FILE_OFFSET_BITS 32 26 #endif 27 28 #include <time.h> /* For struct timespec. */ 29 #include <mach/std_types.h> /* For mach_port_t et al. */ 30 #include <mach/message.h> /* For mach_msg_id_t et al. */ 31 #include <sys/types.h> /* For pid_t and uid_t. */ 32 33 /* A string identifying this release of the GNU Hurd. Our 34 interpretation of the term "release" is that it refers to a set of 35 server interface definitions. A "version" in Posix terminology is 36 a distribution of the Hurd; there may be more than one distribution 37 without changing the release number. */ 38 #define HURD_RELEASE "0.0" 39 40 41 /* Simple type declarations */ 42 43 /* These types identify certain kinds of ports used by the Hurd. */ 44 typedef mach_port_t file_t; 45 typedef mach_port_t fsys_t; 46 typedef mach_port_t io_t; 47 typedef mach_port_t process_t; 48 typedef mach_port_t auth_t; 49 typedef mach_port_t socket_t; 50 typedef mach_port_t pf_t; /* Protocol family */ 51 typedef mach_port_t addr_port_t; 52 typedef mach_port_t startup_t; 53 typedef mach_port_t fs_notify_t; 54 typedef mach_port_t exec_startup_t; 55 typedef mach_port_t interrupt_t; 56 typedef mach_port_t proccoll_t; 57 typedef mach_port_t ctty_t; 58 59 #include <errno.h> /* Defines `error_t'. */ 60 61 /* These names exist only because of MiG deficiencies. 62 You should not use them in C source; use the normal C types instead. */ 63 typedef char *data_t; 64 typedef const char *const_data_t; 65 typedef char string_t [1024]; 66 typedef int *intarray_t; 67 typedef const int *const_intarray_t; 68 typedef int *fd_mask_t; 69 typedef const int *const_fd_mask_t; 70 typedef mach_port_t *portarray_t; 71 typedef const mach_port_t *const_portarray_t; 72 typedef pid_t *pidarray_t; 73 typedef const pid_t *const_pidarray_t; 74 typedef uid_t *idarray_t; 75 typedef const uid_t *const_idarray_t; 76 #if 0 77 typedef __loff_t *off_array_t; 78 typedef const __loff_t *const_off_array_t; 79 #endif 80 typedef struct rusage rusage_t; 81 typedef struct flock flock_t; 82 typedef struct utsname utsname_t; 83 #if _FILE_OFFSET_BITS == 64 84 typedef struct stat io_statbuf_t; 85 typedef struct statfs fsys_statfsbuf_t; 86 #else 87 typedef struct stat64 io_statbuf_t; 88 typedef struct statfs64 fsys_statfsbuf_t; 89 #endif 90 typedef struct timespec timespec_t; 91 92 93 /* Parameters and flags in RPC calls */ 94 95 /* Many such parameters and flags are also defined in various libc 96 headers. */ 97 98 /* Bits for flags in fs.defs:file_exec_paths and exec.defs:exec_* calls: */ 99 #define EXEC_NEWTASK 0x00000001 /* Create new task; kill old one. */ 100 #define EXEC_SECURE 0x00000002 /* Use secure values of portarray, etc. */ 101 #define EXEC_DEFAULTS 0x00000004 /* Use defaults for unspecified ports. */ 102 #define EXEC_SIGTRAP 0x00000008 /* Simulate SIGTRAP on startup. */ 103 /* This flag is passed through by the exec server but not examined by it. */ 104 #define EXEC_STACK_ARGS 0x00000010 /* Use arguments from stack, not RPC. */ 105 106 /* Bits for flags in fs.defs:file_set_translator call: */ 107 #define FS_TRANS_FORCE 0x00000001 /* Must use translator(no sht circuit) */ 108 #define FS_TRANS_EXCL 0x00000002 /* Don't do it if already translated. */ 109 #define FS_TRANS_SET 0x00000004 /* Set or clear translator */ 110 #define FS_TRANS_ORPHAN 0x00000008 /* Orphan the active translator. */ 111 112 /* Values for retry field in fs.defs:dir_lookup call: */ 113 enum retry_type 114 { 115 FS_RETRY_NORMAL = 1, /* Retry normally if retry_name is not null. */ 116 FS_RETRY_REAUTH = 2, /* Retry after reauthenticating retry port. 117 Even if the retry name is null, a retry 118 is still necessary with this code after the 119 reauthentication is complete. */ 120 FS_RETRY_MAGICAL = 3, /* Retry string is magical. */ 121 /* "tty" means controlling tty; 122 123 "fd/%u" means file descriptor N; 124 125 "machtype/..." means replace `machtype' with the numbers in decimal 126 returned by the user's kernel as the cpu_type (N) and 127 cpu_subtype (M) (producing N/M/...) and then retry 128 as for FS_RETRY_NORMAL. 129 130 "/..." means retry "...", but starting from the users root directory. 131 132 "pid/..." means replace `pid' with the PID of the current process in %u 133 format and then retry as for FS_RETRY_NORMAL. 134 */ 135 }; 136 typedef enum retry_type retry_type; 137 138 /* Types for fs_notify.defs:dir_changed call: */ 139 enum dir_changed_type 140 { 141 DIR_CHANGED_NULL, /* Always sent first for sync. */ 142 DIR_CHANGED_NEW, /* Specified name has been added. */ 143 DIR_CHANGED_UNLINK, /* Specified name has been removed. */ 144 DIR_CHANGED_RENUMBER, /* Name has been the target of rename. */ 145 }; 146 typedef enum dir_changed_type dir_changed_type_t; 147 148 /* Types for fs_notify.defs:file_changed call: */ 149 enum file_changed_type 150 { 151 FILE_CHANGED_NULL, /* Always sent first for sync. */ 152 FILE_CHANGED_WRITE, /* File data has been written. */ 153 FILE_CHANGED_EXTEND, /* File has grown. */ 154 FILE_CHANGED_TRUNCATE, /* File has been truncated. */ 155 FILE_CHANGED_META, /* Stat information has changed, and none 156 of the previous three apply. Not sent 157 for changes in node times. */ 158 }; 159 typedef enum file_changed_type file_changed_type_t; 160 161 /* Select types for io.defs:io_select call: */ 162 #define SELECT_READ 0x00000001 163 #define SELECT_WRITE 0x00000002 164 #define SELECT_URG 0x00000004 165 166 /* Flags for fsys.defs:fsys_goaway. Also, these flags are sent as the 167 oldtrans_flags in fs.defs:file_set_translator to describe how to 168 terminate the old translator. */ 169 #define FSYS_GOAWAY_NOWAIT 0x00000001 /* Return immediately. */ 170 #define FSYS_GOAWAY_NOSYNC 0x00000002 /* Don't update physical media. */ 171 #define FSYS_GOAWAY_FORCE 0x00000004 /* Go away despite current users. */ 172 #define FSYS_GOAWAY_UNLINK 0x00000008 /* Go away only if non-directory. */ 173 #define FSYS_GOAWAY_RECURSE 0x00000010 /* Shutdown children too. */ 174 175 /* Types of ports the terminal driver can run on top of; 176 used in term.defs:term_get_bottom_type. */ 177 enum term_bottom_type 178 { 179 TERM_ON_MACHDEV, 180 TERM_ON_HURDIO, 181 TERM_ON_MASTERPTY, 182 }; 183 184 /* Types of storage, as returned by file_get_storage_info. 185 186 STORAGE_DEVICE is a mach device_t (for random access devices) 187 STORAGE_HURD_FILE is a hurd file_t (as if a file were mapped) 188 STORAGE_TASK is a task_t (the storage is in the vm of the task) 189 STORAGE_MEMORY is a memory object port 190 STORAGE_ZERO is a fixed-size constant source of zeros 191 STORAGE_INTERLEAVE is a set of other storage types interleaved at a fixed 192 interval 193 STORAGE_CONCAT is a set of other storage types concatenated end-to-end 194 STORAGE_LAYER is a set of storage types, representing the same address 195 range; all will be written too, and will be read in turn until one 196 succeeds 197 STORAGE_REMAP is a layer on top of another store that remaps its blocks 198 STORAGE_COPY is a memory snapshot of another store 199 STORAGE_NETWORK means that the file is stored elsewhere on the 200 network; all the remaining fields contan type-specific information. 201 STORAGE_OTHER means none of these apply; and should be used when no 202 meaningful answer can be given 203 204 The vectors returned by file_get_storage_info encode each of the above 205 (note that the first int is always the storage type). There are four: 206 ports, ints, offsets (off_t), and data (char); each type of store uses the 207 following entries in each vector: 208 209 -type- -ports- -ints- -offsets- -data- -kids- 210 device DEVICE TY, FL, BS, NR, NL, ML NR * (OFFS, LEN) NL + ML - 211 file FILE TY, FL, BS, NR, NL, ML NR * (OFFS, LEN) NL + ML - 212 memory MEMOBJ TY, FL, BS, NR, NL, ML NR * (OFFS, LEN) NL + ML - 213 task TASK TY, FL, BS, NR, NL, ML NR * (OFFS, LEN) NL + ML - 214 (the data for the above is a name (incl '\0') and a misc data block) 215 null - TY, FL SIZE - - 216 (BS is 1) 217 ileave - TY, FL, IL, NC - - NC 218 (BS is the LCM of its children; SIZE is the minimum of theirs * IL) 219 concat - TY, FL, NC - - NC 220 (BS is the LCM of its children; SIZE is the sum of theirs) 221 layer - TY, FL, NC - - NC 222 (BS is the LCM of its children; SIZE is the minimum of theirs) 223 remap - TY, FL, NR NR * (OFFS, LEN) - 1 224 (BS and SIZE are that of the child) 225 copy - TY, FL, SIZE - DATA - 226 (DATA is preceded by padding to the next page boundary, and is 227 SIZE bytes long itself) 228 229 For ileave, concat, and layer, the children are encoded following the parent. 230 The first int must always be TY. 231 232 key: TY = type code, FL = flags, BS = block size, NR = num runs, 233 NL = name len, ML = misc len, NC = num children, 234 IL = interleave (bytes), SIZE = Size of storage (blocks), 235 LEN = run length (blocks), OFFS = run offset (blocks), 236 237 The NR * (OFFS, LEN) offsets for some of the types is the set of block 238 ranges in the underlying address space that, concatenated, make up the 239 contents of the storage -- for instance, doing file_get_storage_info on a 240 file may return storage of type STORAGE_DEVICE, and the accompanying block 241 ranges are the set of blocks on the given device that correspond to that 242 file. Any OFFS == -1 designates a hole in the address range. Note that 243 the total size (SIZE) for these types is the sum of their LEN's. 244 245 The optional NAME returned by some types (if NL != 0) is a type specific 246 name for the same object referenced by the port also returned. E.g.: 247 device -- The mach device name 248 file -- The file name (unreliable, as the root may not be the same) 249 task -- The pid 250 Unless it is MACH_PORT_NULL, the port should generally be used instead of 251 trying to regenerate it from the associated name, which is intended more for 252 printing messages, etc. */ 253 enum file_storage_class 254 { 255 STORAGE_OTHER, 256 STORAGE_DEVICE, 257 STORAGE_HURD_FILE, 258 STORAGE_NETWORK, 259 STORAGE_MEMORY, 260 STORAGE_TASK, 261 STORAGE_ZERO, 262 STORAGE_CONCAT, 263 STORAGE_INTERLEAVE, 264 STORAGE_LAYER, 265 STORAGE_REMAP, 266 STORAGE_COPY, 267 }; 268 269 /* Flags for the flags word returned by some types . */ 270 #define STORAGE_MUTATED 0x00000001 /* data as stored is munged from file */ 271 272 /* Data types */ 273 274 #include <mach/task_info.h> 275 #include <mach/thread_info.h> 276 #ifndef THREAD_SCHED_INFO 277 #include <mach/policy.h> 278 #endif 279 280 /* Flags sent in proc_getprocinfo request. */ 281 #define PI_FETCH_TASKINFO 0x0001 282 #define PI_FETCH_TASKEVENTS 0x0020 283 #define PI_FETCH_THREADS 0x0002 284 #define PI_FETCH_THREAD_BASIC 0x0004 285 #define PI_FETCH_THREAD_SCHED 0x0008 286 #define PI_FETCH_THREAD_WAITS 0x0010 287 288 struct procinfo 289 { 290 int state; 291 uid_t owner; 292 pid_t ppid; 293 pid_t pgrp; 294 pid_t session; 295 pid_t logincollection; 296 int exitstatus; 297 int sigcode; 298 299 int nthreads; /* size of pi_threadinfos */ 300 301 struct task_basic_info taskinfo; 302 struct task_events_info taskevents; 303 #ifdef TASK_SCHED_TIMESHARE_INFO 304 struct policy_timeshare_base timeshare_base_info; 305 #endif 306 struct 307 { 308 int died; /* this thread died in the middle of call */ 309 mach_msg_id_t rpc_block; /* thread is blocked on this RPC */ 310 struct thread_basic_info pis_bi; 311 #ifdef THREAD_SCHED_INFO 312 struct thread_sched_info pis_si; 313 #else 314 struct policy_infos pis_pi; 315 #endif 316 } threadinfos[0]; 317 }; 318 typedef int *procinfo_t; 319 typedef const int *const_procinfo_t; 320 321 /* Bits in struct procinfo state: */ 322 #define PI_STOPPED 0x00000001 /* Proc server thinks is stopped. */ 323 #define PI_EXECED 0x00000002 /* Has called proc_exec. */ 324 #define PI_WAITING 0x00000004 /* Process is waiting for child to exit */ 325 #define PI_ORPHAN 0x00000008 /* Process group is orphaned. */ 326 #define PI_NOMSG 0x00000010 /* Process has no message port. */ 327 #define PI_SESSLD 0x00000020 /* Session leader. */ 328 #define PI_NOTOWNED 0x0000040 /* Process has no owner. */ 329 #define PI_NOPARENT 0x0000080 /* Hasn't identified a parent. */ 330 #define PI_ZOMBIE 0x00000100 /* Has no associated task. */ 331 #define PI_TRACED 0x00000200 /* Process is being traced */ 332 #define PI_GETMSG 0x00000400 /* Process is blocked in proc_getmsgport. */ 333 #define PI_LOGINLD 0x00000800 /* Process is leader of login collection */ 334 335 336 /* Conventions */ 337 338 339 /* st_fstype in struct stat and fsys_stb_type in fsys_statfsbuf is one of: */ 340 #define FSTYPE_UFS 0x00000000 /* 4.x BSD Fast File System */ 341 #define FSTYPE_NFS 0x00000001 /* Network File System ala Sun */ 342 #define FSTYPE_GFS 0x00000002 /* GNU file system */ 343 #define FSTYPE_LFS 0x00000003 /* Logging File System ala Sprite */ 344 #define FSTYPE_SYSV 0x00000004 /* Old U*x filesystem ala System V */ 345 #define FSTYPE_FTP 0x00000005 /* Transparent FTP */ 346 #define FSTYPE_TAR 0x00000006 /* Transparent TAR */ 347 #define FSTYPE_AR 0x00000007 /* Transparent AR */ 348 #define FSTYPE_CPIO 0x00000008 /* Transparent CPIO */ 349 #define FSTYPE_MSLOSS 0x00000009 /* MS-DOS */ 350 #define FSTYPE_CPM 0x0000000a /* CP/M */ 351 #define FSTYPE_HFS 0x0000000b /* Don't ask */ 352 #define FSTYPE_DTFS 0x0000000c /* used by desktop to provide more info */ 353 #define FSTYPE_GRFS 0x0000000d /* GNU Remote File System */ 354 #define FSTYPE_TERM 0x0000000e /* GNU Terminal driver */ 355 #define FSTYPE_DEV 0x0000000f /* GNU Special file server */ 356 #define FSTYPE_PROC 0x00000010 /* /proc filesystem ala Version 9 */ 357 #define FSTYPE_IFSOCK 0x00000011 /* PF_LOCAL socket naming point */ 358 #define FSTYPE_AFS 0x00000012 /* Andrew File System 3.xx */ 359 #define FSTYPE_DFS 0x00000013 /* Distributed File Sys (OSF) == AFS 4.xx */ 360 #define FSTYPE_PROC9 0x00000014 /* /proc filesystem ala Plan 9 */ 361 #define FSTYPE_SOCKET 0x00000015 /* io_t that isn't a file but a socket */ 362 #define FSTYPE_MISC 0x00000016 /* generic trivfs server */ 363 #define FSTYPE_EXT2FS 0x00000017 /* Linux filesystem by Remy Card */ 364 #define FSTYPE_HTTP 0x00000018 /* Transparent HTTP */ 365 #define FSTYPE_MEMFS 0x00000019 /* In-core filesystem */ 366 #define FSTYPE_ISO9660 0x0000001a /* ISO9660 */ 367 368 /* Standard port assignments for file_exec_paths and exec_* */ 369 enum 370 { 371 INIT_PORT_CWDIR, 372 INIT_PORT_CRDIR, 373 INIT_PORT_AUTH, 374 INIT_PORT_PROC, 375 INIT_PORT_CTTYID, 376 /* If MACH_PORT_NULL is given for the bootstrap port, 377 the bootstrap port of the old task is used. */ 378 INIT_PORT_BOOTSTRAP, 379 INIT_PORT_MAX 380 }; 381 382 /* Standard ints for file_exec_paths and exec_* */ 383 enum 384 { 385 INIT_UMASK, 386 INIT_SIGMASK, 387 INIT_SIGIGN, 388 INIT_SIGPENDING, 389 INIT_TRACEMASK, 390 INIT_INT_MAX, 391 }; 392 393 #endif // _HURD_TYPES_H