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_procnet_storage =
25 {"", {FH_PROCNET}, ""};
27 const device dev_netdrive_storage =
28 {"", {FH_NETDRIVE}, ""};
31 const device dev_dev_storage =
32 {"/dev", {FH_DEV}, "/dev"};
35 const device dev_registry_storage =
36 {"", {FH_REGISTRY}, ""};
38 const device dev_piper_storage =
41 const device dev_pipew_storage =
44 const device dev_tcp_storage =
47 const device dev_udp_storage =
50 const device dev_stream_storage =
51 {"", {FH_STREAM}, ""};
53 const device dev_dgram_storage =
56 const device dev_bad_storage =
63 "/dev/tty", BRACK(FH_TTY), "\\dev\\tty"
64 "/dev/tty%(0-63)d", BRACK(FHDEV(DEV_TTYS_MAJOR, {$1})), "\\dev\\tty{$1}", ttys_dev
65 "/dev/console", BRACK(FH_CONSOLE), "\\dev\\console", console_dev
66 "/dev/ttym", BRACK(FH_TTYM), "\\dev\\ttym", ttym_dev
67 "/dev/ptmx", BRACK(FH_PTYM), "\\dev\\ptmx"
68 "/dev/windows", BRACK(FH_WINDOWS), "\\dev\\windows"
69 "/dev/dsp", BRACK(FH_OSS_DSP), "\\dev\\dsp"
70 "/dev/conin", BRACK(FH_CONIN), "conin"
71 "/dev/conout", BRACK(FH_CONOUT), "conout"
72 "/dev/null", BRACK(FH_NULL), "\\Device\\Null"
73 "/dev/zero", BRACK(FH_ZERO), "\\dev\\zero"
74 "/dev/full", BRACK(FH_FULL), "\\dev\\full"
75 "/dev/random", BRACK(FH_RANDOM), "\\dev\\random"
76 "/dev/urandom", BRACK(FH_URANDOM), "\\dev\\urandom", urandom_dev
77 "/dev/mem", BRACK(FH_MEM), "\\dev\\mem"
78 "/dev/kmem", BRACK(FH_KMEM), "\\dev\\mem"
79 "/dev/clipboard", BRACK(FH_CLIPBOARD), "\\dev\\clipboard"
80 "/dev/port", BRACK(FH_PORT), "\\dev\\port"
81 "/dev/com%(1-16)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1 - 1})), "\\Device\\Serial{$1 - 1}"
82 "/dev/ttyS%(0-63)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1})), "\\Device\\Serial{$1}"
83 "/dev/pipe", BRACK(FH_PIPE), "\\dev\\pipe"
84 "/dev/fifo", BRACK(FH_FIFO), "\\dev\\fifo"
85 "/dev/st%(0-127)d", BRACK(FHDEV(DEV_TAPE_MAJOR, {$1})), "\\Device\\Tape{$1}"
86 "/dev/nst%(0-127)d", BRACK(FHDEV(DEV_TAPE_MAJOR, {$1 + 128})), "\\Device\\Tape{$1}"
87 "/dev/fd%(0-15)d", BRACK(FHDEV(DEV_FLOPPY_MAJOR, {$1})), "\\Device\\Floppy{$1}"
88 "/dev/scd%(0-15)d", BRACK(FHDEV(DEV_CDROM_MAJOR, {$1})), "\\Device\\CdRom{$1}"
89 "/dev/sr%(0-15)d", BRACK(FHDEV(DEV_CDROM_MAJOR, {$1})), "\\Device\\CdRom{$1}"
90 "/dev/sd%{a-z}s", BRACK(FH_SD{uc $1}), "\\Device\\Harddisk{ord($1) - ord('a')}\\Partition0"
91 "/dev/sda%{a-z}s", BRACK(FH_SDA{uc $1}), "\\Device\\Harddisk{26 + ord($1) - ord('a')}\\Partition0"
92 "/dev/sdb%{a-z}s", BRACK(FH_SDB{uc $1}), "\\Device\\Harddisk{52 + ord($1) - ord('a')}\\Partition0"
93 "/dev/sdc%{a-z}s", BRACK(FH_SDC{uc $1}), "\\Device\\Harddisk{78 + ord($1) - ord('a')}\\Partition0"
94 "/dev/sdd%{a-x}s", BRACK(FH_SDD{uc $1}), "\\Device\\Harddisk{104 + ord($1) - ord('a')}\\Partition0"
95 "/dev/sd%{a-z}s%(1-15)d", BRACK(FH_SD{uc $1} | {$2}), "\\Device\\Harddisk{ord($1) - ord('a')}\\Partition{$2 % 16}"
96 "/dev/sda%{a-z}s%(1-15)d", BRACK(FH_SDA{uc $1} | {$2}), "\\Device\\Harddisk{26 + ord($1) - ord('a')}\\Partition{$2 % 16}"
97 "/dev/sdb%{a-z}s%(1-15)d", BRACK(FH_SDB{uc $1} | {$2}), "\\Device\\Harddisk{52 + ord($1) - ord('a')}\\Partition{$2 % 16}"
98 "/dev/sdc%{a-z}s%(1-15)d", BRACK(FH_SDC{uc $1} | {$2}), "\\Device\\Harddisk{78 + ord($1) - ord('a')}\\Partition{$2 % 16}"
99 "/dev/sdd%{a-x}s%(1-15)d", BRACK(FH_SDD{uc $1} | {$2}), "\\Device\\Harddisk{104 + ord($1) - ord('a')}\\Partition{$2 % 16}"
100 "/dev/kmsg", BRACK(FH_KMSG), "\\Device\\MailSlot\\cygwin\\dev\\kmsg"
101 "/dev", BRACK(FH_DEV), "/dev"
102 %other {return NULL;}
106 device::parse (const char *s)
108 size_t len = strlen (s);
109 const device *dev = KR_find_keyword (s, len);
120 /* nothing to do... yet */
124 device::parse (_major_t major, _minor_t minor)
126 _dev_t dev = FHDEV (major, minor);
130 for (unsigned i = 0; i < (sizeof (dev_storage) / sizeof (dev_storage[0])); i++)
131 if (dev_storage[i].devn == dev)
133 *this = dev_storage[i];
138 devn = FHDEV (major, minor);
142 device::parse (_dev_t dev)
144 parse (_major (dev), _minor (dev));
148 device::tty_to_real_device ()
150 if (!real_tty_attached (myself))
151 *this = myself->ctty < 0 ? dev_bad_storage : *console_dev;
153 parse (DEV_TTYS_MAJOR, myself->ctty);
157 device::parsedisk (int drive, int part)
160 if (drive < ('q' - 'a')) /* /dev/sda -to- /dev/sdp */
162 else if (drive < 32) /* /dev/sdq -to- /dev/sdaf */
164 base = DEV_SD1_MAJOR;
167 else if (drive < 48) /* /dev/sdag -to- /dev/sdav */
169 base = DEV_SD2_MAJOR;
172 else if (drive < 64) /* /dev/sdaw -to- /dev/sdbl */
174 base = DEV_SD3_MAJOR;
177 else if (drive < 80) /* /dev/sdbm -to- /dev/sdcb */
179 base = DEV_SD4_MAJOR;
182 else if (drive < 96) /* /dev/sdcc -to- /dev/sdcr */
184 base = DEV_SD5_MAJOR;
187 else if (drive < 112) /* /dev/sdcs -to- /dev/sddh */
189 base = DEV_SD6_MAJOR;
192 /* NOTE: This will cause multiple /dev/sddx entries in
193 /proc/partitions if there are more than 128 devices */
194 else /* /dev/sddi -to- /dev/sddx */
196 base = DEV_SD7_MAJOR;
199 parse (base, part + (drive * 16));