clewis@eci386.uucp (Chris Lewis) (02/14/90)
I'm writing a program that recursively looks through directories analogously to find. Using your traditional stat/opendir/readdir method. I'd like to have the program detect RFS, NFS and symbolic link mount points and decide (based upon a program option) of whether to traverse the directory or not. On some systems doing a traversal of NFS or RFS mounted directories can take hours. Worse still, the program needs to be reasonably portable, in that I'd like to have no more than a couple of ifdef's to cover most flavours of UNIX supporting RFS and/or NFS. I need a way to detect when the program has hit such mount points. I don't really need to know which is which, just whether it's hit something likely to be across a LAN. On most BSD-derived systems I can detect symlinks reasonably easy, for my code is #ifdef'd on "S_IFLNK" to do a lstat first, and if the mode indicates a symbolic link, traverse the subtree according to a program option. Unfortunately *some* systems support symlinks but not S_IFLNK. Sigh... I'm stuck with NFS and RFS. One way of doing this would be to root through /etc/mnttab (BSD) or /etc/mtab (USG) and remember all of the mount points and do searches through this every time I hit a directory. This seems rather gross. Nor have I found enough documentation to suggest that this will even work very well across multiple platforms. HP9000's seem to have 0xFF as the upper 8 bits of st_dev (dev_t is a long) for NFS files, but this isn't documented anywhere I've found, and I suspect that it isn't common to other systems. One would think you could tell from the st_dev, but I've not seen any indication of this in the documentation I have accessible. Any ideas? Please respond by mail, our incoming feeds are currently defunct, and we're not exactly sure when they'll be back up. -- Chris Lewis, Elegant Communications Inc, {uunet!attcan,utzoo}!lsuc!eci386!clewis Ferret mailing list: eci386!ferret-list, psroff mailing list: eci386!psroff-list