Rename FH_BAD to FH_NADA throughout.
* devices.h (FH_ERROR): New value. (iscons_dev): Extend to detect all the console device types. * devices.in: Set aside storage for FH_ERROR. * dtable.cc (dtable::init_std_file_from_handle): Use iscons_dev to detect when device is a console. (fh_alloc): Pass device to console constructor. (build_fh_pc): Short circuit when we detect that the constructor saw an error. * fhandler.h (fhandler_console::fhandler_console): Accept fh_devices parameter. (get_tty_stuff): Change to void. * fhandler_console (fhandler_console::set_unit): Set device to FH_ERROR on attempt to access anything other than the current console. (fhandler_console::get_tty_stuff): Change to void return. (fhandler_console::open): Return EPERM on FH_ERROR device type. (fhandler_console::fhandler_console): Set the device type appropriately before calling get_tty_stuff and rely on that function to reset it if necessary.
This commit is contained in:
@@ -351,7 +351,7 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
|
||||
/* Console windows are not kernel objects, so the access mask returned
|
||||
by NtQueryInformationFile is meaningless. CMD always hands down
|
||||
stdin handles as R/O handles, but our tty slave sides are R/W. */
|
||||
if (dev == FH_TTY || dev == FH_CONSOLE || dev.get_major () == DEV_TTYS_MAJOR)
|
||||
if (dev == FH_TTY || iscons_dev (dev) || dev.get_major () == DEV_TTYS_MAJOR)
|
||||
access |= GENERIC_READ | GENERIC_WRITE;
|
||||
else if (NT_SUCCESS (NtQueryInformationFile (handle, &io, &fai,
|
||||
sizeof fai,
|
||||
@@ -460,7 +460,7 @@ fh_alloc (device dev)
|
||||
fh = cnew (fhandler_serial) ();
|
||||
break;
|
||||
case DEV_CONS_MAJOR:
|
||||
fh = cnew (fhandler_console) ();
|
||||
fh = cnew (fhandler_console) (dev);
|
||||
break;
|
||||
default:
|
||||
switch ((int) dev)
|
||||
@@ -468,7 +468,7 @@ fh_alloc (device dev)
|
||||
case FH_CONSOLE:
|
||||
case FH_CONIN:
|
||||
case FH_CONOUT:
|
||||
fh = cnew (fhandler_console) ();
|
||||
fh = cnew (fhandler_console) (dev);
|
||||
break;
|
||||
case FH_PTYM:
|
||||
fh = cnew (fhandler_pty_master) ();
|
||||
@@ -541,7 +541,7 @@ fh_alloc (device dev)
|
||||
case FH_TTY:
|
||||
{
|
||||
if (iscons_dev (myself->ctty))
|
||||
fh = cnew (fhandler_console) ();
|
||||
fh = cnew (fhandler_console) (dev);
|
||||
else
|
||||
fh = cnew (fhandler_tty_slave) (myself->ctty);
|
||||
break;
|
||||
@@ -564,7 +564,9 @@ build_fh_pc (path_conv& pc, bool set_name)
|
||||
|
||||
if (!fh)
|
||||
set_errno (EMFILE);
|
||||
else if (fh->dev () != FH_BAD)
|
||||
else if (fh->dev () == FH_ERROR)
|
||||
goto out;
|
||||
else if (fh->dev () != FH_NADA)
|
||||
fh->set_name (fh->dev ().name);
|
||||
else if (set_name)
|
||||
fh->set_name (pc);
|
||||
@@ -582,6 +584,7 @@ build_fh_pc (path_conv& pc, bool set_name)
|
||||
*cygheap->fdtab.add_archetype () = fh->archetype;
|
||||
}
|
||||
|
||||
out:
|
||||
debug_printf ("fh %p", fh);
|
||||
return fh;
|
||||
}
|
||||
|
Reference in New Issue
Block a user