Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!aurora!ames!lll-tis!ptsfa!ihnp4!homxb!mtuxo!mtune!codas!killer!wnp From: wnp@killer.UUCP (Wolf Paul) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Determining the names of devices installed in DOS Message-ID: <1801@killer.UUCP> Date: Mon, 12-Oct-87 11:52:40 EDT Article-I.D.: killer.1801 Posted: Mon Oct 12 11:52:40 1987 Date-Received: Wed, 14-Oct-87 05:40:03 EDT Organization: The Unix(R) Connection, Dallas, Texas Lines: 29 Keywords: devices, stat(2) Xref: mnetor comp.sys.ibm.pc:9002 comp.lang.c:4865 Recently I asked for advice on how to determine if a file name refers to a device or to a regular file under DOS, in order to implement a function to simulate the UNIX stat(2) system call. The most promising advice was from Dan Kegel who wrote: > 1. You can find the device driver for any open file and > look at its name. Unfortunately, this is not documented > and the method used to get the device driver pointer > differs slightly from version to version. > > 2. Using (1), you can get a list of all device names by opening > the NUL device and following the chain of device drivers. > Having done this once, it should be easy to evaluate a > given filename for deviceness. Unfortunately he did not elaborate on how to do what he suggested. Can anyone out there tell me how to 1. find the device driver header, given a handle for a device; and 2. how to follow the chain of device drivers from NUL? I find it interesting that apparently the MSC stat(2) function does not know how to distinguish between devices and regular files, whereas the fstat(2) function does make that distinction. I assume they use ioctl on the file handle passed to fstat. Wolf Paul ihnp4!killer!wnp