break;
case FH_PTMX:
if (pc.isopen ())
- fh = cnew (fhandler_pty_master, -1);
+ fh = cnew (fhandler_pty_master, -1, (dev_t) pc.dev);
else
fhraw = cnew_no_ctor (fhandler_pty_master, -1);
break;
if (iscons_dev (myself->ctty))
fh = cnew (fhandler_console, pc.dev);
else
- fh = cnew (fhandler_pty_slave, myself->ctty);
+ fh = cnew (fhandler_pty_slave,
+ minor (myself->ctty), (dev_t) pc.dev);
if (fh->dev () != FH_NADA)
fh->set_name ("/dev/tty");
}
fhandler_termios (), input_ready (false), thread_sync_event (NULL),
input_mutex (NULL), output_mutex (NULL), unit (MAX_CONS_DEV)
{
+ dev_referred_via = (dev_t) devunit;
if (devunit > 0)
dev ().parse (devunit);
setup ();
the console instance. Due to this, get_ttyp() returns NULL here.
So, calling set_unit() is necessary to access getsid(). */
if (!get_ttyp ())
- set_unit ();
+ {
+ dev_referred_via = get_device ();
+ set_unit ();
+ }
- fhandler_base::fstat (st);
+ fhandler_termios::fstat (st);
st->st_mode = S_IFCHR | S_IRUSR | S_IWUSR;
pinfo p (get_ttyp ()->getsid ());
if (p)
/* pty slave stuff */
-fhandler_pty_slave::fhandler_pty_slave (int unit)
+fhandler_pty_slave::fhandler_pty_slave (int unit, dev_t via)
: fhandler_pty_common (), inuse (NULL), output_handle_nat (NULL),
io_handle_nat (NULL), slave_reading (NULL), num_reader (0)
{
+ dev_referred_via = via;
if (unit >= 0)
dev ().parse (DEV_PTYS_MAJOR, unit);
}
int
fhandler_pty_slave::fstat (struct stat *st)
{
- fhandler_base::fstat (st);
+ fhandler_termios::fstat (st);
bool to_close = false;
if (!input_available_event)
/*******************************************************
fhandler_pty_master
*/
-fhandler_pty_master::fhandler_pty_master (int unit)
+fhandler_pty_master::fhandler_pty_master (int unit, dev_t via)
: fhandler_pty_common (), pktmode (0), master_ctl (NULL),
master_thread (NULL), from_master_nat (NULL), to_master_nat (NULL),
from_slave_nat (NULL), to_slave_nat (NULL), echo_r (NULL), echo_w (NULL),
dwProcessId (0), to_master (NULL), from_master (NULL),
master_fwd_thread (NULL)
{
+ dev_referred_via = via;
if (unit >= 0)
dev ().parse (DEV_PTYM_MAJOR, unit);
set_name ("/dev/ptmx");
return -1;
}
+int
+fhandler_termios::fstat (struct stat *buf)
+{
+ fhandler_base::fstat (buf);
+ if (dev_referred_via > 0)
+ buf->st_rdev = dev_referred_via;
+ return 0;
+}
+
static bool
is_console_app (const WCHAR *filename)
{
virtual void acquire_input_mutex_if_necessary (DWORD ms) {};
virtual void release_input_mutex_if_necessary (void) {};
virtual void discard_input () {};
+ dev_t dev_referred_via;
/* Result status of processing keys in process_sigs(). */
enum process_sig_state {
void echo_erase (int force = 0);
virtual off_t lseek (off_t, int);
pid_t tcgetsid ();
+ virtual int fstat (struct stat *buf);
fhandler_termios (void *) {}
void copy_from (fhandler_base *x)
{
pc.free_strings ();
+ dev_t via = this->dev_referred_via; /* Do not copy dev_referred_via */
*this = *reinterpret_cast<fhandler_console *> (x);
+ this->dev_referred_via = via;
_copy_from_reset_helper ();
}
typedef ptys_handle_set_t handle_set_t;
/* Constructor */
- fhandler_pty_slave (int);
+ fhandler_pty_slave (int, dev_t via = 0);
void set_output_handle_nat (HANDLE h) { output_handle_nat = h; }
HANDLE& get_output_handle_nat () { return output_handle_nat; }
void copy_from (fhandler_base *x)
{
pc.free_strings ();
+ dev_t via = this->dev_referred_via; /* Do not copy dev_referred_via */
*this = *reinterpret_cast<fhandler_pty_slave *> (x);
+ this->dev_referred_via = via;
_copy_from_reset_helper ();
}
public:
HANDLE get_echo_handle () const { return echo_r; }
/* Constructor */
- fhandler_pty_master (int);
+ fhandler_pty_master (int, dev_t via = 0);
static DWORD pty_master_thread (const master_thread_param_t *p);
static DWORD pty_master_fwd_thread (const master_fwd_thread_param_t *p);
void copy_from (fhandler_base *x)
{
pc.free_strings ();
+ dev_t via = this->dev_referred_via; /* Do not copy dev_referred_via */
*this = *reinterpret_cast<fhandler_pty_master *> (x);
+ this->dev_referred_via = via;
_copy_from_reset_helper ();
}