* devices.h (lives_in_dev): New field.

(dev_on_fs): Set bit size.
(is_dev_resident): Define new method.
* devices.in: Use different method for labelling requested name for dev
storage: prefix it with a ='.  Use an actual ':' to denote an internal device.
(exists_console): Avoid repeated test.
(exists_ntdev_silent): Rename from the less-descriptive exists_ntdevs.
(dev_dev_storage): Delete unneeded define.
* gendevices: Add a flag to each line denoting whether the device lives in /dev
space.
(generate): Handle special ":" case here for internal devices.  Parse
=something_dev as requiring a storage location.  Tack the rest of the line back
onto the reformulated "$rest".
* devices.cc: Regenerate.
This commit is contained in:
Christopher Faylor 2012-04-02 20:41:46 +00:00
parent eb7729eb36
commit 17a61045ff
5 changed files with 3574 additions and 3496 deletions

View File

@ -1,3 +1,21 @@
2012-04-02 Christopher Faylor <me.cygwin2012@cgf.cx>
* devices.h (lives_in_dev): New field.
(dev_on_fs): Set bit size.
(is_dev_resident): Define new method.
* devices.in: Use different method for labelling requested name for dev
storage: prefix it with a ='. Use an actual ':' to denote an internal
device.
(exists_console): Avoid repeated test.
(exists_ntdev_silent): Rename from the less-descriptive exists_ntdevs.
(dev_dev_storage): Delete unneeded define.
* gendevices: Add a flag to each line denoting whether the device lives
in /dev space.
(generate): Handle special ":" case here for internal devices. Parse
=something_dev as requiring a storage location. Tack the rest of the
line back onto the reformulated "$rest".
* devices.cc: Regenerate.
2012-04-02 Corinna Vinschen <corinna@vinschen.de>
* devices.h (device::get_device): New method.

File diff suppressed because it is too large Load Diff

View File

@ -275,7 +275,8 @@ struct device
const char *native;
int (*exists_func) (const device&);
_mode_t mode;
bool dev_on_fs;
bool lives_in_dev:4;
bool dev_on_fs:4;
static const device *lookup (const char *, unsigned int = UINT32_MAX);
void parse (const char *);
void parse (_major_t major, _minor_t minor);
@ -318,6 +319,7 @@ struct device
inline void setfs (bool x) {dev_on_fs = x;}
inline bool isfs () const {return dev_on_fs || d.devn == FH_FS;}
inline bool is_fs_special () const {return dev_on_fs && d.devn != FH_FS;}
inline bool is_dev_resident () const {return lives_in_dev;}
inline int exists () const {return exists_func (*this);}
unsigned char type () const
{

View File

@ -55,7 +55,7 @@ exists_ntdev (const device& dev)
/* Don't list via readdir but allow as a direct reference. */
static int
exists_ntdevs (const device& dev)
exists_ntdev_silent (const device& dev)
{
return exists_ntdev (dev) ? -1 : false;
}
@ -71,8 +71,9 @@ exists_console (const device& dev)
case FH_CONSOLE:
case FH_CONIN:
case FH_CONOUT:
return iscons_dev (myself->ctty);
return true;
default:
/* Only show my own console device (for now?) */
return myself->ctty == devn;
}
}
@ -105,9 +106,6 @@ const device dev_procsysvipc_storage =
const device dev_netdrive_storage =
{"", {FH_NETDRIVE}, "", exists};
const device dev_dev_storage =
{"/dev", {FH_DEV}, "/dev", exists};
const device dev_registry_storage =
{"", {FH_REGISTRY}, "", exists_internal};
@ -138,17 +136,15 @@ const device dev_error_storage =
#define BRACK(x) {devn_int: x}
%storage_here
}
/* Internal devices below are marked with a //. gendevices will
eventually translate that to a : . This is done because shilka
does not support a colon here since it is designed to only handle
C keywords with special handling for "/". */
/* Internal devices below are prefixed with a ":". This moves them out of
the POSIX namespace. */
%%
"/dev", BRACK(FH_DEV), "/dev", exists, S_IFDIR
"/dev/tty", BRACK(FH_TTY), "/dev/tty", exists, S_IFCHR
"/dev/pty%(0-63)d", BRACK(FHDEV(DEV_PTYS_MAJOR, {$1})), "/dev/pty{$1}", exists_pty, S_IFCHR, ptys_dev
"//ptym%(0-63)d", BRACK(FHDEV(DEV_PTYM_MAJOR, {$1})), "/dev/ptym{$1}", exists_internal, S_IFCHR, ptym_dev
"/dev/cons%(0-63)d", BRACK(FHDEV(DEV_CONS_MAJOR, {$1})), "/dev/cons{$1}", exists_console, S_IFCHR, cons_dev
"/dev/console", BRACK(FH_CONSOLE), "/dev/console", exists_console, S_IFCHR, console_dev
"/dev/pty%(0-63)d", BRACK(FHDEV(DEV_PTYS_MAJOR, {$1})), "/dev/pty{$1}", exists_pty, S_IFCHR, =ptys_dev
":ptym%(0-63)d", BRACK(FHDEV(DEV_PTYM_MAJOR, {$1})), "/dev/ptym{$1}", exists_internal, S_IFCHR, =ptym_dev
"/dev/cons%(0-63)d", BRACK(FHDEV(DEV_CONS_MAJOR, {$1})), "/dev/cons{$1}", exists_console, S_IFCHR, =cons_dev
"/dev/console", BRACK(FH_CONSOLE), "/dev/console", exists_console, S_IFCHR, =console_dev
"/dev/ptmx", BRACK(FH_PTMX), "/dev/ptmx", exists, S_IFCHR
"/dev/windows", BRACK(FH_WINDOWS), "/dev/windows", exists, S_IFCHR
"/dev/dsp", BRACK(FH_OSS_DSP), "/dev/dsp", exists, S_IFCHR
@ -158,15 +154,15 @@ const device dev_error_storage =
"/dev/zero", BRACK(FH_ZERO), "/dev/zero", exists, S_IFCHR
"/dev/full", BRACK(FH_FULL), "/dev/full", exists, S_IFCHR
"/dev/random", BRACK(FH_RANDOM), "/dev/random", exists, S_IFCHR
"/dev/urandom", BRACK(FH_URANDOM), "/dev/urandom", exists, S_IFCHR, urandom_dev
"/dev/urandom", BRACK(FH_URANDOM), "/dev/urandom", exists, S_IFCHR, =urandom_dev
"/dev/mem", BRACK(FH_MEM), "/dev/mem", exists, S_IFCHR
"/dev/kmem", BRACK(FH_KMEM), "/dev/mem", exists, S_IFCHR
"/dev/clipboard", BRACK(FH_CLIPBOARD), "/dev/clipboard", exists, S_IFCHR
"/dev/port", BRACK(FH_PORT), "/dev/port", exists, S_IFCHR
"/dev/com%(1-16)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1 - 1})), "\\??\\COM{$1}", exists_ntdevs, S_IFCHR
"/dev/com%(1-16)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1 - 1})), "\\??\\COM{$1}", exists_ntdev_silent, S_IFCHR
"/dev/ttyS%(0-63)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1})), "\\??\\COM{$1 + 1}", exists_ntdev, S_IFCHR
"//pipe", BRACK(FH_PIPE), "/dev/pipe", exists_internal, S_IFCHR
"//fifo", BRACK(FH_FIFO), "/dev/fifo", exists_internal, S_IFCHR
":pipe", BRACK(FH_PIPE), "/dev/pipe", exists_internal, S_IFCHR
":fifo", BRACK(FH_FIFO), "/dev/fifo", exists_internal, S_IFCHR
"/dev/st%(0-127)d", BRACK(FHDEV(DEV_TAPE_MAJOR, {$1})), "\\Device\\Tape{$1}", exists_ntdev, S_IFBLK
"/dev/nst%(0-127)d", BRACK(FHDEV(DEV_TAPE_MAJOR, {$1 + 128})), "\\Device\\Tape{$1}", exists_ntdev, S_IFBLK
"/dev/fd%(0-15)d", BRACK(FHDEV(DEV_FLOPPY_MAJOR, {$1})), "\\Device\\Floppy{$1}", exists_ntdev, S_IFBLK

View File

@ -41,6 +41,7 @@ while (<INPUT>) {
my $x = $f->[0];
my $rest = $f->[1];
my ($dev, $devrest) = ($x =~ /([^%]+)(%.*)?$/o);
$rest .= ', ' . (($dev =~ m%/dev/%o) ? 'true' : 'false');
push(@lines, generate($dev, $devrest, $rest, []));
}
@patterns = ();
@ -84,7 +85,6 @@ for (my $i = 0; $i < @lines; $i++) {
splice(@lines, $i, 1);
redo;
};
$lines[$i] =~ s%"//%":%go;
}
open(OUTPUT, '>', $output) or do {{
if (chmod(0664, $output)) {
@ -117,6 +117,7 @@ sub generate {
} else {
my $fh = $dev;
$fh =~ s%/%_%og;
$fh =~ s%^:%__%o;
my $shilka_id = $fh;
my $storage_str = $fh . '_storage';
$fh =~ s/^_dev_/FH_/o;
@ -127,9 +128,9 @@ sub generate {
@lines = ('"' . $dev . '"' . " = $shilka_id {return $storage_loc;}\n");
$rest = "$fh, $rest" if $rest =~ /^"/o;
$rest = fixup($rest, $vars);
if ($rest =~ /^(.*), ([a-z_]*_dev)/) {
if ($rest =~ /^(.*), =(\S*_dev)\b\s*(.*)$/) {
$pointers{$2} ||= "const device *$2 = $storage_loc;\n";
$rest = $1;
$rest = $1 . $3;
}
push(@storage, " {\"$dev\", " . $rest . "},\n");
}