Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!tut.cis.ohio-state.edu!ucbvax!hplabs!hpfcdc!rml From: rml@hpfcdc.HP.COM (Bob Lenk) Newsgroups: comp.sys.hp Subject: Re: find(1) function copying on HP-UX Message-ID: <5570178@hpfcdc.HP.COM> Date: 12 May 89 21:19:01 GMT References: <240028@grlab.UUCP> Organization: HP Ft. Collins, Co. Lines: 25 > > At any rate, the readdir routines read the contents of /etc as > > including the regular file "inittab" instead of the hidden > > directory "inittab+", but find(1) is able to display the hidden > > directories with a "-hidden" switch or "-type H". I want to do this, > > too. > > The CDFs can recognized by calling stat(2). The S_ISCDF macro described > in stat(5) will test for a CDF using the st_mode field. You must first attempt to append a '+' to the filename and then call stat(). If it fails with ENOENT, the file is not a CDF. If it succeeds the S_ISDCF() macro will tell whether it is a CDF. If you call stat("/etc/inittab", &buf), the information returned will refer to /etc/inittab+/ not to the hidden directory, and S_ISCDF(buf.st_mode) will return zero. > You might also want to watch for symbolic links with the S_ISLNK macro > from stat(5). This requires use of lstat() rather than stat(). Bob Lenk hplabs!hpfcla!rml rml@hpfcla.hp.com