Re: fflush() on readonly files

From: Tim Robbins (tjr_at_freebsd.org)
Date: 06/19/04

  • Next message: Andrey Chernov: "Re: fflush() on readonly files"
    Date: Sat, 19 Jun 2004 22:01:49 +1000
    To: freebsd-arch@freebsd.org
    
    

    On Sat, Jun 19, 2004 at 02:59:39PM +0400, Andrey Chernov wrote:

    > On Sat, Jun 19, 2004 at 11:56:43AM +0200, Radim Kolar wrote:
    > > Today I have stepped on another example: advancecomp (in ports):
    > > 543 * Get the size of the file.
    > > 544 */
    > > 545 long fzsize(adv_fz* f)
    > > 546 {
    > > 547 if (f->type == fz_file) {
    > > 548 struct stat st;
    > > 549 if (fflush(f->f) != 0) {
    > > 550 return -1;
    > > 551 }
    >
    > This program relies on undocumented behaviour and should be fixed in
    > anycase. Besides of that the only reasonable approach we can take is to do
    > what majority of systems does here. Since you are interested in the
    > subject, please post specific table for all main systems in the form
    > like:
    >
    > System readonly fflush() behaviour

    This has already been discussed:
    - Microsoft libraries and other libraries imitating them discard buffered
      input data (like fpurge().)
    - UNIX libc (at least 7th ed.), Solaris libc, GNU libc and products derived
      from P.J. Plauger's C library (e.g. QNX) do nothing and indicate success.
    - BSD since Torek's stdio rewrite (inc. FreeBSD and Mac OS X) indicate
      an error.

    There is no reason to change from the perfectly correct & well-documented
    behaviour BSD has had for 10-15 years. The original poster's example provides
    a good argument for this: it detects application bugs.

    Tim
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


  • Next message: Andrey Chernov: "Re: fflush() on readonly files"

    Relevant Pages

    • Re: MFC of bump in libcom_err.so another mistake?
      ... There is no bump of libc and I don't see any reason for the libcom_err.so revision bump in -STABLE. ... Libraries also have ABI dependencies on other library revisions -- i.e., if an API changes in libc, and libypclnt depends on the old version of the API, it needs to use the old libc. ...
      (freebsd-current)
    • Re: safe strcpy()?
      ... > Another library 'libslack' has a rich set of string functions: ... That's probably one reason why people still keep using only ... libc stuff - requiring external libraries is annoying, ...
      (SecProg)
    • Re: HEADS UP: shared library bump, symbol versioning, libthr change
      ... you why do you think libraries getting versioned symbols need to be ... There might be a valid reason for this, ... used the namespace LIBPTHREAD_1_0 as their namespace, ... currently has to play some ugly games in order to be compatible ...
      (freebsd-current)
    • Re: Looking for real world exemple of semweb in swi
      ... entailment rules. ... A possible reason is that the Semantic Web is preceived as an extension ... providing libraries and tools for Prolog and have people demonstrated ...
      (comp.lang.prolog)
    • Re: Developing/compiling software
      ... No reason to do so otherwise... ... It turned out the maintainer of one of the key libraries that ... Some of the worst are those who don't want to deal with you as a small company, or a bit offbeat, but are all over you if you mention the client. ... Business depends on mutual trust and cooperation and breaks down if one side or the other is being devious or economical with the truth. ...
      (comp.arch.embedded)