Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!purdue!decwrl!hplabs!hp-pcd!hplsla!hpubvwa!grlab!scott From: scott@grlab.UUCP (Scott Blachowicz) Newsgroups: comp.sys.hp Subject: Re: find(1) function copying on HP-UX Message-ID: <240035@grlab.UUCP> Date: 16 May 89 22:48:40 GMT References: <240028@grlab.UUCP> Organization: Graphicus Lines: 36 / grlab:comp.sys.hp / stroyan@hpfcdc.HP.COM (Mike Stroyan) / 8:42 pm May 11, 1989 / > > ... > > 3) HP-UX has "Context Dependent Files"(CDFs) that are really hidden > > directories containing the file that is really referred to. > > > 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. I notice that macro, but the problem is that the readdir routine resolves the CDF "for" me, so I never get a filename to do a stat on. The only thing I've come up with so far is to have an option that says "look at hidden directories", then call getcdf(3C) on each file and compare with the input file name...if different then back the path up and walk the hidden directory. That is, do something like: real_path = getcdf (readdir_returned_path, real_path, sizeof(real_path)) if (strcmp (real_path, readdir_returned_path) != 0) { *(strrchr (real_path, '/')) = '\0'; /* Treat real_path as a normal directory file for directory */ /* tree walking purposes. */ } else { /* Non-CDF file processing */ } > You might also want to watch for symbolic links with the S_ISLNK macro > from stat(5). I do a similar sort of maneuver for links, but readdir doesn't resolve them for me, so I have a directory entry I can either stat or lstat depending on what I'm doing. Thanx for the info, Scott Blachowicz scott@grlab.UUCP