* fhandler.h (fhandler_base::fixup_after_exec): Make non-inline. (fhandler_termios::fixup_after_fork): Delete declaration. (fhandler_termios::fixup_after_exec): Ditto. (fhandler_tty_common::inuse): Remove. (fhandler_tty_common::dup): Delete declaration. (fhandler_tty_common::fixup_after_fork): Ditto. (fhandler_tty_slave::fixup_after_exec): Declare new function. (fhandler_pty_master::dwProcessId): New variable. (fhandler_pty_master::from_master): Ditto. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::setup): New function. (fhandler_pty_master::fixup_after_fork): Ditto. (fhandler_pty_master::fixup_after_exec): Ditto. * fhandler_termios.cc (fhandler_termios::fixup_after_exec): Delete definition. (fhandler_termios::fixup_after_fork): Ditto. * fhandler_tty.cc (fhandler_tty_master::init): Use fhandler_pty_master setup function rather than obsolete tty::common_init. Delete obsolete inuse setting. (fhandler_tty_slave::fhandler_tty_slave): Set inuse to NULL here. (fhandler_tty_slave::open): Change debugging output for clarity. Check for different things when doing a sanity check on the tty. Reflect the fact that master_pid now is the cygwin pid rather than the windows pid. Use "arch" rather than "archetype" for consistency. (fhandler_tty_slave::close): Close inuse here. (fhandler_tty_slave::dup): Remove old if 0'ed code. (fhandler_pty_master::dup): New function. Handles pty master archetype. (fhandler_pty_master::fhandler_pty_master): Zero pty_master specific fields. (fhandler_pty_master::open): Implement using archetypes, similar to slave. Use fhandler_pty_master setup function rather than obsolete tty::common_init. Don't set inuse. (fhandler_tty_common::close): Don't deal with inuse. Delete old if 0'ed code. (fhandler_pty_master::close): Implement using archetypes. Close from_master and to_master. (fhandler_tty_common::set_close_on_exec): Just set close_on_exec flag here since everything uses archetypes now. (fhandler_tty_common::fixup_after_fork): Delete definition. (fhandler_tty_slave::fixup_after_exec): Define new function. (fhandler_pty_master::setup): New function, derived from tty::common_init. (fhandler_pty_master::fixup_after_fork): New function. (shared_info.h): Reset SHARED_INFO_CB to reflect new tty size. * tty.cc (tty_list::terminate): Close individual handles from tty_master. (tty::master_alive): Delete. (tty::make_pipes): Ditto. (tty::common_init): Ditto. * tty.h (tty::from_slave): Delete. (tty::to_slave): Ditto. (tty::common_init): Delete declaration. (tty::make_pipes): Ditto. (tty::master_pid): Define as pid_t since it is now a cygwin pid.
		
			
				
	
	
		
			205 lines
		
	
	
		
			5.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			205 lines
		
	
	
		
			5.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/* shared_info.h: shared info for cygwin
 | 
						|
 | 
						|
   Copyright 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
 | 
						|
 | 
						|
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. */
 | 
						|
 | 
						|
#include "tty.h"
 | 
						|
#include "security.h"
 | 
						|
 | 
						|
/* Mount table entry */
 | 
						|
 | 
						|
class mount_item
 | 
						|
{
 | 
						|
 public:
 | 
						|
  /* FIXME: Nasty static allocation.  Need to have a heap in the shared
 | 
						|
     area [with the user being able to configure at runtime the max size].  */
 | 
						|
  /* Win32-style mounted partition source ("C:\foo\bar").
 | 
						|
     native_path[0] == 0 for unused entries.  */
 | 
						|
  char native_path[CYG_MAX_PATH];
 | 
						|
  int native_pathlen;
 | 
						|
 | 
						|
  /* POSIX-style mount point ("/foo/bar") */
 | 
						|
  char posix_path[CYG_MAX_PATH];
 | 
						|
  int posix_pathlen;
 | 
						|
 | 
						|
  unsigned flags;
 | 
						|
 | 
						|
  void init (const char *dev, const char *path, unsigned flags);
 | 
						|
 | 
						|
  struct mntent *getmntent ();
 | 
						|
  int fnmunge (char *, const char *, int&);
 | 
						|
  int build_win32 (char *, const char *, unsigned *, unsigned);
 | 
						|
};
 | 
						|
 | 
						|
/* Warning: Decreasing this value will cause cygwin.dll to ignore existing
 | 
						|
   higher numbered registry entries.  Don't change this number willy-nilly.
 | 
						|
   What we need is to have a more dynamic allocation scheme, but the current
 | 
						|
   scheme should be satisfactory for a long while yet.  */
 | 
						|
#define MAX_MOUNTS 30
 | 
						|
 | 
						|
#define USER_VERSION	1	// increment when mount table changes and
 | 
						|
#define USER_VERSION_MAGIC CYGWIN_VERSION_MAGIC (USER_MAGIC, USER_VERSION)
 | 
						|
#define CURR_USER_MAGIC 0x8dc7b1d5U
 | 
						|
 | 
						|
class reg_key;
 | 
						|
struct device;
 | 
						|
 | 
						|
/* NOTE: Do not make gratuitous changes to the names or organization of the
 | 
						|
   below class.  The layout is checksummed to determine compatibility between
 | 
						|
   different cygwin versions. */
 | 
						|
class mount_info
 | 
						|
{
 | 
						|
 public:
 | 
						|
  DWORD sys_mount_table_counter;
 | 
						|
  int nmounts;
 | 
						|
  mount_item mount[MAX_MOUNTS];
 | 
						|
 | 
						|
  /* cygdrive_prefix is used as the root of the path automatically
 | 
						|
     prepended to a path when the path has no associated mount.
 | 
						|
     cygdrive_flags are the default flags for the cygdrives. */
 | 
						|
  char cygdrive[CYG_MAX_PATH];
 | 
						|
  size_t cygdrive_len;
 | 
						|
  unsigned cygdrive_flags;
 | 
						|
 private:
 | 
						|
  int posix_sorted[MAX_MOUNTS];
 | 
						|
  int native_sorted[MAX_MOUNTS];
 | 
						|
 | 
						|
 public:
 | 
						|
  void init ();
 | 
						|
  int add_item (const char *dev, const char *path, unsigned flags, int reg_p);
 | 
						|
  int del_item (const char *path, unsigned flags, int reg_p);
 | 
						|
 | 
						|
  void from_registry ();
 | 
						|
  int add_reg_mount (const char * native_path, const char * posix_path,
 | 
						|
		      unsigned mountflags);
 | 
						|
  int del_reg_mount (const char * posix_path, unsigned mountflags);
 | 
						|
 | 
						|
  unsigned set_flags_from_win32_path (const char *path);
 | 
						|
  int conv_to_win32_path (const char *src_path, char *dst, device&,
 | 
						|
			  unsigned *flags = NULL);
 | 
						|
  int conv_to_posix_path (const char *src_path, char *posix_path,
 | 
						|
			  int keep_rel_p);
 | 
						|
  struct mntent *getmntent (int x);
 | 
						|
 | 
						|
  int write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsigned flags);
 | 
						|
  int remove_cygdrive_info_from_registry (const char *cygdrive_prefix, unsigned flags);
 | 
						|
  int get_cygdrive_info (char *user, char *system, char* user_flags,
 | 
						|
			 char* system_flags);
 | 
						|
  void cygdrive_posix_path (const char *src, char *dst, int trailing_slash_p);
 | 
						|
  int get_mounts_here (const char *parent_dir, int, char **mount_points);
 | 
						|
 | 
						|
 private:
 | 
						|
 | 
						|
  void sort ();
 | 
						|
  void read_mounts (reg_key& r);
 | 
						|
  void mount_slash ();
 | 
						|
  void to_registry ();
 | 
						|
 | 
						|
  int cygdrive_win32_path (const char *src, char *dst, int& unit);
 | 
						|
  void read_cygdrive_info_from_registry ();
 | 
						|
};
 | 
						|
 | 
						|
/******** Close-on-delete queue ********/
 | 
						|
 | 
						|
/* First pass at a file deletion queue structure.
 | 
						|
 | 
						|
   We can't keep this list in the per-process info, since
 | 
						|
   one process may open a file, and outlive a process which
 | 
						|
   wanted to unlink the file - and the data would go away.
 | 
						|
*/
 | 
						|
 | 
						|
#define MAX_DELQUEUES_PENDING 100
 | 
						|
 | 
						|
class delqueue_list
 | 
						|
{
 | 
						|
  char name[MAX_DELQUEUES_PENDING][CYG_MAX_PATH];
 | 
						|
  char inuse[MAX_DELQUEUES_PENDING];
 | 
						|
  int empty;
 | 
						|
 | 
						|
public:
 | 
						|
  void init ();
 | 
						|
  void queue_file (const char *dosname);
 | 
						|
  void process_queue ();
 | 
						|
};
 | 
						|
 | 
						|
class user_info
 | 
						|
{
 | 
						|
public:
 | 
						|
  DWORD version;
 | 
						|
  DWORD cb;
 | 
						|
  delqueue_list delqueue;
 | 
						|
  mount_info mountinfo;
 | 
						|
};
 | 
						|
/******** Shared Info ********/
 | 
						|
/* Data accessible to all tasks */
 | 
						|
 | 
						|
#define SHARED_VERSION (unsigned)(cygwin_version.api_major << 8 | \
 | 
						|
				  cygwin_version.api_minor)
 | 
						|
#define SHARED_VERSION_MAGIC CYGWIN_VERSION_MAGIC (SHARED_MAGIC, SHARED_VERSION)
 | 
						|
 | 
						|
#define SHARED_INFO_CB 19984
 | 
						|
 | 
						|
#define CURR_SHARED_MAGIC 0x818f75beU
 | 
						|
 | 
						|
/* NOTE: Do not make gratuitous changes to the names or organization of the
 | 
						|
   below class.  The layout is checksummed to determine compatibility between
 | 
						|
   different cygwin versions. */
 | 
						|
class shared_info
 | 
						|
{
 | 
						|
  DWORD version;
 | 
						|
  DWORD cb;
 | 
						|
 public:
 | 
						|
  unsigned heap_chunk;
 | 
						|
  DWORD sys_mount_table_counter;
 | 
						|
 | 
						|
  tty_list tty;
 | 
						|
  void initialize ();
 | 
						|
  unsigned heap_chunk_size ();
 | 
						|
};
 | 
						|
 | 
						|
extern shared_info *cygwin_shared;
 | 
						|
extern user_info *user_shared;
 | 
						|
#define mount_table (&(user_shared->mountinfo))
 | 
						|
extern HANDLE cygwin_user_h;
 | 
						|
 | 
						|
enum shared_locations
 | 
						|
{
 | 
						|
  SH_CYGWIN_SHARED,
 | 
						|
  SH_USER_SHARED,
 | 
						|
  SH_SHARED_CONSOLE,
 | 
						|
  SH_MYSELF,
 | 
						|
  SH_MTINFO,
 | 
						|
  SH_TOTAL_SIZE,
 | 
						|
  SH_JUSTCREATE,
 | 
						|
  SH_JUSTOPEN
 | 
						|
 | 
						|
};
 | 
						|
void __stdcall memory_init ();
 | 
						|
 | 
						|
#define shared_align_past(p) \
 | 
						|
  ((char *) (system_info.dwAllocationGranularity * \
 | 
						|
	     (((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
 | 
						|
	      system_info.dwAllocationGranularity)))
 | 
						|
 | 
						|
#define cygwin_shared_address	((void *) 0x60000000)
 | 
						|
 | 
						|
#ifdef _FHANDLER_H_
 | 
						|
struct console_state
 | 
						|
{
 | 
						|
  tty_min tty_min_state;
 | 
						|
  dev_console dev_state;
 | 
						|
};
 | 
						|
#endif
 | 
						|
 | 
						|
char *__stdcall shared_name (char *, const char *, int);
 | 
						|
void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size,
 | 
						|
			     shared_locations&, PSECURITY_ATTRIBUTES psa = &sec_all,
 | 
						|
			     DWORD access = FILE_MAP_READ | FILE_MAP_WRITE);
 | 
						|
extern void user_shared_initialize (bool reinit);
 | 
						|
 |