home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.27 / text0039.txt < prev    next >
Encoding:
Text File  |  1992-05-20  |  2.2 KB  |  40 lines

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