OSDN Git Service

Reintegrate socket duplication via WSADuplicateSocket/WSASocket.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / fhandler.h
index 87ae390..2755092 100644 (file)
@@ -226,6 +226,7 @@ class fhandler_base
       return close_on_exec () ? &sec_none_nih : &sec_none;
   }
 
+  virtual int fixup_before_fork_exec (DWORD) { return 0; }
   virtual void fixup_after_fork (HANDLE);
   virtual void fixup_after_exec ();
   void create_read_state (LONG n)
@@ -270,6 +271,7 @@ class fhandler_base
 
   /* fixup fd possibly non-inherited handles after fork */
   bool fork_fixup (HANDLE, HANDLE &, const char *);
+  virtual bool need_fixup_before () const {return false;}
 
   virtual int open (int, mode_t = 0);
   int open_fs (int, mode_t = 0);
@@ -342,8 +344,10 @@ class fhandler_base
   virtual int tcsetpgrp (const pid_t pid);
   virtual int tcgetpgrp ();
   virtual bool is_tty () const { return false; }
-  virtual bool isdevice () { return true; }
-  virtual bool isfifo () { return false; }
+  virtual bool ispipe () const { return false; }
+  virtual pid_t get_popen_pid () const {return 0;}
+  virtual bool isdevice () const { return true; }
+  virtual bool isfifo () const { return false; }
   virtual char *ptsname () { return NULL;}
   virtual class fhandler_socket *is_socket () { return NULL; }
   virtual class fhandler_console *is_console () { return 0; }
@@ -390,11 +394,12 @@ class fhandler_base
   bool is_fs_special () {return pc.is_fs_special ();}
   bool issymlink () {return pc.issymlink ();}
   bool device_access_denied (int) __attribute__ ((regparm (2)));
-  int fhaccess (int flags) __attribute__ ((regparm (2)));
+  int fhaccess (int flags, bool) __attribute__ ((regparm (3)));
 };
 
 class fhandler_mailslot : public fhandler_base
 {
+  POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &, PUNICODE_STRING);
  public:
   fhandler_mailslot ();
   int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
@@ -461,7 +466,14 @@ class fhandler_socket: public fhandler_base
   void wmem (int nwmem) { _wmem = nwmem; }
 
  private:
+  struct _WSAPROTOCOL_INFOW *prot_info_ptr;
+ public:
+  void init_fixup_before ();
+  bool need_fixup_before () const {return prot_info_ptr != NULL;}
+
+ private:
   char *sun_path;
+  char *peer_sun_path;
   struct status_flags
   {
     unsigned async_io              : 1; /* async I/O */
@@ -520,7 +532,9 @@ class fhandler_socket: public fhandler_base
   int dup (fhandler_base *child);
 
   void set_close_on_exec (bool val);
+  int fixup_before_fork_exec (DWORD);
   void fixup_after_fork (HANDLE);
+  void fixup_after_exec ();
   char *get_proc_fd_name (char *buf);
 
   select_record *select_read (select_stuff *);
@@ -533,6 +547,8 @@ class fhandler_socket: public fhandler_base
   int get_socket_type () {return type;}
   void set_sun_path (const char *path);
   char *get_sun_path () {return sun_path;}
+  void set_peer_sun_path (const char *path);
+  char *get_peer_sun_path () {return peer_sun_path;}
 
   int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
   int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2)));
@@ -556,6 +572,8 @@ public:
   OVERLAPPED *get_overlapped_buffer () {return &io_status;}
   void set_overlapped (OVERLAPPED *ov) {overlapped = ov;}
 
+  bool ispipe() const { return true; }
+
   void set_popen_pid (pid_t pid) {popen_pid = pid;}
   pid_t get_popen_pid () const {return popen_pid;}
   _off64_t lseek (_off64_t offset, int whence);
@@ -604,7 +622,7 @@ public:
   int open (int, mode_t);
   int close ();
   int dup (fhandler_base *child);
-  bool isfifo () { return true; }
+  bool isfifo () const { return true; }
   void set_close_on_exec (bool val);
   int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2)));
   OVERLAPPED *get_overlapped () {return &io_status;}
@@ -720,7 +738,7 @@ class fhandler_disk_file: public fhandler_base
 
   int open (int flags, mode_t mode);
   int lock (int, struct __flock64 *);
-  bool isdevice () { return false; }
+  bool isdevice () const { return false; }
   int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
   int __stdcall fchmod (mode_t mode) __attribute__ ((regparm (1)));
   int __stdcall fchown (__uid32_t uid, __gid32_t gid) __attribute__ ((regparm (2)));
@@ -759,7 +777,7 @@ class fhandler_cygdrive: public fhandler_disk_file
   };
   int ndrives;
   const char *pdrive;
-  char pdrive_buf[2 * 26 * DRVSZ];
+  char pdrive_buf[1 + (2 * 26 * DRVSZ)];
   void set_drives ();
  public:
   fhandler_cygdrive ();
@@ -927,7 +945,7 @@ class dev_console
 
   inline UINT get_console_cp ();
   DWORD con_to_str (char *d, int dlen, WCHAR w);
-  DWORD str_to_con (mbtowc_p, char *, PWCHAR d, const char *s, DWORD sz);
+  DWORD str_to_con (mbtowc_p, const char *, PWCHAR d, const char *s, DWORD sz);
   void set_color (HANDLE);
   bool fillin_info (HANDLE);
   void set_default_attr ();
@@ -1102,6 +1120,7 @@ public:
   int dup (fhandler_base *);
   void fixup_after_fork (HANDLE parent);
   void fixup_after_exec ();
+  int tcgetpgrp ();
 };
 
 class fhandler_tty_master: public fhandler_pty_master