9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Geoff Collyer <geoff@collyer.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] what a mess the Unix world has become
Date: Tue, 11 Feb 2003 02:25:20 -0800	[thread overview]
Message-ID: <bbbd182389f4ba4d3afab92be277012a@collyer.net> (raw)
In-Reply-To: <3E48ABC5.6050205@null.net>

Checking close() return values after writing on a descriptor is good
hygiene, but as I recall, NFS made error detection harder by not
necessarily reporting write errors (even synchronous ones like ENOSPC)
via either write() or close(); one had to use fsync() just before the
close() to force any write errors to be reported.

 From code I wrote in the late 1980s:

/*
 * nfclose(stream) - flush the stream, fsync its file descriptor and
 * fclose the stream, checking for errors at all stages.  This dance
 * is needed to work around the lack of Unix file system semantics
 * in Sun's NFS.  Returns EOF on error.
 */

#include <stdio.h>

int
nfclose(stream)
register FILE *stream;
{
	register int ret = 0;

	if (fflush(stream) == EOF)
		ret = EOF;
	if (fsync(fileno(stream)) < 0)		/* may get delayed error here */
		ret = EOF;
	if (fclose(stream) == EOF)
		ret = EOF;
	return ret;
}



  reply	other threads:[~2003-02-11 10:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-09 10:05 Aharon Robbins
2003-02-09 19:48 ` Mike Haertel
2003-02-10  9:00 ` [9fans] mpg123 Conor Williams
2003-02-10 12:02   ` Russ Cox
2003-02-10 14:14   ` Nigel Roles
2003-02-10 14:34     ` Fco.J.Ballesteros
2003-02-10 14:53       ` Axel Belinfante
2003-02-10 15:05         ` Fco.J.Ballesteros
2003-02-10 15:53       ` Conor Williams
2003-02-10 16:41         ` Fco.J.Ballesteros
2003-02-11 10:19     ` Conor Williams
2003-02-11 11:26       ` nigel
2003-02-13  9:02         ` Conor Williams
2003-02-10 18:13   ` Tad Hunt
2003-02-10 10:04 ` [9fans] what a mess the Unix world has become Douglas A. Gwyn
2003-02-10 11:58   ` Russ Cox
2003-02-10 15:20   ` Ronald G. Minnich
2003-02-11  9:29     ` Douglas A. Gwyn
2003-02-11 10:25       ` Geoff Collyer [this message]
2003-02-10 16:19 C H Forsyth
2003-02-10 20:26 ` Ronald G. Minnich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bbbd182389f4ba4d3afab92be277012a@collyer.net \
    --to=geoff@collyer.net \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).