home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / bsd / 3004 < prev    next >
Encoding:
Internet Message Format  |  1992-07-27  |  2.0 KB

  1. Path: sparky!uunet!darwin.sura.net!mips!sdd.hp.com!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!serval!phys1.physics.wsu.edu!hlu
  2. From: hlu@phys1.physics.wsu.edu (Hongjiu Lu)
  3. Newsgroups: comp.unix.bsd
  4. Subject: Re: STDIO Mode "a+" screwed up
  5. Message-ID: <1992Jul27.235032.2655@serval.net.wsu.edu>
  6. Date: 27 Jul 92 23:50:32 GMT
  7. References: <39897@gremlin.nrtc.northrop.com>
  8. Sender: news@serval.net.wsu.edu (USENET News System)
  9. Organization: Washington State University
  10. Lines: 32
  11.  
  12. In article <39897@gremlin.nrtc.northrop.com>, dec@lazarus.nrtc.northrop.com (Dwight E. Cass) writes:
  13. |> Hi folks,
  14. |> 
  15. |>    I have just spent the weekend trying to find out why rogue crashes
  16. |> when it attempts to update its score file and have found the problem:
  17. |> 
  18. |>    In: /usr/src/lib/libc/stdio/flags.c - Mode "a+" translates to an
  19. |>        open flag with O_APPEND (in __sflags()).  This means that if
  20. |>        you seek the file to the beginning and start writting, all the
  21. |>        written will be APPENDED to the end of the file - rather than
  22. |>        updating the top of the file as specified by the plus sign.
  23. |> 
  24. |>    What's the cure - ouch.  It seems that __sflags() is called by all of
  25. |> the open routines and that there is not a clean way of passing back
  26. |> the fact that append is desired (why pass it back - you have to seek
  27. |> to the bottom of the file [lseek (fd, 0, SEEK_END)] after the file
  28. |> is opened (i.e., after you have returned from __sflags()).  So - my
  29. |> proposal (which I will implement tonight and send patches for
  30. |> tommorrow), add one more flag to the ->flags work in the FILE *
  31. |> structure.  This flag, __SUPD 0x4000, will indicate that the file
  32. |> has been opened in an append mode (i.e., I will always set this flag
  33. |> for "a", "a+", "ab+", and look at it rather than O_APPEND to make the
  34. |> decision as to whether to lseek or not.)  We will see what
  35. |> side-effects this has.
  36. |> 
  37.  
  38. I think that is the right behavior according to ANSI C. Unfortunately some
  39. UNICES screw up on this one.
  40.  
  41. -- 
  42. H.J.
  43. Gcc/libc maintainer for Linux.
  44.