Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!amdahl!ames!sdcsvax!ucsdhub!jack!man!nusdhub!rwhite From: rwhite@nusdhub.UUCP (Robert C. White Jr.) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: Determining the names of devices installed in DOS Message-ID: <122@nusdhub.UUCP> Date: Tue, 13-Oct-87 16:41:56 EDT Article-I.D.: nusdhub.122 Posted: Tue Oct 13 16:41:56 1987 Date-Received: Thu, 15-Oct-87 19:55:54 EDT References: <1801@killer.UUCP> Organization: National University, San Diego Lines: 32 Keywords: devices, stat(2) Summary: It's Easy [if I remember correctly] Xref: mnetor comp.sys.ibm.pc:9032 comp.lang.c:4888 In article <1801@killer.UUCP>, wnp@killer.UUCP (Wolf Paul) writes: [Stuff Deleted] > 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. This is SOOOO.... Simple, that the methodologies described above look quite convoluted.... 1) Get the "device status word" using ioctl against the open file descriptor. [I don't remember the subcommand, so you'll have to look it up] 2) Mask out the "Block Device" flag. 3) If the block device flag is set, then you MUST be dealing with a file on a disk someware. If it is not set you have an open character device on your hands. Only character and block devices are defined in MS-DOS. Also, the "get device status word" subcommand of the ioctl/int-24 command MUST! return the status word of the device of ANY file discriptor. Since MS-DOS does not have pipes, streams, swap-devices, or "system facilities" defined in the file system. Because of this you simply have "Disk Files" and "Character Devices" Disclaimer: Neat huh? Robert.