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

  1. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!wupost!sdd.hp.com!usc!isi.edu!gremlin!lazarus.nrtc.northrop.com!dec
  2. From: dec@lazarus.nrtc.northrop.com (Dwight E. Cass)
  3. Newsgroups: comp.unix.bsd
  4. Subject: STDIO Mode "a+" screwed up
  5. Message-ID: <39897@gremlin.nrtc.northrop.com>
  6. Date: 27 Jul 92 17:35:48 GMT
  7. Sender: news@gremlin.nrtc.northrop.com
  8. Organization: Northrop Research & Technology Center, Palos Verdes, CA
  9. Lines: 31
  10.  
  11. Hi folks,
  12.  
  13.    I have just spent the weekend trying to find out why rogue crashes
  14. when it attempts to update its score file and have found the problem:
  15.  
  16.    In: /usr/src/lib/libc/stdio/flags.c - Mode "a+" translates to an
  17.        open flag with O_APPEND (in __sflags()).  This means that if
  18.        you seek the file to the beginning and start writting, all the
  19.        written will be APPENDED to the end of the file - rather than
  20.        updating the top of the file as specified by the plus sign.
  21.  
  22.    What's the cure - ouch.  It seems that __sflags() is called by all of
  23. the open routines and that there is not a clean way of passing back
  24. the fact that append is desired (why pass it back - you have to seek
  25. to the bottom of the file [lseek (fd, 0, SEEK_END)] after the file
  26. is opened (i.e., after you have returned from __sflags()).  So - my
  27. proposal (which I will implement tonight and send patches for
  28. tommorrow), add one more flag to the ->flags work in the FILE *
  29. structure.  This flag, __SUPD 0x4000, will indicate that the file
  30. has been opened in an append mode (i.e., I will always set this flag
  31. for "a", "a+", "ab+", and look at it rather than O_APPEND to make the
  32. decision as to whether to lseek or not.)  We will see what
  33. side-effects this has.
  34.  
  35. Any other ideas?
  36. /dec
  37.  
  38. Dwight E. Cass                 dec@nrtc.northrop.com | But there's a hole
  39. Automation Sciences Laboratory, Northrop Corporation |   in the bucket
  40. One Research Park, Palos Verdes Peninsula, CA  90274 | Dear Liza,
  41. (310) 544-5393                                       |   Dear Liza...
  42.