Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!pa.dec.com!shodha.enet.dec.com!alan From: alan@shodha.enet.dec.com ( Alan's Home for Wayward Notes File.) Newsgroups: comp.unix.ultrix Subject: Re: How to get device information from a file descriptor ? Summary: See the manual page for stat(2). Keywords: UNIX - devices - file descriptor Message-ID: <3279@shodha.enet.dec.com> Date: 4 Jun 91 14:12:19 GMT References: <1991Jun3.104948.20582@info-sparc1.info.ucl.ac.be> Organization: Digital Equipment Corp. - Colorado Springs, CO. Lines: 22 In article <1991Jun3.104948.20582@info-sparc1.info.ucl.ac.be>, Ninane@fynu.ucl.ac.be (Alain Ninane - FYNU) writes: > Dear all of you, > Given a valid file descriptor [from an open(2) call], is there a > standard way to know whether or not this fd points to a specific > special file/device (major number only) ? You can use stat(2) on the file descriptor to get more information about the file. Among the information is the mode flag that will bits to indicate whether the device is a directory, ordinary file, character special device or block special device (and maybe others). There is also field with the major and minor device number. On ULTRIX you can get more detailed information about the device with the ioctl documented in the devio(4) manual page. > Dr. Alain H. Ninane, University of Louvain, Nuclear Physics Dept. -- Alan Rollow alan@nabeth.cxn.dec.com