2001-03-05 22:29:24 +01:00
|
|
|
/* sys/cygwin.h
|
|
|
|
|
2002-05-29 19:12:07 +02:00
|
|
|
Copyright 1997, 1998, 2000, 2001, 2002 Red Hat, Inc.
|
2001-03-05 22:29:24 +01:00
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
#ifndef _SYS_CYGWIN_H
|
|
|
|
#define _SYS_CYGWIN_H
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern pid_t cygwin32_winpid_to_pid (int);
|
|
|
|
extern void cygwin32_win32_to_posix_path_list (const char *, char *);
|
|
|
|
extern int cygwin32_win32_to_posix_path_list_buf_size (const char *);
|
|
|
|
extern void cygwin32_posix_to_win32_path_list (const char *, char *);
|
|
|
|
extern int cygwin32_posix_to_win32_path_list_buf_size (const char *);
|
|
|
|
extern int cygwin32_conv_to_win32_path (const char *, char *);
|
|
|
|
extern int cygwin32_conv_to_full_win32_path (const char *, char *);
|
|
|
|
extern void cygwin32_conv_to_posix_path (const char *, char *);
|
|
|
|
extern void cygwin32_conv_to_full_posix_path (const char *, char *);
|
|
|
|
extern int cygwin32_posix_path_list_p (const char *);
|
|
|
|
extern void cygwin32_split_path (const char *, char *, char *);
|
|
|
|
|
|
|
|
extern pid_t cygwin_winpid_to_pid (int);
|
|
|
|
extern int cygwin_win32_to_posix_path_list (const char *, char *);
|
|
|
|
extern int cygwin_win32_to_posix_path_list_buf_size (const char *);
|
|
|
|
extern int cygwin_posix_to_win32_path_list (const char *, char *);
|
|
|
|
extern int cygwin_posix_to_win32_path_list_buf_size (const char *);
|
|
|
|
extern int cygwin_conv_to_win32_path (const char *, char *);
|
|
|
|
extern int cygwin_conv_to_full_win32_path (const char *, char *);
|
|
|
|
extern int cygwin_conv_to_posix_path (const char *, char *);
|
|
|
|
extern int cygwin_conv_to_full_posix_path (const char *, char *);
|
|
|
|
extern int cygwin_posix_path_list_p (const char *);
|
|
|
|
extern void cygwin_split_path (const char *, char *, char *);
|
|
|
|
|
2000-07-09 07:29:51 +02:00
|
|
|
struct __cygwin_perfile
|
|
|
|
{
|
2000-11-03 05:27:03 +01:00
|
|
|
const char *name;
|
2000-07-09 07:29:51 +02:00
|
|
|
unsigned flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* External interface stuff */
|
|
|
|
|
2003-09-17 03:43:27 +02:00
|
|
|
typedef enum
|
2000-07-09 07:29:51 +02:00
|
|
|
{
|
|
|
|
CW_LOCK_PINFO,
|
|
|
|
CW_UNLOCK_PINFO,
|
|
|
|
CW_GETTHREADNAME,
|
|
|
|
CW_GETPINFO,
|
|
|
|
CW_SETPINFO,
|
|
|
|
CW_SETTHREADNAME,
|
|
|
|
CW_GETVERSIONINFO,
|
|
|
|
CW_READ_V1_MOUNT_TABLES,
|
|
|
|
CW_USER_DATA,
|
2000-07-29 00:33:43 +02:00
|
|
|
CW_PERFILE,
|
2000-07-29 18:24:59 +02:00
|
|
|
CW_GET_CYGDRIVE_PREFIXES,
|
2000-08-25 04:27:42 +02:00
|
|
|
CW_GETPINFO_FULL,
|
2000-11-08 21:36:37 +01:00
|
|
|
CW_INIT_EXCEPTIONS,
|
2001-10-24 23:56:54 +02:00
|
|
|
CW_GET_CYGDRIVE_INFO,
|
|
|
|
CW_SET_CYGWIN_REGISTRY_NAME,
|
2002-01-29 03:02:03 +01:00
|
|
|
CW_GET_CYGWIN_REGISTRY_NAME,
|
2002-02-14 22:20:06 +01:00
|
|
|
CW_STRACE_TOGGLE,
|
2002-02-14 22:31:23 +01:00
|
|
|
CW_STRACE_ACTIVE,
|
2002-06-03 19:56:10 +02:00
|
|
|
CW_CYGWIN_PID_TO_WINPID,
|
2002-10-30 22:05:18 +01:00
|
|
|
CW_EXTRACT_DOMAIN_AND_USER,
|
2003-04-03 10:04:41 +02:00
|
|
|
CW_CMDLINE,
|
|
|
|
CW_CHECK_NTSEC
|
2000-07-09 07:29:51 +02:00
|
|
|
} cygwin_getinfo_types;
|
|
|
|
|
2003-02-05 15:14:26 +01:00
|
|
|
#define CW_NEXTPID 0x80000000 /* or with pid to get next one */
|
2003-03-28 15:21:40 +01:00
|
|
|
unsigned long cygwin_internal (cygwin_getinfo_types, ...);
|
2000-07-09 07:29:51 +02:00
|
|
|
|
|
|
|
/* Flags associated with process_state */
|
|
|
|
enum
|
|
|
|
{
|
2003-02-05 15:14:26 +01:00
|
|
|
PID_IN_USE = 0x0001, /* Entry in use. */
|
|
|
|
PID_ZOMBIE = 0x0002, /* Child exited: no parent wait. */
|
|
|
|
PID_STOPPED = 0x0004, /* Waiting for SIGCONT. */
|
|
|
|
PID_TTYIN = 0x0008, /* Waiting for terminal input. */
|
|
|
|
PID_TTYOU = 0x0010, /* Waiting for terminal output. */
|
|
|
|
PID_ORPHANED = 0x0020, /* Member of an orphaned process group. */
|
|
|
|
PID_ACTIVE = 0x0040, /* Pid accepts signals. */
|
|
|
|
PID_CYGPARENT = 0x0080, /* Set if parent was a cygwin app. */
|
2003-09-13 19:14:15 +02:00
|
|
|
PID_MAP_RW = 0x0100, /* Flag to open map rw. */
|
2003-02-05 15:14:26 +01:00
|
|
|
PID_MYSELF = 0x0200, /* Flag that pid is me. */
|
2003-09-01 04:05:32 +02:00
|
|
|
PID_NOCLDSTOP = 0x0400, /* Set if no SIGCHLD signal on stop. */
|
2003-02-05 15:14:26 +01:00
|
|
|
PID_INITIALIZING = 0x0800, /* Set until ready to receive signals. */
|
|
|
|
PID_USETTY = 0x1000, /* Setting this enables or disables cygwin's */
|
|
|
|
/* tty support. This is inherited by */
|
|
|
|
/* all execed or forked processes. */
|
|
|
|
PID_ALLPIDS = 0x2000, /* child has execed */
|
|
|
|
PID_EXECED = 0x4000, /* redirect to original pid info block */
|
|
|
|
PID_NOREDIR = 0x8000, /* don't redirect if execed */
|
|
|
|
PID_EXITED = 0x80000000 /* Free entry. */
|
2000-07-09 07:29:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef WINVER
|
2000-10-05 05:12:36 +02:00
|
|
|
#ifdef _PATH_PASSWD
|
|
|
|
extern HANDLE cygwin_logon_user (const struct passwd *, const char *);
|
|
|
|
#endif
|
|
|
|
|
2000-07-01 05:51:55 +02:00
|
|
|
/* This lives in the app and is initialized before jumping into the DLL.
|
|
|
|
It should only contain stuff which the user's process needs to see, or
|
|
|
|
which is needed before the user pointer is initialized, or is needed to
|
|
|
|
carry inheritance information from parent to child. Note that it cannot
|
|
|
|
be used to carry inheritance information across exec!
|
|
|
|
|
|
|
|
Remember, this structure is linked into the application's executable.
|
|
|
|
Changes to this can invalidate existing executables, so we go to extra
|
|
|
|
lengths to avoid having to do it.
|
|
|
|
|
|
|
|
When adding/deleting members, remember to adjust {public,internal}_reserved.
|
|
|
|
The size of the class shouldn't change [unless you really are prepared to
|
|
|
|
invalidate all existing executables]. The program does a check (using
|
|
|
|
SIZEOF_PER_PROCESS) to make sure you remember to make the adjustment.
|
|
|
|
*/
|
|
|
|
|
2000-08-23 16:53:25 +02:00
|
|
|
#ifdef __cplusplus
|
2000-08-22 17:12:29 +02:00
|
|
|
class ResourceLocks;
|
|
|
|
class MTinterface;
|
2000-08-23 16:53:25 +02:00
|
|
|
#endif
|
2000-08-22 17:12:29 +02:00
|
|
|
|
2000-07-06 01:46:44 +02:00
|
|
|
struct per_process
|
2000-07-01 05:51:55 +02:00
|
|
|
{
|
|
|
|
char *initial_sp;
|
|
|
|
|
|
|
|
/* The offset of these 3 values can never change. */
|
|
|
|
/* magic_biscuit is the size of this class and should never change. */
|
|
|
|
unsigned long magic_biscuit;
|
|
|
|
unsigned long dll_major;
|
|
|
|
unsigned long dll_minor;
|
|
|
|
|
|
|
|
struct _reent **impure_ptr_ptr;
|
|
|
|
char ***envptr;
|
|
|
|
|
|
|
|
/* Used to point to the memory machine we should use. Usually these
|
|
|
|
point back into the dll, but they can be overridden by the user. */
|
|
|
|
void *(*malloc)(size_t);
|
|
|
|
void (*free)(void *);
|
|
|
|
void *(*realloc)(void *, size_t);
|
|
|
|
|
|
|
|
int *fmode_ptr;
|
|
|
|
|
|
|
|
int (*main)(int, char **, char **);
|
|
|
|
void (**ctors)(void);
|
|
|
|
void (**dtors)(void);
|
|
|
|
|
|
|
|
/* For fork */
|
|
|
|
void *data_start;
|
|
|
|
void *data_end;
|
|
|
|
void *bss_start;
|
|
|
|
void *bss_end;
|
|
|
|
|
|
|
|
void *(*calloc)(size_t, size_t);
|
|
|
|
/* For future expansion of values set by the app. */
|
2001-03-05 07:28:25 +01:00
|
|
|
void (*premain[4]) (int, char **, struct per_process *);
|
2000-07-01 05:51:55 +02:00
|
|
|
|
|
|
|
/* The rest are *internal* to cygwin.dll.
|
|
|
|
Those that are here because we want the child to inherit the value from
|
|
|
|
the parent (which happens when bss is copied) are marked as such. */
|
|
|
|
|
|
|
|
/* non-zero of ctors have been run. Inherited from parent. */
|
|
|
|
int run_ctors_p;
|
|
|
|
|
2001-09-07 23:32:07 +02:00
|
|
|
DWORD unused[7];
|
2000-07-01 05:51:55 +02:00
|
|
|
|
|
|
|
/* Non-zero means the task was forked. The value is the pid.
|
|
|
|
Inherited from parent. */
|
|
|
|
int forkee;
|
|
|
|
|
|
|
|
HMODULE hmodule;
|
|
|
|
|
|
|
|
DWORD api_major; /* API version that this program was */
|
|
|
|
DWORD api_minor; /* linked with */
|
|
|
|
/* For future expansion, so apps won't have to be relinked if we
|
|
|
|
add an item. */
|
2000-07-06 01:46:44 +02:00
|
|
|
DWORD unused2[5];
|
|
|
|
|
2003-03-09 22:51:00 +01:00
|
|
|
#if defined (__INSIDE_CYGWIN__) && defined (__cplusplus)
|
2000-07-01 05:51:55 +02:00
|
|
|
ResourceLocks *resourcelocks;
|
|
|
|
MTinterface *threadinterface;
|
2000-07-07 10:35:31 +02:00
|
|
|
#else
|
|
|
|
void *resourcelocks;
|
|
|
|
void *threadinterface;
|
|
|
|
#endif
|
2000-07-06 01:46:44 +02:00
|
|
|
struct _reent *impure_ptr;
|
2000-07-01 05:51:55 +02:00
|
|
|
};
|
2000-07-06 01:46:44 +02:00
|
|
|
#define per_process_overwrite ((unsigned) &(((struct per_process *) NULL)->resourcelocks))
|
2000-07-01 05:51:55 +02:00
|
|
|
|
2001-03-05 07:28:25 +01:00
|
|
|
extern void cygwin_premain0 (int argc, char **argv, struct per_process *);
|
|
|
|
extern void cygwin_premain1 (int argc, char **argv, struct per_process *);
|
|
|
|
extern void cygwin_premain2 (int argc, char **argv, struct per_process *);
|
|
|
|
extern void cygwin_premain3 (int argc, char **argv, struct per_process *);
|
|
|
|
|
2000-06-22 23:05:46 +02:00
|
|
|
extern void cygwin_set_impersonation_token (const HANDLE);
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
/* included if <windows.h> is included */
|
2000-06-22 23:51:48 +02:00
|
|
|
extern int cygwin32_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
|
|
|
|
extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2003-09-01 04:26:27 +02:00
|
|
|
#ifdef __CYGWIN__
|
2000-05-18 20:32:05 +02:00
|
|
|
#include <sys/resource.h>
|
|
|
|
|
2001-04-29 01:48:28 +02:00
|
|
|
#define TTY_CONSOLE 0x40000000
|
|
|
|
|
2002-05-29 22:07:54 +02:00
|
|
|
#define EXTERNAL_PINFO_VERSION_16_BIT 0
|
|
|
|
#define EXTERNAL_PINFO_VERSION_32_BIT 1
|
2002-05-29 23:00:55 +02:00
|
|
|
#define EXTERNAL_PINFO_VERSION EXTERNAL_PINFO_VERSION_32_BIT
|
2002-05-29 19:12:07 +02:00
|
|
|
|
2002-01-29 03:02:03 +01:00
|
|
|
#ifndef _SYS_TYPES_H
|
2002-02-09 21:39:55 +01:00
|
|
|
typedef unsigned short __uid16_t;
|
|
|
|
typedef unsigned short __gid16_t;
|
2002-05-29 17:04:29 +02:00
|
|
|
typedef unsigned long __uid32_t;
|
|
|
|
typedef unsigned long __gid32_t;
|
2002-01-29 03:02:03 +01:00
|
|
|
#endif
|
|
|
|
|
2000-05-18 20:32:05 +02:00
|
|
|
struct external_pinfo
|
|
|
|
{
|
|
|
|
pid_t pid;
|
|
|
|
pid_t ppid;
|
|
|
|
HANDLE hProcess;
|
|
|
|
DWORD dwProcessId, dwSpawnedProcessId;
|
2002-02-09 21:39:55 +01:00
|
|
|
__uid16_t uid;
|
|
|
|
__gid16_t gid;
|
2000-05-18 20:32:05 +02:00
|
|
|
pid_t pgid;
|
|
|
|
pid_t sid;
|
|
|
|
int ctty;
|
|
|
|
mode_t umask;
|
|
|
|
|
|
|
|
long start_time;
|
|
|
|
struct rusage rusage_self;
|
|
|
|
struct rusage rusage_children;
|
|
|
|
|
|
|
|
char progname[MAX_PATH];
|
|
|
|
|
|
|
|
DWORD strace_mask;
|
2002-05-29 19:12:07 +02:00
|
|
|
DWORD version;
|
2000-05-18 20:32:05 +02:00
|
|
|
|
|
|
|
DWORD process_state;
|
2002-05-29 17:04:29 +02:00
|
|
|
|
2002-05-29 22:07:54 +02:00
|
|
|
/* Only available if version >= EXTERNAL_PINFO_VERSION_32_BIT */
|
2002-05-29 17:04:29 +02:00
|
|
|
__uid32_t uid32;
|
|
|
|
__gid32_t gid32;
|
2000-05-18 20:32:05 +02:00
|
|
|
};
|
2003-09-01 04:26:27 +02:00
|
|
|
#endif /*__CYGWIN__*/
|
2000-06-22 22:18:17 +02:00
|
|
|
#endif /*WINVER*/
|
2000-05-18 20:32:05 +02:00
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
#endif /* _SYS_CYGWIN_H */
|