home *** CD-ROM | disk | FTP | other *** search
- Submitted-by: gwyn@smoke.brl.mil (Doug Gwyn)
-
- In article <1992Mar20.225009.29556@uunet.uu.net> brian.haug@ncrcae.columbiasc.NCR.COM ("Brian R. Haug") writes:
- >I've recently encountered a problem with seekdir in that it does not work
- >when the directory is on a device incapable of seeking (like the /dev/fd
- >filesystem in SVR4) because seekdir calls lseek which fails. I realize that
- >seekdir is no part of POSIX, but we have to be compatible with SVID and X/OPEN
- >too.
-
- I was intimately involved in the 1003.1 specification for the directory
- access functions, and also implemented a widely used more-or-less portable
- version of these functions (including seekdir()/telldir()) that among
- other things served as the basis of the version shipped with UNIX System V.
- I mention this to assure you of my familiarity with the problems..
-
- The reason that 1003.1 did NOT specify seekdir()/telldir() is that there
- simply is no way to guarantee that these can be correctly implemented in
- all reasonable environments. All versions I have seen (including mine)
- depend on filesystem behavior that is by no means guaranteed, and as you
- have discovered this problem has gotten worse as evolution has proceeded.
- My copies of SVID and XPG are not at hand as I write this, but if they are
- currently insisting on reliable seekdir()/telldir() they need to be fixed.
-
- rewinddir() is more important, because it IS required by 1003.1. The only
- way I know of to implement it on a system that doesn't support lseek() to
- the beginning (only!) of an open directory is to record the full pathname
- at opendir() time and use this information to reopen the directory (after
- closing the current fd). As you observe, chroot() could cause this to
- fail, which is not a problem for POSIX but would be for other UNIX
- standards. Are you sure that /dev/fd cannot be lseek()ed even to its
- beginning? That would seem to be a severe deficiency in the implementation
- of that filesystem. Assuming /dev/fd cannot be fixed, then I'd suggest
- that SVID/XPG/etc. exempt rewinddir() from being used (in conforming
- applications) after a chroot(). (chroot() opens a large can of worms, and
- might be better left out of UNIX application interface standards.)
-
-
- Volume-Number: Volume 27, Number 39
-
-