8 #include "sys/cygwin.h"
11 typedef const device *KR_device_t;
15 const device dev_cygdrive_storage =
16 {"/cygdrive", {FH_CYGDRIVE}, "/cygdrive"};
18 const device dev_fs_storage =
21 const device dev_proc_storage =
24 const device dev_registry_storage =
25 {"", {FH_REGISTRY}, ""};
27 const device dev_piper_storage =
30 const device dev_pipew_storage =
33 const device dev_tcp_storage =
36 const device dev_udp_storage =
39 const device dev_stream_storage =
40 {"", {FH_STREAM}, ""};
42 const device dev_dgram_storage =
45 const device dev_bad_storage =
52 "/dev/tty", BRACK(FH_TTY), "\\dev\\tty"
53 "/dev/tty%(0-63)d", BRACK(FHDEV(DEV_TTYS_MAJOR, {$1})), "\\dev\\tty{$1}", ttys_dev
54 "/dev/console", BRACK(FH_CONSOLE), "\\dev\\console", console_dev
55 "/dev/ttym", BRACK(FH_TTYM), "\\dev\\ttym", ttym_dev
56 "/dev/ptmx", BRACK(FH_PTYM), "\\dev\\ptmx"
57 "/dev/windows", BRACK(FH_WINDOWS), "\\dev\\windows"
58 "/dev/dsp", BRACK(FH_OSS_DSP), "\\dev\\dsp"
59 "/dev/conin", BRACK(FH_CONIN), "conin"
60 "/dev/conout", BRACK(FH_CONOUT), "conout"
61 "/dev/null", BRACK(FH_NULL), "nul"
62 "/dev/zero", BRACK(FH_ZERO), "\\dev\\zero"
63 "/dev/full", BRACK(FH_FULL), "\\dev\\full"
64 "/dev/random", BRACK(FH_RANDOM), "\\dev\\random"
65 "/dev/urandom", BRACK(FH_URANDOM), "\\dev\\urandom", urandom_dev
66 "/dev/mem", BRACK(FH_MEM), "\\dev\\mem"
67 "/dev/kmem", BRACK(FH_KMEM), "\\dev\\mem"
68 "/dev/clipboard", BRACK(FH_CLIPBOARD), "\\dev\\clipboard"
69 "/dev/port", BRACK(FH_PORT), "\\dev\\port"
70 "/dev/com%(1-16)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1})), "\\\\.\\com{$1}"
71 "/dev/ttyS%(0-15)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1 + 1})), "\\\\.\\com{$1 + 1}"
72 "/dev/pipe", BRACK(FH_PIPE), "\\dev\\pipe"
73 "/dev/fifo", BRACK(FH_FIFO), "\\dev\\fifo"
74 "/dev/st%(0-127)d", BRACK(FHDEV(DEV_TAPE_MAJOR, {$1})), "\\Device\\Tape{$1}"
75 "/dev/nst%(0-127)d", BRACK(FHDEV(DEV_TAPE_MAJOR, {$1 + 128})), "\\Device\\Tape{$1}"
76 "/dev/fd%(0-15)d", BRACK(FHDEV(DEV_FLOPPY_MAJOR, {$1})), "\\Device\\Floppy{$1}"
77 "/dev/scd%(0-15)d", BRACK(FHDEV(DEV_CDROM_MAJOR, {$1})), "\\Device\\CdRom{$1}"
78 "/dev/sr%(0-15)d", BRACK(FHDEV(DEV_CDROM_MAJOR, {$1})), "\\Device\\CdRom{$1}"
79 "/dev/sd%{a-z}s", BRACK(FH_SD{uc $1}), "\\Device\\Harddisk{ord($1) - ord('a')}\\Partition0"
80 "/dev/sd%{a-z}s%(1-15)d", BRACK(FH_SD{uc $1} | {$2}), "\\Device\\Harddisk{ord($1) - ord('a')}\\Partition{$2 % 16}"
85 device::parse (const char *s)
87 size_t len = strlen (s);
88 const device *dev = KR_find_keyword (s, len);
99 /* nothing to do... yet */
103 device::parse (_major_t major, _minor_t minor)
105 _dev_t dev = FHDEV (major, minor);
109 for (unsigned i = 0; i < (sizeof (dev_storage) / sizeof (dev_storage[0])); i++)
110 if (dev_storage[i].devn == dev)
112 *this = dev_storage[i];
117 devn = FHDEV (major, minor);
122 device::parse (_dev_t dev)
124 parse (_major (dev), _minor (dev));
128 device::tty_to_real_device ()
130 if (!real_tty_attached (myself))
131 *this = myself->ctty < 0 ? dev_bad_storage : *console_dev;
133 parse (DEV_TTYS_MAJOR, myself->ctty);
137 device::parsedisk (int drive, int part)
140 if (drive < ('q' - 'a'))
144 base = DEV_SD1_MAJOR;
147 parse (base, part + (drive * 16));