This is the mail archive of the
mailing list for the Cygwin project.
Update of fhandler-tut.txt
- From: Gerd dot Spalink at t-online dot de (Gerd Spalink)
- To: "'cygwin-patches at cygwin dot com'" <cygwin-patches at cygwin dot com>
- Date: Sun, 28 Nov 2004 19:40:19 +0100
- Subject: Update of fhandler-tut.txt
- Organization: privat
- Reply-to: "Gerd dot Spalink at t-online dot de" <Gerd dot Spalink at t-online dot de>
When trying to add an experimental /dev/mixer, I found that
the fhandler tutorial was obsolete. This patch brings it up-to-date.
2004-11-28 Gerd Spalink <Gerd.Spalink@t-online.de>
* fhandler-tut.txt: Update description to cygwin 1.5.13
RCS file: /cvs/src/src/winsup/doc/fhandler-tut.txt,v
retrieving revision 1.2
diff -p -u -r1.2 fhandler-tut.txt
--- fhandler-tut.txt 18 Aug 2000 19:52:31 -0000 1.2
+++ fhandler-tut.txt 28 Nov 2004 18:38:47 -0000
@@ -6,7 +6,7 @@ showing an example of /dev/zero.
Files to note:
fhandler.h - must define a new derived class here and FH_*
-path.cc - to notice "/dev/zero" and mark it
+devices.in - to notice "/dev/zero" and mark it
fhandler_zero.cc - new
dtable.cc - to create the fhandler instance
@@ -27,23 +27,38 @@ simulating everything. Thus:
handle of -1, which (1) maps swap memory, and (2) zeros it out for
us (at least, on NT).
-OK, let's start with fhandler.h.
+OK, let's start with devices.h.
-First, update the comment about which files are where. We're adding
-fhandler_dev_zero as FH_DEV_ZERO. We're adding this as a "fast"
-device (it will never block) so we have to adjust FH_NDEV also.
+We have to create a new entry in the enum fh_devices. The new
+devices must get a major and a minor ID. As a rule of thumb, just
+copy the ones that are used on a linux system.
-Later in that file, we'll copy fhandler_dev_null and edit it to be
+Now, let's continue with fhandler.h.
+First, update the fhandler_union near the end of the file with a
+line for the new device. Use existing members, in this case __dev_null
+as a template. This union is sorted alphabetically.
+Earlier in that file, we'll copy fhandler_dev_null and edit it to be
fhandler_dev_zero. I chose that one because it's small, but we'll add
more members as we go (since we're simulating the whole thing). In
fact, let's copy the I/O methods from fhandler_windows since we'll
need all those anyway, even though we'll go through the full list
-OK, next we need to edit path.cc to recognize when the user is trying
-to open "/dev/zero". Look in get_device_number; there's a long list
-of cases, just add one (I added one after "null"). Also remember to
-add an entry to the windows_device_names list in the right spot.
+OK, next we need to edit devices.in. There is a section where each device
+is listed with its cygwin path, its structure and its windows path.
+"/dev/zero", FH_ZERO, "\\dev\\zero"
+This is needed to recognize when the user is trying to open "/dev/zero".
+You have to build devices.cc from devices.in now.
+There is a script 'gendevices' in the winsup/cygwin directory which may
+be called at some time in the future if you use 'make' to build the DLL.
+However, I had to type
+in the directory /cygdrive/c/sw/cygwin_dev/obj/i686-pc-cygwin/winsup/cygwin
+to achieve this. Note the absolute path names here.
+You have to have shilka available to do that; this is part of the
+cygwin cocom package.
To go along with that change, we'll need to change dtable.cc. Look for
FH_NULL and add a case for FH_ZERO as well.