Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!snorkelwacker!apple!sun-barr!decwrl!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.unix.questions Subject: Re: Bit pattern of S_IFREG (was Re: What is wrong with this code ?) Message-ID: <6630@jpl-devvax.JPL.NASA.GOV> Date: 19 Dec 89 02:55:40 GMT References: <1156@nsscb.UUCP> <1323@mitisft.Convergent.COM> <2722@auspex.UUCP> <553@mwtech.UUCP> <2736@auspex.UUCP> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 18 In article <2736@auspex.UUCP> guy@auspex.auspex.com (Guy Harris) writes: : >I think I have seen on some older systems, that for regular files : >you must test for both (st_mode & S_IFMT) == S_IFREG : >and *additionally* (st_mode & S_IFMT) == 0. : > : >I don't know if this is still true today. : : If it is true on any "V7 derivative" (BSD and S3/S5 count under this : heading), it is due to a colossal screwup on the part of the vendor. It : may have been true under some emulation of V7 under "last V6", or : something like that. *I* certainly wouldn't bother testing for : (st_mode & S_IFMT) being 0. However, be advised that in BSD (or at least MORE/BSD), fstat() on a socket returns (st_mode & S_IFMT) == 0. This one bit me in perl. Caveat Hackor. Larry Wall lwall@jpl-devvax.jpl.nasa.gov